|
|
|
@ -1,31 +1,41 @@ |
|
|
|
|
package org.jeecg.modules.largeScreen.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
|
import org.jeecg.modules.demo.base.entity.ZyProcess; |
|
|
|
|
import org.jeecg.modules.demo.base.service.IZyProcessService; |
|
|
|
|
import org.jeecg.modules.device.entity.ZyDevice; |
|
|
|
|
import org.jeecg.modules.device.service.IZyDeviceService; |
|
|
|
|
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.entity.vo.ZyPlanProcessVo; |
|
|
|
|
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.Groupx; |
|
|
|
|
import org.jeecg.modules.team.entity.Station; |
|
|
|
|
import org.jeecg.modules.team.service.IGroupxService; |
|
|
|
|
import org.jeecg.modules.team.service.IStationService; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.text.DecimalFormat; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
|
public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IHangRecordService iHangRecordService; |
|
|
|
|
private IZyProcessService iZyProcessService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IZyProductPlanService iZyProductPlanService; |
|
|
|
@ -34,94 +44,117 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
private IZyPlanProcessService iZyPlanProcessService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IProductRecordService iProductRecordService; |
|
|
|
|
private IGroupxService iGroupxService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IStationService iStationService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IZyDeviceService iZyDeviceService; |
|
|
|
|
@Autowired |
|
|
|
|
private ISysDepartService iSysDepartService; |
|
|
|
|
|
|
|
|
|
// D00010:智能定制生产吊挂系统
|
|
|
|
|
private static final String DIAOGUA = "D00010"; |
|
|
|
|
|
|
|
|
|
// D00002:智能定制裁床
|
|
|
|
|
private static final String CAICHUANG = "D00002"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取百分率 含% |
|
|
|
|
* |
|
|
|
|
* @param number |
|
|
|
|
* @param denominator |
|
|
|
|
* @return eg:33.33% |
|
|
|
|
*/ |
|
|
|
|
public static String getRatioStr(double number, double denominator) { |
|
|
|
|
String ratio = "0.0%"; |
|
|
|
|
if (denominator != 0) { |
|
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#0.0%"); |
|
|
|
|
decimalFormat.setRoundingMode(RoundingMode.HALF_UP); |
|
|
|
|
ratio = decimalFormat.format(number / denominator); |
|
|
|
|
} |
|
|
|
|
return ratio; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
String ratioStr = getRatioStr(78, 100); |
|
|
|
|
System.out.println("ratioStr = " + ratioStr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 1,统计当天时间内生产工序 zy_plan_process |
|
|
|
|
* 2,根据工序确定该工序所属工位 |
|
|
|
|
* 3,根据工位确定所需设备(各类设备、吊挂、裁床)信息 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Map<String, Object> getData() { |
|
|
|
|
public Map<String, Object> shebeixinxi_data() { |
|
|
|
|
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
/*//1,吊挂
|
|
|
|
|
// 分组统计,获取最新时间5条吊挂运行记录
|
|
|
|
|
List<HangRecord> recordList = iHangRecordService.list(new LambdaQueryWrapper<HangRecord>().groupBy(HangRecord::getHangCode)); |
|
|
|
|
Map<String, Object> diaoguaData = new HashMap<>(); |
|
|
|
|
if (!ObjectUtils.isEmpty(recordList)) { |
|
|
|
|
recordList.stream().forEach(e -> { |
|
|
|
|
List<HangRecord> records = iHangRecordService.list(new LambdaQueryWrapper<HangRecord>() |
|
|
|
|
.eq(HangRecord::getHangCode, e.getHangCode()) |
|
|
|
|
.orderByDesc(HangRecord::getCreateTime) |
|
|
|
|
.last("limit 5") |
|
|
|
|
); |
|
|
|
|
diaoguaData.put(e.getHangCode(), records); |
|
|
|
|
}); |
|
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
|
// List<ZyProductPlan> productPlanList = iZyProductPlanService.list(new QueryWrapper<ZyProductPlan>().eq("DATE_FORMAT (create_time,'%Y-%m-%d ')", LocalDate.now()));
|
|
|
|
|
List<ZyProductPlan> productPlanList = iZyProductPlanService.list(new QueryWrapper<ZyProductPlan>().eq("DATE_FORMAT (create_time,'%Y-%m-%d ')", "2023-06-03")); |
|
|
|
|
if (!ObjectUtils.isEmpty(productPlanList)) { |
|
|
|
|
Map<String, Object> diaoguaData = new HashMap<>(); |
|
|
|
|
Map<String, Object> caichuangData = new HashMap<>(); |
|
|
|
|
//1,吊挂
|
|
|
|
|
ZyDevice diaogua = iZyDeviceService.getOne(new LambdaQueryWrapper<ZyDevice>().eq(ZyDevice::getTypeCode, DIAOGUA).last("limit 1")); |
|
|
|
|
//当天生产计划列表
|
|
|
|
|
diaoguaData.put("productPlanList", productPlanList); |
|
|
|
|
//吊挂编码
|
|
|
|
|
diaoguaData.put("code", diaogua.getCode()); |
|
|
|
|
//负载
|
|
|
|
|
String ratioStr = getRatioStr(productPlanList.size(), diaogua.getVal()); |
|
|
|
|
diaoguaData.put("ratio", ratioStr); |
|
|
|
|
resultMap.put("diaogua_", diaoguaData); |
|
|
|
|
|
|
|
|
|
//2,裁床
|
|
|
|
|
ZyDevice caichuang = iZyDeviceService.getOne(new LambdaQueryWrapper<ZyDevice>().eq(ZyDevice::getTypeCode, CAICHUANG).last("limit 1")); |
|
|
|
|
//当天生产计划列表
|
|
|
|
|
caichuangData.put("productPlanList", productPlanList); |
|
|
|
|
//吊挂编码
|
|
|
|
|
caichuangData.put("code", caichuang.getCode()); |
|
|
|
|
//负载
|
|
|
|
|
caichuangData.put("ratio", getRatioStr(productPlanList.size(), caichuang.getVal())); |
|
|
|
|
resultMap.put("caichuang_", caichuangData); |
|
|
|
|
} |
|
|
|
|
resultMap.put("diaogua_data", diaoguaData);*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //2,生产线实时状态
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// List<ZyPlanProcess> zyPlanProcessList = iZyPlanProcessService.list(new QueryWrapper<ZyPlanProcess>().eq("DATE_FORMAT (create_time,'%Y-%m-%d ')", LocalDate.now()));
|
|
|
|
|
List<ZyPlanProcess> zyPlanProcessList = iZyPlanProcessService.list(new QueryWrapper<ZyPlanProcess>().eq("DATE_FORMAT (create_time,'%Y-%m-%d ')", "2023-06-03")); |
|
|
|
|
Map<String, Integer> countMachineIdMap = new HashMap<>(); |
|
|
|
|
Map<String, Object> deviceData = new HashMap<>(); |
|
|
|
|
Optional.ofNullable(zyPlanProcessList).orElse(new LinkedList<>()).forEach(e -> { |
|
|
|
|
String machineIds = e.getMachineIds(); |
|
|
|
|
if (machineIds.contains(",")) { |
|
|
|
|
//该工序有多个设备
|
|
|
|
|
String[] machineIdArrs = machineIds.split(","); |
|
|
|
|
for (String machineId : machineIdArrs) { |
|
|
|
|
Integer countByMachineId = countMachineIdMap.getOrDefault(machineId, 0); |
|
|
|
|
countMachineIdMap.put(machineId, countByMachineId.intValue() + 1); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Integer countByMachineIds = countMachineIdMap.getOrDefault(machineIds, 0); |
|
|
|
|
countMachineIdMap.put(machineIds, countByMachineIds.intValue() + 1); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
countMachineIdMap.forEach((k, v) -> { |
|
|
|
|
ZyDevice zyDevice = iZyDeviceService.getById(k); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyDevice)) { |
|
|
|
|
Map<String, Object> deviceMap = new LinkedHashMap<>(); |
|
|
|
|
deviceMap.put("code", zyDevice.getCode()); |
|
|
|
|
deviceMap.put("name", zyDevice.getName()); |
|
|
|
|
deviceMap.put("status", "正常"); |
|
|
|
|
//负载
|
|
|
|
|
deviceMap.put("ratio", getRatioStr(v, zyDevice.getVal())); |
|
|
|
|
deviceData.put(zyDevice.getCode(), deviceMap); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
resultMap.put("shebeixinxi_", deviceData); |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -139,21 +172,11 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
.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")
|
|
|
|
|
// );
|
|
|
|
|
//查询生产计划工序表,对应设备状态 为生产中的数据
|
|
|
|
|
//取每个工位上最新一条工序信息
|
|
|
|
|
ZyPlanProcess zyPlanProcess = iZyPlanProcessService.getOne(new LambdaQueryWrapper<ZyPlanProcess>() |
|
|
|
|
.eq(ZyPlanProcess::getStationId, obj.getId()) |
|
|
|
|
// .eq(ZyPlanProcess::getStatus,"1"))
|
|
|
|
|
.orderByDesc(ZyPlanProcess::getUpdateTime) |
|
|
|
|
.last("limit 1")); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyPlanProcess)) { |
|
|
|
@ -162,15 +185,23 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
ProductRecordVo vo = new ProductRecordVo(); |
|
|
|
|
if (!ObjectUtils.isEmpty(productPlan)) { |
|
|
|
|
vo.setWorkOrder(productPlan.getProductNo()); |
|
|
|
|
Groupx groupx = iGroupxService.getById(productPlan.getTeamId()); |
|
|
|
|
vo.setTeamName(groupx.getGroupName()); |
|
|
|
|
} |
|
|
|
|
vo.setProcessName(zyPlanProcess.getProcessName()); |
|
|
|
|
vo.setStationName(zyPlanProcess.getStationName()); |
|
|
|
|
vo.setMachineNames(zyPlanProcess.getMachineNames()); |
|
|
|
|
vo.setStationNum(zyPlanProcess.getStationNum()); |
|
|
|
|
vo.setProcessStatus(zyPlanProcess.getStatus()); |
|
|
|
|
vo.setPlanProcessInfo(zyPlanProcess); |
|
|
|
|
ZyPlanProcessVo zyPlanProcessVo = new ZyPlanProcessVo(); |
|
|
|
|
BeanUtils.copyProperties(zyPlanProcess, zyPlanProcessVo); |
|
|
|
|
ZyProcess zyProcess = iZyProcessService.getById(zyPlanProcess.getProcessId()); |
|
|
|
|
if (!ObjectUtils.isEmpty(zyProcess)) { |
|
|
|
|
zyPlanProcessVo.setImage(zyProcess.getImage()); |
|
|
|
|
} |
|
|
|
|
vo.setZyPlanProcessVo(zyPlanProcessVo); |
|
|
|
|
productRecordVos.add(vo); |
|
|
|
|
} else { |
|
|
|
|
} else { //没有工序返回工位信息
|
|
|
|
|
ProductRecordVo vo = new ProductRecordVo(); |
|
|
|
|
vo.setStationName(obj.getStationName()); |
|
|
|
|
vo.setStationNum(obj.getStationNum()); |
|
|
|
@ -182,7 +213,7 @@ public class ProductionLargeServiceImpl implements ProductionLargeService { |
|
|
|
|
shengchanxianMap.putAll(departMap); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
resultMap.put("shengchanxian_data", shengchanxianMap); |
|
|
|
|
resultMap.put("shengchanxian_", shengchanxianMap); |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|