2023-05-13-01-bug

master
喻忠伟 2 years ago
parent 6434359480
commit 345e4ad186
  1. 2
      jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/XJobUtils.java
  2. 2
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/IHangerLocationService.java
  3. 235
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangerlocation/service/impl/HangerLocationServiceImpl.java
  4. 8
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/hangermaker/service/impl/HangerMakerServiceImpl.java

@ -21,6 +21,8 @@ public class XJobUtils{
/** /**
* 获取间隔时间 * 获取间隔时间
* @param start_Date * @param start_Date
*s 开始范围
*e 结束范围
* @return * @return
*/ */
public static Date randomIntervaltime(Date start_Date,int s,int e) public static Date randomIntervaltime(Date start_Date,int s,int e)

@ -17,5 +17,5 @@ public interface IHangerLocationService extends IService<HangerLocation> {
public HangerLocation queryByNew(); public HangerLocation queryByNew();
//自动化生产传感器记录 //自动化生产传感器记录
void recordAuto(List<Map<String, List<ZyPlanProcess>>> list); void recordAuto(List<String> woList);
} }

@ -2,12 +2,23 @@ package org.jeecg.modules.hangerlocation.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.util.XJobUtils; 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.entity.HangerLocation;
import org.jeecg.modules.hangerlocation.mapper.HangerLocationMapper; import org.jeecg.modules.hangerlocation.mapper.HangerLocationMapper;
import org.jeecg.modules.hangerlocation.service.IHangerLocationService; import org.jeecg.modules.hangerlocation.service.IHangerLocationService;
import org.jeecg.modules.hangermaker.entity.HangerMaker; import org.jeecg.modules.hangermaker.entity.HangerMaker;
import org.jeecg.modules.hangermaker.mapper.HangerMakerMapper; import org.jeecg.modules.hangermaker.mapper.HangerMakerMapper;
import org.jeecg.modules.productplan.entity.ZyPlanProcess; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,6 +27,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static org.jeecg.common.util.XJobUtils.dateToLong; import static org.jeecg.common.util.XJobUtils.dateToLong;
@ -34,6 +46,33 @@ public class HangerLocationServiceImpl extends ServiceImpl<HangerLocationMapper,
@Autowired @Autowired
private HangerMakerMapper hangerMakerMapper; private HangerMakerMapper hangerMakerMapper;
//生产计划
@Autowired
private ZyProductPlanMapper zyProductPlanMapper;
//生产计划工序
@Autowired
private ZyPlanProcessMapper zyPlanProcessMapper;
//传感器
@Autowired
private SensorMapper sensorMapper;
//传感记录表
@Autowired
private SensorRecordMapper sensorRecordMapper;
//生产记录表
@Autowired
private ProductRecordMapper productRecordMapper;
//吊挂运行记录表
@Autowired
private HangRecordMapper hangRecordMapper;
@Override @Override
public HangerLocation queryByNew() { public HangerLocation queryByNew() {
@ -42,66 +81,170 @@ public class HangerLocationServiceImpl extends ServiceImpl<HangerLocationMapper,
/** /**
* 自动化生产传感器记录 * 自动化生产传感器记录
* @param list * @param woList
*/ */
@Override @Override
public void recordAuto(List<Map<String, List<ZyPlanProcess>>> list) { public void recordAuto(List<String> woList) {
//绑定 //1、读取工单,得到生产计划
if(woList.size()<=0)
{
return;
}
QueryWrapper<ZyProductPlan> qwProduct=new QueryWrapper<>();
qwProduct.in("product_code",woList);
List<ZyProductPlan> productPlanList=zyProductPlanMapper.selectList(qwProduct);
//查找有所传感器
QueryWrapper<Sensor> qws=new QueryWrapper<>();
List<Sensor> sensorList=sensorMapper.selectList(qws);
//遍历list //#region2.遍历list 吊挂(开始+结束)+传感器记录(每个)+生产记录(每个)
for(Map<String, List<ZyPlanProcess>> item :list) for(ZyProductPlan item :productPlanList)
{ {
//遍历map //3、每个生产计划对应工序,每一道工序对应工位
for(Map.Entry<String, List<ZyPlanProcess>> entry : item.entrySet()){ QueryWrapper<ZyPlanProcess> qwProcess=new QueryWrapper<>();
//遍历List<ZyPlanProcess> List<ZyPlanProcess> listProcess=zyPlanProcessMapper.selectList(qwProcess);
//服装进入制作工艺过程 //服装进入制作工艺过程
long timeMillis = System.currentTimeMillis(); long timeMillis = System.currentTimeMillis();
//将获取时间转为日期类型 //将获取时间转为日期类型
Date start_time=XJobUtils.longToDate(timeMillis); Date start_time=XJobUtils.longToDate(timeMillis);
QueryWrapper<HangerMaker> qwhm=new QueryWrapper();
qwhm.eq("order_code",entry.getKey()); //生产记录
HangerMaker hm=hangerMakerMapper.selectOne(qwhm); List<ProductRecord> arrPR=new ArrayList<>();
for(ZyPlanProcess process:entry.getValue()) //传感器
List<SensorRecord> arrSR=new ArrayList<>();
//吊挂
List<HangRecord> 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<Sensor> senlist = sensorList.stream()
.filter(Sensor -> Sensor.getStationId().equals(process.getStationId()))
.collect(Collectors.toList());
//查找进
List<Sensor> 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<Sensor> senOut = sensorList.stream()
.filter(Sensor -> Sensor.getStationId().equals(process.getStationId()))
.collect(Collectors.toList());
if(senOut.size()>0)
{ {
HangerLocation model=new HangerLocation(); Sensor sr=senIn.get(0);
SensorRecord srmodel=new SensorRecord();
/**衣架编码*/ //传感器编号
//String HangerCode="00087896"+randInt(10,99); srmodel.setSensorCode(sr.getSensorCode());
model.setHangerCode(hm.getHangerCode()); //网络地址
/**工位ID*/ srmodel.setSensorIp(sr.getSensorIp());
model.setStationId(process.getStationId()); //工位
/**工位编码*/ srmodel.setStationId(process.getStationId());
model.setStationCode(process.getStationName()); //进出标记
/**设备ID*/ srmodel.setIiOsign("1");
model.setEquipmentId(process.getMachineIds()); //产品标识
/**设备名称*/ //srmodel.setProductIdenti();
model.setEquipmentName(process.getMachineNames()); //触发时间
/**工序ID*/ srmodel.setTriggerTime(str01);
model.setProcedureId(process.getProcessId()); arrSR.add(srmodel);
/**工序名称*/
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);
} }
// System.out.println(entry.getKey()); //#endregion
// System.out.println(entry.getValue());
//#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
} }
} }

@ -40,7 +40,13 @@ public class HangerMakerServiceImpl extends ServiceImpl<HangerMakerMapper, Hange
@Override @Override
public void doAutoHM(List<String> woList) { public void doAutoHM(List<String> woList) {
List<WorkOrder> workList=workOrderMapper.selectBatchIds(woList); if(woList.size()<=0)
{
return;
}
QueryWrapper<WorkOrder> qw=new QueryWrapper<>();
qw.in("id",woList);
List<WorkOrder> workList=workOrderMapper.selectList(qw);
for(WorkOrder item:workList) for(WorkOrder item:workList)
{ {
Hanger h=randomModel(); Hanger h=randomModel();

Loading…
Cancel
Save