|
|
@ -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,6 +126,7 @@ 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) { |
|
|
|
QueryWrapper queryWrapperMain = new QueryWrapper(); |
|
|
@ -224,4 +237,90 @@ public class PurchasePlanMainServiceImpl implements PurchasePlanMainService { |
|
|
|
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);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
} |
|
|
|