|
|
@ -7,6 +7,8 @@ import com.win.framework.common.exception.ServiceException; |
|
|
|
import com.win.framework.common.pojo.CustomConditions; |
|
|
|
import com.win.framework.common.pojo.PageResult; |
|
|
|
import com.win.framework.dict.core.util.DictFrameworkUtils; |
|
|
|
import com.win.module.infra.api.trends.TrendsApi; |
|
|
|
import com.win.module.infra.enums.TrendsTypeEnum; |
|
|
|
import com.win.module.wms.controller.purchasePlan.vo.*; |
|
|
|
import com.win.module.wms.convert.purchasePlan.PurchasePlanDetailConvert; |
|
|
|
import com.win.module.wms.convert.purchasePlan.PurchasePlanMainConvert; |
|
|
@ -19,12 +21,14 @@ import com.win.module.wms.dal.dataobject.supplieritem.SupplieritemDO; |
|
|
|
import com.win.module.wms.dal.mysql.purchasePlan.PurchasePlanDetailMapper; |
|
|
|
import com.win.module.wms.dal.mysql.purchasePlan.PurchasePlanMainMapper; |
|
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
import com.win.module.wms.enums.plan.PlanStatusEnum; |
|
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
import com.win.module.wms.service.shift.ShiftService; |
|
|
|
import com.win.module.wms.service.supplieritem.SupplieritemService; |
|
|
|
import com.win.module.wms.util.JobUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
@ -35,7 +39,7 @@ import java.util.List; |
|
|
|
|
|
|
|
import static com.win.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.PURCHASE_PLAN_MAIN_NOT_EXISTS; |
|
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.PURCHASERECEIPT_REQUEST_MAIN_NOT_EXISTS; |
|
|
|
|
|
|
|
/** |
|
|
|
* 要货计划主 Service 实现类 |
|
|
@ -58,6 +62,9 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
private SupplieritemService supplieritemService; |
|
|
|
@Resource |
|
|
|
private JobUtils jobUtils; |
|
|
|
@Resource |
|
|
|
private TrendsApi trendsApi; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public Long createPurchasePlanMain(PurchasePlanMainCreateReqVO createReqVO) { |
|
|
@ -76,6 +83,7 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
PurchasePlanMainDO updateObj = PurchasePlanMainConvert.INSTANCE.convert(updateReqVO); |
|
|
|
purchasePlanMainMapper.updateById(updateObj); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageResult<PurchasePlanMainDO> getPurchasePlanMainSenior(CustomConditions conditions) { |
|
|
|
return purchasePlanMainMapper.selectSenior(conditions); |
|
|
@ -89,12 +97,16 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
purchasePlanMainMapper.deleteById(id); |
|
|
|
} |
|
|
|
|
|
|
|
private void validatePurchasePlanMainExists(Long id) { |
|
|
|
if (purchasePlanMainMapper.selectById(id) == null) { |
|
|
|
throw exception(PURCHASE_PLAN_MAIN_NOT_EXISTS); |
|
|
|
private PurchasePlanMainDO validatePurchasePlanMainExists(Long id) { |
|
|
|
PurchasePlanMainDO purchasePlanMainDO = purchasePlanMainMapper.selectById(id); |
|
|
|
if (purchasePlanMainDO == null) { |
|
|
|
throw exception(PURCHASERECEIPT_REQUEST_MAIN_NOT_EXISTS); |
|
|
|
} |
|
|
|
return purchasePlanMainDO; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PurchasePlanMainDO getPurchasePlanMain(Long id) { |
|
|
|
return purchasePlanMainMapper.selectById(id); |
|
|
@ -114,34 +126,35 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
public List<PurchasePlanMainDO> getPurchasePlanMainList(PurchasePlanMainExportReqVO exportReqVO) { |
|
|
|
return purchasePlanMainMapper.selectList(exportReqVO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PurchasePlanDetailDO selectPurchasePlan(String pnubmer,String psupplierCode,String ppoNumber,String ppoLine,String pitemCode){ |
|
|
|
public PurchasePlanDetailDO selectPurchasePlan(String pnubmer, String psupplierCode, String ppoNumber, String ppoLine, String pitemCode) { |
|
|
|
QueryWrapper queryWrapperMain = new QueryWrapper(); |
|
|
|
queryWrapperMain.eq("number",pnubmer); |
|
|
|
queryWrapperMain.eq("supplier_code",psupplierCode); |
|
|
|
queryWrapperMain.eq("number", pnubmer); |
|
|
|
queryWrapperMain.eq("supplier_code", psupplierCode); |
|
|
|
PurchasePlanMainDO purchasePlanMainDO = purchasePlanMainMapper.selectOne(queryWrapperMain); |
|
|
|
if(purchasePlanMainDO != null && "TRUE".equals(purchasePlanMainDO.getAvailable())){ |
|
|
|
if(!"CLOSED".equals(purchasePlanMainDO.getStatus())){ |
|
|
|
if (purchasePlanMainDO != null && "TRUE".equals(purchasePlanMainDO.getAvailable())) { |
|
|
|
if (!"CLOSED".equals(purchasePlanMainDO.getStatus())) { |
|
|
|
QueryWrapper queryWrapperDetail = new QueryWrapper(); |
|
|
|
queryWrapperDetail.eq("master_id",purchasePlanMainDO.getId()); |
|
|
|
queryWrapperDetail.eq("number",ppoNumber); |
|
|
|
queryWrapperDetail.eq("po_line",ppoLine); |
|
|
|
queryWrapperDetail.eq("item_code",pitemCode); |
|
|
|
queryWrapperDetail.eq("master_id", purchasePlanMainDO.getId()); |
|
|
|
queryWrapperDetail.eq("number", ppoNumber); |
|
|
|
queryWrapperDetail.eq("po_line", ppoLine); |
|
|
|
queryWrapperDetail.eq("item_code", pitemCode); |
|
|
|
PurchasePlanDetailDO purchasePlanDetailDO = purchasePlanDetailMapper.selectOne(queryWrapperDetail); |
|
|
|
if(purchasePlanDetailDO != null && "TRUE".equals(purchasePlanDetailDO.getAvailable())){ |
|
|
|
if (purchasePlanDetailDO != null && "TRUE".equals(purchasePlanDetailDO.getAvailable())) { |
|
|
|
return purchasePlanDetailDO; |
|
|
|
}else { |
|
|
|
throw new UtilException( "要货计划明细:订单号" + ppoNumber + "、订单行" + ppoLine + "、零件号" + pitemCode + "、无效"); |
|
|
|
} else { |
|
|
|
throw new UtilException("要货计划明细:订单号" + ppoNumber + "、订单行" + ppoLine + "、零件号" + pitemCode + "、无效"); |
|
|
|
} |
|
|
|
}else { |
|
|
|
throw new UtilException( "要货计划" + pnubmer + "已经关闭"); |
|
|
|
} else { |
|
|
|
throw new UtilException("要货计划" + pnubmer + "已经关闭"); |
|
|
|
} |
|
|
|
}else { |
|
|
|
throw new UtilException( "根据计划单号" + pnubmer + ",供应商代码" + psupplierCode + "未查找到要货计划"); |
|
|
|
} else { |
|
|
|
throw new UtilException("根据计划单号" + pnubmer + ",供应商代码" + psupplierCode + "未查找到要货计划"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public List<PurchasePlanMainImportErrorVO> importPurchasePlanMainList(List<PurchasePlanMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
|
public List<PurchasePlanMainImportErrorVO> importPurchasePlanMainList(List<PurchasePlanMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
|
throw exception(PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
|
} |
|
|
@ -180,7 +193,7 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
} |
|
|
|
|
|
|
|
PurchasePlanDetailCreateReqVO purchasePlanDetailCreateReqVO = PurchasePlanDetailConvert.INSTANCE.convert1(purchasePlanDetailDO); |
|
|
|
PurchasePlanMainImportErrorVO importVO = PurchasePlanDetailConvert.INSTANCE.convert(createReqVO, purchasePlanDetailCreateReqVO); |
|
|
|
PurchasePlanMainImportErrorVO importVO = PurchasePlanDetailConvert.INSTANCE.convert(createReqVO, purchasePlanDetailCreateReqVO); |
|
|
|
//进行子表的错误统计
|
|
|
|
//主表没有错误 写入库里
|
|
|
|
if (!messageMain.equals("") || !messageDetail.equals("")) { |
|
|
@ -195,7 +208,7 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
|
|
|
|
if (errorList.isEmpty()) { |
|
|
|
// 判断如果不存在,在进行插入
|
|
|
|
PurchasePlanMainDO existPurchaseclaimRequestMainDO = purchasePlanMainMapper.selectByNumber(createReqVO.getNumber()); |
|
|
|
PurchasePlanMainDO existPurchaseclaimRequestMainDO = purchasePlanMainMapper.selectByNumber(createReqVO.getNumber()); |
|
|
|
if (existPurchaseclaimRequestMainDO == null && mode != 3) { |
|
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("PurchasePlan"); |
|
|
@ -218,10 +231,96 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
} |
|
|
|
}); |
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
|
if(!errorList.isEmpty() && !updatePart) { |
|
|
|
if (!errorList.isEmpty() && !updatePart) { |
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
|
|
|
} |
|
|
|
return errorList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer closePurchasePlanMain(Long id) { |
|
|
|
PurchasePlanMainDO mainDO = validatePurchasePlanMainExists(id); |
|
|
|
mainDO.setStatus(PlanStatusEnum.CLOSED.getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "plan_purchase_main", "关闭了要货计划申请", TrendsTypeEnum.UPDATE); |
|
|
|
return purchasePlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer openPurchasePlanMain(Long id) { |
|
|
|
PurchasePlanMainDO mainDO = validatePurchasePlanMainExists(id); |
|
|
|
mainDO.setStatus(PlanStatusEnum.NEW.getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "plan_purchase_main", "打开了要货计划申请", TrendsTypeEnum.UPDATE); |
|
|
|
return purchasePlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer publishPurchasePlanMain(Long id) { |
|
|
|
PurchasePlanMainDO mainDO = validatePurchasePlanMainExists(id); |
|
|
|
mainDO.setStatus(PlanStatusEnum.PUBLISHED.getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "plan_purchase_main", "发布了要货计划申请", TrendsTypeEnum.UPDATE); |
|
|
|
return purchasePlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer witPurchasePlanMain(Long id) { |
|
|
|
PurchasePlanMainDO mainDO = validatePurchasePlanMainExists(id); |
|
|
|
mainDO.setStatus(PlanStatusEnum.NEW.getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "plan_purchase_main", "下架了要货计划申请", TrendsTypeEnum.UPDATE); |
|
|
|
return purchasePlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer accPurchasePlanMain(Long id) { |
|
|
|
PurchasePlanMainDO mainDO = validatePurchasePlanMainExists(id); |
|
|
|
mainDO.setStatus(PlanStatusEnum.AGREED.getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "plan_purchase_main", "接受了要货计划申请", TrendsTypeEnum.UPDATE); |
|
|
|
return purchasePlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer rejPurchasePlanMain(Long id) { |
|
|
|
PurchasePlanMainDO mainDO = validatePurchasePlanMainExists(id); |
|
|
|
mainDO.setStatus(PlanStatusEnum.REFUSED.getCode());//增加操作记录
|
|
|
|
trendsApi.createTrends(id, "plan_purchase_main", "驳回了要货计划申请", TrendsTypeEnum.UPDATE); |
|
|
|
return purchasePlanMainMapper.updateById(mainDO); |
|
|
|
} |
|
|
|
|
|
|
|
//更新要货计划的已发货数量
|
|
|
|
// @Override
|
|
|
|
// @Transactional
|
|
|
|
// public void updatePlanPurchaseShippedQty(String number, String poNumber,String poLine, String itemCode, BigDecimal shippedQty) {
|
|
|
|
// QueryWrapper<PurchasePlanMainDO> purchaseMainDOQueryWrapper = new QueryWrapper();
|
|
|
|
// purchaseMainDOQueryWrapper.eq("number", poNumber);
|
|
|
|
// purchaseMainDOQueryWrapper.eq("status", OrderStatusEnum.PUBLISHED.getCode());
|
|
|
|
// List<PurchaseMainDO> purchaseMainDOList = purchaseMainMapper.selectList(purchaseMainDOQueryWrapper);
|
|
|
|
// if (purchaseMainDOList != null && purchaseMainDOList.size() > 0) {
|
|
|
|
// for (PurchaseMainDO purchaseMainDO : purchaseMainDOList) {
|
|
|
|
// QueryWrapper<PurchaseDetailDO> purchaseDetailDOQueryWrapper = new QueryWrapper();
|
|
|
|
// purchaseDetailDOQueryWrapper.eq("number", poNumber);
|
|
|
|
// purchaseDetailDOQueryWrapper.eq("line_number", poNumber);
|
|
|
|
// purchaseDetailDOQueryWrapper.eq("item_code", poNumber);
|
|
|
|
// purchaseDetailDOQueryWrapper.eq("available", "TRUE");
|
|
|
|
// List<PurchaseDetailDO> purchaseDetailDOList = purchaseDetailMapper.selectList(purchaseDetailDOQueryWrapper);
|
|
|
|
// for (PurchaseDetailDO purchaseDetailDO : purchaseDetailDOList) {
|
|
|
|
// //如果是离散单
|
|
|
|
// if ("DISCRETE".equals(purchaseMainDO.getType())) {
|
|
|
|
// purchaseDetailDO.setPlannedQty(purchaseDetailDO.getPlannedQty().add(planQty));
|
|
|
|
// } else {
|
|
|
|
// purchaseDetailDO.setPlannedQty(planQty);
|
|
|
|
// }
|
|
|
|
// trendsApi.createTrends(purchaseDetailDO.getId(), "plan_purchase_detail", "修改了采购订单申请子", TrendsTypeEnum.UPDATE);
|
|
|
|
// purchaseDetailMapper.updateById(purchaseDetailDO);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// throw new ServiceException(PURCHASE_MAIN_NUMBERNO);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|