This commit is contained in:
周俊杰
2024-03-07 10:26:27 +08:00
18 changed files with 568 additions and 284 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;
}