修改:部分回滚和新增纸管库

This commit is contained in:
2023-05-08 11:04:25 +08:00
parent 6f02e3a418
commit adeab1ccea
12 changed files with 520 additions and 96 deletions

View File

@@ -139,5 +139,12 @@ public class WmsToAcsController {
return new ResponseEntity<>(wmsToAcsService.realTimefaultInfo(jo), HttpStatus.OK);
}
@PostMapping("/PaperTubeAction")
@Log(value = "LMS下发纸管库指令", isInterfaceLog = true, interfaceLogType = InterfaceLogType.LMS_TO_ACS)
@ApiOperation("LMS下发纸管库指令")
public ResponseEntity<Object> PaperTubeAction(@RequestBody JSONObject jo) {
return new ResponseEntity<>(wmsToAcsService.PaperTubeAction(jo), HttpStatus.OK);
}
}

View File

@@ -110,4 +110,11 @@ public interface WmsToAcsService {
* @return JSONObject
*/
JSONObject realTimefaultInfo(JSONObject jo);
/**
* LMS下发纸管库指令
* @param jo /
* @return JSONObject
*/
JSONObject PaperTubeAction(JSONObject jo);
}

View File

@@ -106,7 +106,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("下发失败:"+result.getString("message"));
throw new BadRequestException("下发失败:" + result.getString("message"));
}
return result;
}
@@ -145,7 +145,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("解锁失败:"+result.getString("message"));
throw new BadRequestException("解锁失败:" + result.getString("message"));
}
return result;
}
@@ -243,8 +243,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
ArrLk.add(json);
}
}
nowJson.put("jsonA1",ArrA1);
nowJson.put("jsonLK",ArrLk);
nowJson.put("jsonA1", ArrA1);
nowJson.put("jsonLK", ArrLk);
result.put("data", nowJson);
} catch (Exception e) {
@@ -258,7 +258,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("查询失败:"+result.getString("message"));
throw new BadRequestException("查询失败:" + result.getString("message"));
}
return result;
}
@@ -315,7 +315,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("下发失败:"+result.getString("message"));
throw new BadRequestException("下发失败:" + result.getString("message"));
}
return result;
}
@@ -354,7 +354,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("同步失败:"+result.getString("message"));
throw new BadRequestException("同步失败:" + result.getString("message"));
}
return result;
}
@@ -392,7 +392,45 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("同步失败:"+result.getString("message"));
throw new BadRequestException("同步失败:" + result.getString("message"));
}
return result;
}
@Override
public JSONObject PaperTubeAction(JSONObject jo) {
String api = "api/wms/paperTubeAction";
//判断是否连接ACS系统
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("is_connect_acs").getValue();
JSONObject result = new JSONObject();
if (StrUtil.equals("0", isConnect)) {
result.put("status", HttpStatus.OK.value());
result.put("message", "下发成功但未连接ACS!");
result.put("data", new JSONArray());
return result;
}
//ACS地址127.0.0.1:8010
String acsUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("acs_url").getValue();
String url = acsUrl + api;
try {
String resultMsg = HttpRequest.post(url)
.body(String.valueOf(jo))
.execute().body();
result = JSONObject.parseObject(resultMsg);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
result.put("status", HttpStatus.BAD_REQUEST);
result.put("message", "网络不通,操作失败!");
result.put("data", new JSONArray());
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("同步失败:" + result.getString("message"));
}
return result;
}

View File

