|
|
@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import nl.basjes.shaded.org.springframework.util.Assert; |
|
|
|
import org.nl.common.enums.GoodsEnum; |
|
|
|
import org.nl.common.enums.VehicleTypeEnum; |
|
|
|
import org.nl.common.enums.region.RegionEnum; |
|
|
|
import org.nl.common.exception.BadRequestException; |
|
|
@ -31,6 +32,7 @@ import org.nl.wms.sch.task_manage.GeneralDefinition; |
|
|
|
import org.nl.wms.sch.task_manage.task.TaskFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
@ -67,7 +69,7 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
|
String vehicle = param.getString("vehicle_list"); |
|
|
|
String device_code = param.getString("device_code"); |
|
|
|
String[] vehicle_list = null; |
|
|
|
if(vehicle.contains(",")){ |
|
|
|
if (vehicle.contains(",")) { |
|
|
|
vehicle_list = vehicle.split(","); |
|
|
|
} |
|
|
|
if (vehicle_list.length != 2 && vehicle_list.length != 4) { |
|
|
@ -93,83 +95,99 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void cageBlankingTask(JSONObject param) { |
|
|
|
Assert.noNullElements(new Object[]{param.getString("device_code"), param.getString("vehicle_code")}, |
|
|
|
"当前点位或目的地不能为空!"); |
|
|
|
JSONArray materials = param.getJSONArray("material"); |
|
|
|
String region_code = param.getString("region_code"); |
|
|
|
String device_code = param.getString("device_code"); |
|
|
|
String vehicle_code = param.getString("vehicle_code"); |
|
|
|
/*String material_qty = param.getString("material_qty"); |
|
|
|
String material_code = param.getString("material_code");*/ |
|
|
|
String region_code = param.getString("region_code"); |
|
|
|
/*String order_code = param.getString("order_code");*/ |
|
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
materials.stream().forEach(material2 -> { |
|
|
|
String replace = StrUtil.replace(StrUtil.toString(material2), "=", ":"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(replace); |
|
|
|
map.put("order_code", jsonObject.getString("order_code")); |
|
|
|
map.put("qty", jsonObject.getString("material_qty")); |
|
|
|
jsonArray.add(map); |
|
|
|
}); |
|
|
|
json.put("vehicle_code", vehicle_code); |
|
|
|
json.put("region_code", region_code); |
|
|
|
json.put("materials", jsonArray); |
|
|
|
JSONObject json1 = wmsToConnectorService.applyRegionAndDueDate(json); |
|
|
|
if (ObjectUtil.isNotEmpty(json1) && json1.getInteger("status") == 200) { |
|
|
|
JSONArray date = json1.getJSONArray("data"); |
|
|
|
date.stream().forEach(date1 -> { |
|
|
|
JSONObject json2 = JSONObject.parseObject(StrUtil.toString(date1)); |
|
|
|
materials.stream().forEach(material -> { |
|
|
|
String replace = StrUtil.replace(StrUtil.toString(material), "=", ":"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(replace); |
|
|
|
if (jsonObject.getString("order_code").equals(json2.getString("order_code"))) { |
|
|
|
jsonObject.put("due_date", json2.getString("due_date")); |
|
|
|
jsonObject.put("region_code", json2.getString("next_region_code")); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
region_code = JSONObject.parseObject(StrUtil.toString(date.get(0))).getString("region_code"); |
|
|
|
} else if (ObjectUtil.isNotEmpty(json1)) { |
|
|
|
throw new BadRequestException(json1.getString("msg")); |
|
|
|
} |
|
|
|
param.put("material", materials); |
|
|
|
if (!param.getString("region_code").equals(RegionEnum.NBJG.getRegion_code())) { |
|
|
|
Assert.noNullElements(param.getJSONArray("material"), "参数不能为空!"); |
|
|
|
} |
|
|
|
AbstractTask connectorTask = taskFactory.getTask("BLANKINGTask"); |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("device_code", device_code); |
|
|
|
if (RegionEnum.NBJG.getRegion_code().equals(region_code) || RegionEnum.WXJG.getRegion_code().equals(region_code)) { |
|
|
|
if (StrUtil.isNotEmpty(region_code) && (RegionEnum.NBJG.getRegion_code().equals(region_code) |
|
|
|
|| RegionEnum.WXJG.getRegion_code().equals(region_code))) { |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("device_code", device_code); |
|
|
|
jo.put("config_code", "ProcessingSMTTask"); |
|
|
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
|
jo.put("vehicle_code", vehicle_code); |
|
|
|
jo.put("region_code", region_code); |
|
|
|
param.put("target_region_code", region_code); |
|
|
|
jo.put("ext_data", param); |
|
|
|
connectorTask.apply(jo); |
|
|
|
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getPoint_code, device_code) |
|
|
|
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) |
|
|
|
.set(SchBasePoint::getIs_lock, true) |
|
|
|
.set(SchBasePoint::getVehicle_code, null)); |
|
|
|
} else { |
|
|
|
Assert.noNullElements(param.getJSONArray("material"), "参数不能为空!"); |
|
|
|
JSONArray materials = param.getJSONArray("material"); |
|
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
materials.stream().forEach(material2 -> { |
|
|
|
boolean material_code = ObjectUtil.isEmpty(((LinkedHashMap) material2).get("material_code")); |
|
|
|
if (material_code) { |
|
|
|
((LinkedHashMap) material2).remove("material_code"); |
|
|
|
} |
|
|
|
String replace = StrUtil.replace(StrUtil.toString(material2), "=", ":"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(replace); |
|
|
|
map.put("order_code", jsonObject.getString("order_code")); |
|
|
|
map.put("qty", jsonObject.getString("material_qty")); |
|
|
|
jsonArray.add(map); |
|
|
|
}); |
|
|
|
json.put("vehicle_code", vehicle_code); |
|
|
|
json.put("region_code", region_code); |
|
|
|
json.put("materials", jsonArray); |
|
|
|
JSONObject json1 = wmsToConnectorService.applyRegionAndDueDate(json); |
|
|
|
if (ObjectUtil.isNotEmpty(json1) && json1.getInteger("status") == 200) { |
|
|
|
JSONArray date = json1.getJSONArray("data"); |
|
|
|
date.stream().forEach(date1 -> { |
|
|
|
JSONObject json2 = JSONObject.parseObject(StrUtil.toString(date1)); |
|
|
|
materials.stream().forEach(material -> { |
|
|
|
String replace = StrUtil.replace(StrUtil.toString(material), "=", ":"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(replace); |
|
|
|
if (jsonObject.getString("order_code").equals(json2.getString("order_code"))) { |
|
|
|
jsonObject.put("due_date", json2.getString("due_date")); |
|
|
|
jsonObject.put("region_code", json2.getString("next_region_code")); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
region_code = JSONObject.parseObject(StrUtil.toString(date.get(0))).getString("region_code"); |
|
|
|
} else if (ObjectUtil.isNotEmpty(json1)) { |
|
|
|
throw new BadRequestException(json1.getString("msg")); |
|
|
|
} |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("device_code", device_code); |
|
|
|
jo.put("config_code", "BLANKINGTask"); |
|
|
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
|
jo.put("vehicle_code", vehicle_code); |
|
|
|
jo.put("region_code", region_code); |
|
|
|
jo.put("ext_data", param); |
|
|
|
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getPoint_code, device_code) |
|
|
|
.set(SchBasePoint::getIs_lock, true) |
|
|
|
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) |
|
|
|
.set(SchBasePoint::getVehicle_code, null)); |
|
|
|
connectorTask.apply(jo); |
|
|
|
iSchBaseVehiclematerialgroupService.remove(Wrappers.lambdaQuery(SchBaseVehiclematerialgroup.class) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicle_code)); |
|
|
|
materials.stream().forEach(material -> { |
|
|
|
String replace = StrUtil.replace(StrUtil.toString(material), "=", ":"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(replace); |
|
|
|
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup(); |
|
|
|
schBaseVehiclematerialgroup.setVehicle_code(vehicle_code); |
|
|
|
schBaseVehiclematerialgroup.setMaterial_qty(jsonObject.getInteger("material_qty")); |
|
|
|
schBaseVehiclematerialgroup.setMaterial_code(jsonObject.getString("material_code")); |
|
|
|
schBaseVehiclematerialgroup.setOrder_code(jsonObject.getString("order_code")); |
|
|
|
schBaseVehiclematerialgroup.setDue_date(jsonObject.getString("due_date")); |
|
|
|
schBaseVehiclematerialgroup.setRegion_code(jsonObject.getString("region_code")); |
|
|
|
iSchBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
|
jo.put("vehicle_code", vehicle_code); |
|
|
|
jo.put("region_code", region_code); |
|
|
|
jo.put("ext_data", param); |
|
|
|
connectorTask.apply(jo); |
|
|
|
iSchBaseVehiclematerialgroupService.remove(Wrappers.lambdaQuery(SchBaseVehiclematerialgroup.class) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicle_code)); |
|
|
|
materials.stream().forEach(material -> { |
|
|
|
String replace = StrUtil.replace(StrUtil.toString(material), "=", ":"); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(replace); |
|
|
|
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup(); |
|
|
|
schBaseVehiclematerialgroup.setVehicle_code(vehicle_code); |
|
|
|
schBaseVehiclematerialgroup.setMaterial_qty(jsonObject.getInteger("material_qty")); |
|
|
|
schBaseVehiclematerialgroup.setMaterial_code(jsonObject.getString("material_code")); |
|
|
|
schBaseVehiclematerialgroup.setOrder_code(jsonObject.getString("order_code")); |
|
|
|
schBaseVehiclematerialgroup.setDue_date(jsonObject.getString("due_date")); |
|
|
|
schBaseVehiclematerialgroup.setRegion_code(jsonObject.getString("region_code")); |
|
|
|
iSchBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup); |
|
|
|
}); |
|
|
|
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getPoint_code, device_code) |
|
|
|
.set(SchBasePoint::getIs_lock, true)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -181,20 +199,17 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
|
.eq(SchBaseRegion::getRegion_code, region_code)); |
|
|
|
if (ObjectUtil.isEmpty(schBaseRegion)) throw new BadRequestException("该区域不存在!"); |
|
|
|
List<String> pointCodes = iSchBasePointService.getByRegionCode(region_code); |
|
|
|
boolean is_executing = iSchBaseTaskService.selectByPointCodeAndStatus(pointCodes); |
|
|
|
if (is_executing) { |
|
|
|
return "当前区域有任务正在执行,请等待任务执行完在锁定!"; |
|
|
|
} |
|
|
|
iSchBaseTaskService.selectByPointCodeAndTaskStatus(pointCodes); |
|
|
|
if (StrUtil.equals(status, "0")) { |
|
|
|
iSchBasePointService.releasePoint(region_code); |
|
|
|
iSchBaseTaskService.updateTaskStatusByPointCode(pointCodes); |
|
|
|
} else if (StrUtil.equals(status, "1")) { |
|
|
|
boolean is_executing = iSchBaseTaskService.selectByPointCodeAndStatus(pointCodes); |
|
|
|
if (is_executing) { |
|
|
|
throw new BadRequestException("该区域有任务正在执行,请等待任务执行完成再锁定!"); |
|
|
|
} |
|
|
|
iSchBaseTaskService.selectByPointCodeAndTaskStatus(pointCodes); |
|
|
|
iSchBasePointService.lockPoint(region_code); |
|
|
|
} |
|
|
|
if (CollUtil.isNotEmpty(pointCodes) && pointCodes.size() > 0) { |
|
|
|
return "当前区域已存在的任务有" + pointCodes.size() + "个"; |
|
|
|
} |
|
|
|
return "操作成功"; |
|
|
|
} |
|
|
|
|
|
|
@ -215,9 +230,13 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
|
jo.put("device_code", device_code); |
|
|
|
jo.put("config_code", "TOSTOREHOUSETask"); |
|
|
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
|
jo.put("vehicle_code", vehicle_type); |
|
|
|
jo.put("vehicle_type", vehicle_type); |
|
|
|
jo.put("ext_data", param); |
|
|
|
connectorTask.apply(jo); |
|
|
|
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getPoint_code, device_code) |
|
|
|
.set(SchBasePoint::getIs_lock, true) |
|
|
|
.set(SchBasePoint::getPoint_status, GoodsEnum.EMPTY_PALLETS.getValue())); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -248,7 +267,7 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
|
@Override |
|
|
|
public void materialTransfer(JSONObject param) { |
|
|
|
Assert.noNullElements(new Object[]{param.getString("device_code"), param.getString("vehicle_code")}, "参数不能为空!"); |
|
|
|
// String vehicle_code = param.getString("vehicle_code");
|
|
|
|
String vehicle_code = param.getString("vehicle_code"); |
|
|
|
String device_code = param.getString("device_code"); |
|
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
@ -258,10 +277,14 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
|
jo.put("device_code", device_code); |
|
|
|
jo.put("config_code", "MTTask"); |
|
|
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
|
/*jo.put("vehicle_code", vehicle_code); |
|
|
|
jo.put("vehicle_type", mdBaseVehicle.getVehicle_type());*/ |
|
|
|
jo.put("vehicle_code", vehicle_code); |
|
|
|
jo.put("ext_data", param); |
|
|
|
connectorTask.apply(jo); |
|
|
|
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getPoint_code, device_code) |
|
|
|
.set(SchBasePoint::getIs_lock, true) |
|
|
|
.set(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) |
|
|
|
.set(SchBasePoint::getVehicle_code, null)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -333,7 +356,7 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
|
public JSONObject |
|
|
|
deviceInLogin(JSONObject json) { |
|
|
|
Assert.notNull(json.getString("device_code"), "登录参数不能为空"); |
|
|
|
if(StrUtil.isNotEmpty(json.getString("device_code"))){ |
|
|
|
if (StrUtil.isNotEmpty(json.getString("device_code"))) { |
|
|
|
Object regin_code = redisUtils.get("mobile:" + json.getString("device_code")); |
|
|
|
if (regin_code != null) { |
|
|
|
throw new BadRequestException("当前设备工序已经登陆,无法继续选择"); |
|
|
|