add:大屏、看板、弹窗接口完善

This commit is contained in:
songxiaopeng
2024-02-28 15:53:25 +08:00
parent e939972a81
commit 1daf8be83e
14 changed files with 515 additions and 254 deletions

View File

@@ -1244,126 +1244,144 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
@Override
public JSONObject getDeviceStatus(JSONArray param) {
log.info("getDeviceStatus - 请求参数 {}", param);
if (ObjectUtil.isNotEmpty(param)) {
for (int i = 0; i < param.size(); i++) {
JSONObject status = param.getJSONObject(i);
if (ObjectUtil.isEmpty(status)) {
continue;
}
String device_code = status.getString("device_code");
if (StrUtil.isBlank(device_code)) {
continue;
}
Device device = DeviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device)) {
continue;
}
if (device.getDeviceDriver() instanceof LnshMixingMillDeviceDriver) {
LnshMixingMillDeviceDriver driver = (LnshMixingMillDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
status.put("real_qty", driver.getWeight());
status.put("mix_num", driver.getMix_num());
} else if (device.getDeviceDriver() instanceof LnshPressDeviceDriver) {
LnshPressDeviceDriver driver = (LnshPressDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
status.put("real_qty", driver.getQty());
status.put("current_weight", driver.getWeight());
} else if (device.getDeviceDriver() instanceof LnshPackagePalletManipulatorDeviceDriver) {
LnshPackagePalletManipulatorDeviceDriver driver = (LnshPackagePalletManipulatorDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
status.put("real_qty", driver.getQty());
} else if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorDeviceDriver) {
LnshPalletizingManipulatorDeviceDriver driver = (LnshPalletizingManipulatorDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
} else if (device.getDeviceDriver() instanceof LnshKilnTrussDeviceDriver) {
LnshKilnTrussDeviceDriver driver = (LnshKilnTrussDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
} else if (device.getDeviceDriver() instanceof LnshKilnLaneDeviceDriver) {
LnshKilnLaneDeviceDriver driver = (LnshKilnLaneDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
} else if (device.getDeviceDriver() instanceof LnshOutKilnTrussDeviceDriver) {
LnshOutKilnTrussDeviceDriver driver = (LnshOutKilnTrussDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
} else if (device.getDeviceDriver() instanceof LnshRGVDeviceDriver) {
LnshRGVDeviceDriver driver = (LnshRGVDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
} else if (device.getDeviceDriver() instanceof LnshPackageLineDeviceDriver) {
LnshPackageLineDeviceDriver driver = (LnshPackageLineDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
} else if (device.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) {
LnshFoldDiscSiteDeviceDriver driver = (LnshFoldDiscSiteDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
}
if (ObjectUtil.isEmpty(param)) {
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", "查询成功!");
result.put("data", null);
log.info("getDeviceStatus - 返回参数 {}", result);
return result;
}
JSONArray jsonArray = param.getJSONArray(0);
List<String> list = JSONArray.parseArray(jsonArray.toString(), String.class);
if (ObjectUtil.isEmpty(list)) {
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", "查询成功!");
result.put("data", null);
log.info("getDeviceStatus - 返回参数 {}", result);
return result;
}
JSONArray res = new JSONArray();
for (String deviceCode : list) {
JSONObject status = new JSONObject();
status.put("device_code", deviceCode);
if (StrUtil.isBlank(deviceCode)) {
continue;
}
Device device = DeviceAppService.findDeviceByCode(deviceCode);
if (ObjectUtil.isEmpty(device)) {
continue;
}
if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorSiteDeviceDriver) {
LnshPalletizingManipulatorSiteDeviceDriver driver = (LnshPalletizingManipulatorSiteDeviceDriver) device.getDeviceDriver();
status.put("mode", driver.getMode());
status.put("error", driver.getError());
status.put("move", driver.getMove());
status.put("encoder_qty", driver.getEncoder_qty());
status.put("barcode", driver.getBarcode());
}
if (device.getDeviceDriver() instanceof LnshMixingMillDeviceDriver) {
LnshMixingMillDeviceDriver driver = (LnshMixingMillDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
status.put("real_qty", driver.getWeight());
status.put("mix_num", driver.getMix_num());
}
if (device.getDeviceDriver() instanceof LnshPressDeviceDriver) {
LnshPressDeviceDriver driver = (LnshPressDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
status.put("real_qty", driver.getQty());
status.put("current_weight", driver.getWeight());
}
if (device.getDeviceDriver() instanceof LnshPackagePalletManipulatorDeviceDriver) {
LnshPackagePalletManipulatorDeviceDriver driver = (LnshPackagePalletManipulatorDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
status.put("real_qty", driver.getQty());
}
if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorDeviceDriver) {
LnshPalletizingManipulatorDeviceDriver driver = (LnshPalletizingManipulatorDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
if (device.getDeviceDriver() instanceof LnshKilnTrussDeviceDriver) {
LnshKilnTrussDeviceDriver driver = (LnshKilnTrussDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
if (device.getDeviceDriver() instanceof LnshKilnLaneDeviceDriver) {
LnshKilnLaneDeviceDriver driver = (LnshKilnLaneDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
if (device.getDeviceDriver() instanceof LnshOutKilnTrussDeviceDriver) {
LnshOutKilnTrussDeviceDriver driver = (LnshOutKilnTrussDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
if (device.getDeviceDriver() instanceof LnshRGVDeviceDriver) {
LnshRGVDeviceDriver driver = (LnshRGVDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
if (device.getDeviceDriver() instanceof LnshPackageLineDeviceDriver) {
LnshPackageLineDeviceDriver driver = (LnshPackageLineDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
if (device.getDeviceDriver() instanceof LnshFoldDiscSiteDeviceDriver) {
LnshFoldDiscSiteDeviceDriver driver = (LnshFoldDiscSiteDeviceDriver) device.getDeviceDriver();
status.put("device_status", driver.getStatus());
status.put("error", driver.getError());
status.put("open_time", driver.getOpen_time());
status.put("stand_time", driver.getStandby_time() / 3600);
status.put("work_time", driver.getProduction_time() / 3600);
status.put("error_time", driver.getError_time() / 3600);
}
res.add(status);
}
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("message", "查询成功!");
result.put("data", param);
result.put("data", res);
log.info("getDeviceStatus - 返回参数 {}", result);
return result;
}

View File

@@ -30,7 +30,7 @@ public class CockPitController {
@Autowired
private CockpitService cockpitService;
@PostMapping("/press")
@GetMapping("/press")
@Log("压制看板")
@ApiOperation("压制看板")
public ResponseEntity<Object> pressedMonitor(){
@@ -46,15 +46,15 @@ public class CockPitController {
}
@GetMapping("/screenTableData")
@Log("大屏")
@ApiOperation("大屏")
@Log("大屏-两侧图表")
@ApiOperation("大屏-两侧图表")
public ResponseEntity<Object> screenLeftData(){
return new ResponseEntity<>(cockpitService.screenTableData(), HttpStatus.OK);
}
@GetMapping("/deviceCondition")
@Log("设备运行情况")
@ApiOperation("设备运行情况")
@Log("大屏-中间设备运行情况")
@ApiOperation("大屏-中间设备运行情况")
public ResponseEntity<Object> deviceCondition(){
return new ResponseEntity<>(cockpitService.deviceCondition(), HttpStatus.OK);
}
@@ -67,8 +67,8 @@ public class CockPitController {
// }
@GetMapping("/inOutKilnDetail")
@Log("出、入窑输送线")
@ApiOperation("出、入窑输送线")
@Log("出、入窑输送线弹窗")
@ApiOperation("出、入窑输送线弹窗")
public ResponseEntity<Object> selectInOutKilnDetail(){
return new ResponseEntity<>(cockpitService.selectInOutKilnDetail(), HttpStatus.OK);
}

View File

@@ -29,14 +29,7 @@ public interface CockpitService {
ConcurrentHashMap<String,Object> screenTableData();
// List<DeviceErrorVo> getDeviceErrorList();
//
// IPage<DasDeviceErrorRecord> getDeviceErrorInfoList(PageQuery page);
//
// DeviceRunStatVo selectDeviceRunStatNum();
Object deviceCondition();
//
// MixingDetailVo selectMixingDetail(Map whereJson);
ConcurrentHashMap<String, Object> deviceCondition();
List<InOutKilnVo> selectInOutKilnDetail();

View File

@@ -0,0 +1,14 @@
package org.nl.wms.cockpit.service.dao;
import lombok.Data;
/**
* @author Administrator
* 混碾机对接位
*/
@Data
public class MixingRelativeVo {
private String pointStatus;
private String pointName;
private String pointCode;
}

View File

@@ -7,11 +7,7 @@ import lombok.Data;
*/
@Data
public class MixingVo {
private String workorderCode;
private String pointName;
private String customer;
private String material;
private String materialSpec;
private String planQty;
private String realQty;
private String materialName;
private String planWeight;
private String realWeight;
}

View File

@@ -2,15 +2,20 @@ package org.nl.wms.cockpit.service.dao;
import lombok.Data;
/**
* @Author: lyd
* @Description: 当前班次、计划生产、已生产、不合格产品数
* @Date: 2023/9/25
* @author Administrator
* 压制看板顶部Vo
*/
@Data
public class PressProductHeaderVo {
private String plan_qty;
private String real_qty;
private String unqualified_qty;
private String qualified_qty;
private String planQty;
private String realQty;
private String unqualifiedQty;
private String qualifiedQty;
private String team;
public String getaTeam() {
return "白班";
}
}

View File

@@ -4,11 +4,16 @@ import lombok.Data;
/**
* @author Administrator
* 当日成品图表Vo
*/
@Data
public class PressProductVo {
//物料名称
private String materialName;
//需生产
private String requiredNum;
//已压制
private String suppressedNum;
//已完成
private String finishedNum;
}

View File

@@ -22,4 +22,8 @@ public class ProductTaskVo {
private String operator;
private String realproducestartDate;
private String realproduceendDate;
public String getTeam() {
return "白班";
}
}

View File

@@ -10,7 +10,7 @@ public class SortingLineVo {
private String workorderCode;
private String pointName;
private String customer;
private String material;
private String materialName;
private String materialSpec;
private String planQty;
private String realQty;

View File

@@ -0,0 +1,26 @@
package org.nl.wms.cockpit.service.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ColorEnum {
GREY(0, "灰色"),
GREEN(2, "绿色"),
RED(3, "红色"),
YELLOW(1, "黄色");
private final Integer index;
private final String colorName;
public static ColorEnum getColorEnumByIndex(int index) {
ColorEnum[] enums = ColorEnum.values();
for (ColorEnum colorEnum : enums) {
if (colorEnum.getIndex() == index) {
return colorEnum;
}
}
return null; // 如果没有找到对应的枚举常量可以根据需要返回null或者抛出异常
}
}

View File

@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.nl.wms.cockpit.service.CockpitService;
import org.nl.wms.cockpit.service.dao.*;
import org.nl.wms.cockpit.service.enums.ColorEnum;
import org.nl.wms.cockpit.service.enums.DeviceEnum;
import org.nl.wms.cockpit.service.mapper.CockPitMapper;
import org.nl.wms.das.device.record.service.IDasDeviceErrorRecordService;
@@ -39,9 +40,6 @@ public class CockpitServiceImpl implements CockpitService {
@Autowired
private IDasDeviceErrorRecordService dasDeviceErrorRecordService;
@Autowired
private ISchBasePointService schBasePointService;
@Override
public ConcurrentHashMap<String, Object> pressedMonitor() {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll();
@@ -66,7 +64,7 @@ public class CockpitServiceImpl implements CockpitService {
map.put("ShiftProductionList", null);
return null;
});
// 2、当日订单
// 3、当日订单
CompletableFuture<List<PressOrderVo>> pressOrderFuture = CompletableFuture.supplyAsync(
() -> cockPitMapper.getPressOrderVoList(), pool);
pressOrderFuture.thenAccept(result -> {
@@ -231,10 +229,10 @@ public class CockpitServiceImpl implements CockpitService {
return res;
}, pool);
deviceRunStatCompletableFuture.thenAccept(result -> {
resultMap.put("deviceRunStatList", result);
resultMap.put("deviceRunStat", result);
}).exceptionally((e) -> {
log.error("设备运行统计: {}", e.getMessage(), e);
resultMap.put("deviceRunStatList", null);
resultMap.put("deviceRunStat", null);
return null;
});
@@ -277,47 +275,194 @@ public class CockpitServiceImpl implements CockpitService {
}
@Override
public Object deviceCondition() {
List<DeviceConditionVo> res = new ArrayList<>();
// 获取所有设备
List<String> allDevice = cockPitMapper.selectAllDevice();
if (allDevice.isEmpty()) {
public ConcurrentHashMap<String, Object> deviceCondition() {
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll();
ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>();
//压制码垛位情况显示
CompletableFuture<JSONArray> stackingPositionTask = CompletableFuture.supplyAsync(() -> {
List<String> points = cockPitMapper.selectYzPoint();
if (points.isEmpty()) {
throw new RuntimeException("压制码垛位点位为空");
}
JSONArray param = new JSONArray(Collections.singletonList(points));
AcsResponse deviceStatus = wmsToAcsService.getDeviceStatus(param);
JSONArray data = ObjectUtil.isNotEmpty(deviceStatus) ? deviceStatus.getData() : param;
for (int i = 0; i < data.size(); i++) {
JSONObject jsonObject = data.getJSONObject(i);
if (jsonObject.getInteger("move") != 0
&& ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
&& jsonObject.getInteger("encoder_qty") > 0) {
// 绿色
jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
} else if (jsonObject.getInteger("move") != 0
&& ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
&& jsonObject.getInteger("encoder_qty") == 0) {
// 黄色
jsonObject.put("color_status", ColorEnum.YELLOW.getIndex());
} else if (jsonObject.getInteger("move") == 0) {
// 红色
jsonObject.put("color_status", ColorEnum.RED.getIndex());
} else { // 有托盘人工
jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
}
}
return data;
}, pool);
stackingPositionTask.thenAccept(result -> {
map.put("StackingPositionList", result);
}).exceptionally((e) -> {
log.error("压制码垛位情况显示: {}", e.getMessage(), e);
map.put("StackingPositionList", e);
return null;
}
JSONArray param = new JSONArray(Collections.singletonList(allDevice));
AcsResponse devicesStatus = wmsToAcsService.getDeviceStatus(param);
JSONArray data = ObjectUtil.isNotEmpty(devicesStatus) ? devicesStatus.getData() : param;
// JSONObject devicesStatus = null;
// 初始化数据 数组下标0关机 1待机 2生产中 3故障
JSONObject total = new JSONObject();
DeviceEnum[] values = DeviceEnum.values();
for (DeviceEnum deviceEnum : values) {
total.put(deviceEnum.getCode(), new int[4]);
}
// 遍历判断
for (int i = 0; i < data.size(); i++) {
JSONObject device = data.getJSONObject(i);
Integer devicesStatus1 = ObjectUtil.isNotEmpty(device.getInteger("status"))
? device.getInteger("status")
: 0;
String regionCode = device.getString("region_code");
DeviceEnum deviceEnumByCode = DeviceEnum.getDeviceEnumByCode(regionCode); // 获取属于哪种设备
int[] ints = (int[]) total.get(deviceEnumByCode.getCode());
ints[devicesStatus1] = ints[devicesStatus1] + 1;
total.put(deviceEnumByCode.getCode(), ints);
}
// 返回输出值
for (DeviceEnum value : values) { // 4个
int[] ints = (int[]) total.get(value.getCode());
DeviceConditionVo dto = new DeviceConditionVo();
dto.setDeviceName(value.getDevice_name()); // 列名
dto.setShutdown(ints[0]);
dto.setStandby(ints[1]);
dto.setRunning(ints[2]);
dto.setFailure(ints[3]);
res.add(dto);
}
return res;
});
// 压机信息显示
CompletableFuture<JSONArray> pressMachineTask = CompletableFuture.supplyAsync(() -> {
List<String> yjPoints = cockPitMapper.selectYjPoint();
if (yjPoints.isEmpty()) {
throw new RuntimeException("压机点位为空");
}
JSONArray yjPointsParam = new JSONArray(Collections.singletonList(yjPoints));
AcsResponse yjStatus = wmsToAcsService.getDeviceStatus(yjPointsParam);
JSONArray yjData = ObjectUtil.isNotEmpty(yjStatus) ? yjStatus.getData() : yjPointsParam;
for (int i = 0; i < yjData.size(); i++) {
JSONObject object = yjData.getJSONObject(i);
String realQty = object.getString("real_qty");
if (ObjectUtil.isNotEmpty(realQty)) {
object.put("now_capacity", realQty);
}
}
return yjData;
}, pool);
pressMachineTask.thenAccept(result -> {
map.put("PressMachineList", result);
}).exceptionally((e) -> {
log.error("压机信息显示: {}", e.getMessage(), e);
map.put("PressMachineList", e.getMessage());
return null;
});
//混碾机信息显示
CompletableFuture<JSONArray> mixMachineTask = CompletableFuture.supplyAsync(() -> {
List<String> hnjPoints = cockPitMapper.selectHnjPoints();
if (hnjPoints.isEmpty()) {
throw new RuntimeException("设备点位为空");
}
JSONArray hnjPointsParam = new JSONArray(Collections.singletonList(hnjPoints));
AcsResponse hnjStatus = wmsToAcsService.getDeviceStatus(hnjPointsParam);
JSONArray hnjData = ObjectUtil.isNotEmpty(hnjStatus) ? hnjStatus.getData() : hnjPointsParam;
for (int i = 0; i < hnjData.size(); i++) {
JSONObject jsonObject = hnjData.getJSONObject(i);
String openTime = jsonObject.getString("open_time");
jsonObject.put("open_time", openTime.substring(openTime.indexOf('-') + 1));
}
return hnjData;
}, pool);
mixMachineTask.thenAccept(result -> {
map.put("MixMachineList", result);
}).exceptionally((e) -> {
log.error("混料机信息显示: {}", e.getMessage(), e);
map.put("MixMachineList", null);
return null;
});
// 困料货架的信息显示 TODO
CompletableFuture<JSONArray> trappedMaterialShelfTask = CompletableFuture.supplyAsync(() -> {
// return cockPitMapper.selectKlhwInfo();
return null;
}, pool);
trappedMaterialShelfTask.thenAccept(result -> {
map.put("TrappedMaterialShelfList", result);
}).exceptionally((e) -> {
log.error("困料货架 - 40 货位的信息显示: {}", e.getMessage(), e);
map.put("TrappedMaterialShelfList", null);
return null;
});
// 混碾机对接位
CompletableFuture<List<MixingRelativeVo>> mixBlankingTask = CompletableFuture.supplyAsync(() -> {
return cockPitMapper.selectMixingRelativeInfo();
}, pool);
mixBlankingTask.thenAccept(result -> {
map.put("MixBlankingList", result);
}).exceptionally((e) -> {
log.error("混料机下料位显示: {}", e.getMessage(), e);
map.put("MixBlankingList", null);
return null;
});
//压制、分拣机械手
CompletableFuture<JSONArray> manipulatorInfoTask = CompletableFuture.supplyAsync(() -> {
List<String> jxsPoints = cockPitMapper.selectJxsPoints();
if (jxsPoints.isEmpty()) {
throw new RuntimeException("设备点位为空");
}
JSONArray jxsPointsParam = new JSONArray(Collections.singletonList(jxsPoints));
AcsResponse jxsStatus = wmsToAcsService.getDeviceStatus(jxsPointsParam);
JSONArray jxsData = ObjectUtil.isNotEmpty(jxsStatus) ? jxsStatus.getData() : jxsPointsParam;
for (int i = 0; i < jxsData.size(); i++) {
JSONObject object = jxsData.getJSONObject(i);
object.put("color_status", object.getInteger("device_status"));
}
return jxsData;
}, pool);
manipulatorInfoTask.thenAccept(result -> {
map.put("ManipulatorInfoList", result);
}).exceptionally((e) -> {
log.error("机械手: {}", e.getMessage(), e);
map.put("ManipulatorInfoList", null);
return null;
});
//分拣拆码垛对接位
CompletableFuture<JSONArray> sortAndPalletizingTask = CompletableFuture.supplyAsync(() -> {
List<String> fjcmdPoints = new ArrayList<>();
fjcmdPoints.add("FJ01CDW01");
fjcmdPoints.add("FJ01CDW02");
JSONArray fjcmdPointsParam = new JSONArray(Collections.singletonList(fjcmdPoints));
AcsResponse fjcmdStatus = wmsToAcsService.getDeviceStatus(fjcmdPointsParam);
JSONArray fjcmdData = ObjectUtil.isNotEmpty(fjcmdStatus) ? fjcmdStatus.getData() : fjcmdPointsParam;
for (int i = 0; i < fjcmdData.size(); i++) {
JSONObject jsonObject = fjcmdData.getJSONObject(i);
if (jsonObject.getInteger("move") != 0
&& ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
&& jsonObject.getInteger("encoder_qty") > 0) {
// 绿色
jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
} else if (jsonObject.getInteger("move") != 0
&& ObjectUtil.isNotEmpty(jsonObject.getInteger("encoder_qty"))
&& jsonObject.getInteger("encoder_qty") == 0) {
// 黄色
jsonObject.put("color_status", ColorEnum.YELLOW.getIndex());
} else if (jsonObject.getInteger("move") == 0) {
// 红色
jsonObject.put("color_status", ColorEnum.RED.getIndex());
} else { // 有托盘人工
jsonObject.put("color_status", ColorEnum.GREEN.getIndex());
}
}
return fjcmdData;
}, pool);
sortAndPalletizingTask.thenAccept(result -> {
map.put("SortAndPalletizingList", result);
}).exceptionally((e) -> {
log.error("分拣拆码垛: {}", e.getMessage(), e);
map.put("SortAndPalletizingList", e);
return null;
});
CompletableFuture<Void> allQuery = CompletableFuture.allOf(
stackingPositionTask,
pressMachineTask,
trappedMaterialShelfTask,
mixMachineTask,
sortAndPalletizingTask,
manipulatorInfoTask,
mixBlankingTask
);
CompletableFuture<ConcurrentHashMap<String, Object>> future
= allQuery.thenApply((result) -> map).exceptionally((e) -> {
log.error(e.getMessage(), e);
return null;
});
future.join();
return map;
}
// @Override
@@ -340,13 +485,13 @@ public class CockpitServiceImpl implements CockpitService {
public List<InOutKilnVo> selectInOutKilnDetail() {
//todo 确定每托盘数量
List<InOutKilnVo> res = new ArrayList<>();
InOutKilnVo in = cockPitMapper.selectInKilnInfo();
InOutKilnVo in = cockPitMapper.selectInKilnInfo();
in.setStat("1");
in.setPointName("入窑输送线");
in.setWorkTime("3.5");
in.setMaterialNum("25000");
InOutKilnVo out = cockPitMapper.selectOutKilnInfo();
if (null == out){
InOutKilnVo out = cockPitMapper.selectOutKilnInfo();
if (null == out) {
out = new InOutKilnVo();
}
out.setStat("1");

View File

@@ -1,5 +1,6 @@
package org.nl.wms.cockpit.service.mapper;
import com.alibaba.fastjson.JSONArray;
import org.nl.wms.cockpit.service.dao.*;
import java.util.List;
@@ -39,4 +40,14 @@ public interface CockPitMapper {
List<KilnMaterialInfo> selectKilnMaterialInfo();
List<String> selectYzPoint();
List<String> selectYjPoint();
List<String> selectHnjPoints();
List<MixingRelativeVo> selectMixingRelativeInfo();
List<String> selectJxsPoints();
}

View File

@@ -2,13 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.nl.wms.cockpit.service.mapper.CockPitMapper">
<select id="getPressProductHeaderList" resultType="org.nl.wms.cockpit.service.dao.PressProductHeaderVo">
SELECT SUM(w.plan_qty) AS plan_qty,
SUM(w.real_qty) AS real_qty,
SUM(w.qualified_qty) AS qualified_qty,
SUM(w.unqualified_qty) AS unqualified_qty
SELECT SUM(w.plan_qty) AS planQty,
SUM(w.real_qty) AS realQty,
SUM(w.qualified_qty) AS qualifiedQty,
SUM(w.unqualified_qty) AS unqualifiedQty
FROM pdm_bd_workorder w
WHERE
DATE ( w.produce_date ) = CURDATE()
WHERE w.region_code = 'YZ'
AND DATE ( w.produce_date ) = CURDATE()
</select>
<select id="getShiftProductionList" resultType="org.nl.wms.cockpit.service.dao.ShiftProductionVo">
SELECT w.point_name AS columnName,
@@ -16,10 +16,12 @@
SUM(w.unqualified_qty) AS unqualifiedQty,
SUM(w.plan_qty - w.qualified_qty - w.unqualified_qty) AS lastQty
FROM `pdm_bd_workorder` w
WHERE
DATE ( w.produce_date ) = CURDATE()
GROUP BY w.point_name
order by w.point_name
WHERE w.region_code = 'YZ'
AND DATE ( w.produce_date ) = CURDATE()
GROUP BY
w.point_name
ORDER BY
w.point_name
</select>
<select id="getPressOrderVoList" resultType="org.nl.wms.cockpit.service.dao.PressOrderVo">
@@ -30,11 +32,11 @@
(SUM(w.plan_qty) != 0, SUM(w.real_qty) / SUM(w.plan_qty), 0),
2
) AS rate,
m.order_number as orderNumber
m.order_number as orderNumber
FROM pdm_bd_workorder w
LEFT JOIN md_base_material m ON m.material_id = w.material_id
WHERE
DATE ( w.produce_date ) = CURDATE()
WHERE w.region_code = 'YZ'
AND DATE ( w.produce_date ) = CURDATE()
GROUP BY
m.order_number
</select>
@@ -66,35 +68,38 @@
</select>
<select id="getSortingLine" resultType="org.nl.wms.cockpit.service.dao.SortingLineVo">
SELECT w.workorder_code as workorderCode,
w.point_name as pointName,
w.plan_qty as planQty,
w.real_qty as realQty,
w.customer,
m.material_name as materialName,
m.material_spec as materialSpec
FROM pdm_bd_workorder w
LEFT JOIN md_base_material m ON m.material_id = w.material_id
WHERE w.region_code = 'FJ'
and w.workorder_status = '3'
order by w.create_time
SELECT
w.workorder_code AS workorderCode,
w.point_name AS pointName,
w.plan_qty AS planQty,
w.real_qty AS realQty,
c.cust_name AS customer,
m.material_name AS materialName,
m.material_spec AS materialSpec
FROM
pdm_bd_workorder w
LEFT JOIN md_base_material m ON m.material_id = w.material_id
LEFT JOIN md_cs_customerbase c ON w.customer = c.cust_id
WHERE
w.region_code in ('FJ','RGFJ')
AND w.workorder_status = '3'
ORDER BY
w.create_time
</select>
<select id="getUnstackingList" resultType="org.nl.wms.cockpit.service.dao.StackVo">
SELECT
t.create_time AS createTime,
t.vehicle_code AS vehicleCode,
m.material_name AS materialName,
g.material_qty AS materialQty,
g.material_weight AS materialWeight
FROM
`sch_base_task` t
LEFT JOIN sch_base_vehiclematerialgroup g ON t.group_id = g.group_id
LEFT JOIN md_base_material m ON g.material_id = m.material_id
WHERE
t.config_code ='FJQLTask'
SELECT t.create_time AS createTime,
t.vehicle_code AS vehicleCode,
m.material_name AS materialName,
g.material_qty AS materialQty,
g.material_weight AS materialWeight
FROM `sch_base_task` t
LEFT JOIN sch_base_vehiclematerialgroup g ON t.group_id = g.group_id
LEFT JOIN md_base_material m ON g.material_id = m.material_id
WHERE t.config_code = 'FJQLTask'
AND t.task_status = '5'
order by create_time desc
AND DATE (t.create_time) = CURDATE()
order by t.create_time desc
</select>
<select id="getLastWorkOrderList" resultType="org.nl.wms.cockpit.service.dao.WorkOrderVo">
@@ -104,11 +109,12 @@
w.plan_qty as planQty,
w.plan_weight as planWeight,
w.produce_order as produceOrder,
w.customer,
c.cust_name as customer,
w.vehicle_type as vehicleType,
w.create_time as createTime
FROM pdm_bd_workorder w
LEFT JOIN md_base_material m ON m.material_id = w.material_id
LEFT JOIN md_cs_customerbase c ON w.customer = c.cust_id
WHERE w.region_code = 'FJ'
AND w.workorder_status <![CDATA[ <> ]]> '5'
ORDER BY w.create_time
@@ -116,8 +122,8 @@
<select id="getMixingList" resultType="org.nl.wms.cockpit.service.dao.MixingVo">
SELECT m.material_name AS materialName,
SUM(w.plan_qty) AS planQty,
SUM(w.real_qty) AS realQty
SUM(w.plan_weight) AS planWeight,
SUM(w.real_weight) AS realWeight
FROM pdm_bd_workorder w
LEFT JOIN md_base_material m ON m.material_id = w.material_id
WHERE w.region_code = 'HN'
@@ -129,33 +135,30 @@
<select id="getPressWorkerOrder" resultType="org.nl.wms.cockpit.service.dao.PressProductVo">
SELECT m.material_name as materialName,
SUM(w.plan_qty) as requiredNum,
SUM(CASE WHEN w.workorder_status = '5' THEN w.plan_qty ELSE 0 END) AS finishedNum,
SUM(CASE
WHEN w.workorder_status = '3' or w.workorder_status = '4'
THEN w.plan_qty
ELSE 0 END) AS suppressedNum
SUM(w.real_qty) as suppressedNum,
SUM(CASE WHEN w.workorder_status = '5' THEN w.real_qty ELSE 0 END) AS finishedNum
FROM pdm_bd_workorder w
LEFT JOIN md_base_material m ON w.material_id = m.material_id
WHERE w.region_code = 'YZ'
AND w.workorder_status IN ('2', '3', '4', '5')
AND w.produce_date = DATE_FORMAT(CURRENT_DATE (), '%Y%m%d')
group by m.material_name
order by m.material_name
</select>
<select id="getHistoryList" resultType="org.nl.wms.cockpit.service.dao.HistoryVo">
SELECT DATE_FORMAT(produce_date, '%m-%d') as produceDate,
SUM(CASE WHEN workorder_status = '5' THEN plan_qty ELSE 0 END) AS finishedNum,
SUM(CASE
WHEN workorder_status = '3' or workorder_status = '4'
THEN plan_qty
ELSE 0 END) AS suppressedNum
FROM pdm_bd_workorder
WHERE region_code = 'YZ'
AND workorder_status IN ('2', '3', '4', '5')
SELECT
DATE_FORMAT( produce_date, '%m-%d' ) AS produceDate,
SUM( CASE WHEN workorder_status = '5' THEN real_qty ELSE 0 END ) AS finishedNum,
SUM( qualified_qty ) AS suppressedNum
FROM
pdm_bd_workorder
WHERE
region_code = 'YZ'
AND produce_date >= CURDATE() - INTERVAL 7 DAY
group by produceDate
order by produce_date desc
GROUP BY
produceDate
ORDER BY
produceDate DESC
</select>
<select id="selectAllDevice" resultType="java.lang.String">
@@ -218,4 +221,45 @@
GROUP BY
m.material_code, c.cust_name
</select>
<select id="selectYzPoint" resultType="java.lang.String">
SELECT point_code AS device_code
FROM `sch_base_point`
WHERE point_type = '2'
and region_code = 'YZ'
</select>
<select id="selectYjPoint" resultType="java.lang.String">
SELECT point_code AS device_code
FROM `sch_base_point`
WHERE point_type = '1'
and region_code = 'YZ'
and LENGTH(point_code) = 4
</select>
<select id="selectHnjPoints" resultType="java.lang.String">
SELECT point_code AS device_code
FROM `sch_base_point`
WHERE point_type = '1'
and region_code = 'HN'
</select>
<select id="selectMixingRelativeInfo" resultType="org.nl.wms.cockpit.service.dao.MixingRelativeVo">
SELECT p.point_code as pointCode,
p.point_name as pointName,
p.point_status as pointStatus
FROM `sch_base_point` p
WHERE p.region_code = 'HN'
AND P.point_type = '2'
ORDER BY p.point_code
</select>
<select id="selectJxsPoints" resultType="java.lang.String">
SELECT p.point_code as pointCode,
p.point_name as pointName,
p.point_status as pointStatus
FROM `sch_base_point` p
WHERE p.region_code in( 'YZ','FJ')
AND P.point_type = '1'
and LENGTH(point_code) <![CDATA[ > ]]> 4
ORDER BY p.point_code
</select>
</mapper>

View File

@@ -5,7 +5,7 @@
<select id="queryErrorVo" resultType="org.nl.wms.cockpit.service.dao.DeviceErrorVo">
select p.point_name as deviceName,
count(*) as errorNum
from das_device_check_record r
from das_device_error_record r
left join sch_base_point p on r.device_code = p.point_code
where STR_TO_DATE(r.record_time, '%Y-%m-%d') > NOW() - INTERVAL 30 DAY
group by deviceName