天眼增加判断上次请求是否满足条件,如果与上次同步时间戳不同且点位状态相同,视为稳定状态

This commit is contained in:
psh
2024-06-27 15:44:48 +08:00
parent c41db16f77
commit ef163770e9

View File

@@ -38,6 +38,8 @@ public class SyncPoint {
@Autowired
private IPdmBdProductionProcessTrackingService processTrackingService;
private JSONArray last_jsonArray = new JSONArray();
public void run() throws Exception {
try {
@@ -55,39 +57,48 @@ public class SyncPoint {
JSONArray jsonArray = JSONObject.parseObject(result.body()).getJSONArray("data");
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
for (SchBasePoint temp : schBasePointList) {
if (temp.getPoint_code().equals(jsonObject.getString("binNo"))) {
if (jsonObject.getInteger("pred") == 0 && "2".equals(temp.getPoint_status())
|| jsonObject.getInteger("pred") == 1 && "1".equals(temp.getPoint_status())) {
log.info("检测到点位{}当前库存有变动pred={}更新lms库存", jsonObject.getString("binNo"), jsonObject.getInteger("pred"));
temp.setPoint_status(String.valueOf(jsonObject.getInteger("pred") + 1));
temp.setVehicle_type("");
temp.setVehicle_code("");
temp.setIng_task_code("");
temp.setVehicle_qty(0);
temp.setUpdate_time(DateUtil.now());
schBasePointService.update(temp);
SchBaseVehiclematerialgroup groupInfo = vehiclematerialgroupService.getVehicleGroupInfo(
temp.getVehicle_code(),
temp.getVehicle_type(),
GroupBindMaterialStatusEnum.BOUND.getValue());
// 插入生产过程跟踪表
PdmBdProductionProcessTracking processTracking = new PdmBdProductionProcessTracking();
if (ObjectUtil.isNotEmpty(groupInfo)) {
groupInfo.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
vehiclematerialgroupService.update(groupInfo);
processTracking.setBuss_move_id(groupInfo.getBuss_move_id());
for (int j = 0; j < last_jsonArray.size(); j++) {
JSONObject last_jsonObject = last_jsonArray.getJSONObject(j);
//如果与上次同步时间戳不同且点位状态相同,视为稳定状态
if(ObjectUtil.equals(jsonObject.getString("binNo"),last_jsonObject.getString("binNo"))&&
!ObjectUtil.equals(jsonObject.getString("timestamp"),last_jsonObject.getString("timestamp"))&&
ObjectUtil.equals(jsonObject.getString("pred"),last_jsonObject.getString("pred"))) {
for (SchBasePoint temp : schBasePointList) {
if (temp.getPoint_code().equals(jsonObject.getString("binNo"))) {
if (jsonObject.getInteger("pred") == 0 && "2".equals(temp.getPoint_status())
|| jsonObject.getInteger("pred") == 1 && "1".equals(temp.getPoint_status())) {
log.info("检测到点位{}当前库存有变动pred={}更新lms库存", jsonObject.getString("binNo"), jsonObject.getInteger("pred"));
temp.setPoint_status(String.valueOf(jsonObject.getInteger("pred") + 1));
temp.setVehicle_type("");
temp.setVehicle_code("");
temp.setIng_task_code("");
temp.setVehicle_qty(0);
temp.setUpdate_time(DateUtil.now());
schBasePointService.update(temp);
SchBaseVehiclematerialgroup groupInfo = vehiclematerialgroupService.getVehicleGroupInfo(
temp.getVehicle_code(),
temp.getVehicle_type(),
GroupBindMaterialStatusEnum.BOUND.getValue());
// 插入生产过程跟踪表
PdmBdProductionProcessTracking processTracking = new PdmBdProductionProcessTracking();
if (ObjectUtil.isNotEmpty(groupInfo)) {
groupInfo.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
vehiclematerialgroupService.update(groupInfo);
processTracking.setBuss_move_id(groupInfo.getBuss_move_id());
}
processTracking.setProcess_action("暂存区人工出库");
processTracking.setProcess_location(temp.getPoint_code());
processTracking.setRecord_time(DateUtil.now());
processTrackingService.create(processTracking);
break;
}
}
processTracking.setProcess_action("暂存区人工出库");
processTracking.setProcess_location(temp.getPoint_code());
processTracking.setRecord_time(DateUtil.now());
processTrackingService.create(processTracking);
break;
}
}
}
}
last_jsonArray = jsonArray;
} catch (Exception e) {
log.error("自动线程查询天眼点位失败{}{}", e, e.getMessage());
}