|
@ -1,6 +1,9 @@ |
|
|
package org.nl.wms.pda.service.impl; |
|
|
package org.nl.wms.pda.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
@ -9,11 +12,16 @@ import org.nl.modules.common.exception.BadRequestException; |
|
|
import org.nl.modules.common.utils.SecurityUtils; |
|
|
import org.nl.modules.common.utils.SecurityUtils; |
|
|
import org.nl.modules.wql.WQL; |
|
|
import org.nl.modules.wql.WQL; |
|
|
import org.nl.modules.wql.core.bean.WQLObject; |
|
|
import org.nl.modules.wql.core.bean.WQLObject; |
|
|
|
|
|
import org.nl.wms.basedata.eum.TrueOrFalse; |
|
|
import org.nl.wms.pda.service.PdaService; |
|
|
import org.nl.wms.pda.service.PdaService; |
|
|
|
|
|
import org.nl.wms.sch.manage.ACSSystem; |
|
|
import org.nl.wms.sch.manage.CreateMode; |
|
|
import org.nl.wms.sch.manage.CreateMode; |
|
|
|
|
|
import org.nl.wms.sch.manage.Region; |
|
|
import org.nl.wms.sch.task.send.material.HLSendMaterialTask; |
|
|
import org.nl.wms.sch.task.send.material.HLSendMaterialTask; |
|
|
|
|
|
import org.nl.wms.sch.task.send.material.YZSendMaterialTask; |
|
|
import org.nl.wms.sch.task.util.TaskUtils; |
|
|
import org.nl.wms.sch.task.util.TaskUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @author 张江玮 |
|
|
* @author 张江玮 |
|
@ -26,63 +34,185 @@ public class PdaServiceImpl implements PdaService { |
|
|
|
|
|
|
|
|
private final HLSendMaterialTask hlSendMaterialTask; |
|
|
private final HLSendMaterialTask hlSendMaterialTask; |
|
|
|
|
|
|
|
|
/** |
|
|
private final YZSendMaterialTask yzSendMaterialTask; |
|
|
* 查询所有区域 |
|
|
|
|
|
* |
|
|
|
|
|
* @return 所有区域信息 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public JSONArray queryRegion() { |
|
|
public JSONArray region(String func) { |
|
|
return WQLObject |
|
|
switch (func) { |
|
|
.getWQLObject("sch_base_region") |
|
|
case "send_material": |
|
|
.query() |
|
|
// 送料
|
|
|
|
|
|
case "call_material": |
|
|
|
|
|
// 送料
|
|
|
|
|
|
return WQL |
|
|
|
|
|
.getWO("PDA") |
|
|
|
|
|
.addParam("flag", "1") |
|
|
|
|
|
.addParam("where", "('HL', 'YZ', 'FJ')") |
|
|
|
|
|
.process() |
|
|
.getResultJSONArray(0); |
|
|
.getResultJSONArray(0); |
|
|
|
|
|
default: |
|
|
|
|
|
throw new BadRequestException("未知功能!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 查询对接位 |
|
|
|
|
|
* |
|
|
|
|
|
* @param type 手持界面 HLSL-混料送料 |
|
|
|
|
|
* @return 对接位信息 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public JSONArray queryPoint(String type) { |
|
|
public JSONArray point(String func, String region_code) { |
|
|
|
|
|
Region region = Region.get(region_code); |
|
|
|
|
|
if (ObjectUtil.isEmpty(region)) { |
|
|
|
|
|
throw new BadRequestException("未知区域!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (func) { |
|
|
|
|
|
case "send_material": |
|
|
|
|
|
// 送料
|
|
|
|
|
|
switch (region) { |
|
|
|
|
|
case HL: |
|
|
return WQL |
|
|
return WQL |
|
|
.getWO("PDA") |
|
|
.getWO("PDA") |
|
|
.addParam("flag", "1") |
|
|
.addParam("flag", "2") |
|
|
.addParam("type", type) |
|
|
.addParam("region_code", region_code) |
|
|
|
|
|
.addParam("point_type", "('1', '2')") |
|
|
|
|
|
.process() |
|
|
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
case YZ: |
|
|
|
|
|
return WQL |
|
|
|
|
|
.getWO("PDA") |
|
|
|
|
|
.addParam("flag", "2") |
|
|
|
|
|
.addParam("region_code", region_code) |
|
|
|
|
|
.addParam("point_type", "('1')") |
|
|
|
|
|
.process() |
|
|
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
case FJ: |
|
|
|
|
|
return WQL |
|
|
|
|
|
.getWO("PDA") |
|
|
|
|
|
.addParam("flag", "2") |
|
|
|
|
|
.addParam("region_code", region_code) |
|
|
|
|
|
.addParam("point_type", "('2')") |
|
|
|
|
|
.process() |
|
|
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
default: |
|
|
|
|
|
throw new BadRequestException(region.label() + "没有送料点位!"); |
|
|
|
|
|
} |
|
|
|
|
|
case "call_material": |
|
|
|
|
|
// 叫料
|
|
|
|
|
|
switch (region) { |
|
|
|
|
|
case YZ: |
|
|
|
|
|
JSONArray result = WQL |
|
|
|
|
|
.getWO("PDA") |
|
|
|
|
|
.addParam("flag", "2") |
|
|
|
|
|
.addParam("region_code", region_code) |
|
|
|
|
|
.addParam("point_type", "('2')") |
|
|
|
|
|
.process() |
|
|
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
result.addAll(WQL |
|
|
|
|
|
.getWO("PDA") |
|
|
|
|
|
.addParam("flag", "2") |
|
|
|
|
|
.addParam("region_code", Region.KLHJ.value()) |
|
|
|
|
|
.addParam("point_type", "('2')") |
|
|
|
|
|
.process() |
|
|
|
|
|
.getResultJSONArray(0)); |
|
|
|
|
|
return result; |
|
|
|
|
|
case FJ: |
|
|
|
|
|
return WQL |
|
|
|
|
|
.getWO("PDA") |
|
|
|
|
|
.addParam("flag", "2") |
|
|
|
|
|
.addParam("region_code", region_code) |
|
|
|
|
|
.addParam("point_type", "('1')") |
|
|
.process() |
|
|
.process() |
|
|
.getResultJSONArray(0); |
|
|
.getResultJSONArray(0); |
|
|
|
|
|
default: |
|
|
|
|
|
throw new BadRequestException(region.label() + "没有叫料点位!"); |
|
|
|
|
|
} |
|
|
|
|
|
default: |
|
|
|
|
|
throw new BadRequestException("未知功能!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 创建任务 |
|
|
|
|
|
* |
|
|
|
|
|
* @param request_param 请求带的参数 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void createTask(JSONObject request_param) { |
|
|
public JSONArray device(String func) { |
|
|
String type = request_param.getString("type"); |
|
|
return WQL |
|
|
|
|
|
.getWO("PDA") |
|
|
|
|
|
.addParam("flag", "3") |
|
|
|
|
|
.process() |
|
|
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
@Override |
|
|
|
|
|
public void report(String device_code, String unqualified_qty) { |
|
|
|
|
|
WQLObject workorder_table = WQLObject.getWQLObject("pdm_bd_workorder"); |
|
|
|
|
|
JSONObject work_order = workorder_table |
|
|
|
|
|
.query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") |
|
|
|
|
|
.uniqueResult(0); |
|
|
|
|
|
if (ObjectUtil.isEmpty(work_order)) { |
|
|
|
|
|
throw new BadRequestException("设备 [" + device_code + "] 未开始生产!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int current_qty = work_order.getIntValue("unqualified_qty"); |
|
|
|
|
|
work_order.put("unqualified_qty", current_qty + Integer.parseInt(unqualified_qty)); |
|
|
|
|
|
workorder_table.update(work_order); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
@Override |
|
|
|
|
|
public void sendMaterial(String point_code, String vehicle_code, String qty, String weight, String is_full, String request_param) { |
|
|
JSONObject point = WQLObject |
|
|
JSONObject point = WQLObject |
|
|
.getWQLObject("sch_base_point") |
|
|
.getWQLObject("sch_base_point") |
|
|
.query("is_delete = '0' AND is_used = '1' AND point_code = '" + request_param.getString("point_code") + "'") |
|
|
.query("is_used = '1' AND point_code = '" + point_code + "'") |
|
|
.uniqueResult(0); |
|
|
.uniqueResult(0); |
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
throw new BadRequestException("点位已删除或未启用!"); |
|
|
throw new BadRequestException("[" + point_code + "] 已删除或未启用!"); |
|
|
} |
|
|
} |
|
|
|
|
|
TaskUtils.isLocked(point); |
|
|
|
|
|
JSONObject workorder = TaskUtils.hasWorkOrder(point); |
|
|
|
|
|
String vehicle_type = workorder.getString("vehicle_type"); |
|
|
|
|
|
String device_code = workorder.getString("device_code"); |
|
|
|
|
|
WQLObject vd_table = WQLObject.getWQLObject("st_ivt_vehicle_detail"); |
|
|
|
|
|
JSONObject vd_update = new JSONObject(); |
|
|
|
|
|
vd_update.put("is_delete", TrueOrFalse.TRUE.value()); |
|
|
|
|
|
vd_table.update(vd_update, "vehicle_type = '" + vehicle_type + "' AND vehicle_code = '" + vehicle_code + "'"); |
|
|
|
|
|
|
|
|
|
|
|
// 组盘
|
|
|
|
|
|
JSONObject vd = new JSONObject(); |
|
|
|
|
|
vd.put("vd_id", IdUtil.getSnowflake(1L, 1L).nextId()); |
|
|
|
|
|
vd.put("vehicle_type", vehicle_type); |
|
|
|
|
|
vd.put("vehicle_code", vehicle_code); |
|
|
|
|
|
vd.put("material_id", workorder.getString("material_id")); |
|
|
|
|
|
vd.put("qty", qty); |
|
|
|
|
|
vd.put("weight", weight); |
|
|
|
|
|
vd.put("is_full", is_full); |
|
|
|
|
|
vd.put("workorder_id", workorder.getString("workorder_id")); |
|
|
|
|
|
vd.put("point_code", point_code); |
|
|
|
|
|
vd.put("create_id", SecurityUtils.getCurrentUserId()); |
|
|
|
|
|
vd.put("create_name", SecurityUtils.getCurrentNickName()); |
|
|
|
|
|
vd.put("create_time", DateUtil.now()); |
|
|
|
|
|
vd.put("is_delete", "0"); |
|
|
|
|
|
if (device_code.startsWith("FJ")) { |
|
|
|
|
|
vd.put("is_fire", TrueOrFalse.TRUE.value()); |
|
|
|
|
|
} |
|
|
|
|
|
vd.put("is_in_kiln", TrueOrFalse.trueOrFalse(is_full) ? TrueOrFalse.TRUE.value() : TrueOrFalse.FALSE.value()); |
|
|
|
|
|
if (device_code.startsWith("FJ")) { |
|
|
|
|
|
vd.put("is_in_kiln", TrueOrFalse.FALSE.value()); |
|
|
|
|
|
} |
|
|
|
|
|
vd_table.insert(vd); |
|
|
|
|
|
|
|
|
|
|
|
Region region = Region.get(point.getString("region_code")); |
|
|
JSONObject method_param = new JSONObject(); |
|
|
JSONObject method_param = new JSONObject(); |
|
|
|
|
|
method_param.put("point", point); |
|
|
|
|
|
method_param.put("workorder", workorder); |
|
|
|
|
|
method_param.put("vd", vd); |
|
|
method_param.put("create_mode", CreateMode.SCCJ.value()); |
|
|
method_param.put("create_mode", CreateMode.SCCJ.value()); |
|
|
method_param.put("request_param", request_param); |
|
|
method_param.put("request_param", request_param); |
|
|
method_param.put("create_id", SecurityUtils.getCurrentUserId()); |
|
|
method_param.put("create_id", SecurityUtils.getCurrentUserId()); |
|
|
method_param.put("create_name", SecurityUtils.getCurrentNickName()); |
|
|
method_param.put("create_name", SecurityUtils.getCurrentNickName()); |
|
|
switch (type) { |
|
|
switch (region) { |
|
|
case "1": |
|
|
case HL: |
|
|
// 混料机送料
|
|
|
|
|
|
method_param.put("point", point); |
|
|
|
|
|
method_param.put("vehicle_code", TaskUtils.formatVehicleCode(request_param.getString("vehicle_code"))); |
|
|
|
|
|
hlSendMaterialTask.createTask(method_param); |
|
|
hlSendMaterialTask.createTask(method_param); |
|
|
break; |
|
|
break; |
|
|
case "2": |
|
|
case YZ: |
|
|
|
|
|
yzSendMaterialTask.createTask(method_param); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
throw new BadRequestException("[" + region.label() + "] 不能发起送料任务!"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|