From 345e4ad1860ed45c9ff5c65c086b60e2342c50d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=86=E7=B1=B3=E8=8A=B1?= <417727563@qq.com> Date: Sat, 13 May 2023 17:10:29 +0800 Subject: [PATCH] 2023-05-13-01-bug --- .../java/org/jeecg/common/util/XJobUtils.java | 4 +- .../service/IHangerLocationService.java | 2 +- .../impl/HangerLocationServiceImpl.java | 245 ++++++++++++++---- .../service/impl/HangerMakerServiceImpl.java | 8 +- 4 files changed, 205 insertions(+), 54 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/XJobUtils.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/XJobUtils.java index 24c6ccb8..223859e2 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/XJobUtils.java +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/XJobUtils.java @@ -21,7 +21,9 @@ public class XJobUtils{ /** * 获取间隔时间 * @param start_Date - * @return + *s 开始范围 + *e 结束范围 + * @return */ public static Date randomIntervaltime(Date start_Date,int s,int e) { diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/IHangerLocationService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/IHangerLocationService.java index 2f58548f..1d15cf40 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/IHangerLocationService.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/IHangerLocationService.java @@ -17,5 +17,5 @@ public interface IHangerLocationService extends IService { public HangerLocation queryByNew(); //自动化生产传感器记录 - void recordAuto(List>> list); + void recordAuto(List woList); } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/impl/HangerLocationServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/impl/HangerLocationServiceImpl.java index 0c78db0c..f9f831dc 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/impl/HangerLocationServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/impl/HangerLocationServiceImpl.java @@ -2,12 +2,23 @@ package org.jeecg.modules.hangerlocation.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.jeecg.common.util.XJobUtils; +import org.jeecg.modules.demo.productrecord.entity.ProductRecord; +import org.jeecg.modules.demo.productrecord.mapper.ProductRecordMapper; +import org.jeecg.modules.demo.sensor.entity.Sensor; +import org.jeecg.modules.demo.sensor.mapper.SensorMapper; +import org.jeecg.modules.demo.sensorrecord.entity.SensorRecord; +import org.jeecg.modules.demo.sensorrecord.mapper.SensorRecordMapper; +import org.jeecg.modules.hanger.entity.HangRecord; +import org.jeecg.modules.hanger.mapper.HangRecordMapper; import org.jeecg.modules.hangerlocation.entity.HangerLocation; import org.jeecg.modules.hangerlocation.mapper.HangerLocationMapper; import org.jeecg.modules.hangerlocation.service.IHangerLocationService; import org.jeecg.modules.hangermaker.entity.HangerMaker; import org.jeecg.modules.hangermaker.mapper.HangerMakerMapper; import org.jeecg.modules.productplan.entity.ZyPlanProcess; +import org.jeecg.modules.productplan.entity.ZyProductPlan; +import org.jeecg.modules.productplan.mapper.ZyPlanProcessMapper; +import org.jeecg.modules.productplan.mapper.ZyProductPlanMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -16,6 +27,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; import static org.jeecg.common.util.XJobUtils.dateToLong; @@ -34,6 +46,33 @@ public class HangerLocationServiceImpl extends ServiceImpl>> list) { + public void recordAuto(List woList) { - //绑定 + //1、读取工单,得到生产计划 + if(woList.size()<=0) + { + return; + } + QueryWrapper qwProduct=new QueryWrapper<>(); + qwProduct.in("product_code",woList); + List productPlanList=zyProductPlanMapper.selectList(qwProduct); + //查找有所传感器 + QueryWrapper qws=new QueryWrapper<>(); + List sensorList=sensorMapper.selectList(qws); - //遍历list - for(Map> item :list) + //#region2.遍历list 吊挂(开始+结束)+传感器记录(每个)+生产记录(每个) + for(ZyProductPlan item :productPlanList) { - //遍历map - for(Map.Entry> entry : item.entrySet()){ - //遍历List - - //服装进入制作工艺过程 - long timeMillis = System.currentTimeMillis(); - //将获取时间转为日期类型 - Date start_time=XJobUtils.longToDate(timeMillis); - QueryWrapper qwhm=new QueryWrapper(); - qwhm.eq("order_code",entry.getKey()); - HangerMaker hm=hangerMakerMapper.selectOne(qwhm); - for(ZyPlanProcess process:entry.getValue()) + //3、每个生产计划对应工序,每一道工序对应工位 + QueryWrapper qwProcess=new QueryWrapper<>(); + List listProcess=zyPlanProcessMapper.selectList(qwProcess); + + //服装进入制作工艺过程 + long timeMillis = System.currentTimeMillis(); + //将获取时间转为日期类型 + Date start_time=XJobUtils.longToDate(timeMillis); + + //生产记录 + List arrPR=new ArrayList<>(); + //传感器 + List arrSR=new ArrayList<>(); + //吊挂 + List arrHR=new ArrayList<>(); + + //#region每一道工序 + for(ZyPlanProcess process:listProcess) + { + //传感器记录(每个)+生产记录(每个) + //开始时间 + Date str01= start_time; + //结束时间 + Date str02= XJobUtils.randomIntervaltime(str01,1,5); + //生产时间 + long time=XJobUtils.dateToLong(str01,str02); + + + //#region生产记录 + ProductRecord prmodel=new ProductRecord(); + //工位 + prmodel.setStationId(process.getStationId()); + //工位 + prmodel.setStationName(process.getStationName()); + //工单编号 + prmodel.setOrderCode(item.getProductCode()); + //工单编号 + prmodel.setOrderId(item.getProductCode()); + //生产开始时间 + prmodel.setWorkTime(str01); + //生产结束时间 + prmodel.setOffTime(str02); + //时长 + prmodel.setDuration(time+""); + //状态 + prmodel.setStatus("1"); + arrPR.add(prmodel); + //#endregion + + //#region 传感器记录 + //查找工位对应的传感器 + List senlist = sensorList.stream() + .filter(Sensor -> Sensor.getStationId().equals(process.getStationId())) + .collect(Collectors.toList()); + //查找进 + List senIn = senlist.stream() + .filter(Sensor -> Sensor.getStationId().equals(process.getStationId())) + .collect(Collectors.toList()); + if(senIn.size()>0) + { + Sensor sr=senIn.get(0); + SensorRecord srmodel=new SensorRecord(); + //传感器编号 + srmodel.setSensorCode(sr.getSensorCode()); + //网络地址 + srmodel.setSensorIp(sr.getSensorIp()); + //工位 + srmodel.setStationId(process.getStationId()); + //进出标记 + srmodel.setIiOsign("1"); + //产品标识 + //srmodel.setProductIdenti(); + //触发时间 + srmodel.setTriggerTime(str01); + arrSR.add(srmodel); + } + //查找出 + List senOut = sensorList.stream() + .filter(Sensor -> Sensor.getStationId().equals(process.getStationId())) + .collect(Collectors.toList()); + if(senOut.size()>0) { - HangerLocation model=new HangerLocation(); - - /**衣架编码*/ - //String HangerCode="00087896"+randInt(10,99); - model.setHangerCode(hm.getHangerCode()); - /**工位ID*/ - model.setStationId(process.getStationId()); - /**工位编码*/ - model.setStationCode(process.getStationName()); - /**设备ID*/ - model.setEquipmentId(process.getMachineIds()); - /**设备名称*/ - model.setEquipmentName(process.getMachineNames()); - /**工序ID*/ - model.setProcedureId(process.getProcessId()); - /**工序名称*/ - model.setProcedureName(process.getProcessName()); - /**工人ID*/ - model.setWorkerId(process.getUserIds()); - /**工人名称*/ - model.setWorkerName(process.getUserNames()); - /**到达时间*/ - model.setArrivalTime(start_time); - /**离开时间*/ - Date end_time= XJobUtils.randomIntervaltime(start_time,3,5); - model.setLeaveTime(end_time); - /**时长*/ - model.setDuration(dateToLong(start_time,end_time)+""); - - //执行下一步间隔时间 - start_time=XJobUtils.randomIntervaltime(end_time,1,3); - hangerLocationMapper.insert(model); + Sensor sr=senIn.get(0); + SensorRecord srmodel=new SensorRecord(); + //传感器编号 + srmodel.setSensorCode(sr.getSensorCode()); + //网络地址 + srmodel.setSensorIp(sr.getSensorIp()); + //工位 + srmodel.setStationId(process.getStationId()); + //进出标记 + srmodel.setIiOsign("1"); + //产品标识 + //srmodel.setProductIdenti(); + //触发时间 + srmodel.setTriggerTime(str01); + arrSR.add(srmodel); } -// System.out.println(entry.getKey()); -// System.out.println(entry.getValue()); + //#endregion + + //#region吊挂运行记录 + HangRecord hrmodel=new HangRecord(); + //吊挂编号 + hrmodel.setHangCode("DG1000"); + //工站编号 + hrmodel.setPoint(process.getStationId()); + //工单编号 + hrmodel.setOrderCode(item.getProductCode()); + //生产开始时间 + hrmodel.setWorkTime(str01); + //生产结束时间 + hrmodel.setOffTime(str02); + //时长 + hrmodel.setDuration(time+""); + //状态 + hrmodel.setStatus("1"); + arrHR.add(hrmodel); + //#endregion + //间隔时间 + start_time=XJobUtils.randomIntervaltime(str01,1,2); + } + //#endregion + + //#region批量保存 + for(ProductRecord arr:arrPR) + {//生产记录 + productRecordMapper.insert(arr); + } + for(SensorRecord arr:arrSR) + {//传感器 + sensorRecordMapper.insert(arr); } + for(HangRecord arr:arrHR) + {//吊挂 + hangRecordMapper.insert(arr); + } + //#endregion + } + //#endregion + //#region修改工单状态 + + //#endregion } + } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangermaker/service/impl/HangerMakerServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangermaker/service/impl/HangerMakerServiceImpl.java index 1372a9dc..dd38abbe 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangermaker/service/impl/HangerMakerServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangermaker/service/impl/HangerMakerServiceImpl.java @@ -40,7 +40,13 @@ public class HangerMakerServiceImpl extends ServiceImpl woList) { - List workList=workOrderMapper.selectBatchIds(woList); + if(woList.size()<=0) + { + return; + } + QueryWrapper qw=new QueryWrapper<>(); + qw.in("id",woList); + List workList=workOrderMapper.selectList(qw); for(WorkOrder item:workList) { Hanger h=randomModel();