修改:部分回滚和新增纸管库
This commit is contained in:
@@ -139,5 +139,12 @@ public class WmsToAcsController {
|
|||||||
return new ResponseEntity<>(wmsToAcsService.realTimefaultInfo(jo), HttpStatus.OK);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,4 +110,11 @@ public interface WmsToAcsService {
|
|||||||
* @return JSONObject
|
* @return JSONObject
|
||||||
*/
|
*/
|
||||||
JSONObject realTimefaultInfo(JSONObject jo);
|
JSONObject realTimefaultInfo(JSONObject jo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LMS下发纸管库指令
|
||||||
|
* @param jo /
|
||||||
|
* @return JSONObject
|
||||||
|
*/
|
||||||
|
JSONObject PaperTubeAction(JSONObject jo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -397,4 +397,42 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
|||||||
return result;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -668,6 +668,55 @@
|
|||||||
ENDQUERY
|
ENDQUERY
|
||||||
ENDIF
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class AcsUtil {
|
|||||||
}
|
}
|
||||||
//acs抛异常这里
|
//acs抛异常这里
|
||||||
if (!StrUtil.equals(result.getString("status"), "200")) {
|
if (!StrUtil.equals(result.getString("status"), "200")) {
|
||||||
throw new BadRequestException("下发失败:"+result.getString("message"));
|
throw new BadRequestException(result.toString());
|
||||||
} else {
|
} else {
|
||||||
//如果向ACS下发任务,变更任务状态为下发
|
//如果向ACS下发任务,变更任务状态为下发
|
||||||
if (api.equals("api/wms/task")) {
|
if (api.equals("api/wms/task")) {
|
||||||
|
|||||||
@@ -1197,7 +1197,7 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
|
|||||||
moveParam.put("jsonAllBlockPoint", jsonLockArr);
|
moveParam.put("jsonAllBlockPoint", jsonLockArr);
|
||||||
moveParam.put("is_move", "1");
|
moveParam.put("is_move", "1");
|
||||||
moveParam.put("task_group_id", IdUtil.getSnowflake(1,1).nextId());
|
moveParam.put("task_group_id", IdUtil.getSnowflake(1,1).nextId());
|
||||||
bean.createMove(moveParam);
|
bean.createMove(moveParam,null);
|
||||||
|
|
||||||
// 下发移库任务组
|
// 下发移库任务组
|
||||||
handMoveStorAcsTask.immediateNotifyAcs(null);
|
handMoveStorAcsTask.immediateNotifyAcs(null);
|
||||||
|
|||||||
@@ -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.service.impl.HandMoveStorServiceImpl;
|
||||||
import org.nl.wms.st.instor.task.HandMoveStorAcsTask;
|
import org.nl.wms.st.instor.task.HandMoveStorAcsTask;
|
||||||
import org.nl.wms.st.returns.service.impl.InAndOutRetrunServiceImpl;
|
import org.nl.wms.st.returns.service.impl.InAndOutRetrunServiceImpl;
|
||||||
|
import org.nl.wms.util.TranUtil;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -51,6 +52,8 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PC端出入库新增
|
* PC端出入库新增
|
||||||
@@ -1936,8 +1939,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
||||||
//仓位表
|
//仓位表
|
||||||
WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||||
// 库存表
|
|
||||||
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
|
|
||||||
|
|
||||||
String struct_id = whereJson.getString("struct_id");
|
String struct_id = whereJson.getString("struct_id");
|
||||||
String point_code = whereJson.getString("point_code"); // 终点
|
String point_code = whereJson.getString("point_code"); // 终点
|
||||||
@@ -2610,6 +2611,9 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<String> arr = new ArrayList<>();
|
||||||
|
TranUtil.openTransaction((req, allTransactionConsumer) -> {
|
||||||
|
try {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
// 查询此明细所有的层
|
// 查询此明细所有的层
|
||||||
JSONArray layerArr = WQL.getWO("ST_OUTIVT04")
|
JSONArray layerArr = WQL.getWO("ST_OUTIVT04")
|
||||||
@@ -2652,7 +2656,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
JSONObject moveParam = new JSONObject();
|
JSONObject moveParam = new JSONObject();
|
||||||
moveParam.put("jsonAllBlockPoint", paramMoveArr);
|
moveParam.put("jsonAllBlockPoint", paramMoveArr);
|
||||||
moveParam.put("task_group_id", IdUtil.getSnowflake(1, 1).nextId());
|
moveParam.put("task_group_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||||
this.createMove(moveParam);
|
this.createMove(moveParam, allTransactionConsumer);
|
||||||
|
|
||||||
new HandMoveStorAcsTask().immediateNotifyAcs(null);
|
new HandMoveStorAcsTask().immediateNotifyAcs(null);
|
||||||
|
|
||||||
@@ -2672,12 +2676,26 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
jsonRow.put("checked", checked);
|
jsonRow.put("checked", checked);
|
||||||
jsonRow.put("iostorinvdtl_id", iostorinvdtl_id);
|
jsonRow.put("iostorinvdtl_id", iostorinvdtl_id);
|
||||||
jsonRow.put("point_id", jsonPoint2.getString("point_id"));
|
jsonRow.put("point_id", jsonPoint2.getString("point_id"));
|
||||||
this.rowDispose(jsonRow);
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}, new JSONArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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");
|
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();
|
long task_group_id = IdUtil.getSnowflake(1, 1).nextId();
|
||||||
|
|
||||||
|
/*-----------------------update开始------------------------------*/
|
||||||
|
|
||||||
// 判断是否需要生成移库
|
// 判断是否需要生成移库
|
||||||
if (ObjectUtil.isNotEmpty(moveArr)) {
|
if (ObjectUtil.isNotEmpty(moveArr)) {
|
||||||
JSONObject moveParam = new JSONObject();
|
JSONObject moveParam = new JSONObject();
|
||||||
moveParam.put("jsonAllBlockPoint", moveArr);
|
moveParam.put("jsonAllBlockPoint", moveArr);
|
||||||
moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id"));
|
moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id"));
|
||||||
moveParam.put("task_group_id", task_group_id);
|
moveParam.put("task_group_id", task_group_id);
|
||||||
this.createMove(moveParam);
|
this.createMove(moveParam, allTransactionConsumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断是否是异常出库口
|
// 判断是否是异常出库口
|
||||||
@@ -2972,6 +2992,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
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();
|
JSONObject param = new JSONObject();
|
||||||
param.put("task_type", "010503");
|
param.put("task_type", "010503");
|
||||||
@@ -3018,6 +3039,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
}
|
}
|
||||||
wo_Task.update(jsonTask);
|
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);
|
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();
|
JSONObject param2 = new JSONObject();
|
||||||
param2.put("task_type", "010503");
|
param2.put("task_type", "010503");
|
||||||
param2.put("vehicle_code", jsonNext.getString("box_no"));
|
param2.put("vehicle_code", jsonNext.getString("box_no"));
|
||||||
@@ -3053,6 +3076,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
|
|
||||||
String create_task_id2 = outTask.createTask(param2);
|
String create_task_id2 = outTask.createTask(param2);
|
||||||
|
|
||||||
|
outTask.immediateNotifyAcs(null);
|
||||||
|
|
||||||
// 更新分配状态、任务标识、出库点位
|
// 更新分配状态、任务标识、出库点位
|
||||||
JSONObject jsonTask2 = wo_Task.query("task_id = '" + create_task_id2 + "'").uniqueResult(0);
|
JSONObject jsonTask2 = wo_Task.query("task_id = '" + create_task_id2 + "'").uniqueResult(0);
|
||||||
JSONObject jsonUpdateMap2 = new JSONObject();
|
JSONObject jsonUpdateMap2 = new JSONObject();
|
||||||
@@ -3093,7 +3118,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
task_group_id = IdUtil.getSnowflake(1, 1).nextId();
|
task_group_id = IdUtil.getSnowflake(1, 1).nextId();
|
||||||
} else {
|
} else {
|
||||||
// 迭代调用自身
|
// 迭代调用自身
|
||||||
this.rowDispose(jsonRow);
|
this.rowDispose(jsonRow, allTransactionConsumer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3376,7 +3401,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
moveParam.put("jsonAllBlockPoint", moveArr);
|
moveParam.put("jsonAllBlockPoint", moveArr);
|
||||||
moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id"));
|
moveParam.put("iostorinvdis_id", jsonObject.getString("iostorinvdis_id"));
|
||||||
moveParam.put("task_group_id", task_group_id);
|
moveParam.put("task_group_id", task_group_id);
|
||||||
this.createMove(moveParam);
|
this.createMove(moveParam, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断是否是异常出库口
|
// 判断是否是异常出库口
|
||||||
@@ -3526,7 +3551,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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 wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||||
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
|
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
|
||||||
@@ -3537,6 +3562,9 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
for (int i = 0; i < jsonAllBlockPoint.size(); i++) {
|
for (int i = 0; i < jsonAllBlockPoint.size(); i++) {
|
||||||
JSONObject json = jsonAllBlockPoint.getJSONObject(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 jsonAttr = attrTab.query("struct_code = '" + json.getString("struct_code") + "'").uniqueResult(0);
|
||||||
|
|
||||||
JSONObject mapParam = new JSONObject();// 生成移库单传入参数
|
JSONObject mapParam = new JSONObject();// 生成移库单传入参数
|
||||||
@@ -3603,6 +3631,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
param2.put("sort_seq", i + 1); // 任务组顺序号
|
param2.put("sort_seq", i + 1); // 任务组顺序号
|
||||||
String move_task_id = outTask.createTask(param2);
|
String move_task_id = outTask.createTask(param2);
|
||||||
|
|
||||||
|
new HandMoveStorAcsTask().immediateNotifyAcs(null);
|
||||||
|
|
||||||
// 回显移库明细任务id
|
// 回显移库明细任务id
|
||||||
jsonMoveDtl.put("task_id", move_task_id);
|
jsonMoveDtl.put("task_id", move_task_id);
|
||||||
table.add(jsonMoveDtl);
|
table.add(jsonMoveDtl);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -640,7 +640,7 @@ export default {
|
|||||||
'checked': this.checked
|
'checked': this.checked
|
||||||
}
|
}
|
||||||
checkoutbill.allSetPoint(data).then(res => {
|
checkoutbill.allSetPoint(data).then(res => {
|
||||||
// this.queryTableDdis(this.currentRow.iostorinvdtl_id)
|
this.queryTableDdis(this.currentRow.iostorinvdtl_id)
|
||||||
this.crud.notify('设置成功!', CRUD.NOTIFICATION_TYPE.INFO)
|
this.crud.notify('设置成功!', CRUD.NOTIFICATION_TYPE.INFO)
|
||||||
this.loadingSetAllPoint = false
|
this.loadingSetAllPoint = false
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user