异常封装之单据信息后台修改

This commit is contained in:
qiankunpingtai
2019-04-18 10:21:50 +08:00
parent 8bfe0ba916
commit ca6c23f2a3
3 changed files with 326 additions and 66 deletions

View File

@@ -55,7 +55,7 @@ public class DepotHeadController {
@PostMapping(value = "/batchSetStatus") @PostMapping(value = "/batchSetStatus")
public String batchSetStatus(@RequestParam("status") String status, public String batchSetStatus(@RequestParam("status") String status,
@RequestParam("depotHeadIDs") String depotHeadIDs, @RequestParam("depotHeadIDs") String depotHeadIDs,
HttpServletRequest request) { HttpServletRequest request) throws Exception{
Map<String, Object> objectMap = new HashMap<String, Object>(); Map<String, Object> objectMap = new HashMap<String, Object>();
int res = depotHeadService.batchSetStatus(status, depotHeadIDs); int res = depotHeadService.batchSetStatus(status, depotHeadIDs);
if(res > 0) { if(res > 0) {

View File

@@ -19,16 +19,16 @@ public class DepotHeadComponent implements ICommonQuery {
private DepotHeadService depotHeadService; private DepotHeadService depotHeadService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getDepotHeadList(map); return getDepotHeadList(map);
} }
private List<?> getDepotHeadList(Map<String, String> map) { private List<?> getDepotHeadList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
String subType = StringUtil.getInfo(search, "subType"); String subType = StringUtil.getInfo(search, "subType");
@@ -41,7 +41,7 @@ public class DepotHeadComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
String subType = StringUtil.getInfo(search, "subType"); String subType = StringUtil.getInfo(search, "subType");
@@ -53,27 +53,27 @@ public class DepotHeadComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return depotHeadService.insertDepotHead(beanJson, request); return depotHeadService.insertDepotHead(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return depotHeadService.updateDepotHead(beanJson, id); return depotHeadService.updateDepotHead(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return depotHeadService.deleteDepotHead(id); return depotHeadService.deleteDepotHead(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return depotHeadService.batchDeleteDepotHead(ids); return depotHeadService.batchDeleteDepotHead(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return depotHeadService.checkIsNameExist(id, name); return depotHeadService.checkIsNameExist(id, name);
} }

View File

@@ -2,6 +2,7 @@ package com.jsh.erp.service.depotHead;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.DepotHead; import com.jsh.erp.datasource.entities.DepotHead;
import com.jsh.erp.datasource.entities.DepotHeadExample; import com.jsh.erp.datasource.entities.DepotHeadExample;
import com.jsh.erp.datasource.entities.DepotItem; import com.jsh.erp.datasource.entities.DepotItem;
@@ -13,6 +14,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail;
import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount; import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
import com.jsh.erp.datasource.vo.DepotHeadVo4List; import com.jsh.erp.datasource.vo.DepotHeadVo4List;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount; import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depotItem.DepotItemService; import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.serialNumber.SerialNumberService; import com.jsh.erp.service.serialNumber.SerialNumberService;
@@ -58,19 +60,45 @@ public class DepotHeadService {
private LogService logService; private LogService logService;
public DepotHead getDepotHead(long id) { public DepotHead getDepotHead(long id)throws Exception {
return depotHeadMapper.selectByPrimaryKey(id); DepotHead result=null;
try{
result=depotHeadMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<DepotHead> getDepotHead() { public List<DepotHead> getDepotHead()throws Exception {
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return depotHeadMapper.selectByExample(example); List<DepotHead> list=null;
try{
list=depotHeadMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows) { public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows)throws Exception {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>(); List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list = depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows); List<DepotHeadVo4List> list=null;
try{
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
if (null != list) { if (null != list) {
for (DepotHeadVo4List dh : list) { for (DepotHeadVo4List dh : list) {
if(dh.getOthermoneylist() != null) { if(dh.getOthermoneylist() != null) {
@@ -97,12 +125,21 @@ public class DepotHeadService {
public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) { public Long countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) throws Exception{
return depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds); Long result=null;
try{
result=depotHeadMapperEx.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotHead(String beanJson, HttpServletRequest request) { public int insertDepotHead(String beanJson, HttpServletRequest request)throws Exception {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过,登录过不再处理 //判断用户是否已经登录过,登录过不再处理
Object userInfo = request.getSession().getAttribute("user"); Object userInfo = request.getSession().getAttribute("user");
@@ -113,42 +150,94 @@ public class DepotHeadService {
} }
depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setCreatetime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT); depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
return depotHeadMapper.insert(depotHead); int result=0;
try{
result=depotHeadMapper.insert(depotHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepotHead(String beanJson, Long id) { public int updateDepotHead(String beanJson, Long id) throws Exception{
DepotHead dh = depotHeadMapper.selectByPrimaryKey(id); DepotHead dh=null;
try{
dh = depotHeadMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
depotHead.setId(id); depotHead.setId(id);
depotHead.setStatus(dh.getStatus()); depotHead.setStatus(dh.getStatus());
depotHead.setCreatetime(dh.getCreatetime()); depotHead.setCreatetime(dh.getCreatetime());
depotHead.setOperpersonname(dh.getOperpersonname()); depotHead.setOperpersonname(dh.getOperpersonname());
return depotHeadMapper.updateByPrimaryKey(depotHead); int result=0;
try{
result = depotHeadMapper.updateByPrimaryKey(depotHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotHead(Long id) { public int deleteDepotHead(Long id)throws Exception {
return depotHeadMapper.deleteByPrimaryKey(id); int result=0;
try{
result = depotHeadMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHead(String ids) { public int batchDeleteDepotHead(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return depotHeadMapper.deleteByExample(example); int result=0;
try{
result = depotHeadMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<DepotHead> list = depotHeadMapper.selectByExample(example); List<DepotHead> list = null;
return list.size(); try{
list = depotHeadMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list==null?0:list.size();
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetStatus(String status, String depotHeadIDs) { public int batchSetStatus(String status, String depotHeadIDs)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHeadIDs).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(depotHeadIDs).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
@@ -157,15 +246,32 @@ public class DepotHeadService {
depotHead.setStatus(status); depotHead.setStatus(status);
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(ids); example.createCriteria().andIdIn(ids);
return depotHeadMapper.updateByExampleSelective(depotHead, example); int result = 0;
try{
result = depotHeadMapper.updateByExampleSelective(depotHead, example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
/** /**
* 创建一个唯一的序列号 * 创建一个唯一的序列号
* */ * */
public String buildOnlyNumber(){ public String buildOnlyNumber()throws Exception{
Long buildOnlyNumber=null; Long buildOnlyNumber=null;
synchronized (this){ synchronized (this){
buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ); try{
buildOnlyNumber= depotHeadMapperEx.getBuildOnlyNumber(BusinessConstants.DEPOT_NUMBER_SEQ);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
} }
if(buildOnlyNumber<BusinessConstants.SEQ_TO_STRING_MIN_LENGTH){ if(buildOnlyNumber<BusinessConstants.SEQ_TO_STRING_MIN_LENGTH){
StringBuffer sb=new StringBuffer(buildOnlyNumber.toString()); StringBuffer sb=new StringBuffer(buildOnlyNumber.toString());
@@ -179,68 +285,174 @@ public class DepotHeadService {
} }
} }
public Long getMaxId() { public Long getMaxId()throws Exception {
return depotHeadMapperEx.getMaxId(); Long result = null;
try{
result = depotHeadMapperEx.getMaxId();
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public String findMaterialsListByHeaderId(Long id) { public String findMaterialsListByHeaderId(Long id)throws Exception {
String allReturn = depotHeadMapperEx.findMaterialsListByHeaderId(id); String result = null;
return allReturn; try{
result = depotHeadMapperEx.findMaterialsListByHeaderId(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<DepotHead> findByMonth(String monthTime) { public List<DepotHead> findByMonth(String monthTime)throws Exception {
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
monthTime = monthTime + "-31 23:59:59"; monthTime = monthTime + "-31 23:59:59";
Date month = StringUtil.getDateByString(monthTime, null); Date month = StringUtil.getDateByString(monthTime, null);
example.createCriteria().andOpertimeLessThanOrEqualTo(month).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andOpertimeLessThanOrEqualTo(month).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return depotHeadMapper.selectByExample(example); List<DepotHead> list = null;
try{
list = depotHeadMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<DepotHead> getDepotHeadGiftOut(String projectId) { public List<DepotHead> getDepotHeadGiftOut(String projectId)throws Exception {
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
if (projectId != null) { if (projectId != null) {
example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId)); example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId));
} }
return depotHeadMapper.selectByExample(example); List<DepotHead> list = null;
try{
list =depotHeadMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) { public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) throws Exception{
return depotHeadMapperEx.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows); List<DepotHeadVo4InDetail> list = null;
try{
list =depotHeadMapperEx.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) { public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) throws Exception{
return depotHeadMapperEx.findByAllCount(beginTime, endTime, type, pid, dids, oId); int result = 0;
try{
result =depotHeadMapperEx.findByAllCount(beginTime, endTime, type, pid, dids, oId);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) { public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows)throws Exception {
return depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows); List<DepotHeadVo4InOutMCount> list = null;
try{
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) { public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId)throws Exception {
return depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId); int result = 0;
try{
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<DepotHeadVo4StatementAccount> findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows) { public List<DepotHeadVo4StatementAccount> findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows)throws Exception {
return depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, offset, rows); List<DepotHeadVo4StatementAccount> list = null;
try{
list =depotHeadMapperEx.findStatementAccount(beginTime, endTime, organId, supType, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) { public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) throws Exception{
return depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType); int result = 0;
try{
result =depotHeadMapperEx.findStatementAccountCount(beginTime, endTime, organId, supType);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) { public BigDecimal findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime)throws Exception {
String modeName = ""; String modeName = "";
if (mode.equals("实际")) { if (mode.equals("实际")) {
modeName = "ChangeAmount"; modeName = "ChangeAmount";
} else if (mode.equals("合计")) { } else if (mode.equals("合计")) {
modeName = "DiscountLastMoney"; modeName = "DiscountLastMoney";
} }
return depotHeadMapperEx.findAllMoney(supplierId, type, subType, modeName, endTime); BigDecimal result = null;
try{
result =depotHeadMapperEx.findAllMoney(supplierId, type, subType, modeName, endTime);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<DepotHeadVo4List> getDetailByNumber(String number) { public List<DepotHeadVo4List> getDetailByNumber(String number)throws Exception {
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>(); List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list = depotHeadMapperEx.getDetailByNumber(number); List<DepotHeadVo4List> list = null;
try{
list = depotHeadMapperEx.getDetailByNumber(number);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
if (null != list) { if (null != list) {
for (DepotHeadVo4List dh : list) { for (DepotHeadVo4List dh : list) {
if(dh.getOthermoneylist() != null) { if(dh.getOthermoneylist() != null) {
@@ -288,7 +500,15 @@ public class DepotHeadService {
depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername()); depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername());
depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setCreatetime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT); depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
depotHeadMapperEx.adddepotHead(depotHead); try{
depotHeadMapperEx.adddepotHead(depotHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
/**入库和出库处理预付款信息*/ /**入库和出库处理预付款信息*/
if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){ if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){
if(depotHead.getOrganid()!=null) { if(depotHead.getOrganid()!=null) {
@@ -303,7 +523,14 @@ public class DepotHeadService {
depotHeadOrders.setStatus(BusinessConstants.BILLS_STATUS_SKIP); depotHeadOrders.setStatus(BusinessConstants.BILLS_STATUS_SKIP);
DepotHeadExample example = new DepotHeadExample(); DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andNumberEqualTo(depotHead.getLinknumber()); example.createCriteria().andNumberEqualTo(depotHead.getLinknumber());
depotHeadMapper.updateByExampleSelective(depotHeadOrders, example); try{
depotHeadMapper.updateByExampleSelective(depotHeadOrders, example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
} }
} }
/** /**
@@ -331,7 +558,14 @@ public class DepotHeadService {
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername()); depotHead.setOperpersonname(userInfo==null?null:userInfo.getUsername());
depotHead.setOpertime(new Timestamp(System.currentTimeMillis())); depotHead.setOpertime(new Timestamp(System.currentTimeMillis()));
depotHeadMapperEx.updatedepotHead(depotHead); try{
depotHeadMapperEx.updatedepotHead(depotHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
/**入库和出库处理预付款信息*/ /**入库和出库处理预付款信息*/
if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){ if(BusinessConstants.PAY_TYPE_PREPAID.equals(depotHead.getPaytype())){
if(depotHead.getOrganid()!=null){ if(depotHead.getOrganid()!=null){
@@ -362,7 +596,16 @@ public class DepotHeadService {
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType()) if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())){ &&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())){
//查询单据子表列表 //查询单据子表列表
List<DepotItem> depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(id,BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED); List<DepotItem> depotItemList=null;
try{
depotItemList = depotItemMapperEx.findDepotItemListBydepotheadId(id,BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
/**回收序列号*/ /**回收序列号*/
if(depotItemList!=null&&depotItemList.size()>0){ if(depotItemList!=null&&depotItemList.size()>0){
for(DepotItem depotItem:depotItemList){ for(DepotItem depotItem:depotItemList){
@@ -372,7 +615,15 @@ public class DepotHeadService {
} }
} }
/**删除单据子表数据*/ /**删除单据子表数据*/
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long []{id}); try{
depotItemMapperEx.batchDeleteDepotItemByDepotHeadIds(new Long []{id});
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
/**删除单据主表信息*/ /**删除单据主表信息*/
batchDeleteDepotHeadByIds(id.toString()); batchDeleteDepotHeadByIds(id.toString());
} }
@@ -397,12 +648,21 @@ public class DepotHeadService {
} }
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHeadByIds(String ids) { public int batchDeleteDepotHeadByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT_HEAD,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
return depotHeadMapperEx.batchDeleteDepotHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result = depotHeadMapperEx.batchDeleteDepotHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
} }