|
|
|
@ -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<String, Object> getData() { |
|
|
|
|
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
//1,吊挂
|
|
|
|
|
/*//1,吊挂
|
|
|
|
|
// 分组统计,获取最新时间5条吊挂运行记录
|
|
|
|
|
List<HangRecord> recordList = iHangRecordService.list(new LambdaQueryWrapper<HangRecord>().groupBy(HangRecord::getHangCode)); |
|
|
|
|
Map<String, Object> 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<ZyProductPlan> planList = iZyProductPlanService.list(new LambdaQueryWrapper<ZyProductPlan>().eq(ZyProductPlan::getStatus, ProductPlanStatusEnum.PRODUCTION.getCode())); |
|
|
|
|
Map<String, Object> shengchanxianMap = new HashMap<>(); |
|
|
|
|
if (!ObjectUtils.isEmpty(planList)) { |
|
|
|
|
planList.stream().forEach(e -> { |
|
|
|
|
List<ZyPlanProcess> planProcessList = iZyPlanProcessService.list(new LambdaQueryWrapper<ZyPlanProcess>().eq(ZyPlanProcess::getPlanId, e.getId())); |
|
|
|
|
if (!ObjectUtils.isEmpty(planProcessList)) { |
|
|
|
|
shengchanxianMap.put(e.getId(), planProcessList); |
|
|
|
|
List<Station> stationGroup = iStationService.list(new LambdaQueryWrapper<Station>().groupBy(Station::getDepartId)); |
|
|
|
|
Map<String, Object> shengchanxianMap = new LinkedHashMap<>(); |
|
|
|
|
if (!ObjectUtils.isEmpty(stationGroup)) { |
|
|
|
|
stationGroup.stream().forEach(station -> { |
|
|
|
|
Map<String, Object> departMap = new LinkedHashMap<>(); |
|
|
|
|
//每个车间的工位
|
|
|
|
|
List<Station> stationList = iStationService.list(new LambdaQueryWrapper<Station>() |
|
|
|
|
.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); |
|
|
|
|
|
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|