|
@ -2,25 +2,52 @@ package com.win.module.wms.service.production; |
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
import com.win.framework.common.exception.ServiceException; |
|
|
|
|
|
import com.win.framework.common.pojo.CommonResult; |
|
|
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.dict.core.util.DictFrameworkUtils; |
|
|
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.system.api.dict.DictDataApi; |
|
|
|
|
|
import com.win.module.system.api.serialnumber.SerialNumberApi; |
|
|
|
|
|
import com.win.module.system.enums.serialNumber.RuleCodeEnum; |
|
|
import com.win.module.wms.controller.production.vo.*; |
|
|
import com.win.module.wms.controller.production.vo.*; |
|
|
|
|
|
import com.win.module.wms.controller.work.vo.WorkDetailCreateReqVO; |
|
|
|
|
|
import com.win.module.wms.controller.work.vo.WorkMainImportErrorVO; |
|
|
import com.win.module.wms.convert.production.ProductionDetailConvert; |
|
|
import com.win.module.wms.convert.production.ProductionDetailConvert; |
|
|
import com.win.module.wms.convert.production.ProductionMainConvert; |
|
|
import com.win.module.wms.convert.production.ProductionMainConvert; |
|
|
|
|
|
import com.win.module.wms.convert.purchasereceiptRequest.PurchasereceiptRequestDetailConvert; |
|
|
|
|
|
import com.win.module.wms.convert.work.WorkDetailConvert; |
|
|
|
|
|
import com.win.module.wms.convert.work.WorkMainConvert; |
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
import com.win.module.wms.dal.dataobject.businesstype.BusinesstypeDO; |
|
|
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.production.ProductionDetailDO; |
|
|
import com.win.module.wms.dal.dataobject.production.ProductionDetailDO; |
|
|
import com.win.module.wms.dal.dataobject.production.ProductionMainDO; |
|
|
import com.win.module.wms.dal.dataobject.production.ProductionMainDO; |
|
|
import com.win.module.wms.dal.dataobject.productionline.ProductionlineDO; |
|
|
import com.win.module.wms.dal.dataobject.productionline.ProductionlineDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestDetailDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRequest.PurchasereceiptRequestMainDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.requestsetting.RequestsettingDO; |
|
|
import com.win.module.wms.dal.dataobject.team.TeamDO; |
|
|
import com.win.module.wms.dal.dataobject.team.TeamDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.work.WorkDetailDO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.work.WorkMainDO; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.documentSwitch.SwitchMapper; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.documentsetting.DocumentsettingMapper; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.preparetoissue.PreparetoissueMainMapper; |
|
|
import com.win.module.wms.dal.mysql.production.ProductionDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.production.ProductionDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.production.ProductionMainMapper; |
|
|
import com.win.module.wms.dal.mysql.production.ProductionMainMapper; |
|
|
import com.win.module.wms.dal.mysql.productreceiptJob.ProductreceiptJobDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.productreceiptJob.ProductreceiptJobDetailMapper; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.productreceiptRequest.ProductreceiptRequestMainMapper; |
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
import com.win.module.wms.enums.DictTypeConstants; |
|
|
|
|
|
import com.win.module.wms.enums.plan.PlanStatusState; |
|
|
|
|
|
import com.win.module.wms.enums.request.RequestStatusEnum; |
|
|
|
|
|
import com.win.module.wms.enums.request.RequestStatusState; |
|
|
|
|
|
import com.win.module.wms.service.bom.BomService; |
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
import com.win.module.wms.service.itembasic.ItembasicService; |
|
|
|
|
|
import com.win.module.wms.service.preparetoissue.PreparetoissueMainService; |
|
|
import com.win.module.wms.service.productionline.ProductionlineService; |
|
|
import com.win.module.wms.service.productionline.ProductionlineService; |
|
|
import com.win.module.wms.service.productionlineitem.ProductionlineitemService; |
|
|
import com.win.module.wms.service.productionlineitem.ProductionlineitemService; |
|
|
import com.win.module.wms.service.shift.ShiftService; |
|
|
import com.win.module.wms.service.shift.ShiftService; |
|
@ -29,19 +56,29 @@ import com.win.module.wms.service.team.TeamService; |
|
|
import com.win.module.wms.service.work.WorkMainService; |
|
|
import com.win.module.wms.service.work.WorkMainService; |
|
|
import com.win.module.wms.service.workshop.WorkshopService; |
|
|
import com.win.module.wms.service.workshop.WorkshopService; |
|
|
import com.win.module.wms.util.JobUtils; |
|
|
import com.win.module.wms.util.JobUtils; |
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
import org.springframework.web.bind.annotation.PutMapping; |
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import javax.validation.Validator; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Collection; |
|
|
import java.util.Collection; |
|
|
|
|
|
import java.util.Date; |
|
|
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.PRODUCTION_MAIN_NOT_EXISTS; |
|
|
import static com.win.framework.common.pojo.CommonResult.success; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY; |
|
|
import static com.win.module.wms.enums.ErrorCodeConstants.*; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生产计划主 Service 实现类 |
|
|
* 生产计划主 Service 实现类 |
|
@ -52,6 +89,19 @@ import static com.win.module.wms.enums.ErrorCodeConstants.PURCHASECLAIM_REQUEST_ |
|
|
@Validated |
|
|
@Validated |
|
|
public class ProductionMainServiceImpl implements ProductionMainService { |
|
|
public class ProductionMainServiceImpl implements ProductionMainService { |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private SwitchMapper switchMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private DictDataApi dictDataApi; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private TrendsApi trendsApi; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private SerialNumberApi serialNumberApi; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private Validator validator; |
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
private BomService bomService; |
|
|
@Resource |
|
|
@Resource |
|
|
private ProductionMainMapper productionMainMapper; |
|
|
private ProductionMainMapper productionMainMapper; |
|
|
@Resource |
|
|
@Resource |
|
@ -77,18 +127,34 @@ public class ProductionMainServiceImpl implements ProductionMainService { |
|
|
@Resource |
|
|
@Resource |
|
|
private WorkMainService workMainService; |
|
|
private WorkMainService workMainService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
public Long createProductionMain(ProductionMainCreateReqVO createReqVO) { |
|
|
public Long createProductionMain(ProductionMainCreateReqVO createReqVO) { |
|
|
// 插入
|
|
|
// 插入
|
|
|
ProductionMainDO productionMain = ProductionMainConvert.INSTANCE.convert(createReqVO); |
|
|
ProductionMainDO mainDO = ProductionMainConvert.INSTANCE.convert(createReqVO); |
|
|
productionMainMapper.insert(productionMain); |
|
|
List<ProductionDetailDO> subDOList = ProductionDetailConvert.INSTANCE.convertList03(createReqVO.getSubList()); |
|
|
|
|
|
for (ProductionDetailDO detailDO : subDOList) { |
|
|
|
|
|
this.validateProductionDetailCreate(mainDO, detailDO); |
|
|
|
|
|
} |
|
|
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.WORK_PLAN.getCode()); |
|
|
|
|
|
mainDO.setNumber(number); |
|
|
|
|
|
mainDO.setBusinessType("ProductReceipt"); // 业务类型:制品收货
|
|
|
|
|
|
productionMainMapper.insert(mainDO); |
|
|
|
|
|
for (ProductionDetailDO detailDO : subDOList) { |
|
|
|
|
|
detailDO.setMasterId(mainDO.getId()); |
|
|
|
|
|
detailDO.setNumber(number); |
|
|
|
|
|
detailDO.setGoodQty(new BigDecimal(0.0)); |
|
|
|
|
|
detailDO.setNotGoodQty(new BigDecimal(0.0)); |
|
|
|
|
|
} |
|
|
|
|
|
productionDetailMapper.insertBatch(subDOList); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(mainDO.getId(), "productionMain", "增加了生产计划", TrendsTypeEnum.CREATE); |
|
|
// 返回
|
|
|
// 返回
|
|
|
return productionMain.getId(); |
|
|
return mainDO.getId(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
public void updateProductionMain(ProductionMainUpdateReqVO updateReqVO) { |
|
|
public void updateProductionMain(ProductionMainUpdateReqVO updateReqVO) { |
|
|
// 校验存在
|
|
|
// 校验存在
|
|
|
validateProductionMainExists(updateReqVO.getId()); |
|
|
validateProductionMainExists(updateReqVO.getId()); |
|
@ -105,10 +171,12 @@ public class ProductionMainServiceImpl implements ProductionMainService { |
|
|
productionMainMapper.deleteById(id); |
|
|
productionMainMapper.deleteById(id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void validateProductionMainExists(Long id) { |
|
|
private ProductionMainDO validateProductionMainExists(Long id) { |
|
|
if (productionMainMapper.selectById(id) == null) { |
|
|
ProductionMainDO existProductionMainDO = productionMainMapper.selectById(id); |
|
|
|
|
|
if (existProductionMainDO == null) { |
|
|
throw exception(PRODUCTION_MAIN_NOT_EXISTS); |
|
|
throw exception(PRODUCTION_MAIN_NOT_EXISTS); |
|
|
} |
|
|
} |
|
|
|
|
|
return existProductionMainDO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -163,135 +231,154 @@ public class ProductionMainServiceImpl implements ProductionMainService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<ProductionMainImportErrorVO> importProductionMainList(List<ProductionMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
public List<ProductionMainDO> getProductionMainList(CustomConditions conditions) { |
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
return productionMainMapper.selectSeniorList(conditions); |
|
|
throw exception(PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
|
|
|
} |
|
|
|
|
|
List<ProductionMainImportErrorVO> errorList = new ArrayList<>(); |
|
|
|
|
|
datas.forEach(createReqVO -> { |
|
|
|
|
|
// 校验,判断是否有不符合的原因,并加入errorList,如果主表则所有子表都加入errorList
|
|
|
|
|
|
String messageMain = ""; |
|
|
|
|
|
//主表的验证
|
|
|
|
|
|
// 校验班组基础信息
|
|
|
|
|
|
try { |
|
|
|
|
|
if (!"".equals(createReqVO.getTeam())) { |
|
|
|
|
|
TeamDO teamDO = teamService.selectTeamExist(createReqVO.getTeam()); |
|
|
|
|
|
if (teamDO == null) { |
|
|
|
|
|
messageMain += "班组" + createReqVO.getTeam() + "无效" + ","; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} catch (Exception ex) { |
|
|
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
/** |
|
|
|
|
|
* 新增校验 |
|
|
|
|
|
* @param detailDo |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
private void validateProductionDetailCreate(ProductionMainDO mainDo, ProductionDetailDO detailDo) { |
|
|
|
|
|
// 校验物品代码
|
|
|
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(detailDo.getItemCode()); |
|
|
|
|
|
if (!itembasicDO.getUom().equals(detailDo.getUom())) { |
|
|
|
|
|
throw exception(ITEMBASIC_UOM_EXCEPTION, dictDataApi.selectDictValue(detailDo.getUom()).getLabel(), dictDataApi.selectDictValue(itembasicDO.getUom()).getLabel()); |
|
|
} |
|
|
} |
|
|
|
|
|
// 校验车间 基础信息
|
|
|
|
|
|
workshopService.selectWorkshopExist(mainDo.getWorkshop()); |
|
|
|
|
|
// 校验生产线基础信息
|
|
|
|
|
|
productionlineService.productionLineCodeExist(mainDo.getProductionLine()); |
|
|
|
|
|
// 校验班组基础信息
|
|
|
|
|
|
teamService.selectTeamExist(mainDo.getTeam()); |
|
|
// 校验班次基础信息
|
|
|
// 校验班次基础信息
|
|
|
try { |
|
|
shiftService.selectShiftExist(mainDo.getShift()); |
|
|
if (!"".equals(createReqVO.getShift())) { |
|
|
// 校验生产线和物品关系
|
|
|
TeamDO teamDO = teamService.selectTeamExist(createReqVO.getTeam()); |
|
|
productionlineitemService.productionLineCodeAndpItemCodeExist(mainDo.getProductionLine(), detailDo.getItemCode()); |
|
|
if (teamDO == null) { |
|
|
// 校验物品和bom关系
|
|
|
messageMain += "班组" + createReqVO.getTeam() + "无效" + ","; |
|
|
bomService.bomItemCodeAndVersionExist(detailDo.getItemCode(), detailDo.getBomVersion()); |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
messageMain += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//子表的验证
|
|
|
/** |
|
|
List<ProductionDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
* 主表校验导入 |
|
|
List<ProductionDetailDO> subDOList = ProductionDetailConvert.INSTANCE.convertList03(subList); |
|
|
* @param mainDo |
|
|
for (ProductionDetailDO purchasePlanDetailDO : subDOList) { |
|
|
* @return |
|
|
String messageDetail = ""; |
|
|
*/ |
|
|
// 校验物品基础信息
|
|
|
private String validateProductionMainImport(ProductionMainDO mainDo) { |
|
|
|
|
|
StringBuilder message = new StringBuilder(); |
|
|
try { |
|
|
try { |
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(purchasePlanDetailDO.getItemCode()); |
|
|
ValidationUtils.validate(validator, mainDo); |
|
|
if (itembasicDO.getUom() != purchasePlanDetailDO.getUom()) { |
|
|
} catch (Exception ex) { |
|
|
messageDetail += "计量单位" + itembasicDO.getUom() + "错误,应该是" + purchasePlanDetailDO.getUom() + ","; |
|
|
message.append(ex.getMessage()).append(","); |
|
|
} else { |
|
|
|
|
|
// purchasePlanDetailDO.setItemDesc1(itembasicDO.getDesc1());
|
|
|
|
|
|
// purchasePlanDetailDO.setItemDesc2(itembasicDO.getDesc2());
|
|
|
|
|
|
// purchasePlanDetailDO.setItemName(itembasicDO.getName());
|
|
|
|
|
|
// purchasePlanDetailDO.setProjectCode(itembasicDO.getProject());
|
|
|
|
|
|
} |
|
|
|
|
|
} catch (ServiceException ex) { |
|
|
|
|
|
messageDetail += ex.getMessage() + ","; |
|
|
|
|
|
} |
|
|
} |
|
|
// 校验车间 基础信息
|
|
|
// 校验车间 基础信息
|
|
|
try { |
|
|
try { |
|
|
workshopService.selectWorkshopExist(createReqVO.getWorkshop()); |
|
|
workshopService.selectWorkshopExist(mainDo.getWorkshop()); |
|
|
} catch (Exception ex) { |
|
|
} catch (Exception ex) { |
|
|
messageMain += ex.getMessage() + ","; |
|
|
message.append(ex.getMessage()).append(","); |
|
|
} |
|
|
} |
|
|
// 校验生产线基础信息
|
|
|
// 校验生产线基础信息
|
|
|
try { |
|
|
try { |
|
|
ProductionlineDO productionlineDO = productionlineService.productionLineCodeExist(createReqVO.getProductionLine()); |
|
|
productionlineService.productionLineCodeExist(mainDo.getProductionLine()); |
|
|
if (productionlineDO != null) { |
|
|
|
|
|
//prodlinedto.fg_location_code=to_location_code
|
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception ex) { |
|
|
} catch (Exception ex) { |
|
|
messageMain += ex.getMessage() + ","; |
|
|
message.append(ex.getMessage()).append(","); |
|
|
} |
|
|
} |
|
|
|
|
|
// 校验班组基础信息
|
|
|
// 校验工位基础信息
|
|
|
|
|
|
// try {
|
|
|
|
|
|
// if("".equals(work_station_code){
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
|
|
|
|
|
// } catch (Exception ex) {
|
|
|
|
|
|
// messageMain += ex.getMessage() + ",";
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 校验零件生产线关系
|
|
|
|
|
|
try { |
|
|
try { |
|
|
// productionlineitemService.productionLineCodeAndpItemCodeExist(createReqVO.getProductionLineCode(), purchasePlanDetailDO.getItemCode());
|
|
|
teamService.selectTeamExist(mainDo.getTeam()); |
|
|
} catch (Exception ex) { |
|
|
} catch (Exception ex) { |
|
|
messageMain += ex.getMessage() + ","; |
|
|
message.append(ex.getMessage()).append(","); |
|
|
} |
|
|
} |
|
|
|
|
|
// 校验班次基础信息
|
|
|
// 检验生产订单
|
|
|
|
|
|
try { |
|
|
try { |
|
|
workMainService.selectWorkExist(createReqVO.getNumber(),purchasePlanDetailDO.getItemCode()); |
|
|
shiftService.selectShiftExist(mainDo.getShift()); |
|
|
} catch (Exception ex) { |
|
|
} catch (Exception ex) { |
|
|
messageMain += ex.getMessage() + ","; |
|
|
message.append(ex.getMessage()).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
return message.toString(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ProductionDetailCreateReqVO purchasePlanDetailCreateReqVO = ProductionDetailConvert.INSTANCE.convert1(purchasePlanDetailDO); |
|
|
/** |
|
|
ProductionMainImportErrorVO importVO = ProductionDetailConvert.INSTANCE.convert(createReqVO, purchasePlanDetailCreateReqVO); |
|
|
* 子表校验导入 |
|
|
//进行子表的错误统计
|
|
|
* @param detailDo |
|
|
//主表没有错误 写入库里
|
|
|
* @return |
|
|
if (!messageMain.equals("") || !messageDetail.equals("")) { |
|
|
*/ |
|
|
importVO.setImportStatus("失败"); |
|
|
private String validateProductionDetailImport(ProductionMainDO mainDo, ProductionDetailDO detailDo) { |
|
|
messageMain = messageMain + messageDetail; |
|
|
StringBuilder message = new StringBuilder(); |
|
|
importVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
try { |
|
|
errorList.add(importVO); |
|
|
ValidationUtils.validate(validator, detailDo); |
|
|
} else { |
|
|
} catch (Exception e) { |
|
|
purchasePlanDetailDO.setNumber(createReqVO.getNumber()); |
|
|
message.append(e.getMessage()).append(","); |
|
|
purchasePlanDetailDO.setMasterId(createReqVO.getId()); |
|
|
} |
|
|
purchasePlanDetailDO.setGoodQty(new BigDecimal(0)); |
|
|
// 校验物品代码
|
|
|
purchasePlanDetailDO.setNotGoodQty(new BigDecimal(0)); |
|
|
try { |
|
|
|
|
|
ItembasicDO itembasicDO = itembasicService.selectItembasic(detailDo.getItemCode()); |
|
|
|
|
|
if (!dictDataApi.selectDictValue(itembasicDO.getUom()).getLabel().equals(detailDo.getUom())) { |
|
|
|
|
|
message.append("计量单位【").append(detailDo.getUom()).append("】错误,应该是【").append(dictDataApi.selectDictValue(itembasicDO.getUom()).getLabel()).append("】").append(","); |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
message.append(e.getMessage()).append(","); |
|
|
} |
|
|
} |
|
|
|
|
|
// 校验生产线和物品关系
|
|
|
if (errorList.isEmpty()) { |
|
|
try { |
|
|
ProductionMainDO existPurchaseclaimRequestMainDO = productionMainMapper.selectByNumber(createReqVO.getNumber()); |
|
|
productionlineitemService.productionLineCodeAndpItemCodeExist(mainDo.getProductionLine(), detailDo.getItemCode()); |
|
|
// 判断如果不存在,在进行插入
|
|
|
} catch (Exception e) { |
|
|
if (existPurchaseclaimRequestMainDO == null && mode != 3) { |
|
|
message.append(e.getMessage()).append(","); |
|
|
createReqVO.setStatus(DictFrameworkUtils.parseDictDataValue(DictTypeConstants.REQUEST_STATUS, "新增")); |
|
|
} |
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("WorkPlan"); |
|
|
// 校验物品和bom关系
|
|
|
if (businesstypeDO != null) { |
|
|
try { |
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
bomService.bomItemCodeAndVersionExist(detailDo.getItemCode(), detailDo.getBomVersion()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
message.append(e.getMessage()).append(","); |
|
|
|
|
|
} |
|
|
|
|
|
return message.toString(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ProductionMainDO createObj = ProductionMainConvert.INSTANCE.convert(createReqVO); |
|
|
@Override |
|
|
productionMainMapper.insert(createObj); |
|
|
@Transactional |
|
|
productionDetailMapper.insertBatch(subDOList); |
|
|
public List<ProductionMainImportErrorVO> importProductionMainList(List<ProductionMainCreateReqVO> datas, Integer mode, boolean updatePart) { |
|
|
} else if (existPurchaseclaimRequestMainDO == null && mode != 2) { |
|
|
if (CollUtil.isEmpty(datas)) { |
|
|
BusinesstypeDO businesstypeDO = jobUtils.selectDocumentSettingFromBusinessType("WorkPlan"); |
|
|
throw exception(PURCHASECLAIM_REQUEST_IMPORT_LIST_IS_EMPTY); |
|
|
if (businesstypeDO != null) { |
|
|
|
|
|
createReqVO.setBusinessType(businesstypeDO.getCode()); |
|
|
|
|
|
} |
|
|
} |
|
|
ProductionMainDO createObj = ProductionMainConvert.INSTANCE.convert(createReqVO); |
|
|
List<ProductionMainImportErrorVO> errorList = new ArrayList<>(); |
|
|
productionMainMapper.updateById(createObj); |
|
|
datas.forEach(createReqVO -> { |
|
|
productionDetailMapper.updateBatch(subDOList); |
|
|
ProductionMainDO mainDO = ProductionMainConvert.INSTANCE.convert(createReqVO); |
|
|
|
|
|
String messageMain = this.validateProductionMainImport(mainDO); |
|
|
|
|
|
List<ProductionDetailCreateReqVO> subList = createReqVO.getSubList(); |
|
|
|
|
|
List<ProductionDetailDO> subDOList = ProductionDetailConvert.INSTANCE.convertList03(subList); |
|
|
|
|
|
// 是否有错误数据
|
|
|
|
|
|
boolean flag = true; |
|
|
|
|
|
for (ProductionDetailDO detailDO : subDOList) { |
|
|
|
|
|
String messageDetail = this.validateProductionDetailImport(mainDO, detailDO); |
|
|
|
|
|
if (!messageMain.isEmpty() || !messageDetail.isEmpty()) { |
|
|
|
|
|
ProductionMainImportErrorVO importErrorVO = ProductionMainConvert.INSTANCE.convert(createReqVO, detailDO); |
|
|
|
|
|
importErrorVO.setImportStatus("失败"); |
|
|
|
|
|
messageMain = messageMain + messageDetail; |
|
|
|
|
|
importErrorVO.setImportRemark(messageMain.substring(0, messageMain.length() - 1)); |
|
|
|
|
|
errorList.add(importErrorVO); |
|
|
|
|
|
flag = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//写入数据
|
|
|
|
|
|
if(flag) { |
|
|
|
|
|
//申请单目前只做新增
|
|
|
|
|
|
String number = serialNumberApi.generateCode(RuleCodeEnum.WORK_PLAN.getCode()); |
|
|
|
|
|
mainDO.setNumber(number); |
|
|
|
|
|
mainDO.setAvailable("TRUE"); // 导入默认 可用
|
|
|
|
|
|
mainDO.setBusinessType("ProductReceipt"); // 业务类型:制品收货
|
|
|
|
|
|
mainDO.setStatus("1"); // 默认新增状态
|
|
|
|
|
|
productionMainMapper.insert(mainDO); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(mainDO.getId(), "productionMain", "导入了生产计划", TrendsTypeEnum.CREATE); |
|
|
|
|
|
for (ProductionDetailDO detailDO : subDOList) { |
|
|
|
|
|
detailDO.setMasterId(mainDO.getId()); |
|
|
|
|
|
detailDO.setNumber(number); |
|
|
|
|
|
detailDO.setAvailable("TRUE"); // 导入默认 可用
|
|
|
|
|
|
detailDO.setGoodQty(new BigDecimal(0.0)); |
|
|
|
|
|
detailDO.setNotGoodQty(new BigDecimal(0.0)); |
|
|
} |
|
|
} |
|
|
|
|
|
productionDetailMapper.insertBatch(subDOList); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
//错误不为空并非部分更新,手工回滚
|
|
|
//错误不为空并非部分更新,手工回滚
|
|
@ -301,4 +388,123 @@ public class ProductionMainServiceImpl implements ProductionMainService { |
|
|
return errorList; |
|
|
return errorList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public Integer closeProductionMain(Long id) { |
|
|
|
|
|
// 校验存在存在下级单据
|
|
|
|
|
|
ProductionMainDO mainDO = validateProductionMainExists(id); |
|
|
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = planStatusState.close(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(PRODUCTION_MAIN_CANNOT_CLOSE); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(planStatusState.getState().getCode()); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "productionMain", "关闭了生产计划", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return productionMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional |
|
|
|
|
|
public Integer submitProductionMain(Long id) { |
|
|
|
|
|
ProductionMainDO mainDO = validateProductionMainExists(id); |
|
|
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = planStatusState.submit(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(PRODUCTION_MAIN_CANNOT_SUBMIT); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(planStatusState.getState().getCode()); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "productionMain", "提交了生产计划", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return productionMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Integer openProductionMain(Long id) { |
|
|
|
|
|
ProductionMainDO mainDO = validateProductionMainExists(id); |
|
|
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = planStatusState.open(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(PRODUCTION_MAIN_CANNOT_OPEN); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(planStatusState.getState().getCode()); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "productionMain", "打开了生产计划", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return productionMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Integer rejectProductionMain(Long id) { |
|
|
|
|
|
ProductionMainDO mainDO = validateProductionMainExists(id); |
|
|
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = planStatusState.reject(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(PRODUCTION_MAIN_CANNOT_REJECT); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(planStatusState.getState().getCode()); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "productionMain", "驳回了生产计划", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return productionMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Integer agreeProductionMain(Long id) { |
|
|
|
|
|
ProductionMainDO mainDO = validateProductionMainExists(id); |
|
|
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = planStatusState.agree(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(PRODUCTION_MAIN_CANNOT_AGREE); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(planStatusState.getState().getCode()); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "productionMain", "审批通过了生产计划", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return productionMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Integer publishProductionMain(Long id) { |
|
|
|
|
|
ProductionMainDO mainDO = validateProductionMainExists(id); |
|
|
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = planStatusState.publish(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(PRODUCTION_MAIN_CANNOT_PUBLISH); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(planStatusState.getState().getCode()); |
|
|
|
|
|
// 生成申请单据
|
|
|
|
|
|
this.generateRequest(mainDO, productionDetailMapper.selectList(mainDO.getId())); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "productionMain", "发布了生产计划", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return productionMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Integer resettingProductionMain(Long id) { |
|
|
|
|
|
ProductionMainDO mainDO = validateProductionMainExists(id); |
|
|
|
|
|
PlanStatusState planStatusState = new PlanStatusState(mainDO.getStatus()); |
|
|
|
|
|
boolean flag = planStatusState.resetting(); |
|
|
|
|
|
if(!flag) { |
|
|
|
|
|
throw new ServiceException(PRODUCTION_MAIN_CANNOT_RESETTING); |
|
|
|
|
|
} |
|
|
|
|
|
mainDO.setStatus(planStatusState.getState().getCode()); |
|
|
|
|
|
//增加操作记录
|
|
|
|
|
|
trendsApi.createTrends(id, "productionMain", "重置了生产计划", TrendsTypeEnum.UPDATE); |
|
|
|
|
|
return productionMainMapper.updateById(mainDO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生成申请单据 |
|
|
|
|
|
* @param mainDO |
|
|
|
|
|
* @param detailDOList |
|
|
|
|
|
*/ |
|
|
|
|
|
private void generateRequest(ProductionMainDO mainDO, List<ProductionDetailDO> detailDOList ) { |
|
|
|
|
|
// 判断单据设置:该计划发布后 是否创建 备料计划
|
|
|
|
|
|
if(switchMapper.selectByCode("CreatePrepareToIssuePlanAfterProductionPlanPublished").getEffectiveSetValue().equals("TRUE")) { |
|
|
|
|
|
// TODO:先做备料计划导入新增编辑 之后再补充这里
|
|
|
|
|
|
} |
|
|
|
|
|
// 判断单据设置:该计划发布后 是否创建 制品收货申请
|
|
|
|
|
|
if(switchMapper.selectByCode("CreateProductReciptRequestAfterProductionPlanPublished").getEffectiveSetValue().equals("TRUE")) { |
|
|
|
|
|
// TODO:先做制品收货申请导入新增编辑 之后再补充这里
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|