生产数据大屏 接口 5.16

master
zhc077 2 years ago
parent 7111b40d4f
commit 1f7dda1573
  1. 91
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/service/impl/ProductionLargeServiceImpl.java
  2. 50
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/vo/ProductRecordVo.java

@ -1,21 +1,25 @@
package org.jeecg.modules.largeScreen.service.impl; package org.jeecg.modules.largeScreen.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.hanger.entity.HangRecord; import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.demo.productrecord.entity.ProductRecord;
import org.jeecg.modules.demo.productrecord.service.IProductRecordService;
import org.jeecg.modules.hanger.service.IHangRecordService; import org.jeecg.modules.hanger.service.IHangRecordService;
import org.jeecg.modules.largeScreen.service.ProductionLargeService; import org.jeecg.modules.largeScreen.service.ProductionLargeService;
import org.jeecg.modules.largeScreen.vo.ProductRecordVo;
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.entity.ZyProductPlan;
import org.jeecg.modules.productplan.enums.ProductPlanStatusEnum;
import org.jeecg.modules.productplan.service.IZyPlanProcessService; import org.jeecg.modules.productplan.service.IZyPlanProcessService;
import org.jeecg.modules.productplan.service.IZyProductPlanService; import org.jeecg.modules.productplan.service.IZyProductPlanService;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.team.entity.Station;
import org.jeecg.modules.team.service.IStationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
@Service @Service
public class ProductionLargeServiceImpl implements ProductionLargeService { public class ProductionLargeServiceImpl implements ProductionLargeService {
@ -23,18 +27,27 @@ public class ProductionLargeServiceImpl implements ProductionLargeService {
@Autowired @Autowired
private IHangRecordService iHangRecordService; private IHangRecordService iHangRecordService;
@Autowired
private IZyProductPlanService iZyProductPlanService;
@Autowired @Autowired
private IZyPlanProcessService iZyPlanProcessService; private IZyPlanProcessService iZyPlanProcessService;
@Autowired @Autowired
private IZyProductPlanService iZyProductPlanService; private IProductRecordService iProductRecordService;
@Autowired
private IStationService iStationService;
@Autowired
private ISysDepartService iSysDepartService;
@Override @Override
public Map<String, Object> getData() { public Map<String, Object> getData() {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
//1,吊挂 /*//1,吊挂
// 分组统计,获取最新时间5条吊挂运行记录 // 分组统计,获取最新时间5条吊挂运行记录
List<HangRecord> recordList = iHangRecordService.list(new LambdaQueryWrapper<HangRecord>().groupBy(HangRecord::getHangCode)); List<HangRecord> recordList = iHangRecordService.list(new LambdaQueryWrapper<HangRecord>().groupBy(HangRecord::getHangCode));
Map<String, Object> diaoguaData = new HashMap<>(); Map<String, Object> diaoguaData = new HashMap<>();
@ -48,23 +61,67 @@ public class ProductionLargeServiceImpl implements ProductionLargeService {
diaoguaData.put(e.getHangCode(), records); diaoguaData.put(e.getHangCode(), records);
}); });
} }
resultMap.put("diaogua_data", diaoguaData); resultMap.put("diaogua_data", diaoguaData);*/
//2,生产线实时状态 //2,生产线实时状态
// 统计生产计划状为生产中的数据 List<Station> stationGroup = iStationService.list(new LambdaQueryWrapper<Station>().groupBy(Station::getDepartId));
List<ZyProductPlan> planList = iZyProductPlanService.list(new LambdaQueryWrapper<ZyProductPlan>().eq(ZyProductPlan::getStatus, ProductPlanStatusEnum.PRODUCTION.getCode())); Map<String, Object> shengchanxianMap = new LinkedHashMap<>();
Map<String, Object> shengchanxianMap = new HashMap<>(); if (!ObjectUtils.isEmpty(stationGroup)) {
if (!ObjectUtils.isEmpty(planList)) { stationGroup.stream().forEach(station -> {
planList.stream().forEach(e -> { Map<String, Object> departMap = new LinkedHashMap<>();
List<ZyPlanProcess> planProcessList = iZyPlanProcessService.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, e.getId())); //每个车间的工位
if (!ObjectUtils.isEmpty(planProcessList)) { List<Station> stationList = iStationService.list(new LambdaQueryWrapper<Station>()
shengchanxianMap.put(e.getId(), planProcessList); .eq(Station::getDepartId, station.getDepartId())
.orderByAsc(Station::getStationNum)
);
/**
* 取每个工位的生产记录状态0(生产中)的最新一条数据
*/
List<ProductRecordVo> productRecordVos = new LinkedList<>();
Optional.ofNullable(stationList).orElse(new LinkedList<>()).forEach(obj -> {
ProductRecord productRecord = iProductRecordService.getOne(new LambdaQueryWrapper<ProductRecord>()
.eq(ProductRecord::getStationId, obj.getId())
.eq(ProductRecord::getStatus, "0")
.orderByDesc(ProductRecord::getCreateTime)
.last("limit 1")
);
if (!ObjectUtils.isEmpty(productRecord)) {
ZyProductPlan productPlan = iZyProductPlanService.getOne(new LambdaQueryWrapper<ZyProductPlan>().eq(ZyProductPlan::getProductCode, productRecord.getOrderCode()));
Optional.ofNullable(productPlan).orElseThrow(() -> new JeecgBootException("工单编号:" + productRecord.getOrderCode() + "不存在!"));
List<ZyPlanProcess> zyPlanProcessList = iZyPlanProcessService.list(new LambdaQueryWrapper<ZyPlanProcess>()
.eq(ZyPlanProcess::getPlanId, productPlan.getId())
.eq(ZyPlanProcess::getStationId, obj.getId())
);
if (!ObjectUtils.isEmpty(zyPlanProcessList)) {
ZyPlanProcess zyPlanProcess = zyPlanProcessList.get(0);
ProductRecordVo vo = new ProductRecordVo();
vo.setProductCode(productRecord.getOrderCode());
vo.setProcessName(zyPlanProcess.getProcessName());
vo.setStationName(zyPlanProcess.getStationName());
vo.setMachineNames(zyPlanProcess.getMachineNames());
vo.setStationNum(zyPlanProcess.getStationNum());
productRecordVos.add(vo);
} else {
ProductRecordVo vo = new ProductRecordVo();
vo.setStationName(obj.getStationName());
vo.setStationNum(obj.getStationNum());
productRecordVos.add(vo);
} }
} else {
ProductRecordVo vo = new ProductRecordVo();
vo.setStationName(obj.getStationName());
vo.setStationNum(obj.getStationNum());
productRecordVos.add(vo);
}
});
SysDepart depart = iSysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getId, station.getDepartId()));
// productRecordVos.stream().map(o -> o.getStationNum()).collect(Collectors.toList());
departMap.put(depart.getDepartName(), productRecordVos);
shengchanxianMap.putAll(departMap);
}); });
} }
resultMap.put("shengchanxian_data", shengchanxianMap); resultMap.put("shengchanxian_data", shengchanxianMap);
return resultMap; return resultMap;
} }
} }