@@ -0,0 +1,54 @@
package org.nl.wms.pda.mps.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.logging.annotation.Log;
import org.nl.wms.pda.mps.service.PaperTubeService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@Api(tags = "纸管库管理")
@RequestMapping("api/pda/paper")
@Slf4j
public class PaperTubeController {
private final PaperTubeService paperTubeService;
@PostMapping("/queryDeviceList")
@Log("查询纸管库设备")
@ApiOperation("查询纸管库设备")
public ResponseEntity<Object> queryDeviceList(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(paperTubeService.queryDeviceList(whereJson), HttpStatus.OK);
}
@PostMapping("/queryPaperMaterial")
@Log("查询纸管物料")
@ApiOperation("查询纸管物料")
public ResponseEntity<Object> queryPaperMaterial(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(paperTubeService.queryPaperMaterial(whereJson), HttpStatus.OK);
}
@PostMapping("/PaperDeviceOperate")
@Log("纸管库操作")
@ApiOperation("纸管库操作")
public ResponseEntity<Object> PaperDeviceOperate(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(paperTubeService.PaperDeviceOperate(whereJson), HttpStatus.OK);
}
@PostMapping("/queryPaperTubeInfo")
@Log("查询纸管库信息")
@ApiOperation("查询纸管库信息")
public ResponseEntity<Object> queryPaperTubeInfo(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(paperTubeService.queryPaperTubeInfo(whereJson), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,40 @@
package org.nl.wms.pda.mps.service;
import com.alibaba.fastjson.JSONObject;
public interface PaperTubeService {
/**
* 查询纸管库设备
*
* @param whereJson /
* @return JSONObject
*/
JSONObject queryDeviceList(JSONObject whereJson);
/**
* 查询纸管、FRP管物料
*
* @param whereJson /
* @return JSONObject
*/
JSONObject queryPaperMaterial(JSONObject whereJson);
/**
* 对纸管库设备进行操作
* type:1、设置物料2、出库
*
* @param whereJson /
* @return JSONObject
*/
JSONObject PaperDeviceOperate(JSONObject whereJson);
/**
* 查询纸管库库存
*
* @param whereJson /
* @return JSONObject
*/
JSONObject queryPaperTubeInfo(JSONObject whereJson);
}

View File

@@ -0,0 +1,137 @@
package org.nl.wms.pda.mps.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.utils.SecurityUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.impl.WmsToAcsServiceImpl;
import org.nl.wms.pda.mps.eum.RegionTypeEnum;
import org.nl.wms.pda.mps.service.BakingService;
import org.nl.wms.pda.mps.service.PaperTubeService;
import org.nl.wms.sch.tasks.CutConveyorTask;
import org.nl.wms.sch.tasks.InCoolIvtTask;
import org.nl.wms.sch.tasks.InHotTask;
import org.nl.wms.sch.tasks.OutHotTask;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
@Service
@RequiredArgsConstructor
@Slf4j
public class PaperTubeServiceImpl implements PaperTubeService {
private final WmsToAcsService wmsToAcsService;
@Override
public JSONObject queryDeviceList(JSONObject whereJson) {
String product_area = whereJson.getString("product_area");
HashMap<String, String> map = new HashMap();
if (StrUtil.isNotEmpty(product_area)) {
map.put("product_area", product_area);
}
map.put("flag", "21");
JSONArray rows = WQL.getWO("PDA_02").addParamMap(map).process().getResultJSONArray(0);
JSONObject result = new JSONObject();
result.put("rows", rows);
return result;
}
@Override
public JSONObject PaperDeviceOperate(JSONObject whereJson) {
String option = whereJson.getString("option");
if ("1".equals(option)) {
String device_code = whereJson.getString("device_code");
String material_code = whereJson.getString("material_code");
if (StrUtil.isEmpty(device_code)) {
throw new BadRequestException("设备不能为空!");
}
if (StrUtil.isEmpty(material_code)) {
throw new BadRequestException("物料不能为空!");
}
JSONObject jo = new JSONObject();
jo.put("device_code", device_code);
jo.put("material_code", material_code);
jo.put("type", "1");
wmsToAcsService.PaperTubeAction(jo);
}
if ("2".equals(option)) {
String device_code = whereJson.getString("device_code");
String material_code = whereJson.getString("material_code");
Integer qty = whereJson.getIntValue("qty");
if (StrUtil.isEmpty(device_code)) {
throw new BadRequestException("设备不能为空!");
}
if (StrUtil.isEmpty(material_code)) {
throw new BadRequestException("物料不能为空!");
}
if (qty <= 0) {
throw new BadRequestException("出库数量必须大于0");
}
JSONObject jo = new JSONObject();
jo.put("device_code", device_code);
jo.put("material_code", material_code);
jo.put("type", "2");
jo.put("qty", qty);
wmsToAcsService.PaperTubeAction(jo);
}
return null;
}
@Override
public JSONObject queryPaperTubeInfo(JSONObject whereJson) {
String product_area = whereJson.getString("product_area");
HashMap<String, String> map = new HashMap();
if (StrUtil.isNotEmpty(product_area)) {
map.put("product_area", product_area);
}
map.put("flag", "22");
JSONArray rows = WQL.getWO("PDA_02").addParamMap(map).process().getResultJSONArray(0);
JSONObject device_jo = wmsToAcsService.getPointStatus(rows);
JSONArray de_rows = new JSONArray();
if (device_jo.containsKey("data")) {
JSONArray ma_rows = device_jo.getJSONArray("data");
for (int i = 0; i < ma_rows.size(); i++) {
JSONObject row = ma_rows.getJSONObject(i);
String material_code = row.getString("material_code");
JSONObject mater = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '"+material_code+"'").uniqueResult(0);
if (!ObjectUtil.isEmpty(mater)){
row.put("material_name",mater.getString("material_name"));
}
de_rows.add(row);
}
}
JSONObject result = new JSONObject();
result.put("rows", de_rows);
return result;
}
@Override
public JSONObject queryPaperMaterial(JSONObject whereJson) {
String material_code = whereJson.getString("material_code");
HashMap map = new HashMap();
if (StrUtil.isNotEmpty(material_code)) {
map.put("material_code", "%" + material_code + "%");
}
map.put("flag", "20");
JSONArray rows = WQL.getWO("PDA_02").addParamMap(map).process().getResultJSONArray(0);
JSONObject result = new JSONObject();
result.put("rows", rows);
return result;
}
}

View File

@@ -668,6 +668,55 @@
ENDQUERY
ENDIF
IF 输入.flag = "20"
QUERY
SELECT
material_code AS value,
material_name AS text
FROM
md_me_materialbase
WHERE
(material_code like '48221%'
OR
material_code like '701990999%')
OPTION 输入.material_code <> ""
material_code like 输入.material_code
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "21"
QUERY
SELECT
po.point_code AS value,
po.point_name AS text
FROM
sch_base_point po
WHERE
po.point_code LIKE '%ZGK%'
OPTION 输入.product_area <> ""
product_area = 输入.product_area
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "22"
QUERY
SELECT
po.point_code AS device_code
FROM
sch_base_point po
WHERE
po.point_code LIKE '%ZGK%'
OPTION 输入.product_area <> ""
product_area = 输入.product_area
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -22,7 +22,7 @@ import java.util.HashMap;
@Slf4j
public class AcsUtil {
public static JSONObject notifyAcs(String api, JSONArray list) {
log.info("下发ACS参数----------------------------------------+"+api+",---"+list.toString());
log.info("下发ACS参数----------------------------------------+" + api + ",---" + list.toString());
//判断是否连接ACS系统
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("is_connect_acs").getValue();
JSONObject result = new JSONObject();
@@ -42,7 +42,7 @@ public class AcsUtil {
.body(String.valueOf(list))
.execute().body();
result = JSONObject.parseObject(resultMsg);
log.info("ACS相应参数----------------------------------------+"+api+",---"+result.toString());
log.info("ACS相应参数----------------------------------------+" + api + ",---" + result.toString());
} catch (Exception e) {
String msg = e.getMessage();
@@ -55,15 +55,15 @@ public class AcsUtil {
}
//acs抛异常这里
if (!StrUtil.equals(result.getString("status"), "200")) {
throw new BadRequestException("下发失败:"+result.getString("message"));
}else {
throw new BadRequestException(result.toString());
} else {
//如果向ACS下发任务变更任务状态为下发
if (api.equals("api/wms/task")){
if (api.equals("api/wms/task")) {
for (int i = 0; i < list.size(); i++) {
JSONObject task_jo = list.getJSONObject(i);
HashMap<String,String> map = new HashMap<>();
HashMap<String, String> map = new HashMap<>();
map.put("task_status", TaskStatusEnum.ISSUE.getCode());
WQLObject.getWQLObject("SCH_BASE_Task").update(map,"task_id = '"+task_jo.getString("ext_task_id")+"'");
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + task_jo.getString("ext_task_id") + "'");
}
}
}

View File

@@ -1197,7 +1197,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
moveParam.put("jsonAllBlockPoint", jsonLockArr);
moveParam.put("is_move", "1");
moveParam.put("task_group_id", IdUtil.getSnowflake(1,1).nextId());
bean.createMove(moveParam);
bean.createMove(moveParam,null);
// 下发移库任务组
handMoveStorAcsTask.immediateNotifyAcs(null);

View File

@@ -39,6 +39,7 @@ import org.nl.wms.st.instor.service.HandMoveStorService;
import org.nl.wms.st.instor.service.impl.HandMoveStorServiceImpl;
import org.nl.wms.st.instor.task.HandMoveStorAcsTask;
import org.nl.wms.st.returns.service.impl.InAndOutRetrunServiceImpl;
import org.nl.wms.util.TranUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -51,6 +52,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Consumer;
/**
* PC端出入库新增
@@ -626,7 +629,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
// 任务为下发之后就不允许取消
if (jsonTask.getIntValue("task_status") > Integer.valueOf(TaskStatusEnum.START_AND_POINT.getCode())) {
throw new BadRequestException("任务:"+jsonTask.getString("task_code")+"已下发,不可取消");
throw new BadRequestException("任务:" + jsonTask.getString("task_code") + "已下发,不可取消");
}
// 更新分配明细 任务状态、清空任务id
@@ -1936,8 +1939,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
//仓位表
WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr");
// 库存表
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
String struct_id = whereJson.getString("struct_id");
String point_code = whereJson.getString("point_code"); // 终点
@@ -2606,78 +2607,95 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
+ "' and row_num = '" + jsonRow.getString("row_num") + "' and is_used = '1' and is_delete = '0' and lock_type not in ('1','6','3')").getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(structArr)) {
throw new BadRequestException(jsonRow.getString("block_num")+"区-"+jsonRow.getString("row_num")+"排有未完成的入库任务!");
throw new BadRequestException(jsonRow.getString("block_num") + "区-" + jsonRow.getString("row_num") + "排有未完成的入库任务!");
}
}
if (checked) {
// 查询此明细所有的层
JSONArray layerArr = WQL.getWO("ST_OUTIVT04")
.addParam("flag", "9")
.addParam("iostorinv_id", iostorinv_id)
.process()
.getResultJSONArray(0);
ArrayList<String> arr = new ArrayList<>();
TranUtil.openTransaction((req, allTransactionConsumer) -> {
try {
if (checked) {
// 查询此明细所有的层
JSONArray layerArr = WQL.getWO("ST_OUTIVT04")
.addParam("flag", "9")
.addParam("iostorinv_id", iostorinv_id)
.process()
.getResultJSONArray(0);
for (int i = 0; i < layerArr.size(); i++) {
JSONObject json = layerArr.getJSONObject(i);
for (int i = 0; i < layerArr.size(); i++) {
JSONObject json = layerArr.getJSONObject(i);
String layer_num = json.getString("layer_num");
String layer_num = json.getString("layer_num");
String out_point = "";
String out_point = "";
switch (layer_num) {
case "1" :
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue();
break;
case "2" :
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue();
break;
case "3" :
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue();
break;
switch (layer_num) {
case "1":
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue();
break;
case "2":
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue();
break;
case "3":
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue();
break;
}
// 将这一巷道的所有木箱进行移库
JSONObject jsonNextPoint = attrTab.query("struct_code = '" + out_point + "'").uniqueResult(0);
JSONObject map2 = new JSONObject();
map2.put("block_num", jsonNextPoint.getString("block_num"));
map2.put("row_num", jsonNextPoint.getString("row_num"));
map2.put("out_order_seq", jsonNextPoint.getString("out_order_seq"));
map2.put("flag", "7");
JSONArray paramMoveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map2).process().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(paramMoveArr)) {
JSONObject moveParam = new JSONObject();
moveParam.put("jsonAllBlockPoint", paramMoveArr);
moveParam.put("task_group_id", IdUtil.getSnowflake(1, 1).nextId());
this.createMove(moveParam, allTransactionConsumer);
new HandMoveStorAcsTask().immediateNotifyAcs(null);
// 更新任务为下发
JSONObject param = new JSONObject();
param.put("task_status", TaskStatusEnum.ISSUE.getCode());
wo_Task.update(param, "task_group_id = '" + moveParam.getString("task_group_id") + "'");
}
}
}
// 将这一巷道的所有木箱进行移库
JSONObject jsonNextPoint = attrTab.query("struct_code = '" + out_point + "'").uniqueResult(0);
JSONObject map2 = new JSONObject();
map2.put("block_num", jsonNextPoint.getString("block_num"));
map2.put("row_num", jsonNextPoint.getString("row_num"));
map2.put("out_order_seq", jsonNextPoint.getString("out_order_seq"));
map2.put("flag", "7");
JSONArray paramMoveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map2).process().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(paramMoveArr)) {
JSONObject moveParam = new JSONObject();
moveParam.put("jsonAllBlockPoint", paramMoveArr);
moveParam.put("task_group_id", IdUtil.getSnowflake(1,1).nextId());
this.createMove(moveParam);
new HandMoveStorAcsTask().immediateNotifyAcs(null);
// 更新任务为下发
JSONObject param = new JSONObject();
param.put("task_status", TaskStatusEnum.ISSUE.getCode());
wo_Task.update(param,"task_group_id = '"+moveParam.getString("task_group_id")+"'");
for (int i = 0; i < allRowArr.size(); i++) {
// 调用当前排处理方法
JSONObject jsonRow = allRowArr.getJSONObject(i);
jsonRow.put("iostorinv_id", iostorinv_id);
jsonRow.put("point_code", point_code);
jsonRow.put("checked", checked);
jsonRow.put("iostorinvdtl_id", iostorinvdtl_id);
jsonRow.put("point_id", jsonPoint2.getString("point_id"));
this.rowDispose(jsonRow, allTransactionConsumer);
}
} catch (Exception e) {
JSONObject result = (JSONObject) JSONObject.parse(e.getMessage());
if (result.containsKey("errArr")) {
JSONArray errArr = result.getJSONArray("errArr");
for (int i = 0; i < errArr.size(); i++) {
JSONObject err_jo = errArr.getJSONObject(i);
arr.add(err_jo.getJSONObject("data").getString("start_device_code"));
}
} else {
throw new BadRequestException(e.getMessage());
}
}
}
for (int i = 0; i < allRowArr.size(); i++) {
// 调用当前排处理方法
JSONObject jsonRow = allRowArr.getJSONObject(i);
jsonRow.put("iostorinv_id", iostorinv_id);
jsonRow.put("point_code", point_code);
jsonRow.put("checked", checked);
jsonRow.put("iostorinvdtl_id", iostorinvdtl_id);
jsonRow.put("point_id", jsonPoint2.getString("point_id"));
this.rowDispose(jsonRow);
}
return arr;
}, new JSONArray());
}
@Transactional(rollbackFor = Exception.class)
public void rowDispose(JSONObject jsonRow) {
public void rowDispose(JSONObject jsonRow, Consumer<String> allTransactionConsumer) {
//出库分配表
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
//任务表
@@ -2940,13 +2958,15 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
// 创建任务组
long task_group_id = IdUtil.getSnowflake(1, 1).nextId();
/*-----------------------update开始------------------------------*/
// 判断是否需要生成移库
if (ObjectUtil.isNotEmpty(moveArr)) {
JSONObject moveParam = new JSONObject();
moveParam.put("jsonAllBlockPoint", moveArr);
moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id"));
moveParam.put("task_group_id", task_group_id);
this.createMove(moveParam);
this.createMove(moveParam, allTransactionConsumer);
}
// 判断是否是异常出库口
@@ -2957,21 +2977,22 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
String layer_num = jsonStartPoint.getString("layer_num");
switch (layer_num) {
case "1" :
case "1":
point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue();
break;
case "2" :
case "2":
point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue();
break;
case "3" :
case "3":
point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue();
break;
default:
throw new BadRequestException("起点楼层异常:"+jsonStartPoint.getString("struct_code"));
throw new BadRequestException("起点楼层异常:" + jsonStartPoint.getString("struct_code"));
}
point_id = point_tab.query("point_code = '"+point_code+"'").uniqueResult(0).getString("point_id");
point_id = point_tab.query("point_code = '" + point_code + "'").uniqueResult(0).getString("point_id");
}
allTransactionConsumer.accept(jsonObject.getString("struct_code"));
// 创建任务
JSONObject param = new JSONObject();
param.put("task_type", "010503");
@@ -3018,6 +3039,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
}
wo_Task.update(jsonTask);
outTask.immediateNotifyAcs(null);
/*
* 判断下一个出库仓位是否相邻
*/
@@ -3041,6 +3063,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
// 查询此任务组最后一个生成的任务
JSONObject jsonTaskLast = wo_Task.query("task_group_id = '" + task_group_id + "' order by sort_seq DESC").uniqueResult(0);
// 创建任务并添加到任务组
allTransactionConsumer.accept(jsonNext.getString("struct_code"));
JSONObject param2 = new JSONObject();
param2.put("task_type", "010503");
param2.put("vehicle_code", jsonNext.getString("box_no"));
@@ -3053,6 +3076,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
String create_task_id2 = outTask.createTask(param2);
outTask.immediateNotifyAcs(null);
// 更新分配状态、任务标识、出库点位
JSONObject jsonTask2 = wo_Task.query("task_id = '" + create_task_id2 + "'").uniqueResult(0);
JSONObject jsonUpdateMap2 = new JSONObject();
@@ -3093,7 +3118,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
task_group_id = IdUtil.getSnowflake(1, 1).nextId();
} else {
// 迭代调用自身
this.rowDispose(jsonRow);
this.rowDispose(jsonRow, allTransactionConsumer);
}
}
@@ -3376,7 +3401,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
moveParam.put("jsonAllBlockPoint", moveArr);
moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id"));
moveParam.put("task_group_id", task_group_id);
this.createMove(moveParam);
this.createMove(moveParam, null);
}
// 判断是否是异常出库口
@@ -3387,19 +3412,19 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
String layer_num = jsonStartPoint.getString("layer_num");
switch (layer_num) {
case "1" :
case "1":
point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue();
break;
case "2" :
case "2":
point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue();
break;
case "3" :
case "3":
point_code = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue();
break;
default:
throw new BadRequestException("起点楼层异常:"+jsonStartPoint.getString("struct_code"));
throw new BadRequestException("起点楼层异常:" + jsonStartPoint.getString("struct_code"));
}
point_id = wo_Point.query("point_code = '"+point_code+"'").uniqueResult(0).getString("point_id");
point_id = wo_Point.query("point_code = '" + point_code + "'").uniqueResult(0).getString("point_id");
}
// 创建任务
@@ -3526,7 +3551,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
}
@Transactional(rollbackFor = Exception.class)
public void createMove(JSONObject whereJson) {
public void createMove(JSONObject whereJson, Consumer<String> allTransactionConsumer) {
//任务表
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
@@ -3537,6 +3562,9 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
for (int i = 0; i < jsonAllBlockPoint.size(); i++) {
JSONObject json = jsonAllBlockPoint.getJSONObject(i);
if (ObjectUtil.isNotEmpty(allTransactionConsumer)) {
allTransactionConsumer.accept(json.getString("struct_code"));
}
JSONObject jsonAttr = attrTab.query("struct_code = '" + json.getString("struct_code") + "'").uniqueResult(0);
JSONObject mapParam = new JSONObject();// 生成移库单传入参数
@@ -3603,6 +3631,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
param2.put("sort_seq", i + 1); // 任务组顺序号
String move_task_id = outTask.createTask(param2);
new HandMoveStorAcsTask().immediateNotifyAcs(null);
// 回显移库明细任务id
jsonMoveDtl.put("task_id", move_task_id);
table.add(jsonMoveDtl);
@@ -4139,7 +4169,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
// 更新对应任务为完成
JSONObject jsonTask = taskTab.query("task_id = '" + jsonDis.getString("task_id") + "' and task_status < '07'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonTask)) {
jsonTask.put("task_status",TaskStatusEnum.FINISHED.getCode());
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
taskTab.update(jsonTask);
}
@@ -4237,9 +4267,9 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
if (ObjectUtil.isEmpty(jsonPlan)) throw new BadRequestException("未找到对应改制计划");
JSONObject map = new JSONObject();
map.put("is_parent_ok","1");
map.put("is_parent_ok", "1");
WQLObject.getWQLObject("PDM_BI_SlittingProductionPlan").update(map,"package_box_sn = '"+source_dtl.getString("box_no")+"'");
WQLObject.getWQLObject("PDM_BI_SlittingProductionPlan").update(map, "package_box_sn = '" + source_dtl.getString("box_no") + "'");
}
@@ -4772,7 +4802,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); // 子卷包装关系表
WQLObject tranTab = WQLObject.getWQLObject("MD_CS_TransportationBase"); // 物流公司表
WQLObject storTab = WQLObject.getWQLObject("st_ivt_bsrealstorattr"); // 实物仓库表
JSONObject jsonMst = mstTab.query("iostorinv_id = '" + MapUtil.getStr(whereJson, "iostorinv_id") + "'").uniqueResult(0);
String cust_code = jsonMst.getString("cust_code");

View File

@@ -0,0 +1,62 @@
package org.nl.wms.util;
import com.alibaba.fastjson.JSONArray;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/*
* @author ZZQ
* @Date 2023/4/24 16:39
*/
public class TranUtil {
public static Object openTransaction(BiFunction<JSONArray, Consumer<String>, List> function, JSONArray request) {
PlatformTransactionManager txManager = SpringContextHolder.getBean(PlatformTransactionManager.class);
Map<String, TransactionStatus> statusMap = new HashMap<>();
Collection<TransactionStatus> commits = new ArrayList<>();
DefaultTransactionDefinition external = new DefaultTransactionDefinition();
external.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus externalStatus = txManager.getTransaction(external);
try {
//创建所有事务集合
Consumer<String> allTransactionConsumer = task -> {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus status = txManager.getTransaction(def);
statusMap.put(task, status);
};
//业务
List errTask = function.apply(request, allTransactionConsumer);
//过滤异常事务的任务id
List<TransactionStatus> collect = statusMap.entrySet().stream()
.filter(tmap -> !errTask.contains(tmap.getKey()))
.map(tmap -> tmap.getValue())
.collect(Collectors.toList());
commits = statusMap.values();
commits.removeAll(collect);
for (TransactionStatus status : collect) {
txManager.commit(status);
}
} finally {
//释放剩余资源
if (!CollectionUtils.isEmpty(commits)) {
for (TransactionStatus commit : commits) {
txManager.rollback(commit);
}
}
txManager.commit(externalStatus);
}
return null;
}
}