|
@ -1,20 +1,38 @@ |
|
|
package com.win.module.wms.service.purchasereceiptRecord; |
|
|
package com.win.module.wms.service.purchasereceiptRecord; |
|
|
|
|
|
|
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
import cn.hutool.core.exceptions.UtilException; |
|
|
|
|
|
import cn.hutool.json.JSONObject; |
|
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
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.module.system.api.serialnumber.SerialNumberApi; |
|
|
|
|
|
import com.win.module.system.enums.serialNumber.RuleCodeEnum; |
|
|
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestDetailCreateReqVO; |
|
|
|
|
|
import com.win.module.wms.controller.inspectRequest.vo.InspectRequestMainCreateReqVO; |
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainExportReqVO; |
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainExportReqVO; |
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainPageReqVO; |
|
|
import com.win.module.wms.controller.purchasereceiptRecord.vo.PurchasereceiptRecordMainPageReqVO; |
|
|
|
|
|
import com.win.module.wms.controller.rule.vo.RuleRespVO; |
|
|
|
|
|
import com.win.module.wms.dal.dataobject.documentSwitch.SwitchDO; |
|
|
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.purchasereceiptRecord.PurchasereceiptRecordMainDO; |
|
|
import com.win.module.wms.dal.dataobject.purchasereceiptRecord.PurchasereceiptRecordMainDO; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.purchasereceiptJob.PurchasereceiptJobMainMapper; |
|
|
import com.win.module.wms.dal.mysql.purchasereceiptRecord.PurchasereceiptRecordDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.purchasereceiptRecord.PurchasereceiptRecordDetailMapper; |
|
|
import com.win.module.wms.dal.mysql.purchasereceiptRecord.PurchasereceiptRecordMainMapper; |
|
|
import com.win.module.wms.dal.mysql.purchasereceiptRecord.PurchasereceiptRecordMainMapper; |
|
|
|
|
|
import com.win.module.wms.dal.mysql.purchasereceiptRequest.PurchasereceiptRequestMainMapper; |
|
|
|
|
|
import com.win.module.wms.service.documentSwitch.SwitchService; |
|
|
|
|
|
import com.win.module.wms.service.inspectRequest.InspectRequestMainService; |
|
|
|
|
|
import com.win.module.wms.service.rule.RuleService; |
|
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 采购收货记录主 Service 实现类 |
|
|
* 采购收货记录主 Service 实现类 |
|
@ -30,6 +48,23 @@ public class PurchasereceiptRecordMainServiceImpl implements PurchasereceiptReco |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
private PurchasereceiptRecordDetailMapper purchasereceiptRecordDetailMapper; |
|
|
private PurchasereceiptRecordDetailMapper purchasereceiptRecordDetailMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private PurchasereceiptJobMainMapper purchasereceiptJobMainMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private PurchasereceiptRequestMainMapper purchasereceiptRequestMainMapper; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private RuleService ruleService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private SwitchService switchService; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private SerialNumberApi serialNumberApi; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private InspectRequestMainService inspectRequestMainService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public PurchasereceiptRecordMainDO getPurchasereceiptRecordMainById(Long id) { |
|
|
|
|
|
return purchasereceiptRecordMainMapper.selectById(id); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageResult<PurchasereceiptRecordMainDO> getPurchasereceiptRecordMainSenior(CustomConditions conditions) { |
|
|
public PageResult<PurchasereceiptRecordMainDO> getPurchasereceiptRecordMainSenior(CustomConditions conditions) { |
|
@ -75,4 +110,79 @@ public class PurchasereceiptRecordMainServiceImpl implements PurchasereceiptReco |
|
|
throw new UtilException( "采购收货记录无效" + pNumber + "无效"); |
|
|
throw new UtilException( "采购收货记录无效" + pNumber + "无效"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public int generateInspectRequest(PurchasereceiptRecordMainDO mainDO, List<PurchasereceiptRecordDetailDO> detailDOList) { |
|
|
|
|
|
int result = 0; |
|
|
|
|
|
RuleRespVO ruleRespVO = ruleService.inspect(mainDO.getSupplierCode(), null); |
|
|
|
|
|
//上架申请子
|
|
|
|
|
|
List<InspectRequestDetailCreateReqVO> inspectRequestDetailCreateReqVOList = new ArrayList<>(); |
|
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(ruleRespVO.getConfiguration()); |
|
|
|
|
|
SwitchDO switchDO1 = switchService.selectSwitchExist("CreateInspectRequestAfterPurchaseReceiptRecordCreated"); |
|
|
|
|
|
SwitchDO switchDO2 = switchService.selectSwitchExist("ExemptItemCreatePutawayRequestAfterPurchaseReceiptRecordCreated"); |
|
|
|
|
|
//采购收货记录 生成后 创建 到货检验申请
|
|
|
|
|
|
if(switchDO1.getEffectiveSetValue().equals("TRUE") && !"EXAMPT".equals(String.valueOf(jsonObject.get("InspectType")))) { |
|
|
|
|
|
//按零件号和批次分组
|
|
|
|
|
|
Map<String, List<PurchasereceiptRecordDetailDO>> listMap = new HashMap<>(); |
|
|
|
|
|
for(PurchasereceiptRecordDetailDO purchasereceiptRecordDetailDO : detailDOList) { |
|
|
|
|
|
//采购收货记录 生成后免检物品 创建 上架申请
|
|
|
|
|
|
if(switchDO2.getEffectiveSetValue().equals("TRUE")) { |
|
|
|
|
|
InspectRequestDetailCreateReqVO inspectRequestDetailCreateReqVO = new InspectRequestDetailCreateReqVO(); |
|
|
|
|
|
BeanUtils.copyProperties(purchasereceiptRecordDetailDO, inspectRequestDetailCreateReqVO); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setId(null); |
|
|
|
|
|
inspectRequestDetailCreateReqVOList.add(inspectRequestDetailCreateReqVO); |
|
|
|
|
|
} |
|
|
|
|
|
String key = purchasereceiptRecordDetailDO.getItemCode() + "_" + purchasereceiptRecordDetailDO.getFromBatch(); |
|
|
|
|
|
List<PurchasereceiptRecordDetailDO> list = listMap.get(key); |
|
|
|
|
|
if(list == null) { |
|
|
|
|
|
list = new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
list.add(purchasereceiptRecordDetailDO); |
|
|
|
|
|
listMap.put(key, list); |
|
|
|
|
|
} |
|
|
|
|
|
//组装到货检验数据
|
|
|
|
|
|
for(String mapKey : listMap.keySet()) { |
|
|
|
|
|
List<PurchasereceiptRecordDetailDO> purchasereceiptRecordDetailDOList1 = listMap.get(mapKey); |
|
|
|
|
|
//创建主表信息
|
|
|
|
|
|
PurchasereceiptRecordDetailDO recordDetailDO = purchasereceiptRecordDetailDOList1.get(0); |
|
|
|
|
|
InspectRequestMainCreateReqVO inspectRequestMainCreateReqVO = new InspectRequestMainCreateReqVO(); |
|
|
|
|
|
String inspectRecordNumber = serialNumberApi.generateCode(RuleCodeEnum.INSPECT_RECORD.getCode()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setNumber(inspectRecordNumber); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setPurchaseReceiptRecordNumber(mainDO.getNumber()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setSupplierCode(mainDO.getSupplierCode()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setItemCode(recordDetailDO.getItemCode()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setBatch(recordDetailDO.getFromBatch()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setPoNumber(recordDetailDO.getPoNumber()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setPoLine(recordDetailDO.getPoLine()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setUom(recordDetailDO.getUom()); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setReceiveQty(BigDecimal.ZERO); |
|
|
|
|
|
inspectRequestMainCreateReqVO.setFromWarehouseCode(mainDO.getToWarehouseCode()); |
|
|
|
|
|
//创建子表信息
|
|
|
|
|
|
for(PurchasereceiptRecordDetailDO purchasereceiptRecordDetailDO : purchasereceiptRecordDetailDOList1) { |
|
|
|
|
|
InspectRequestDetailCreateReqVO inspectRequestDetailCreateReqVO = new InspectRequestDetailCreateReqVO(); |
|
|
|
|
|
BeanUtils.copyProperties(purchasereceiptRecordDetailDO, inspectRequestDetailCreateReqVO); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setPackingNumber(purchasereceiptRecordDetailDO.getFromPackingNumber()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setContainerNumber(purchasereceiptRecordDetailDO.getFromContainerNumber()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setInventoryStatus(purchasereceiptRecordDetailDO.getInventoryStatus()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setFromLocationCode(purchasereceiptRecordDetailDO.getFromLocationCode()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setItemCode(purchasereceiptRecordDetailDO.getItemCode()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setItemName(purchasereceiptRecordDetailDO.getItemName()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setItemDesc1(purchasereceiptRecordDetailDO.getItemDesc1()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setItemDesc2(purchasereceiptRecordDetailDO.getItemDesc2()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setProjectCode(purchasereceiptRecordDetailDO.getProjectCode()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setQty(purchasereceiptRecordDetailDO.getQty()); |
|
|
|
|
|
inspectRequestDetailCreateReqVO.setUom(purchasereceiptRecordDetailDO.getUom()); |
|
|
|
|
|
//合计数量
|
|
|
|
|
|
inspectRequestMainCreateReqVO.setReceiveQty(inspectRequestMainCreateReqVO.getReceiveQty().add(inspectRequestDetailCreateReqVO.getQty())); |
|
|
|
|
|
inspectRequestDetailCreateReqVOList.add(inspectRequestDetailCreateReqVO); |
|
|
|
|
|
} |
|
|
|
|
|
inspectRequestMainCreateReqVO.setSubList(inspectRequestDetailCreateReqVOList); |
|
|
|
|
|
//创建检验申请
|
|
|
|
|
|
inspectRequestMainService.createInspectRequestMain(inspectRequestMainCreateReqVO); |
|
|
|
|
|
result++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|