生产计划自动化 2.24

zhc4dev
zhc077 2 years ago
parent 42564fab6b
commit ad8a9bf67c
  1. 4
      ant-design-vue-jeecg/src/views/productplan/ProductplanManage.vue
  2. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/IZyProductPlanAutoService.java
  3. 205
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java
  4. 41
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyPlanProcessServiceImpl.java

@ -240,7 +240,7 @@ export default {
path: '/productplan/ZyPlanProcessFabricDataList', path: '/productplan/ZyPlanProcessFabricDataList',
query: { // query: { //
'planId': props.row.planId, 'planId': props.row.planId,
'planProcessId': props.row.processId, 'planProcessId': props.row.id,
}, },
}); });
}, },
@ -251,7 +251,7 @@ export default {
path: '/productplan/ZyPlanProcessAccessoriesDataList', path: '/productplan/ZyPlanProcessAccessoriesDataList',
query: { // query: { //
'planId': props.row.planId, 'planId': props.row.planId,
'planProcessId': props.row.processId, 'planProcessId': props.row.id,
}, },
}); });
}, },

@ -16,5 +16,5 @@ public interface IZyProductPlanAutoService extends IService<ZyProductPlan> {
void doAuto(HttpServletRequest req); void doAuto(HttpServletRequest req);
void filling4Auto(String planId); boolean filling4Auto(String planId);
} }

