diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/service/impl/ProductionLargeServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/service/impl/ProductionLargeServiceImpl.java index 41fde517..3bd4988c 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/service/impl/ProductionLargeServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/service/impl/ProductionLargeServiceImpl.java @@ -1,21 +1,25 @@ package org.jeecg.modules.largeScreen.service.impl; 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.largeScreen.service.ProductionLargeService; +import org.jeecg.modules.largeScreen.vo.ProductRecordVo; import org.jeecg.modules.productplan.entity.ZyPlanProcess; 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.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.stereotype.Service; import org.springframework.util.ObjectUtils; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class ProductionLargeServiceImpl implements ProductionLargeService { @@ -23,18 +27,27 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { @Autowired private IHangRecordService iHangRecordService; + @Autowired + private IZyProductPlanService iZyProductPlanService; + @Autowired private IZyPlanProcessService iZyPlanProcessService; @Autowired - private IZyProductPlanService iZyProductPlanService; + private IProductRecordService iProductRecordService; + + @Autowired + private IStationService iStationService; + + @Autowired + private ISysDepartService iSysDepartService; @Override public Map getData() { Map resultMap = new HashMap<>(); - //1,吊挂 + /*//1,吊挂 // 分组统计,获取最新时间5条吊挂运行记录 List recordList = iHangRecordService.list(new LambdaQueryWrapper().groupBy(HangRecord::getHangCode)); Map diaoguaData = new HashMap<>(); @@ -48,23 +61,67 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { diaoguaData.put(e.getHangCode(), records); }); } - resultMap.put("diaogua_data", diaoguaData); + resultMap.put("diaogua_data", diaoguaData);*/ //2,生产线实时状态 - // 统计生产计划状为生产中的数据 - List planList = iZyProductPlanService.list(new LambdaQueryWrapper().eq(ZyProductPlan::getStatus, ProductPlanStatusEnum.PRODUCTION.getCode())); - Map shengchanxianMap = new HashMap<>(); - if (!ObjectUtils.isEmpty(planList)) { - planList.stream().forEach(e -> { - List planProcessList = iZyPlanProcessService.list(new LambdaQueryWrapper().eq(ZyPlanProcess::getPlanId, e.getId())); - if (!ObjectUtils.isEmpty(planProcessList)) { - shengchanxianMap.put(e.getId(), planProcessList); - } + List stationGroup = iStationService.list(new LambdaQueryWrapper().groupBy(Station::getDepartId)); + Map shengchanxianMap = new LinkedHashMap<>(); + if (!ObjectUtils.isEmpty(stationGroup)) { + stationGroup.stream().forEach(station -> { + Map departMap = new LinkedHashMap<>(); + //每个车间的工位 + List stationList = iStationService.list(new LambdaQueryWrapper() + .eq(Station::getDepartId, station.getDepartId()) + .orderByAsc(Station::getStationNum) + ); + /** + * 取每个工位的,生产记录状态0(生产中)的最新一条数据 + */ + List productRecordVos = new LinkedList<>(); + Optional.ofNullable(stationList).orElse(new LinkedList<>()).forEach(obj -> { + ProductRecord productRecord = iProductRecordService.getOne(new LambdaQueryWrapper() + .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().eq(ZyProductPlan::getProductCode, productRecord.getOrderCode())); + Optional.ofNullable(productPlan).orElseThrow(() -> new JeecgBootException("工单编号:" + productRecord.getOrderCode() + "不存在!")); + List zyPlanProcessList = iZyPlanProcessService.list(new LambdaQueryWrapper() + .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().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); - return resultMap; } } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/vo/ProductRecordVo.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/vo/ProductRecordVo.java new file mode 100644 index 00000000..f2a57098 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/largeScreen/vo/ProductRecordVo.java @@ -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; +}