|
@ -6,6 +6,7 @@ import cn.hutool.core.exceptions.UtilException; |
|
|
import cn.hutool.json.JSONArray; |
|
|
import cn.hutool.json.JSONArray; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONObject; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
import com.win.framework.common.util.validation.ValidationUtils; |
|
|
import com.win.framework.common.util.validation.ValidationUtils; |
|
@ -25,6 +26,7 @@ import com.win.module.wms.dal.dataobject.inspectRequest.InspectRequestMainDO; |
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
import com.win.module.wms.dal.dataobject.itembasic.ItembasicDO; |
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRecord.PurchasereceiptRecordDetailDO; |
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRecord.PurchasereceiptRecordDetailDO; |
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.inspectJob.InspectJobMainMapper; |
|
|
import com.win.module.wms.dal.mysql.inspectRequest.InspectRequestDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.inspectRequest.InspectRequestDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.inspectRequest.InspectRequestMainMapper; |
|
|
import com.win.module.wms.dal.mysql.inspectRequest.InspectRequestMainMapper; |
|
|
import com.win.module.wms.enums.request.RequestStatusEnum; |
|
|
import com.win.module.wms.enums.request.RequestStatusEnum; |
|
@ -49,8 +51,7 @@ import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.INSPECT_REQUEST_IMPORT_LIST_IS_EMPTY; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.*; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.INSPECT_REQUEST_MAIN_NOT_EXISTS; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 检验申请主 Service 实现类 |
|
|
* 检验申请主 Service 实现类 |
|
@ -66,6 +67,8 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
@Resource |
|
|
@Resource |
|
|
private InspectRequestDetailMapper inspectRequestDetailMapper; |
|
|
private InspectRequestDetailMapper inspectRequestDetailMapper; |
|
|
@Resource |
|
|
@Resource |
|
|
|
|
|
private InspectJobMainMapper inspectJobMainMapper; |
|
|
|
|
|
@Resource |
|
|
private PurchasereceiptRecordMainService purchasereceiptRecordMainService; |
|
|
private PurchasereceiptRecordMainService purchasereceiptRecordMainService; |
|
|
@Resource |
|
|
@Resource |
|
|
private SerialNumberApi serialNumberApi; |
|
|
private SerialNumberApi serialNumberApi; |
|
@ -104,6 +107,10 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
requestStatusState.newObject(requestsettingDO.getAutoCommit(), requestsettingDO.getAutoAgree(), requestsettingDO.getAutoExecute()); |
|
|
requestStatusState.newObject(requestsettingDO.getAutoCommit(), requestsettingDO.getAutoAgree(), requestsettingDO.getAutoExecute()); |
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
inspectRequestMainMapper.insert(mainDO); |
|
|
inspectRequestMainMapper.insert(mainDO); |
|
|
|
|
|
for (InspectRequestDetailDO detailDO : subDOList) { |
|
|
|
|
|
detailDO.setNumber(number); |
|
|
|
|
|
detailDO.setMasterId(mainDO.getId()); |
|
|
|
|
|
} |
|
|
inspectRequestDetailMapper.insertBatch(subDOList); |
|
|
inspectRequestDetailMapper.insertBatch(subDOList); |
|
|
//调用自动执行方法
|
|
|
//调用自动执行方法
|
|
|
if (RequestStatusEnum.HANDLING.getCode().equals(mainDO.getStatus())) { |
|
|
if (RequestStatusEnum.HANDLING.getCode().equals(mainDO.getStatus())) { |
|
@ -159,6 +166,11 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
return inspectRequestMainMapper.selectList(exportReqVO); |
|
|
return inspectRequestMainMapper.selectList(exportReqVO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<InspectRequestMainDO> getInspectRequestMainList(CustomConditions conditions) { |
|
|
|
|
|
return inspectRequestMainMapper.selectSeniorList(conditions); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional |
|
|
@Transactional |
|
|
public List<InspectRequestImportErrorVO> importInspectRequestList(List<InspectRequestMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
public List<InspectRequestImportErrorVO> importInspectRequestList(List<InspectRequestMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
@ -207,6 +219,7 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
inspectRequestMainMapper.insert(mainDO); |
|
|
inspectRequestMainMapper.insert(mainDO); |
|
|
for(InspectRequestDetailDO inspectRequestDetailDO : subDOList) { |
|
|
for(InspectRequestDetailDO inspectRequestDetailDO : subDOList) { |
|
|
inspectRequestDetailDO.setMasterId(mainDO.getId()); |
|
|
inspectRequestDetailDO.setMasterId(mainDO.getId()); |
|
|
|
|
|
inspectRequestDetailDO.setNumber(number); |
|
|
} |
|
|
} |
|
|
inspectRequestDetailMapper.insertBatch(subDOList); |
|
|
inspectRequestDetailMapper.insertBatch(subDOList); |
|
|
} else if (existInspectRequestMainDO != null && mode != 2) { |
|
|
} else if (existInspectRequestMainDO != null && mode != 2) { |
|
@ -222,6 +235,94 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
return errorList; |
|
|
return errorList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public Integer closeInspectRequestMain(Long id) { |
|
|
|
|
|
// 校验存在存在下级单据
|
|
|
|
|
|
InspectRequestMainDO mainDO = validateInspectRequestMainExists(id); |
|
|
|
|
|
Long count = inspectJobMainMapper.selectByRequestNumber(mainDO.getNumber()); |
|
|
|
|
|
if(count > 0) { |
|
|
|
|
|
throw new ServiceException(INSPECT_REQUEST_JOB_EXISTS); |
|
|
|
|
|
} |
|
|
|
|
|
RequestStatusState requestStatusState = new RequestStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = requestStatusState.close(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(INSPECT_REQUEST_CANNOT_CLOSE); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode());//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "inspectRequest", "关闭了到货校验申请", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return inspectRequestMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public Integer submitInspectRequestMain(Long id) { |
|
|
|
|
|
InspectRequestMainDO mainDO = validateInspectRequestMainExists(id); |
|
|
|
|
|
RequestStatusState requestStatusState = new RequestStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = requestStatusState.submit(mainDO.getAutoAgree(), mainDO.getAutoExecute()); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(INSPECT_REQUEST_CANNOT_SUBMIT); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
|
|
|
//调用自动执行方法
|
|
|
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(mainDO.getStatus())) { |
|
|
|
|
|
this.generateJob(mainDO, inspectRequestDetailMapper.selectList(mainDO.getId())); |
|
|
|
|
|
} |
|
|
|
|
|
trendsApi.createTrends(id, "inspectRequest", "提交了到货校验申请", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return inspectRequestMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public Integer agreeInspectRequestMain(Long id) { |
|
|
|
|
|
// 校验存在
|
|
|
|
|
|
InspectRequestMainDO mainDO = validateInspectRequestMainExists(id); |
|
|
|
|
|
RequestStatusState requestStatusState = new RequestStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = requestStatusState.agree(mainDO.getAutoExecute()); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(INSPECT_REQUEST_CANNOT_AGREE); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
|
|
|
//调用自动执行方法
|
|
|
|
|
|
if(RequestStatusEnum.HANDLING.getCode().equals(mainDO.getStatus())) { |
|
|
|
|
|
this.generateJob(mainDO, inspectRequestDetailMapper.selectList(mainDO.getId())); |
|
|
|
|
|
} |
|
|
|
|
|
trendsApi.createTrends(id, "inspectRequest", "审批同意了到货校验申请", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return inspectRequestMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public Integer handleInspectRequestMain(Long id) { |
|
|
|
|
|
// 校验存在
|
|
|
|
|
|
InspectRequestMainDO mainDO = validateInspectRequestMainExists(id); |
|
|
|
|
|
RequestStatusState requestStatusState = new RequestStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = requestStatusState.handle(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(INSPECT_REQUEST_CANNOT_HANDLE); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
|
|
|
//调用执行方法
|
|
|
|
|
|
this.generateJob(mainDO, inspectRequestDetailMapper.selectList(mainDO.getId())); |
|
|
|
|
|
trendsApi.createTrends(id, "inspectRequest", "执行了到货校验申请", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return inspectRequestMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public Integer abortInspectRequestMain(Long id) { |
|
|
|
|
|
// 校验存在
|
|
|
|
|
|
InspectRequestMainDO mainDO = validateInspectRequestMainExists(id); |
|
|
|
|
|
RequestStatusState requestStatusState = new RequestStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = requestStatusState.reject(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(INSPECT_REQUEST_CANNOT_ABORT); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(requestStatusState.getState().getCode()); |
|
|
|
|
|
trendsApi.createTrends(id, "inspectRequest", "审批拒绝了到货校验申请", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return inspectRequestMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生成收货检验任务,不要改动事务传播方式,否则会有事务问题 |
|
|
* 生成收货检验任务,不要改动事务传播方式,否则会有事务问题 |
|
|
* @param mainDO 收货检验主 |
|
|
* @param mainDO 收货检验主 |
|
@ -331,10 +432,12 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
mainDO.setSampleQty(selectInspectType(mainDO.getReceiveQty(), rule)); |
|
|
mainDO.setSampleQty(selectInspectType(mainDO.getReceiveQty(), rule)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void validateInspectRequestMainExists(Long id) { |
|
|
private InspectRequestMainDO validateInspectRequestMainExists(Long id) { |
|
|
if (inspectRequestMainMapper.selectById(id) == null) { |
|
|
InspectRequestMainDO mainDO = inspectRequestMainMapper.selectById(id); |
|
|
|
|
|
if (mainDO == null) { |
|
|
throw exception(INSPECT_REQUEST_MAIN_NOT_EXISTS); |
|
|
throw exception(INSPECT_REQUEST_MAIN_NOT_EXISTS); |
|
|
} |
|
|
} |
|
|
|
|
|
return mainDO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//校验主表公共方法(适用于新增/修改)
|
|
|
//校验主表公共方法(适用于新增/修改)
|
|
@ -356,6 +459,7 @@ public class InspectRequestMainServiceImpl implements InspectRequestMainService |
|
|
//校验子表公共方法(适用于新增/修改)
|
|
|
//校验子表公共方法(适用于新增/修改)
|
|
|
private void validatorDetail(InspectRequestDetailDO detailDo, InspectRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
private void validatorDetail(InspectRequestDetailDO detailDo, InspectRequestMainDO mainDo, BusinesstypeDO businesstypeDO) { |
|
|
ItembasicDO itembasicDO = validatorItembasic(detailDo.getItemCode()); |
|
|
ItembasicDO itembasicDO = validatorItembasic(detailDo.getItemCode()); |
|
|
|
|
|
detailDo.setNumber(mainDo.getNumber()); |
|
|
detailDo.setItemDesc1(itembasicDO.getDesc1()); |
|
|
detailDo.setItemDesc1(itembasicDO.getDesc1()); |
|
|
detailDo.setItemDesc2(itembasicDO.getDesc2()); |
|
|
detailDo.setItemDesc2(itembasicDO.getDesc2()); |
|
|
detailDo.setItemName(itembasicDO.getName()); |
|
|
detailDo.setItemName(itembasicDO.getName()); |
|
|