@ -2,26 +2,30 @@ package org.jeecg.modules.productplan.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.demo.pro.entity.ZyProcessMachine; import org.jeecg.modules.demo.pro.entity.ZyProcessMachine;
import org.jeecg.modules.demo.pro.service.IZyProcessMachineService; import org.jeecg.modules.demo.pro.service.IZyProcessMachineService;
import org.jeecg.modules.operationtool.entity.ZyOperationtool;
import org.jeecg.modules.operationtool.service.IZyOperationtoolService;
import org.jeecg.modules.productplan.entity.ZyPlanProcess; import org.jeecg.modules.productplan.entity.ZyPlanProcess;
import org.jeecg.modules.productplan.entity.ZyPlanProcessAccessories;
import org.jeecg.modules.productplan.entity.ZyPlanProcessFabric;
import org.jeecg.modules.productplan.entity.ZyProductPlan; import org.jeecg.modules.productplan.entity.ZyProductPlan;
import org.jeecg.modules.productplan.enums.ProductPlanStatusEnum; import org.jeecg.modules.productplan.enums.ProductPlanStatusEnum;
import org.jeecg.modules.productplan.mapper.ZyPlanProcessAccessoriesMapper;
import org.jeecg.modules.productplan.mapper.ZyPlanProcessFabricMapper;
import org.jeecg.modules.productplan.mapper.ZyProductPlanMapper; import org.jeecg.modules.productplan.mapper.ZyProductPlanMapper;
import org.jeecg.modules.productplan.service.IZyPlanProcessService; import org.jeecg.modules.productplan.service.*;
import org.jeecg.modules.productplan.service.IZyProductPlanAutoService; import org.jeecg.modules.productprocessaccessories.service.IProductProcessAccessoriesService;
import org.jeecg.modules.productplan.service.IZyProductPlanService; import org.jeecg.modules.productprocessfabric.entity.ProductProcessFabric;
import org.jeecg.modules.productprocessfabric.service.IProductProcessFabricService;
import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService; import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.system.service.ISysUserService; import org.jeecg.modules.system.service.ISysUserService;
import org.jeecg.modules.team.entity.Groupx; import org.jeecg.modules.team.entity.*;
import org.jeecg.modules.team.entity.Station; import org.jeecg.modules.team.service.*;
import org.jeecg.modules.team.entity.StationMachine;
import org.jeecg.modules.team.service.IGroupxService;
import org.jeecg.modules.team.service.IStationMachineService;
import org.jeecg.modules.team.service.IStationService;
import org.jeecg.modules.workorder.entity.WorkOrder; import org.jeecg.modules.workorder.entity.WorkOrder;
import org.jeecg.modules.workorder.enums.WorkOrderStatusEnum; import org.jeecg.modules.workorder.enums.WorkOrderStatusEnum;
import org.jeecg.modules.workorder.service.IWorkOrderService; import org.jeecg.modules.workorder.service.IWorkOrderService;
@ -63,15 +67,30 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
@Autowired @Autowired
private IGroupxService iGroupxService; private IGroupxService iGroupxService;
@Autowired
private IGroupxMemberService iGroupxMemberService;
@Autowired @Autowired
private IStationService iStationService; private IStationService iStationService;
@Autowired @Autowired
private IZyProcessMachineService iZyProcessMachineService; private IZyProcessMachineService iZyProcessMachineService;
@Autowired
private IZyOperationtoolService iZyOperationtoolService;
@Autowired @Autowired
private IStationMachineService iStationMachineService; private IStationMachineService iStationMachineService;
@Transactional(rollbackFor = Exception.class, readOnly = false) @Autowired
private IStationToolService iStationToolService;
@Autowired
private IZyPlanProcessFabricService iZyPlanProcessFabricService;
@Autowired
private IZyPlanProcessAccessoriesService iZyPlanProcessAccessoriesService;
// @Transactional(rollbackFor = Exception.class, readOnly = false)
@Transactional
List<ZyProductPlan> saveProductPlan(List<WorkOrder> workOrderList) { List<ZyProductPlan> saveProductPlan(List<WorkOrder> workOrderList) {
if (ObjectUtils.isEmpty(workOrderList)) return Collections.EMPTY_LIST; if (ObjectUtils.isEmpty(workOrderList)) return Collections.EMPTY_LIST;
@ -90,6 +109,8 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
//2,保存生产计划 //2,保存生产计划
ZyProductPlan zyProductPlan = new ZyProductPlan(); ZyProductPlan zyProductPlan = new ZyProductPlan();
zyProductPlan.setProductCode(productCode); zyProductPlan.setProductCode(productCode);
// zyProductPlan.setProductNo(StringUtils.isNotBlank(zyProduct.getProductCode()) ? zyProduct.getProductCode() : "");
zyProductPlan.setProductName(zyProduct.getProductName());
//生产时长,取zy_product表生产时间 //生产时长,取zy_product表生产时间
zyProductPlan.setDuration(zyProduct.getProduceTime()); zyProductPlan.setDuration(zyProduct.getProduceTime());
SysDepart sysDepart = sysDepartList2.get(i.get()); SysDepart sysDepart = sysDepartList2.get(i.get());
@ -104,7 +125,7 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
} }
//车间 //车间
zyProductPlan.setWorkshopId(sysDepart.getId()); zyProductPlan.setWorkshopId(sysDepart.getId());
List<Groupx> groupxList = iGroupxService.list(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, sysDepart)); List<Groupx> groupxList = iGroupxService.list(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, sysDepart.getId()));
if (!ObjectUtils.isEmpty(groupxList)) { if (!ObjectUtils.isEmpty(groupxList)) {
Groupx groupx = groupxList.get(0); Groupx groupx = groupxList.get(0);
//班组 //班组
@ -112,8 +133,13 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
//班长 //班长
zyProductPlan.setTeamLeader(groupx.getEnterprisesManager()); zyProductPlan.setTeamLeader(groupx.getEnterprisesManager());
} }
//保存生产计划 //保存生产计划
iZyProductPlanService.create(zyProductPlan); zyProductPlan.setStatus(new Integer(ProductPlanStatusEnum.UNAUDITED.getCode()));
iZyProductPlanService.save(zyProductPlan);
//更新work_order表work_order_status为“1” (不能为其新增生产计划)
iWorkOrderService.lambdaUpdate().set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.REVIEWED.getCode()).update();
zyProductPlanProductCodes.add(productCode); zyProductPlanProductCodes.add(productCode);
}); });
//根据productCode,查询本次创建生产计划 //根据productCode,查询本次创建生产计划
@ -182,16 +208,28 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
List<ZyProductPlan> productPlanList = this.saveProductPlan(workOrderList); List<ZyProductPlan> productPlanList = this.saveProductPlan(workOrderList);
if (ObjectUtils.isEmpty(productPlanList)) return; if (ObjectUtils.isEmpty(productPlanList)) return;
//3,保存计划生产工序 //3,同步计划生产工序、同步生产计划工序面料、同步生产计划辅料
productPlanList.stream().forEach(f -> { productPlanList.stream().forEach(f -> {
ZyPlanProcess zyPlanProcess = new ZyPlanProcess(); ZyPlanProcess zyPlanProcess = new ZyPlanProcess();
zyPlanProcess.setPlanId(f.getId()); zyPlanProcess.setPlanId(f.getId());
zyPlanProcessService.syncProductBaseProcess(zyPlanProcess); zyPlanProcessService.syncProductBaseProcess(zyPlanProcess);
}); });
//4,自动排位 //4,自动排位(匹配工序设备、工序工具、工人)
// 匹配工序设备、工序工具有一个工序失败,则工单作为异常处理,删除生产计划及相关子表
//只有一个生产计划的设备、工具都匹配成功才进行一下操作(生成物料单、发送到仓库)
productPlanList.stream().forEach(k -> { productPlanList.stream().forEach(k -> {
this.filling4Auto(k.getId()); // boolean b = this.filling4Auto(k.getId());
// if (b) {
List<ZyPlanProcess> planProcessList = zyPlanProcessService.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, k.getId()));
Optional.ofNullable(planProcessList).orElse(new LinkedList<>()).forEach(e -> {
// 5,生成物料单
zyPlanProcessService.createMaterialBill(e);
// 5,发送到仓库
zyPlanProcessService.sendToRepository(e);
});
// }
}); });
} }
@ -202,7 +240,7 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
* @param planId * @param planId
*/ */
@Override @Override
public void filling4Auto(String planId) { public boolean filling4Auto(String planId) {
ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId); ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId);
if (ObjectUtils.isEmpty(zyProductPlan)) { if (ObjectUtils.isEmpty(zyProductPlan)) {
throw new JeecgBootException("生产计划不存在!"); throw new JeecgBootException("生产计划不存在!");
@ -210,7 +248,7 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
List<ZyPlanProcess> planProcessList = zyPlanProcessService.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, planId)); List<ZyPlanProcess> planProcessList = zyPlanProcessService.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, planId));
//是否有计划工序 //是否有计划工序
if (ObjectUtils.isEmpty(planProcessList)) return; if (ObjectUtils.isEmpty(planProcessList)) return false;
//生产计划车间工位列表 //生产计划车间工位列表
List<Station> stationList = iStationService.list(new LambdaQueryWrapper<Station>().eq(Station::getDepartId, zyProductPlan.getWorkshopId())); List<Station> stationList = iStationService.list(new LambdaQueryWrapper<Station>().eq(Station::getDepartId, zyProductPlan.getWorkshopId()));
@ -221,9 +259,15 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
* 依次用该生产计划的车间工位设备循环与工序设备比对(工位设备包含工序设备即是匹配成功则自动填充工位设备字段数据匹配不上则不自动填充由用户自己录入) * 依次用该生产计划的车间工位设备循环与工序设备比对(工位设备包含工序设备即是匹配成功则自动填充工位设备字段数据匹配不上则不自动填充由用户自己录入)
* 根据工序查询工序设备表zy_process_machine * 根据工序查询工序设备表zy_process_machine
*/ */
if(this.diffMachine(planProcessList, stationList, planId)){ boolean b = this.diff(planProcessList, stationList, planId);
//TODO 匹配工具 //工序匹配失败,已删除生产计划、生产计划工序
if (!b) {
return false;
} }
//匹配工人
this.diffWorker(planProcessList, planId);
return true;
} }
/** /**
@ -234,48 +278,119 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
* @param stationList * @param stationList
*/ */
@Transactional(rollbackFor = Exception.class, readOnly = false) @Transactional(rollbackFor = Exception.class, readOnly = false)
public boolean diffMachine(List<ZyPlanProcess> planProcessList, List<Station> stationList, final String planId) { public boolean diff(List<ZyPlanProcess> planProcessList, List<Station> stationList, final String planId) {
if (ObjectUtils.isEmpty(stationList) || ObjectUtils.isEmpty(planProcessList)) return false;
AtomicBoolean b = new AtomicBoolean(true);
List<ZyPlanProcess> updateList = new LinkedList<>(); List<ZyPlanProcess> updateList = new LinkedList<>();
k: if (b.get()) { if (ObjectUtils.isEmpty(stationList) || ObjectUtils.isEmpty(planProcessList)) return false;
f: for (int i = 0; i < planProcessList.size(); i++) { AtomicBoolean b = new AtomicBoolean(true);
flag:
if (b.get()) {
planProcessList:
for (int i = 0; i < planProcessList.size(); i++) {
ZyPlanProcess obj = planProcessList.get(i); ZyPlanProcess obj = planProcessList.get(i);
List<ZyProcessMachine> machineList = iZyProcessMachineService.list(new LambdaQueryWrapper<ZyProcessMachine>().eq(ZyProcessMachine::getProcessId, obj.getProcessId())); List<ZyProcessMachine> machineList = iZyProcessMachineService.list(new LambdaQueryWrapper<ZyProcessMachine>().eq(ZyProcessMachine::getProcessId, obj.getProcessId()));
List<ZyOperationtool> toolList = iZyOperationtoolService.list(new LambdaQueryWrapper<ZyOperationtool>().eq(ZyOperationtool::getOperationid, obj.getProcessId()));
List<String> zyProcessMachineIds = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList()); List<String> zyProcessMachineIds = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList());
for (int j = 0; j < stationList.size(); j++) { List<String> zyProcessToolIds = toolList.stream().map(ZyOperationtool::getOperationid).collect(Collectors.toList());
Station station = stationList.get(j);
List<StationMachine> stationMachineList = iStationMachineService.list(new LambdaQueryWrapper<StationMachine>().eq(StationMachine::getStationId, station.getId())); ZyPlanProcess diffMachine = this.diffMachine(obj, zyProcessMachineIds, stationList);
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream() //设备匹配失败,直接结束
.map(StationMachine::getMachineId).collect(Collectors.toList()); if (ObjectUtils.isEmpty(diffMachine)) {
// 设备匹配成功 b.set(false);
if (stationMachineIds.containsAll(zyProcessMachineIds)) { break flag;
String collect = zyProcessMachineIds.stream().collect(Collectors.joining(",")); } else { // 设备匹配,则匹配工具
obj.setMachineIds(collect); ZyPlanProcess diffTool = this.diffTool(diffMachine, zyProcessToolIds, stationList);
obj.setMachineNames(iStationMachineService.convertByMachineIds(zyProcessMachineIds)); if (ObjectUtils.isEmpty(diffTool)) {
obj.setStationId(station.getId()); b.set(false);
obj.setStationName(station.getStationName()); break flag;
obj.setStationNum(station.getStationNum()); } else { // 匹配工人
updateList.add(obj); updateList.add(diffTool);
break f; //匹配下一个工序的设备和工具
continue planProcessList;
}
}
}
zyPlanProcessService.saveOrUpdateBatch(updateList);
return true;
} else { } else {
// 作工单异常处理,删除该工单的生产计划,删除生产计划工序
ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId); ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId);
// 1,作工单异常处理,
iWorkOrderService.lambdaUpdate() iWorkOrderService.lambdaUpdate()
.set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.EXCEPTION.getCode()) .set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.EXCEPTION.getCode())
.eq(WorkOrder::getProductCode, zyProductPlan.getProductCode()).update(); .eq(WorkOrder::getProductCode, zyProductPlan.getProductCode()).update();
// 2,删除生产计划工序面料
iZyPlanProcessFabricService.remove(new LambdaQueryWrapper<ZyPlanProcessFabric>().in(ZyPlanProcessFabric::getPlanId, planId));
// 3,删除生产计划工序辅料
iZyPlanProcessAccessoriesService.remove(new LambdaQueryWrapper<ZyPlanProcessAccessories>().in(ZyPlanProcessAccessories::getPlanId, planId));
// 4,删除生产计划工序
zyPlanProcessService.remove(new LambdaQueryWrapper<ZyPlanProcess>().in(ZyPlanProcess::getPlanId, planId)); zyPlanProcessService.remove(new LambdaQueryWrapper<ZyPlanProcess>().in(ZyPlanProcess::getPlanId, planId));
// 5,删除生产计划
iZyProductPlanService.remove(new LambdaQueryWrapper<ZyProductPlan>().in(ZyProductPlan::getId, planId)); iZyProductPlanService.remove(new LambdaQueryWrapper<ZyProductPlan>().in(ZyProductPlan::getId, planId));
b.set(false); return false;
break k;
} }
return false;
} }
@Transactional(rollbackFor = Exception.class, readOnly = false)
public void diffWorker(List<ZyPlanProcess> zyPlanProcessList, final String planId) {
ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId);
Groupx groupx = iGroupxService.getOne(new LambdaQueryWrapper<Groupx>().eq(Groupx::getDepartId, zyProductPlan.getWorkshopId()));
List<GroupxMember> memberList = iGroupxMemberService.list(new LambdaQueryWrapper<GroupxMember>()
.eq(GroupxMember::getGroupxId, groupx.getId()));
if (ObjectUtils.isEmpty(memberList)) return;
int size = zyPlanProcessList.size();
List<GroupxMember> groupxMember2 = new LinkedList<>();
groupxMember2.addAll(memberList);
int size2 = groupxMember2.size();
while (size2 < size) {
groupxMember2.addAll(memberList);
size2 = groupxMember2.size();
} }
AtomicInteger i = new AtomicInteger(0);
Optional.ofNullable(zyPlanProcessList).orElse(new LinkedList<>()).forEach(e -> {
GroupxMember groupxMember = groupxMember2.get(i.get());
e.setUserIds(groupxMember.getUserId());
SysUser sysUser = iSysUserService.getById(groupxMember.getUserId());
e.setUserNames(sysUser.getRealname());
i.set(i.get() + 1);
});
zyPlanProcessService.saveOrUpdateBatch(zyPlanProcessList);
}
ZyPlanProcess diffMachine(ZyPlanProcess zyPlanProcess, List<String> zyProcessMachineIds, List<Station> stationList) {
for (int j = 0; j < stationList.size(); j++) {
Station station = stationList.get(j);
List<StationMachine> stationMachineList = iStationMachineService.list(new LambdaQueryWrapper<StationMachine>().eq(StationMachine::getStationId, station.getId()));
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream()
.map(StationMachine::getMachineId).collect(Collectors.toList());
// 设备匹配成功
if (stationMachineIds.containsAll(zyProcessMachineIds)) {
String machineIds = zyProcessMachineIds.stream().collect(Collectors.joining(","));
zyPlanProcess.setMachineIds(machineIds);
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(zyProcessMachineIds));
zyPlanProcess.setStationId(station.getId());
zyPlanProcess.setStationName(station.getStationName());
zyPlanProcess.setStationNum(station.getStationNum());
return zyPlanProcess;
}
}
return null;
}
ZyPlanProcess diffTool(ZyPlanProcess zyPlanProcess, List<String> zyProcessToolIds, List<Station> stationList) {
for (int j = 0; j < stationList.size(); j++) {
Station station = stationList.get(j);
List<StationTool> stationToolList = iStationToolService.list(new LambdaQueryWrapper<StationTool>().eq(StationTool::getToolsId, station.getId()));
List<String> stationToolIds = Optional.ofNullable(stationToolList).orElse(new ArrayList<>()).stream()
.map(StationTool::getToolsId).collect(Collectors.toList());
// 工具匹配成功
if (stationToolIds.containsAll(zyProcessToolIds)) {
String toolIds = zyProcessToolIds.stream().collect(Collectors.joining(","));
zyPlanProcess.setToolsIds(toolIds);
return zyPlanProcess;
} }
if (b.get()) {
zyPlanProcessService.saveOrUpdateBatch(updateList);
} }
return b.get(); return null;
} }
} }

