feat: 马钢看板v2
This commit is contained in:
@@ -30,4 +30,9 @@ public class CockPitController {
|
||||
public ResponseEntity<Object> PressedMonitor() {
|
||||
return new ResponseEntity<>(cockpitService.PressedMonitor(), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/v2/press")
|
||||
@Log("压制看板")
|
||||
public ResponseEntity<Object> PressedMonitorV2() {
|
||||
return new ResponseEntity<>(cockpitService.PressedMonitorV2(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,10 @@ public interface CockpitService {
|
||||
* @return
|
||||
*/
|
||||
ConcurrentHashMap<String, Object> PressedMonitor();
|
||||
/**
|
||||
* 压制看板2
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ConcurrentHashMap<String, Object> PressedMonitorV2();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.wms.cockpit.service.dao;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 泥料VO
|
||||
* @Date: 2024/7/8
|
||||
*/
|
||||
@Data
|
||||
public class LoamInfoVo {
|
||||
private String redundance_material_code;
|
||||
private String material_name;
|
||||
private String material_weight;
|
||||
private String down_time;
|
||||
private String minutes_difference;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.wms.cockpit.service.dao;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 压机信息vo
|
||||
* @Date: 2024/6/25
|
||||
*/
|
||||
@Data
|
||||
public class PressDeviceInfoVo {
|
||||
private String point_code;
|
||||
private String ext_point_code;
|
||||
private String point_status;
|
||||
private String material_code;
|
||||
private String raw_material_code;
|
||||
private String team_qty;
|
||||
private String blj_weight;
|
||||
private String rate;
|
||||
}
|
||||
@@ -1,12 +1,20 @@
|
||||
package org.nl.wms.cockpit.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.cockpit.service.CockpitService;
|
||||
import org.nl.wms.cockpit.service.dao.MonthlyWorkOrderVo;
|
||||
import org.nl.wms.cockpit.service.dao.PressProductHeaderVo;
|
||||
import org.nl.wms.cockpit.service.dao.ProductTaskVo;
|
||||
import org.nl.wms.cockpit.service.dao.ShiftProductionVo;
|
||||
import org.nl.wms.cockpit.service.dao.*;
|
||||
import org.nl.wms.cockpit.service.mapper.CockPitMapper;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.acs.service.dto.to.acs.DeviceInfoDto;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.util.CommonUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -16,6 +24,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
@@ -27,6 +36,10 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
public class CockpitServiceImpl implements CockpitService {
|
||||
@Autowired
|
||||
private CockPitMapper cockPitMapper;
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Autowired
|
||||
private WmsToAcsService wmsToAcsService;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("threadPoolExecutor")
|
||||
@@ -102,4 +115,111 @@ public class CockpitServiceImpl implements CockpitService {
|
||||
future.join();
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConcurrentHashMap<String, Object> PressedMonitorV2() {
|
||||
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>();
|
||||
// 白班、晚班
|
||||
String dayShift = CommonUtils.getDayShift();
|
||||
List<SchBasePoint> yzPoints = pointService.list(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getRegion_code, "YZ")
|
||||
.eq(SchBasePoint::getPoint_type, "1")
|
||||
.eq(SchBasePoint::getIs_has_workder, true));
|
||||
// 1、各压机信息
|
||||
CompletableFuture<List<PressDeviceInfoVo>> pressDeviceInfoVoListFuture = CompletableFuture.supplyAsync(
|
||||
() -> {
|
||||
// 调用acs
|
||||
List<DeviceInfoDto> deviceCodes = yzPoints
|
||||
.stream()
|
||||
.map(p -> DeviceInfoDto.buildDevice(p.getPoint_code()))
|
||||
.collect(Collectors.toList());
|
||||
// AcsResponse statusByCode = wmsToAcsService.getDeviceStatusByCode(deviceCodes);
|
||||
List<PressDeviceInfoVo> allPressInfo = cockPitMapper.getAllPressInfo(dayShift);
|
||||
// 便利allPressInfo 赋值
|
||||
// if (HttpStatus.HTTP_OK == statusByCode.getCode()) {
|
||||
// JSONArray datas = statusByCode.getData();
|
||||
// JSONObject data = datas.getJSONObject(0);
|
||||
// // 赋值
|
||||
// allPressInfo.forEach(pi -> {
|
||||
// pi.setPoint_status(data.getString("status"));
|
||||
// pi.setBlj_weight(data.getString("remainingweight"));
|
||||
// });
|
||||
// }
|
||||
return allPressInfo;
|
||||
}, pool);
|
||||
pressDeviceInfoVoListFuture.thenAccept(result -> {
|
||||
map.put("PressInfo", result);
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取压机信息错误: {}", e.getMessage(), e);
|
||||
map.put("PressInfo", e);
|
||||
return null;
|
||||
});
|
||||
// 2、工序计划量与合格率
|
||||
CompletableFuture<JSONObject> dayPlanFuture = CompletableFuture.supplyAsync(() -> {
|
||||
JSONObject res = new JSONObject();
|
||||
// 2.1 获取当天压制工单的信息
|
||||
List<PdmBdWorkorder> dayOrders = cockPitMapper.getTheDayOrderInfos();
|
||||
// 2.1.1 每天计划量
|
||||
long planSum = dayOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getPlan_weight())).mapToLong(o -> o.getPlan_weight().longValue()).sum();
|
||||
// 2.1.2 每天实际量
|
||||
long realSum = dayOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getReal_weight())).mapToLong(o -> o.getReal_weight().longValue()).sum();
|
||||
res.put("dayPlanSum", planSum / 1000);
|
||||
res.put("dayRealSum", realSum / 1000);
|
||||
// 2.2 统计每天数据
|
||||
List<PdmBdWorkorder> monthOrders = cockPitMapper.getTheMonthOrderInfos();
|
||||
long planMonthSum = monthOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getPlan_weight())).mapToLong(o -> o.getPlan_weight().longValue()).sum();
|
||||
long realMonthSum = monthOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getReal_weight())).mapToLong(o -> o.getReal_weight().longValue()).sum();
|
||||
res.put("planMonthSum", planMonthSum / 1000);
|
||||
res.put("realMonthSum", realMonthSum / 1000);
|
||||
// 2.3 每天的合格数
|
||||
double dayQualityQty = dayOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getQualified_qty())).mapToDouble(o -> o.getQualified_qty().doubleValue()).sum();
|
||||
double dayUnQualityQty = dayOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getUnqualified_qty())).mapToDouble(o -> o.getUnqualified_qty().doubleValue()).sum();
|
||||
double monthQualityQty = monthOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getQualified_qty())).mapToDouble(o -> o.getQualified_qty().doubleValue()).sum();
|
||||
double monthUnQualityQty = monthOrders.stream().filter(o -> ObjectUtil.isNotEmpty(o.getUnqualified_qty())).mapToDouble(o -> o.getUnqualified_qty().doubleValue()).sum();
|
||||
double sum1 = dayQualityQty + dayUnQualityQty;
|
||||
res.put("dayPassRate", sum1 == 0 ? 0 : dayQualityQty / sum1 * 100);
|
||||
double sum2 = monthQualityQty + monthUnQualityQty;
|
||||
res.put("montPassRate", sum2 == 0 ? 0 : monthQualityQty / sum2 * 100);
|
||||
return res;
|
||||
}, pool);
|
||||
dayPlanFuture.thenAccept(result -> {
|
||||
map.put("PlanInfo", result);
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取计划数据错误: {}", e.getMessage(), e);
|
||||
map.put("PlanInfo", e);
|
||||
return null;
|
||||
});
|
||||
// 3、缓存线泥料数据
|
||||
CompletableFuture<JSONObject> loamFuture = CompletableFuture.supplyAsync(() -> {
|
||||
JSONObject res = new JSONObject();
|
||||
// 泥料数据
|
||||
List<LoamInfoVo> loamInfoVos = cockPitMapper.getAllDayLoamsInfo();
|
||||
// 泥料种类
|
||||
long count = loamInfoVos.stream().distinct().count();
|
||||
// 重量之和
|
||||
double sum = loamInfoVos.stream().mapToDouble(p -> Double.parseDouble(p.getMaterial_weight())).sum();
|
||||
res.put("dataInfo", loamInfoVos);
|
||||
res.put("count", count);
|
||||
res.put("sum", sum);
|
||||
return res;
|
||||
}, pool);
|
||||
loamFuture.thenAccept(result -> {
|
||||
map.put("DataInfo", result);
|
||||
}).exceptionally((e) -> {
|
||||
log.error("获取合格率数据错误: {}", e.getMessage(), e);
|
||||
map.put("DataInfo", e);
|
||||
return null;
|
||||
});
|
||||
// 提交
|
||||
CompletableFuture<Void> allQuery = CompletableFuture.allOf(
|
||||
pressDeviceInfoVoListFuture,
|
||||
dayPlanFuture,
|
||||
loamFuture);
|
||||
CompletableFuture<ConcurrentHashMap<String, Object>> future
|
||||
= allQuery.thenApply((result) -> map).exceptionally((e) -> {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
});
|
||||
future.join();
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.cockpit.service.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import org.nl.wms.cockpit.service.dao.*;
|
||||
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -49,4 +50,29 @@ public interface CockPitMapper {
|
||||
*/
|
||||
@DS("oracle")
|
||||
List<MonthlyWorkOrderVo> getMonthlyWorkOrderFutureList();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dayShift
|
||||
* @return
|
||||
*/
|
||||
List<PressDeviceInfoVo> getAllPressInfo(String dayShift);
|
||||
|
||||
/**
|
||||
* 当前泥料数据
|
||||
* @return /
|
||||
*/
|
||||
List<LoamInfoVo> getAllDayLoamsInfo();
|
||||
|
||||
/**
|
||||
* 获取每天订单信息
|
||||
* @return /
|
||||
*/
|
||||
List<PdmBdWorkorder> getTheDayOrderInfos();
|
||||
|
||||
/**
|
||||
* 获取每月订单信息
|
||||
* @return /
|
||||
*/
|
||||
List<PdmBdWorkorder> getTheMonthOrderInfos();
|
||||
}
|
||||
|
||||
@@ -72,4 +72,79 @@
|
||||
WHERE TO_DATE(FPLANSTART_DATE, 'YYYYMMDD') <![CDATA[ >= ]]> TRUNC(SYSDATE, 'MONTH')
|
||||
AND TO_DATE(FPLANSTART_DATE, 'YYYYMMDD') <![CDATA[ < ]]> ADD_MONTHS(TRUNC(SYSDATE, 'MONTH'), 1)
|
||||
</select>
|
||||
<select id="getAllPressInfo" resultType="org.nl.wms.cockpit.service.dao.PressDeviceInfoVo">
|
||||
SELECT
|
||||
p.point_code,
|
||||
p.ext_point_code,
|
||||
IF(m.material_spec IS NULL,'-',m.material_spec) AS material_code,
|
||||
IF(w.raw_material_code IS NULL,'-',w.raw_material_code) AS raw_material_code,
|
||||
IF(sub_query.total_real_qty IS NULL,'0',sub_query.total_real_qty) AS team_qty,
|
||||
IF(sub_query2.qualified_rate IS NULL,'0',sub_query2.qualified_rate) AS rate
|
||||
FROM
|
||||
sch_base_point p
|
||||
LEFT JOIN pdm_bd_workorder w ON p.point_code = w.point_code AND w.workorder_status = '3'
|
||||
AND w.produce_date = DATE_FORMAT(CURDATE(), '%Y%m%d')
|
||||
LEFT JOIN md_base_material m ON m.material_id = w.material_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ww.point_code,
|
||||
SUM(ww.real_qty) AS total_real_qty
|
||||
FROM
|
||||
pdm_bd_workorder ww
|
||||
WHERE
|
||||
ww.produce_date = DATE_FORMAT(CURDATE(), '%Y%m%d')
|
||||
AND ww.team = #{dayShift}
|
||||
AND ww.workorder_status = '5'
|
||||
GROUP BY
|
||||
ww.point_code
|
||||
) sub_query ON p.point_code = sub_query.point_code
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
ww.point_code,
|
||||
SUM(ww.qualified_qty) / (SUM(ww.qualified_qty) + SUM(ww.unqualified_qty)) * 100 AS qualified_rate
|
||||
FROM
|
||||
pdm_bd_workorder ww
|
||||
WHERE
|
||||
ww.produce_date = DATE_FORMAT(CURDATE(), '%Y%m%d')
|
||||
AND ww.team = #{dayShift}
|
||||
AND ww.workorder_status = '5'
|
||||
GROUP BY
|
||||
ww.point_code
|
||||
) sub_query2 ON p.point_code = sub_query2.point_code
|
||||
WHERE p.region_code = 'YZ'
|
||||
AND p.point_type = '1'
|
||||
AND p.is_has_workder = TRUE
|
||||
</select>
|
||||
<select id="getAllDayLoamsInfo" resultType="org.nl.wms.cockpit.service.dao.LoamInfoVo">
|
||||
SELECT
|
||||
p.redundance_material_code,
|
||||
m.material_name,
|
||||
p.material_weight,
|
||||
IF(p.group_bind_material_status = '3',p.update_time,'-') AS down_time,
|
||||
TIMESTAMPDIFF(MINUTE, p.instorage_time, NOW()) AS minutes_difference
|
||||
FROM
|
||||
sch_base_vehiclematerialgroup p
|
||||
LEFT JOIN md_base_material m ON m.material_id = p.material_id
|
||||
WHERE p.point_code LIKE 'KLW%' AND DATE(p.create_time) = CURDATE()
|
||||
ORDER BY p.create_time DESC
|
||||
</select>
|
||||
<select id="getTheDayOrderInfos" resultType="org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
`pdm_bd_workorder`
|
||||
WHERE
|
||||
region_code = 'YZ' AND
|
||||
produce_date = DATE_FORMAT(CURDATE(), '%Y%m%d')
|
||||
</select>
|
||||
<select id="getTheMonthOrderInfos" resultType="org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
`pdm_bd_workorder`
|
||||
WHERE
|
||||
region_code = 'YZ' AND
|
||||
DATE_FORMAT(produce_date, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user