opt:优化
This commit is contained in:
@@ -189,6 +189,12 @@ public class ReturnShaftAgvTask extends AbstractAcsTask {
|
||||
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode());
|
||||
task.setPoint_code1(form.getString("point_code1"));
|
||||
task.setPoint_code2(form.getString("point_code2"));
|
||||
if (this.isSingleTask(form.getString("point_code1"))) {
|
||||
throw new BadRequestException("点位:" + form.getString("point_code1") + "存在未完成的任务!");
|
||||
}
|
||||
if (this.isSingleTask(form.getString("point_code2"))) {
|
||||
throw new BadRequestException("点位:" + form.getString("point_code2") + "存在未完成的任务!");
|
||||
}
|
||||
task.setVehicle_code(form.getString("vehicle_code1"));
|
||||
task.setVehicle_code2(form.getString("vehicle_code2"));
|
||||
task.setAcs_task_type("3");
|
||||
@@ -227,4 +233,18 @@ public class ReturnShaftAgvTask extends AbstractAcsTask {
|
||||
this.updateTaskStatus(taskObj, "0");
|
||||
}
|
||||
|
||||
//判断该点位是否存在未完成的任务
|
||||
public boolean isSingleTask(String point_code) {
|
||||
JSONObject task1 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code1 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
JSONObject task2 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code2 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
JSONObject task3 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code3 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
JSONObject task4 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code4 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(task1) || ObjectUtil.isNotEmpty(task2) || ObjectUtil.isNotEmpty(task3) || ObjectUtil.isNotEmpty(task4)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -107,6 +107,12 @@ public class SlitterDownAgvTask extends AbstractAcsTask {
|
||||
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode());
|
||||
task.setPoint_code1(form.getString("point_code1"));
|
||||
task.setPoint_code2(form.getString("point_code2"));
|
||||
if (this.isSingleTask(form.getString("point_code1"))) {
|
||||
throw new BadRequestException("点位:" + form.getString("point_code1") + "存在未完成的任务!");
|
||||
}
|
||||
if (this.isSingleTask(form.getString("point_code2"))) {
|
||||
throw new BadRequestException("点位:" + form.getString("point_code2") + "存在未完成的任务!");
|
||||
}
|
||||
task.setVehicle_code(form.getString("vehicle_code1"));
|
||||
task.setVehicle_code2(form.getString("vehicle_code2"));
|
||||
task.setAcs_task_type("3");
|
||||
@@ -142,4 +148,18 @@ public class SlitterDownAgvTask extends AbstractAcsTask {
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
this.updateTaskStatus(taskObj, "0");
|
||||
}
|
||||
|
||||
//判断该点位是否存在未完成的任务
|
||||
public boolean isSingleTask(String point_code) {
|
||||
JSONObject task1 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code1 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
JSONObject task2 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code2 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
JSONObject task3 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code3 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
JSONObject task4 = WQLObject.getWQLObject("SCH_BASE_Task").query("point_code4 = '" + point_code + "' AND task_status < '07' AND is_delete = '0'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(task1) || ObjectUtil.isNotEmpty(task2) || ObjectUtil.isNotEmpty(task3) || ObjectUtil.isNotEmpty(task4)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2515,7 +2515,6 @@ public class SlitterServiceImpl implements SlitterService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject returnShaft(JSONObject param) {
|
||||
log.info("空轴退回 - {}", param);
|
||||
JSONObject res = new JSONObject();
|
||||
|
||||
@@ -69,4 +69,10 @@ public class SapToLmsController {
|
||||
return new ResponseEntity<>(sapToLmsService.getUnPlanInfo(jo), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/inventoryTransferInfoSync")
|
||||
@Log("转单指令在MES平台查看后,更新信息,发送LMS(是否拆包、更新后的入库日期、是否更换外包装箱标签),LMS重打子卷标签、包装箱外标签")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> inventoryTransferInfoSync(@RequestBody JSONObject jo) {
|
||||
return new ResponseEntity<>(sapToLmsService.inventoryTransferInfoSync(jo), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,9 @@ public interface SapToLmsService {
|
||||
JSONObject getReCutInfo(JSONObject jo);
|
||||
|
||||
JSONObject getUnPlanInfo(JSONObject jo);
|
||||
|
||||
/**
|
||||
* 转单指令在MES平台查看后,更新信息,发送LMS(是否拆包、更新后的入库日期、是否更换外包装箱标签),LMS重打子卷标签、包装箱外标签
|
||||
*/
|
||||
JSONObject inventoryTransferInfoSync(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.ext.sap.service.SapToLmsService;
|
||||
import org.nl.wms.st.instor.service.RecutPlanService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@@ -160,6 +160,184 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转单指令在MES平台查看后,更新信息,发送LMS(是否拆包、更新后的入库日期、是否更换外包装箱标签),LMS重打子卷标签、包装箱外标签
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject inventoryTransferInfoSync(JSONObject param) {
|
||||
/**
|
||||
* {
|
||||
* "SaleOrderItem": "销售订单号-行号",
|
||||
* "CustomerName": "客户编码",
|
||||
* "DemandDate": "销售订单行交货日期",
|
||||
* "item": [
|
||||
* {
|
||||
* "SaleOrderItem": "销售订单号-行号",
|
||||
* "PackageBoxSN": "包装箱号",
|
||||
* "isRePrintPackageBoxLabel": "是否需要重打外包装标签",
|
||||
* "isUnPackBox": "是否需要拆包重打子卷标签",
|
||||
* "UpdatedDateOfProduction": "更改后的制造完成日期"
|
||||
* },
|
||||
* {
|
||||
* "SaleOrderItem": "销售订单号-行号",
|
||||
* "PackageBoxSN": "包装箱号",
|
||||
* "isRePrintPackageBoxLabel": "是否需要重打外包装标签",
|
||||
* "isUnPackBox": "是否需要拆包重打子卷标签",
|
||||
* "UpdatedDateOfProduction": "更改后的制造完成日期"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
log.info("inventoryTransferInfoSync接口输入参数为:-------------------" + param.toString());
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
try {
|
||||
JSONArray rows = param.getJSONArray("details");
|
||||
String SaleOrderItem = param.getString("SaleOrderItem");
|
||||
String CustomerName = param.getString("CustomerName");
|
||||
String DemandDate = param.getString("DemandDate");
|
||||
|
||||
if (ObjectUtil.isEmpty(rows) || rows.size() == 0) {
|
||||
throw new BadRequestException("item长度不能为0!");
|
||||
}
|
||||
|
||||
// 定义set集合储存仓库
|
||||
HashSet<String> storSet = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject json = rows.getJSONObject(i);
|
||||
String PackageBoxSN = json.getString("PackageBoxSN");
|
||||
|
||||
// 查询此木箱在哪个仓库
|
||||
JSONObject jsonBox = WQLObject.getWQLObject("st_ivt_structattr")
|
||||
.query("storagevehicle_code = '" + PackageBoxSN + "' and is_delete = '0' and is_used = '1' and lock_type = '1'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonBox)) {
|
||||
throw new BadRequestException("此木箱不在库内:" + PackageBoxSN);
|
||||
}
|
||||
storSet.add(jsonBox.getString("stor_code"));
|
||||
}
|
||||
|
||||
// 根据仓库生成多个库存变更单据
|
||||
for (String stor_code : storSet) {
|
||||
double total_qty = 0;
|
||||
double detail_count = 0;
|
||||
String changeinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
|
||||
JSONObject jsonStor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("stor_code = '" + stor_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonStor)) {
|
||||
throw new BadRequestException("仓库不存在:" + stor_code);
|
||||
}
|
||||
|
||||
JSONArray rowsDtl = new JSONArray();
|
||||
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
String PackageBoxSN = row.getString("PackageBoxSN");
|
||||
|
||||
JSONObject jsonBox = WQLObject.getWQLObject("st_ivt_structattr")
|
||||
.query("storagevehicle_code = '" + PackageBoxSN + "' and is_delete = '0' and is_used = '1' and lock_type = '1'").uniqueResult(0);
|
||||
|
||||
if (StrUtil.equals(jsonBox.getString("stor_code"), stor_code)) {
|
||||
rowsDtl.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
// 插入库存变更主表明细表
|
||||
for (int i = 0; i < rowsDtl.size(); i++) {
|
||||
JSONObject row = rowsDtl.getJSONObject(i);
|
||||
String PackageBoxSN = row.getString("PackageBoxSN");
|
||||
String isRePrintPackageBoxLabel = row.getString("isRePrintPackageBoxLabel");
|
||||
String isUnPackBox = row.getString("isUnPackBox");
|
||||
String UpdatedDateOfProduction = row.getString("UpdatedDateOfProduction");
|
||||
//查询该木箱内子卷数量
|
||||
JSONArray container_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + PackageBoxSN + "'").getResultJSONArray(0);
|
||||
for (int j = 0; j < container_rows.size(); j++) {
|
||||
JSONObject container_row = container_rows.getJSONObject(j);
|
||||
JSONObject change_jo = new JSONObject();
|
||||
change_jo.put("changeinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + "");
|
||||
change_jo.put("changeinv_id", changeinv_id);
|
||||
change_jo.put("seq_no", detail_count + 1);
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + container_row.getString("product_name") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(mater_jo)) {
|
||||
throw new BadRequestException("物料不存在:" + container_row.getString("product_name"));
|
||||
}
|
||||
change_jo.put("material_id", mater_jo.getString("material_id"));
|
||||
change_jo.put("pcsn", container_row.getString("container_name"));
|
||||
change_jo.put("package_box_sn", container_row.getString("package_box_sn"));
|
||||
change_jo.put("mfg_order_name", SaleOrderItem);
|
||||
change_jo.put("demand_date", DemandDate);
|
||||
change_jo.put("customer_name", CustomerName);
|
||||
//查询对应的客户
|
||||
JSONObject customer_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + CustomerName + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(customer_jo)) {
|
||||
throw new BadRequestException("客户不存在:" + CustomerName);
|
||||
}
|
||||
change_jo.put("customer_description", customer_jo.getString("cust_name"));
|
||||
change_jo.put("isRePrintPackageBoxLabel", isRePrintPackageBoxLabel);
|
||||
change_jo.put("isUnPackBox", isUnPackBox);
|
||||
change_jo.put("UpdatedDateOfProduction", UpdatedDateOfProduction);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + mater_jo.getString("base_unit_id") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(unit)) {
|
||||
throw new BadRequestException("计量单位不存在:" + mater_jo.getString("base_unit_id"));
|
||||
}
|
||||
change_jo.put("qty_unit_id", mater_jo.getString("base_unit_id"));
|
||||
change_jo.put("qty_unit_name", unit.getString("unit_name"));
|
||||
change_jo.put("qty", container_row.getString("net_weight"));
|
||||
WQLObject.getWQLObject("ST_IVT_StructIvtChangeDtl").insert(change_jo);
|
||||
total_qty += container_row.getDoubleValue("net_weight");
|
||||
detail_count += 1;
|
||||
}
|
||||
}
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
JSONObject mst_jo = new JSONObject();
|
||||
mst_jo.put("changeinv_id", changeinv_id);
|
||||
mst_jo.put("bill_code", CodeUtil.getNewCode("CHANGE_CODE"));
|
||||
mst_jo.put("buss_type", "2001");
|
||||
mst_jo.put("bill_type", "2001");
|
||||
mst_jo.put("biz_date", DateUtil.today());
|
||||
mst_jo.put("stor_id", jsonStor.getString("stor_id"));
|
||||
mst_jo.put("stor_code", jsonStor.getString("stor_code"));
|
||||
mst_jo.put("stor_name", jsonStor.getString("stor_name"));
|
||||
mst_jo.put("total_qty", total_qty);
|
||||
mst_jo.put("detail_count", detail_count);
|
||||
mst_jo.put("bill_status", "10");
|
||||
mst_jo.put("create_mode", "03");
|
||||
mst_jo.put("input_optid", currentUserId + "");
|
||||
mst_jo.put("input_optname", nickName);
|
||||
mst_jo.put("input_time", now);
|
||||
mst_jo.put("update_optid", currentUserId + "");
|
||||
mst_jo.put("update_optname", nickName);
|
||||
mst_jo.put("update_time", now);
|
||||
mst_jo.put("is_delete", "0");
|
||||
mst_jo.put("is_upload", "0");
|
||||
Long deptId = SecurityUtils.getDeptId();
|
||||
mst_jo.put("sysdeptid", deptId + "");
|
||||
mst_jo.put("syscompanyid", deptId + "");
|
||||
WQLObject.getWQLObject("ST_IVT_StructIvtChange").insert(mst_jo);
|
||||
}
|
||||
result.put("RTYPE", "S");
|
||||
result.put("RTMSG", "操作成功!");
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
} catch (Exception e) {
|
||||
result.put("RTYPE", "E");
|
||||
result.put("RTMSG", "操作失败!," + e.getMessage());
|
||||
result.put("RTOAL", 0);
|
||||
result.put("RTDAT", null);
|
||||
}
|
||||
// }
|
||||
log.info("inventoryTransferInfoSync接口输出参数为:-------------------" + result.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getMaterialInfo(JSONObject jo) {
|
||||
JSONArray rows = jo.getJSONArray("DATAS");
|
||||
|
||||
Reference in New Issue
Block a user