@ -34,6 +34,10 @@ import org.jeecg.modules.productplan.mapper.ZyPlanProcessAccessoriesMapper;
import org.jeecg.modules.productplan.mapper.ZyPlanProcessFabricMapper; import org.jeecg.modules.productplan.mapper.ZyPlanProcessFabricMapper;
import org.jeecg.modules.productplan.mapper.ZyPlanProcessMapper; import org.jeecg.modules.productplan.mapper.ZyPlanProcessMapper;
import org.jeecg.modules.productplan.service.*; import org.jeecg.modules.productplan.service.*;
import org.jeecg.modules.productprocessaccessories.entity.ProductProcessAccessories;
import org.jeecg.modules.productprocessaccessories.service.IProductProcessAccessoriesService;
import org.jeecg.modules.productprocessfabric.entity.ProductProcessFabric;
import org.jeecg.modules.productprocessfabric.service.IProductProcessFabricService;
import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysDepartService; import org.jeecg.modules.system.service.ISysDepartService;
@ -111,7 +115,6 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
@Autowired @Autowired
private IZyProductService iZyProductService; private IZyProductService iZyProductService;
@Autowired @Autowired
private IZyPlanProcessFabricService iZyPlanProcessFabricService; private IZyPlanProcessFabricService iZyPlanProcessFabricService;
@ -126,12 +129,20 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
@Autowired @Autowired
private IZyProcessFabricService iZyProcessFabricService; private IZyProcessFabricService iZyProcessFabricService;
@Autowired
private IZyProcessAccessoriesService iZyProcessAccessoriesService;
//产品工序面料
@Autowired @Autowired
IZyFabricService iZyFabricService; private IProductProcessFabricService iProductProcessFabricService;
//产品工序辅料
@Autowired @Autowired
private IZyProcessAccessoriesService iZyProcessAccessoriesService; private IProductProcessAccessoriesService iProductProcessAccessoriesService;
@Autowired
IZyFabricService iZyFabricService;
@Autowired @Autowired
private IZyAccessoriesService iZyAccessoriesService; private IZyAccessoriesService iZyAccessoriesService;
@ -274,7 +285,6 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
zyPlanAccessoriesList.add(zyPlanAccessories); zyPlanAccessoriesList.add(zyPlanAccessories);
} }
iZyPlanAccessoriesService.saveBatch(zyPlanAccessoriesList); iZyPlanAccessoriesService.saveBatch(zyPlanAccessoriesList);
} }
@ -341,9 +351,10 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
List<ZyPlanProcess> planProcessList = this.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, zyPlanProcess.getPlanId())); List<ZyPlanProcess> planProcessList = this.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, zyPlanProcess.getPlanId()));
//工序面料同步到计划工序面料表 //工序面料同步到计划工序面料表
//产品工序面料同步到计划工序面料表
this.saveBatchFabricByProcessIdList(planProcessList); this.saveBatchFabricByProcessIdList(planProcessList);
//工序辅料同步到计划工序辅料表 //产品工序辅料同步到计划工序辅料表
this.saveBatchAccessoriesByProcessIdList(planProcessList); this.saveBatchAccessoriesByProcessIdList(planProcessList);
//填充前导工序、和后导工序 //填充前导工序、和后导工序
@ -413,13 +424,17 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
void saveBatchAccessoriesByProcessIdList(List<ZyPlanProcess> planProcessList) { void saveBatchAccessoriesByProcessIdList(List<ZyPlanProcess> planProcessList) {
Optional.ofNullable(planProcessList).orElse(new ArrayList<>()).forEach(e -> { Optional.ofNullable(planProcessList).orElse(new ArrayList<>()).forEach(e -> {
List<ZyProcessAccessories> accessoriesList = this.iZyProcessAccessoriesService.list(new LambdaQueryWrapper<ZyProcessAccessories>() // List<ZyProcessAccessories> accessoriesList = this.iZyProcessAccessoriesService.list(new LambdaQueryWrapper<ZyProcessAccessories>()
.eq(ZyProcessAccessories::getProcessId, e.getProcessId())); // .eq(ZyProcessAccessories::getProcessId, e.getProcessId()));
List<ProductProcessAccessories> accessoriesList = iProductProcessAccessoriesService.list(new LambdaQueryWrapper<ProductProcessAccessories>()
.eq(ProductProcessAccessories::getProductProcessId, e.getProcessId()));
List<ZyPlanProcessAccessories> list = new LinkedList<>(); List<ZyPlanProcessAccessories> list = new LinkedList<>();
Optional.ofNullable(accessoriesList).orElse(new ArrayList<>()).forEach(obj -> { Optional.ofNullable(accessoriesList).orElse(new ArrayList<>()).forEach(obj -> {
ZyPlanProcessAccessories en = new ZyPlanProcessAccessories(); ZyPlanProcessAccessories en = new ZyPlanProcessAccessories();
en.setPlanProcessId(e.getId()); en.setPlanProcessId(e.getId());
en.setPlanId(e.getPlanId()); en.setPlanId(e.getPlanId());
en.setAmount(new BigDecimal(obj.getAmount()));
en.setAccessoriesId(obj.getAccessoriesId()); en.setAccessoriesId(obj.getAccessoriesId());
ZyAccessories zyAccessories = iZyAccessoriesService.getById(obj.getAccessoriesId()); ZyAccessories zyAccessories = iZyAccessoriesService.getById(obj.getAccessoriesId());
en.setAccessoriesName(StringUtils.isNotBlank(zyAccessories.getContents()) ? zyAccessories.getContents() : ""); en.setAccessoriesName(StringUtils.isNotBlank(zyAccessories.getContents()) ? zyAccessories.getContents() : "");
@ -430,17 +445,21 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
} }
void saveBatchFabricByProcessIdList(List<ZyPlanProcess> planProcessList) { void saveBatchFabricByProcessIdList(List<ZyPlanProcess> planProcessList) {
if (!org.springframework.util.StringUtils.isEmpty(planProcessList)) { if (!ObjectUtils.isEmpty(planProcessList)) {
planProcessList.forEach(e -> { planProcessList.forEach(e -> {
List<ZyProcessFabric> fabricList = this.iZyProcessFabricService.list(new LambdaQueryWrapper<ZyProcessFabric>() // List<ZyProcessFabric> fabricList = this.iZyProcessFabricService.list(new LambdaQueryWrapper<ZyProcessFabric>()
.eq(ZyProcessFabric::getProcessId, e.getProcessId())); // .eq(ZyProcessFabric::getProcessId, e.getProcessId()));
List<ProductProcessFabric> fabricList = iProductProcessFabricService.list(new LambdaQueryWrapper<ProductProcessFabric>()
.eq(ProductProcessFabric::getProductProcessId, e.getProcessId()));
List<ZyPlanProcessFabric> list = new LinkedList<>(); List<ZyPlanProcessFabric> list = new LinkedList<>();
if (!org.springframework.util.StringUtils.isEmpty(fabricList)) { if (!ObjectUtils.isEmpty(fabricList)) {
fabricList.forEach(obj -> { fabricList.forEach(obj -> {
ZyPlanProcessFabric en = new ZyPlanProcessFabric(); ZyPlanProcessFabric en = new ZyPlanProcessFabric();
en.setPlanProcessId(e.getId()); en.setPlanProcessId(e.getId());
en.setPlanId(e.getPlanId()); en.setPlanId(e.getPlanId());
en.setFabricId(obj.getFabricId()); en.setFabricId(obj.getFabricId());
en.setAmount(new BigDecimal(obj.getAmount()));
ZyFabric zyFabric = iZyFabricService.getById(obj.getFabricId()); ZyFabric zyFabric = iZyFabricService.getById(obj.getFabricId());
en.setFabricName(StringUtils.isNotBlank(zyFabric.getName()) ? zyFabric.getName() : ""); en.setFabricName(StringUtils.isNotBlank(zyFabric.getName()) ? zyFabric.getName() : "");
list.add(en); list.add(en);

Loading…
Cancel
Save