@ -0,0 +1,50 @@
package org.jeecg.modules.largeScreen.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
@Data
public class ProductRecordVo implements Serializable {
private static final long serialVersionUID = 007555;
// @Excel(name = "工序id", width = 15)
// @ApiModelProperty(value = "工序id列表")
// @Dict(dictTable = "zy_process", dicText = "process_name", dicCode = "id")
// private String processId;
private String processName;
// @Excel(name = "设备id列表", width = 15)
// @ApiModelProperty(value = "设备id列表")
// @Dict(dictTable = "zy_device", dicText = "name", dicCode = "id")
// private String machineIds;
private String machineNames;
// @Excel(name = "工位id", width = 15)
// @ApiModelProperty(value = "工位id")
// @Dict(dictTable = "station", dicText = "station_name", dicCode = "id")
// private String stationId;
@ApiModelProperty(value = "工序名称")
private String stationName;
/**
* 工具id列表
*/
// @Excel(name = "工具id列表", width = 15)
// @ApiModelProperty(value = "工具id列表")
// @Dict(dictTable = "zy_tool", dicText = "name", dicCode = "id")
// private String toolsIds;
// private String toolsNames;
@Excel(name = "工单编号", width = 15)
@ApiModelProperty(value = "工单编号")
private String productCode;
private Integer stationNum;
}
Loading…
Cancel
Save