|
@ -68,12 +68,93 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
}, "参数不能为空!"); |
|
|
}, "参数不能为空!"); |
|
|
String vehicle = param.getString("vehicle_list"); |
|
|
String vehicle = param.getString("vehicle_list"); |
|
|
String device_code = param.getString("device_code"); |
|
|
String device_code = param.getString("device_code"); |
|
|
|
|
|
String type = param.getString("type"); |
|
|
|
|
|
switch (type) { |
|
|
|
|
|
case "1": |
|
|
|
|
|
artificialBending(vehicle, device_code, param); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2": |
|
|
|
|
|
semiAutomaticBending(vehicle, device_code, param); |
|
|
|
|
|
break; |
|
|
|
|
|
case "3": |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 空料架送回 |
|
|
|
|
|
* |
|
|
|
|
|
* @param vehicle |
|
|
|
|
|
* @param device_code |
|
|
|
|
|
* @param param |
|
|
|
|
|
*/ |
|
|
|
|
|
private void semiAutomaticBending(String vehicle, String device_code, JSONObject param) { |
|
|
|
|
|
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle); |
|
|
|
|
|
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!"); |
|
|
|
|
|
if (!mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.RACKS_S04.getVehicleCode()) |
|
|
|
|
|
&& !mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.RACKS_S06.getVehicleCode())) { |
|
|
|
|
|
throw new BadRequestException("不是料架,生成搬运任务失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
|
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
|
|
|
AbstractTask connectorTask = taskFactory.getTask("RACKTask"); |
|
|
|
|
|
// 准备参数:设备编码
|
|
|
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
|
|
jo.put("device_code", device_code); |
|
|
|
|
|
jo.put("config_code", "RACKTask"); |
|
|
|
|
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
|
|
|
jo.put("vehicle_code", vehicle); |
|
|
|
|
|
jo.put("vehicle_type", mdBaseVehicle.getVehicle_type()); |
|
|
|
|
|
jo.put("ext_data", param); |
|
|
|
|
|
connectorTask.apply(jo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 空料框送回 |
|
|
|
|
|
* |
|
|
|
|
|
* @param vehicle |
|
|
|
|
|
* @param device_code |
|
|
|
|
|
* @param param |
|
|
|
|
|
*/ |
|
|
|
|
|
private void artificialBending(String vehicle, String device_code, JSONObject param) { |
|
|
String[] vehicle_list = null; |
|
|
String[] vehicle_list = null; |
|
|
if (vehicle.contains(",")) { |
|
|
if (vehicle.contains(",")) { |
|
|
vehicle_list = vehicle.split(","); |
|
|
vehicle_list = vehicle.split(","); |
|
|
} |
|
|
} |
|
|
if (vehicle_list.length != 2 && vehicle_list.length != 4) { |
|
|
if(CollUtil.isEmpty(Arrays.asList(vehicle_list))){ |
|
|
throw new BadRequestException("笼框数量不匹配,请确认笼框数量后重新扫码!"); |
|
|
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle); |
|
|
|
|
|
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!"); |
|
|
|
|
|
if (!mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.RACKS_S04.getVehicleCode()) |
|
|
|
|
|
&& !mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.RACKS_S06.getVehicleCode())){ |
|
|
|
|
|
throw new BadRequestException("托盘类型不匹配,,生成搬运任务失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
}else { |
|
|
|
|
|
String[] finalVehicle_list = vehicle_list; |
|
|
|
|
|
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle_list[0]); |
|
|
|
|
|
if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!"); |
|
|
|
|
|
if (mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R01.getVehicleCode())) { |
|
|
|
|
|
if (finalVehicle_list.length != 2) { |
|
|
|
|
|
throw new BadRequestException("笼框数量不匹配,请确认笼框数量后重新扫码!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) { |
|
|
|
|
|
if (finalVehicle_list.length != 4) { |
|
|
|
|
|
throw new BadRequestException("笼框数量不匹配,请确认笼框数量后重新扫码!"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
Arrays.stream(vehicle_list).forEach(vehicleCode -> { |
|
|
|
|
|
String vehicleCode1 = vehicleCode; |
|
|
|
|
|
MdBaseVehicle mdBaseVehicle1 = iMdBaseVehicleService.selectByVehicleCode(vehicleCode1); |
|
|
|
|
|
if (ObjectUtil.isEmpty(mdBaseVehicle1)) throw new BadRequestException("载具不存在!"); |
|
|
|
|
|
if (!mdBaseVehicle1.getVehicle_type().equals(VehicleTypeEnum.FRAME_R01.getVehicleCode()) |
|
|
|
|
|
&& !mdBaseVehicle1.getVehicle_type().equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) { |
|
|
|
|
|
throw new BadRequestException("托盘类型不匹配,,生成搬运任务失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
@ -102,28 +183,39 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
String region_code = param.getString("region_code"); |
|
|
String region_code = param.getString("region_code"); |
|
|
String device_code = param.getString("device_code"); |
|
|
String device_code = param.getString("device_code"); |
|
|
String vehicle_code = param.getString("vehicle_code"); |
|
|
String vehicle_code = param.getString("vehicle_code"); |
|
|
|
|
|
String type = param.getString("type"); |
|
|
AbstractTask connectorTask = taskFactory.getTask("BLANKINGTask"); |
|
|
AbstractTask connectorTask = taskFactory.getTask("BLANKINGTask"); |
|
|
if (StrUtil.isNotEmpty(region_code) && (RegionEnum.NBJG.getRegion_code().equals(region_code) |
|
|
switch (type) { |
|
|
|| RegionEnum.WXJG.getRegion_code().equals(region_code))) { |
|
|
case "1": |
|
|
JSONObject jo = new JSONObject(); |
|
|
goShelves(param, region_code, device_code, vehicle_code, connectorTask); |
|
|
jo.put("device_code", device_code); |
|
|
break; |
|
|
jo.put("config_code", "ProcessingSMTTask"); |
|
|
case "2": |
|
|
jo.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
goWxOrNx(param, region_code, device_code, vehicle_code, connectorTask); |
|
|
jo.put("vehicle_code", vehicle_code); |
|
|
break; |
|
|
jo.put("region_code", region_code); |
|
|
case "3": |
|
|
param.put("target_region_code", region_code); |
|
|
goWxOrNx(param, region_code, device_code, vehicle_code, connectorTask); |
|
|
jo.put("ext_data", param); |
|
|
break; |
|
|
connectorTask.apply(jo); |
|
|
default: |
|
|
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
break; |
|
|
.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"); |
|
|
* @param param |
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
* @param region_code |
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
* @param device_code |
|
|
|
|
|
* @param vehicle_code |
|
|
|
|
|
* @param connectorTask |
|
|
|
|
|
*/ |
|
|
|
|
|
private void goShelves(JSONObject param, String region_code, String device_code, String vehicle_code, AbstractTask connectorTask) { |
|
|
|
|
|
Assert.noNullElements(param.getJSONArray("material"), "参数不能为空!"); |
|
|
|
|
|
JSONArray materials = param.getJSONArray("material"); |
|
|
|
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); |
|
|
|
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
|
|
if (StrUtil.isBlank(region_code)) { |
|
|
JSONObject json = new JSONObject(); |
|
|
JSONObject json = new JSONObject(); |
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
JSONArray jsonArray = new JSONArray(); |
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
@ -159,57 +251,98 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
} else if (ObjectUtil.isNotEmpty(json1)) { |
|
|
} else if (ObjectUtil.isNotEmpty(json1)) { |
|
|
throw new BadRequestException(json1.getString("msg")); |
|
|
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("region_code", region_code); |
|
|
jo.put("ext_data", param); |
|
|
} else { |
|
|
iSchBasePointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
jo.put("region_code", region_code); |
|
|
.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("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)); |
|
|
|
|
|
String finalRegion_code = region_code; |
|
|
|
|
|
materials.stream().forEach(material -> { |
|
|
|
|
|
String replace = StrUtil.replace(StrUtil.toString(material), "=", ":"); |
|
|
|
|
|
replace = replace.replaceAll("material_code:,", ""); |
|
|
|
|
|
// 使用 Hutool 的 JSONUtil 解析 JSON 字符串
|
|
|
|
|
|
cn.hutool.json.JSONObject jsonObject1 = JSONUtil.parseObj(replace); |
|
|
|
|
|
// 判断 material_code 是否为空
|
|
|
|
|
|
if (replace.contains("OR")) { |
|
|
|
|
|
Object materialCode = jsonObject1.get("order_code"); |
|
|
|
|
|
jsonObject1.put("order_code", materialCode.toString()); |
|
|
|
|
|
replace = jsonObject1.toString(); |
|
|
|
|
|
} |
|
|
|
|
|
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(StrUtil.isBlank(finalRegion_code) ? jsonObject.getString("region_code") : finalRegion_code); |
|
|
|
|
|
iSchBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 物料下料去外协或内部加工区 |
|
|
|
|
|
* |
|
|
|
|
|
* @param param |
|
|
|
|
|
* @param region_code |
|
|
|
|
|
* @param device_code |
|
|
|
|
|
* @param vehicle_code |
|
|
|
|
|
* @param connectorTask |
|
|
|
|
|
*/ |
|
|
|
|
|
private void goWxOrNx(JSONObject param, String region_code, String device_code, String vehicle_code, AbstractTask connectorTask) { |
|
|
|
|
|
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)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public String pointLock(JSONObject param) { |
|
|
public String pointLock(JSONObject param) { |
|
|
Assert.noNullElements(new Object[]{param.getString("region_code"), param.getString("status")}, "参数不能为空!"); |
|
|
Assert.noNullElements(new Object[]{param.getString("region_code"), param.getString("status")}, "参数不能为空!"); |
|
|
String region_code = param.getString("region_code"); |
|
|
JSONArray region_code = param.getJSONArray("region_code"); |
|
|
String status = param.getString("status"); |
|
|
String status = param.getString("status"); |
|
|
SchBaseRegion schBaseRegion = iSchBaseRegionService.getOne(Wrappers.lambdaQuery(SchBaseRegion.class) |
|
|
region_code.stream().forEach(region -> { |
|
|
.eq(SchBaseRegion::getRegion_code, region_code)); |
|
|
String s = StrUtil.toString(region); |
|
|
if (ObjectUtil.isEmpty(schBaseRegion)) throw new BadRequestException("该区域不存在!"); |
|
|
SchBaseRegion schBaseRegion = iSchBaseRegionService.getOne(Wrappers.lambdaQuery(SchBaseRegion.class) |
|
|
List<String> pointCodes = iSchBasePointService.getByRegionCode(region_code); |
|
|
.eq(SchBaseRegion::getRegion_code, s)); |
|
|
if (StrUtil.equals(status, "0")) { |
|
|
if (ObjectUtil.isEmpty(schBaseRegion)) throw new BadRequestException("该区域不存在!"); |
|
|
iSchBasePointService.releasePoint(region_code); |
|
|
List<String> pointCodes = iSchBasePointService.getByRegionCode(s); |
|
|
iSchBaseTaskService.updateTaskStatusByPointCode(pointCodes); |
|
|
if (StrUtil.equals(status, "0")) { |
|
|
} else if (StrUtil.equals(status, "1")) { |
|
|
iSchBasePointService.releasePoint(s); |
|
|
boolean is_executing = iSchBaseTaskService.selectByPointCodeAndStatus(pointCodes); |
|
|
iSchBaseTaskService.updateTaskStatusByPointCode(pointCodes); |
|
|
if (is_executing) { |
|
|
} else if (StrUtil.equals(status, "1")) { |
|
|
throw new BadRequestException("该区域有任务正在执行,请等待任务执行完成再锁定!"); |
|
|
boolean is_executing = iSchBaseTaskService.selectByPointCodeAndStatus(pointCodes); |
|
|
|
|
|
if (is_executing) { |
|
|
|
|
|
throw new BadRequestException("该区域有任务正在执行,请等待任务执行完成再锁定!"); |
|
|
|
|
|
} |
|
|
|
|
|
iSchBaseTaskService.selectByPointCodeAndTaskStatus(pointCodes); |
|
|
|
|
|
iSchBasePointService.lockPoint(s); |
|
|
} |
|
|
} |
|
|
iSchBaseTaskService.selectByPointCodeAndTaskStatus(pointCodes); |
|
|
}); |
|
|
iSchBasePointService.lockPoint(region_code); |
|
|
|
|
|
} |
|
|
|
|
|
return "操作成功"; |
|
|
return "操作成功"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -377,5 +510,13 @@ public class HandheldServiceImpl implements HandheldService { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public String selectVehicleByPoint(JSONObject json) { |
|
|
|
|
|
Assert.notNull(json.getString("device_code"), "参数不能为空!"); |
|
|
|
|
|
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(json.getString("device_code")); |
|
|
|
|
|
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); |
|
|
|
|
|
return schBasePoint.getVehicle_code(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|