|
|
@ -12,6 +12,8 @@ import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.erp.domain.ErpBom; |
|
|
|
import com.ruoyi.erp.domain.ErpInboundOrder; |
|
|
|
import com.ruoyi.erp.domain.ErpInboundOrderDetail; |
|
|
|
import com.ruoyi.erp.domain.ErpMaterial; |
|
|
|
import com.ruoyi.erp.mapper.ErpMaterialMapper; |
|
|
|
import com.ruoyi.erp.service.IErpBomService; |
|
|
|
import com.ruoyi.purchase.service.IPurchasePlanService; |
|
|
|
import com.ruoyi.quality.domain.QualityOrder; |
|
|
@ -37,6 +39,7 @@ import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 生产订单Service业务层处理 |
|
|
@ -98,6 +101,12 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysMakeorderBomMapper makeorderBomMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ProcessIssueRecordMapper processIssueRecordMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ErpMaterialMapper erpMaterialMapper; |
|
|
|
/** |
|
|
|
* 查询生产订单 |
|
|
|
* |
|
|
@ -242,7 +251,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
// 是
|
|
|
|
makeOrder.setUseStatus("1"); |
|
|
|
makeOrder.setSaleNo(salesOrderCode); |
|
|
|
makeOrder.setMakeStatus("0"); |
|
|
|
makeOrder.setPurchaseStatus("0"); |
|
|
|
makeOrder.setSalesman(sysSalesOrderVo.getBusinessMembers()); |
|
|
|
makeOrder.setSaleNo(sysSalesOrderVo.getSalesOrderCode()); |
|
|
|
makeOrder.setOrderType(sysSalesOrderVo.getSalesOrderType()); |
|
|
@ -253,68 +262,197 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
makeOrder.setMaterial(String.valueOf(sysSalesOrderVo.getMaterialSum())); |
|
|
|
String makeNo = redisCache.generateBillNo("PO"); |
|
|
|
makeOrder.setMakeNo(makeNo); |
|
|
|
makeOrder.setCreateTime(sysSalesOrderVo.getApplyTime()); |
|
|
|
insertSysMakeOrder(makeOrder); |
|
|
|
// 生成部门待预审数据
|
|
|
|
List<SysSalesOrderChild> salesOrderChildList = salesOrderChildService.selectSysSalesOrderChildByQuoteId(salesOrderCode); |
|
|
|
if(CollectionUtil.isNotEmpty(salesOrderChildList)){ |
|
|
|
salesOrderChildList.forEach(t->{ |
|
|
|
String materialCode = t.getMaterialCode(); |
|
|
|
makeorderDeptService.generateYsDataByMakeNoAndMaterialNo(makeNo,materialCode,salesOrderType); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void gcReview(SysMakeOrder sysMakeOrder) { |
|
|
|
String makeNo = sysMakeOrder.getMakeNo(); |
|
|
|
// 定义一个列表用于收集新插入的SysMakeorderBom
|
|
|
|
List<SysMakeorderBom> insertedSysMakeorderBoms = new ArrayList<>(); |
|
|
|
// 待生产
|
|
|
|
sysMakeOrder.setMakeStatus("3"); |
|
|
|
updateByMakeNo(sysMakeOrder); |
|
|
|
// 根据销售订单物料生成BOM
|
|
|
|
String saleNo = sysMakeOrder.getSaleNo(); |
|
|
|
List<SysSalesOrderChild> salesOrderChildList = salesOrderChildService.selectSysSalesOrderChildByQuoteId(saleNo); |
|
|
|
if(CollectionUtil.isNotEmpty(salesOrderChildList)){ |
|
|
|
// 根据销售订单物料生成生产订单BOM
|
|
|
|
Long sortNo = 0L; |
|
|
|
for (int i = 0; i < salesOrderChildList.size(); i++) { |
|
|
|
SysSalesOrderChild sysSalesOrderChild = salesOrderChildList.get(i); |
|
|
|
for (SysSalesOrderChild sysSalesOrderChild:salesOrderChildList) { |
|
|
|
String materialCode = sysSalesOrderChild.getMaterialCode(); |
|
|
|
// 0阶
|
|
|
|
// 0阶保存(后续采购审核可能会修改0阶)
|
|
|
|
ErpBom erpBom = erpBomService.selectErpBomByOneMaterialNo(materialCode); |
|
|
|
|
|
|
|
if (erpBom != null){ |
|
|
|
SysMakeorderBom makeorderBom = new SysMakeorderBom(); |
|
|
|
BeanUtils.copyProperties(erpBom,makeorderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); |
|
|
|
makeorderBom.setMakeNo(makeNo); |
|
|
|
makeorderBom.setSalesOrderCode(salesOrderCode); |
|
|
|
makeorderBom.setLossRate(erpBom.getLossRate()); |
|
|
|
makeorderBom.setUseNum(erpBom.getUseNum()); |
|
|
|
makeorderBom.setLevel(0L); |
|
|
|
sortNo ++; |
|
|
|
makeorderBom.setSortNo(sortNo); |
|
|
|
makeorderBom.setOrderNum(sysSalesOrderChild.getMaterialNum()); |
|
|
|
makeorderBom.setDeliveryTime(sysSalesOrderChild.getDeliveryTime()); |
|
|
|
makeorderBom.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
makeorderBom.setCreateTime(DateUtils.getNowDate()); |
|
|
|
makeorderBomService.insertSysMakeorderBom(makeorderBom); |
|
|
|
Long id = erpBom.getId(); |
|
|
|
// 查询1阶及以下
|
|
|
|
ErpBom oneLevelBom = new ErpBom(); |
|
|
|
oneLevelBom.setParentId(id); |
|
|
|
List<ErpBom> subBomList = erpBomService.selectOtherOrderErpBomAllLevelList(oneLevelBom); |
|
|
|
for (int j = 0; j < subBomList.size(); j++) { |
|
|
|
ErpBom subBom = subBomList.get(j); |
|
|
|
SysMakeorderBom orderBom = new SysMakeorderBom(); |
|
|
|
BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); |
|
|
|
orderBom.setMakeNo(makeNo); |
|
|
|
orderBom.setSalesOrderCode(saleNo); |
|
|
|
orderBom.setSalesOrderMaterialNo(materialCode); |
|
|
|
orderBom.setLossRate(subBom.getLossRate()); |
|
|
|
orderBom.setUseNum(subBom.getUseNum()); |
|
|
|
//如果sys_makeorder_bom数据表里面没有入库部门.这里给他加入
|
|
|
|
//orderBom.setWarehouseDept(subBom.getWarehouseDept());
|
|
|
|
sortNo++; |
|
|
|
orderBom.setSortNo(sortNo); |
|
|
|
makeorderBomService.insertSysMakeorderBom(orderBom); |
|
|
|
insertedSysMakeorderBoms.add(orderBom); |
|
|
|
//采购类型无下阶物料, 只有料号为5/6/7/8/9开头时才有bom,其他为原料/辅料
|
|
|
|
if(!erpBom.getProcessMethod().equals("0") && materialCode!=null && ((materialCode.startsWith("5"))||(materialCode.startsWith("6")) |
|
|
|
||(materialCode.startsWith("7"))||(materialCode.startsWith("8"))||(materialCode.startsWith("9")))){ |
|
|
|
// 查询1阶及以下
|
|
|
|
ErpBom oneLevelBom = new ErpBom(); |
|
|
|
oneLevelBom.setParentId(id); |
|
|
|
|
|
|
|
List<ErpBom> subBomList = erpBomService.selectPurchaseLimitedErpBomAllLevelList(oneLevelBom); |
|
|
|
for (int j = 0; j < subBomList.size(); j++) { |
|
|
|
ErpBom subBom = subBomList.get(j); |
|
|
|
SysMakeorderBom orderBom = new SysMakeorderBom(); |
|
|
|
BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); |
|
|
|
orderBom.setMakeNo(makeNo); |
|
|
|
orderBom.setSalesOrderCode(salesOrderCode); |
|
|
|
orderBom.setSalesOrderMaterialNo(materialCode); |
|
|
|
orderBom.setLossRate(subBom.getLossRate()); |
|
|
|
orderBom.setUseNum(subBom.getUseNum()); |
|
|
|
//如果sys_makeorder_bom数据表里面没有入库部门.这里给他加入
|
|
|
|
//orderBom.setWarehouseDept(subBom.getWarehouseDept());
|
|
|
|
sortNo++; |
|
|
|
orderBom.setSortNo(sortNo); |
|
|
|
makeorderBom.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
makeorderBom.setCreateTime(DateUtils.getNowDate()); |
|
|
|
makeorderBomService.insertSysMakeorderBom(orderBom); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
throw new BusinessException("料号为"+materialCode+"的Bom信息不全,请补充!"); |
|
|
|
sortNo ++; |
|
|
|
SysMakeorderBom sysMakeorderBom = generateMakeorderBom(sortNo,sysSalesOrderChild); |
|
|
|
sysMakeorderBom.setMakeNo(makeNo); |
|
|
|
sysMakeorderBom.setSalesOrderCode(salesOrderCode); |
|
|
|
int result = makeorderBomMapper.insertSysMakeorderBom(sysMakeorderBom); |
|
|
|
if(result<=0){ |
|
|
|
throw new BusinessException("新增生产bom" + materialCode +"失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
makeorderDeptService.generateYsDataByMakeNoAndMaterialNo(makeNo,materialCode,salesOrderType); |
|
|
|
} |
|
|
|
} |
|
|
|
makeOrder.setCreateTime(sysSalesOrderVo.getApplyTime()); |
|
|
|
insertSysMakeOrder(makeOrder); |
|
|
|
} |
|
|
|
|
|
|
|
//根据销售订单子表生成生产bom0阶
|
|
|
|
public SysMakeorderBom generateMakeorderBom(Long sortNo,SysSalesOrderChild sysSalesOrderChild){ |
|
|
|
SysMakeorderBom makeorderBom = new SysMakeorderBom(); |
|
|
|
makeorderBom.setMaterialNo(sysSalesOrderChild.getMaterialCode()); |
|
|
|
makeorderBom.setMaterialName(sysSalesOrderChild.getMaterialName()); |
|
|
|
makeorderBom.setMaterialType(sysSalesOrderChild.getMaterialType()); |
|
|
|
makeorderBom.setMaterialModel(sysSalesOrderChild.getMaterialModel()); |
|
|
|
makeorderBom.setUnit(sysSalesOrderChild.getUnit()); |
|
|
|
makeorderBom.setBrand(sysSalesOrderChild.getBrand()); |
|
|
|
makeorderBom.setDescribe(sysSalesOrderChild.getDescribe()); |
|
|
|
makeorderBom.setProcessMethod(sysSalesOrderChild.getProcessMethod()); |
|
|
|
makeorderBom.setLevel(0L); |
|
|
|
|
|
|
|
makeorderBom.setSortNo(sortNo); |
|
|
|
makeorderBom.setOrderNum(sysSalesOrderChild.getMaterialNum()); |
|
|
|
makeorderBom.setDeliveryTime(sysSalesOrderChild.getDeliveryTime()); |
|
|
|
makeorderBom.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
makeorderBom.setCreateTime(DateUtils.getNowDate()); |
|
|
|
return makeorderBom; |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void gcReview(SysMakeOrder sysMakeOrder) { |
|
|
|
String makeNo = sysMakeOrder.getMakeNo(); |
|
|
|
String salesOrderCode = sysMakeOrder.getSaleNo(); |
|
|
|
List<SysMakeorderBom> makeorderBoms = sysMakeOrder.getSysMakeorderBomList(); |
|
|
|
/* |
|
|
|
* 获取前端返回生产bom列表0阶料号合集(只返回有修改的bom)*/ |
|
|
|
Set<String> uniqueMaterialNos = new HashSet<>(); |
|
|
|
for (SysMakeorderBom bom : makeorderBoms) { |
|
|
|
uniqueMaterialNos.add(bom.getSalesOrderMaterialNo()); |
|
|
|
} |
|
|
|
/* |
|
|
|
* 获取该生产订单关联销售订单中的0阶物料(存在bom)*/ |
|
|
|
/*SysSalesOrderChild tempChild = new SysSalesOrderChild(); |
|
|
|
tempChild.setQuoteId(salesOrderCode); |
|
|
|
List<SysSalesOrderChild> salesOrderChildList = salesOrderChildService.selectSysSalesOrderChildListWithBom(tempChild); |
|
|
|
*/ |
|
|
|
/* |
|
|
|
* 获取该生产订单关联销售订单中的0阶物料(存在bom)*/ |
|
|
|
SysMakeorderBom tempMakeorderBom = new SysMakeorderBom(); |
|
|
|
tempMakeorderBom.setMakeNo(makeNo); |
|
|
|
tempMakeorderBom.setSalesOrderCode(salesOrderCode); |
|
|
|
tempMakeorderBom.setLevel(0L); |
|
|
|
List<SysMakeorderBom> tempBomList = makeorderBomService.selectSysMakeorderBomList(tempMakeorderBom); |
|
|
|
/* |
|
|
|
* 比对获取前端未修改过的bom料号,后续查找生产bom表看其子阶是否为空,另外要去除加工类型为采购的数据*/ |
|
|
|
List<String> filteredList = tempBomList.stream() |
|
|
|
.filter(child -> !uniqueMaterialNos.contains(child.getMaterialNo())) |
|
|
|
.filter(child -> child.getMaterialNo().startsWith("5")||child.getMaterialNo().startsWith("6") |
|
|
|
||child.getMaterialNo().startsWith("7")||child.getMaterialNo().startsWith("8") |
|
|
|
||child.getMaterialNo().startsWith("9")) |
|
|
|
.filter(child -> !child.getProcessMethod().equals("0")) |
|
|
|
.map(SysMakeorderBom::getMaterialNo) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
/* |
|
|
|
* 判断bom是否为空*/ |
|
|
|
if(StringUtils.isNotEmpty(filteredList)){ |
|
|
|
for (String code:filteredList) { |
|
|
|
SysMakeorderBom tempMakeBom = new SysMakeorderBom(); |
|
|
|
tempMakeBom.setMakeNo(makeNo); |
|
|
|
tempMakeBom.setSalesOrderCode(salesOrderCode); |
|
|
|
tempMakeBom.setSalesOrderMaterialNo(code); |
|
|
|
List<SysMakeorderBom> makeorderBomList = makeorderBomService.selectSysMakeorderBomList(tempMakeBom); |
|
|
|
if(StringUtils.isEmpty(makeorderBomList)){ |
|
|
|
throw new BusinessException(code + "BOM不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/* |
|
|
|
* 删除返回0阶料号的原有bom*/ |
|
|
|
for (String materialNo:uniqueMaterialNos) { |
|
|
|
SysMakeorderBom tempBom = new SysMakeorderBom(); |
|
|
|
tempBom.setMakeNo(makeNo); |
|
|
|
tempBom.setSalesOrderCode(salesOrderCode); |
|
|
|
tempBom.setSalesOrderMaterialNo(materialNo); |
|
|
|
makeorderBomMapper.deleteSysMakeorderBomByNos(tempBom); |
|
|
|
} |
|
|
|
Long sortNo = 0L; |
|
|
|
for (SysMakeorderBom makeBom:makeorderBoms) { |
|
|
|
sortNo ++; |
|
|
|
makeBom.setSortNo(sortNo); |
|
|
|
int insertResult = makeorderBomMapper.insertSysMakeorderBom(makeBom); |
|
|
|
if(insertResult<=0){ |
|
|
|
throw new BusinessException("bom"+makeBom.getSalesOrderMaterialNo()+"层级添加失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 待采购审核
|
|
|
|
sysMakeOrder.setMakeStatus("7"); |
|
|
|
updateByMakeNo(sysMakeOrder); |
|
|
|
// todo 加工方式“采购”的物料生成采购计划
|
|
|
|
purchasePlanService.generatePurchasePlanByMakeOrder(insertedSysMakeorderBoms); |
|
|
|
// purchasePlanService.generatePurchasePlanByMakeOrder(insertedSysMakeorderBoms);
|
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* 采购审核,修改加工方式委外或采购为采购,若修改则删除下阶物料 |
|
|
|
* */ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void cgReview(SysMakeOrder sysMakeOrder) { |
|
|
|
List<SysMakeorderBom> makeorderBomList = sysMakeOrder.getSysMakeorderBomList(); |
|
|
|
if(StringUtils.isNotEmpty(makeorderBomList)){ |
|
|
|
for (SysMakeorderBom makeBom:makeorderBomList) { |
|
|
|
if(makeBom.getProcessMethod().equals("0")){ |
|
|
|
SysMakeorderBom tempBom = new SysMakeorderBom(); |
|
|
|
tempBom.setMakeNo(sysMakeOrder.getMakeNo()); |
|
|
|
tempBom.setSalesOrderCode(sysMakeOrder.getSaleNo()); |
|
|
|
tempBom.setSalesOrderMaterialNo(makeBom.getMaterialNo()); |
|
|
|
makeorderBomMapper.deleteSysMakeorderBomByNos(tempBom); |
|
|
|
} |
|
|
|
makeBom.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
makeBom.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
makeorderBomMapper.updateSysMakeorderBom(makeBom); |
|
|
|
} |
|
|
|
} |
|
|
|
// sysMakeOrder.setMakeStatus("3");//生产状态-待生产
|
|
|
|
// sysMakeOrder.setEceiptStatus("0");//入库状态-待采购
|
|
|
|
|
|
|
|
//测试用状态(跳过采购)
|
|
|
|
sysMakeOrder.setMakeStatus("4");//生产状态-待生产
|
|
|
|
sysMakeOrder.setEceiptStatus("7");//入库状态-待采购
|
|
|
|
updateSysMakeOrder(sysMakeOrder); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -322,7 +460,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
return sysMakeOrderMapper.selectMaterialList(sysMakeOrder); |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
* 品质管理制程检验工序关联生产单号 |
|
|
|
* */ |
|
|
|
@Override |
|
|
@ -380,7 +518,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto) { |
|
|
|
public List<AfterSalesShippingDevice> addEquipmentResumeSave(SysEquipMaterialDto equipMaterialDto) { |
|
|
|
if (CollectionUtils.isEmpty(equipMaterialDto.getSysEquipDetailDtos())) { |
|
|
|
log.warn("设备履历详情数据为空"); |
|
|
|
throw new BusinessException("设备履历详情数据为空"); |
|
|
@ -388,6 +526,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
|
|
|
|
int result = 0; |
|
|
|
|
|
|
|
List<AfterSalesShippingDevice> shippingDevice = new ArrayList<>(); |
|
|
|
for (SysEquipDetailDto sysEquipDetailDto : equipMaterialDto.getSysEquipDetailDtos()) { |
|
|
|
AfterSalesShippingDevice afterSalesShippingDevice = new AfterSalesShippingDevice(); |
|
|
|
|
|
|
@ -402,24 +541,43 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
afterSalesShippingDevice.setMaterialDescribe(equipMaterialDto.getDescribe()); |
|
|
|
afterSalesShippingDevice.setDeviceModelCode(sysEquipDetailDto.getEquipmentModel()); |
|
|
|
afterSalesShippingDevice.setDeviceRunningNumber(sysEquipDetailDto.getSerialNo()); |
|
|
|
afterSalesShippingDevice.setStartMakeTime(sysEquipDetailDto.getStartMakeTime()); |
|
|
|
afterSalesShippingDevice.setEndMakeTime(sysEquipDetailDto.getEndMakeTime()); |
|
|
|
afterSalesShippingDevice.setAddProcessIssueRecordFlag(sysEquipDetailDto.getAddProcessIssueRecordFlag()); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(sysEquipDetailDto.getEquipmentId())) { |
|
|
|
// 如果设备ID为空,说明是新记录,需要插入
|
|
|
|
afterSalesShippingDevice.setShippingDeviceId(redisCache.generateBillNo("CHSB")); |
|
|
|
afterSalesShippingDevice.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
afterSalesShippingDevice.setCreateTime(new Date()); |
|
|
|
afterSalesShippingDevice.setCreateTime(DateUtils.getNowDate()); |
|
|
|
afterSalesShippingDevice.setQualityStatus("0");//待申请
|
|
|
|
result += afterSalesShippingDeviceMapper.insertAfterSalesShippingDevice(afterSalesShippingDevice); |
|
|
|
} else { |
|
|
|
// 设备ID不为空,假设需要更新逻辑(根据业务需求确定是否需要此分支)
|
|
|
|
afterSalesShippingDevice.setShippingDeviceId(sysEquipDetailDto.getEquipmentId()); // 确保ID设置正确
|
|
|
|
afterSalesShippingDevice.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
afterSalesShippingDevice.setUpdateTime(new Date()); |
|
|
|
afterSalesShippingDevice.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
afterSalesShippingDevice.setQualityStatus("0");//待申请
|
|
|
|
// 注意:这里假设了updateAfterSalesShippingDevice方法是存在的且逻辑正确,根据实际情况调整
|
|
|
|
result += afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(afterSalesShippingDevice); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
if(result<=0){ |
|
|
|
throw new BusinessException("新增设备履历失败"); |
|
|
|
} |
|
|
|
shippingDevice.add(afterSalesShippingDevice); |
|
|
|
ProcessIssueRecord tempRecord = new ProcessIssueRecord(); |
|
|
|
tempRecord.setSerialNo(afterSalesShippingDevice.getDeviceRunningNumber()); |
|
|
|
List<ProcessIssueRecord> processIssueRecords = processIssueRecordMapper.selectProcessIssueRecordList(tempRecord); |
|
|
|
if(StringUtils.isNotEmpty(processIssueRecords)){ |
|
|
|
for (ProcessIssueRecord processRecord:processIssueRecords) { |
|
|
|
processRecord.setShippingDeviceId(afterSalesShippingDevice.getShippingDeviceId()); |
|
|
|
processIssueRecordMapper.updateProcessIssueRecord(processRecord); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return shippingDevice; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -432,23 +590,40 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
erpInboundOrder.setCreateBy(loginName); |
|
|
|
erpInboundOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
String qualityOrderCode = redisCache.generateBillNo("PZ"); |
|
|
|
QualityOrder qualityOrder = createQualityOrder(qualityOrderCode, erpInboundOrder, loginName); |
|
|
|
//更新生产订单的本次完成数
|
|
|
|
List<ErpInboundOrderDetail> inboundDetails = erpInboundOrder.getInboundDetails(); |
|
|
|
if(StringUtils.isEmpty(inboundDetails)){ |
|
|
|
throw new BusinessException("入库单物料为空!"); |
|
|
|
} |
|
|
|
int result = 0; |
|
|
|
long finishNum = erpInboundOrder.getInboundDetails().stream().mapToLong(ErpInboundOrderDetail::getCurrentNum).sum(); |
|
|
|
SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(erpInboundOrder.getMakeNo()); |
|
|
|
sysMakeOrder.setFinishNum(finishNum); |
|
|
|
int updateSysMakeOrderResult = sysMakeOrderMapper.updateSysMakeOrder(sysMakeOrder); |
|
|
|
if (updateSysMakeOrderResult <= 0){ |
|
|
|
throw new BusinessException("更新生产订单失败"); |
|
|
|
if(finishNum == 0){ |
|
|
|
throw new BusinessException("本次完成数不能全为0"); |
|
|
|
} |
|
|
|
for (ErpInboundOrderDetail inboundDetail:inboundDetails) { |
|
|
|
String qualityOrderCode = redisCache.generateBillNo("PZ"); |
|
|
|
QualityOrder qualityOrder = createQualityOrder(qualityOrderCode, erpInboundOrder, loginName); |
|
|
|
|
|
|
|
result += qualityOrderMapper.insertQualityOrder(qualityOrder); |
|
|
|
List<AfterSalesShippingDevice> deviceList = inboundDetail.getSalesShippingDeviceList(); |
|
|
|
if(StringUtils.isNotEmpty(deviceList)){ |
|
|
|
for (AfterSalesShippingDevice device:deviceList) { |
|
|
|
device.setQualityStatus("1");//待品质
|
|
|
|
afterSalesShippingDeviceMapper.updateAfterSalesShippingDevice(device); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Map<String, SysSalesOrderChild> materialInfoMap = fetchMaterialInfoMap(erpInboundOrder); |
|
|
|
|
|
|
|
addQualityOrderDetails(qualityOrder, erpInboundOrder, materialInfoMap); |
|
|
|
addQualityOrderReports(qualityOrder, erpInboundOrder, materialInfoMap); |
|
|
|
//品质报告单审核通过后再更新已完成数
|
|
|
|
// SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(erpInboundOrder.getMakeNo());
|
|
|
|
// long hasFinished = sysMakeOrder.getFinishNum();
|
|
|
|
// finishNum += hasFinished;
|
|
|
|
// sysMakeOrder.setFinishNum(finishNum);
|
|
|
|
// int updateSysMakeOrderResult = sysMakeOrderMapper.updateSysMakeOrder(sysMakeOrder);
|
|
|
|
// if (updateSysMakeOrderResult <= 0){
|
|
|
|
// throw new BusinessException("更新生产订单失败");
|
|
|
|
// }
|
|
|
|
|
|
|
|
return qualityOrderMapper.insertQualityOrder(qualityOrder); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private QualityOrder createQualityOrder(String code, ErpInboundOrder erpInboundOrder, String loginName) { |
|
|
@ -458,7 +633,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
qualityOrder.setQualityStatus("0"); |
|
|
|
qualityOrder.setQualityStorageStatus("4"); |
|
|
|
qualityOrder.setQualityOrderType("1"); |
|
|
|
qualityOrder.setCreateTime(new Date()); |
|
|
|
qualityOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
qualityOrder.setCreateBy(loginName); |
|
|
|
return qualityOrder; |
|
|
|
} |
|
|
@ -502,7 +677,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService |
|
|
|
qualityOrderDetail.setMakeTotal(salesOrderChild.getMaterialNum()); |
|
|
|
qualityOrderDetail.setMakeCompletionNum(Math.toIntExact(detail.getCurrentNum())); |
|
|
|
qualityOrderDetail.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
qualityOrderDetail.setCreateTime(new Date()); |
|
|
|
qualityOrderDetail.setCreateTime(DateUtils.getNowDate()); |
|
|
|
return qualityOrderDetail; |
|
|
|
} |
|
|
|
|
|
|
|