fix:部分事务回滚、纸管库操作提示、系统参数操作不显示
This commit is contained in:
@@ -16,6 +16,7 @@ import org.springframework.cache.annotation.CacheConfig;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -98,6 +99,7 @@ public class GenCodeServiceImpl implements GenCodeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||||
public String codeDemo(Map form) {
|
public String codeDemo(Map form) {
|
||||||
String code = (String) form.get("code");
|
String code = (String) form.get("code");
|
||||||
String id = this.queryIdByCode(code);
|
String id = this.queryIdByCode(code);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class PaperTubeServiceImpl implements PaperTubeService {
|
|||||||
JSONArray rows = WQL.getWO("PDA_02").addParamMap(map).process().getResultJSONArray(0);
|
JSONArray rows = WQL.getWO("PDA_02").addParamMap(map).process().getResultJSONArray(0);
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("rows", rows);
|
result.put("rows", rows);
|
||||||
|
result.put("message", "查询成功!");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +91,9 @@ public class PaperTubeServiceImpl implements PaperTubeService {
|
|||||||
jo.put("qty", qty);
|
jo.put("qty", qty);
|
||||||
wmsToAcsService.PaperTubeAction(jo);
|
wmsToAcsService.PaperTubeAction(jo);
|
||||||
}
|
}
|
||||||
return null;
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("message", "操作成功!");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -118,6 +121,7 @@ public class PaperTubeServiceImpl implements PaperTubeService {
|
|||||||
}
|
}
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("rows", de_rows);
|
result.put("rows", de_rows);
|
||||||
|
result.put("message", "查询成功!");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +136,7 @@ public class PaperTubeServiceImpl implements PaperTubeService {
|
|||||||
JSONArray rows = WQL.getWO("PDA_02").addParamMap(map).process().getResultJSONArray(0);
|
JSONArray rows = WQL.getWO("PDA_02").addParamMap(map).process().getResultJSONArray(0);
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("rows", rows);
|
result.put("rows", rows);
|
||||||
|
result.put("message", "查询成功!");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public class AcsUtil {
|
|||||||
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("is_connect_acs").getValue();
|
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("is_connect_acs").getValue();
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
if (StrUtil.equals("0", isConnect)) {
|
if (StrUtil.equals("0", isConnect)) {
|
||||||
|
|
||||||
result.put("status", HttpStatus.OK.value());
|
result.put("status", HttpStatus.OK.value());
|
||||||
result.put("message", "下发成功,但未连接ACS!");
|
result.put("message", "下发成功,但未连接ACS!");
|
||||||
result.put("data", new JSONObject());
|
result.put("data", new JSONObject());
|
||||||
@@ -55,7 +56,7 @@ public class AcsUtil {
|
|||||||
}
|
}
|
||||||
//acs抛异常这里
|
//acs抛异常这里
|
||||||
if (!StrUtil.equals(result.getString("status"), "200")) {
|
if (!StrUtil.equals(result.getString("status"), "200")) {
|
||||||
throw new BadRequestException(result.toString());
|
throw new BadRequestException(result.getString("message"));
|
||||||
} else {
|
} else {
|
||||||
//如果向ACS下发任务,变更任务状态为下发
|
//如果向ACS下发任务,变更任务状态为下发
|
||||||
if (api.equals("api/wms/task")) {
|
if (api.equals("api/wms/task")) {
|
||||||
|
|||||||
@@ -186,7 +186,6 @@ public class OutTask extends AbstractAcsTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public String createTask(JSONObject form) {
|
public String createTask(JSONObject form) {
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ import java.math.BigDecimal;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PC端出入库新增
|
* PC端出入库新增
|
||||||
@@ -2613,82 +2615,69 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
|
|
||||||
ArrayList<String> arr = new ArrayList<>();
|
ArrayList<String> arr = new ArrayList<>();
|
||||||
TranUtil.openTransaction((req, allTransactionConsumer) -> {
|
TranUtil.openTransaction((req, allTransactionConsumer) -> {
|
||||||
try {
|
if (checked) {
|
||||||
if (checked) {
|
// 查询此明细所有的层
|
||||||
// 查询此明细所有的层
|
JSONArray layerArr = WQL.getWO("ST_OUTIVT04")
|
||||||
JSONArray layerArr = WQL.getWO("ST_OUTIVT04")
|
.addParam("flag", "9")
|
||||||
.addParam("flag", "9")
|
.addParam("iostorinv_id", iostorinv_id)
|
||||||
.addParam("iostorinv_id", iostorinv_id)
|
.process()
|
||||||
.process()
|
.getResultJSONArray(0);
|
||||||
.getResultJSONArray(0);
|
|
||||||
|
|
||||||
for (int i = 0; i < layerArr.size(); i++) {
|
for (int i = 0; i < layerArr.size(); i++) {
|
||||||
JSONObject json = layerArr.getJSONObject(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) {
|
switch (layer_num) {
|
||||||
case "1":
|
case "1":
|
||||||
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue();
|
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_1").getValue();
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue();
|
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_2").getValue();
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue();
|
out_point = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("out_point_3").getValue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将这一巷道的所有木箱进行移库
|
// 将这一巷道的所有木箱进行移库
|
||||||
JSONObject jsonNextPoint = attrTab.query("struct_code = '" + out_point + "'").uniqueResult(0);
|
JSONObject jsonNextPoint = attrTab.query("struct_code = '" + out_point + "'").uniqueResult(0);
|
||||||
|
|
||||||
JSONObject map2 = new JSONObject();
|
JSONObject map2 = new JSONObject();
|
||||||
map2.put("block_num", jsonNextPoint.getString("block_num"));
|
map2.put("block_num", jsonNextPoint.getString("block_num"));
|
||||||
map2.put("row_num", jsonNextPoint.getString("row_num"));
|
map2.put("row_num", jsonNextPoint.getString("row_num"));
|
||||||
map2.put("out_order_seq", jsonNextPoint.getString("out_order_seq"));
|
map2.put("out_order_seq", jsonNextPoint.getString("out_order_seq"));
|
||||||
|
|
||||||
map2.put("flag", "7");
|
map2.put("flag", "7");
|
||||||
JSONArray paramMoveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map2).process().getResultJSONArray(0);
|
JSONArray paramMoveArr = WQL.getWO("ST_OUTIVT04").addParamMap(map2).process().getResultJSONArray(0);
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(paramMoveArr)) {
|
if (ObjectUtil.isNotEmpty(paramMoveArr)) {
|
||||||
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, allTransactionConsumer);
|
this.createMove(moveParam, allTransactionConsumer);
|
||||||
|
|
||||||
new HandMoveStorAcsTask().immediateNotifyAcs(null);
|
new HandMoveStorAcsTask().immediateNotifyAcs(null);
|
||||||
|
|
||||||
// 更新任务为下发
|
// 更新任务为下发
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
param.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
param.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
||||||
wo_Task.update(param, "task_group_id = '" + moveParam.getString("task_group_id") + "'");
|
wo_Task.update(param, "task_group_id = '" + moveParam.getString("task_group_id") + "'");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < allRowArr.size(); i++) {
|
for (int i = 0; i < allRowArr.size(); i++) {
|
||||||
// 调用当前排处理方法
|
// 调用当前排处理方法
|
||||||
JSONObject jsonRow = allRowArr.getJSONObject(i);
|
JSONObject jsonRow = allRowArr.getJSONObject(i);
|
||||||
jsonRow.put("iostorinv_id", iostorinv_id);
|
jsonRow.put("iostorinv_id", iostorinv_id);
|
||||||
jsonRow.put("point_code", point_code);
|
jsonRow.put("point_code", point_code);
|
||||||
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, allTransactionConsumer);
|
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;
|
return arr;
|
||||||
}, new JSONArray());
|
}, new JSONArray());
|
||||||
@@ -2934,9 +2923,13 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
/*
|
/*
|
||||||
* 生成任务
|
* 生成任务
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//已经生成任务的点位数组
|
||||||
|
JSONArray create_rows = new JSONArray();
|
||||||
boolean canOut = false;
|
boolean canOut = false;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
JSONObject jsonObject = disRowArrNew.getJSONObject(j);
|
JSONObject jsonObject = disRowArrNew.getJSONObject(j);
|
||||||
|
create_rows.add(disRowArrNew.getJSONObject(j));
|
||||||
|
|
||||||
// 查询未被锁住的仓位
|
// 查询未被锁住的仓位
|
||||||
JSONArray moveArr = new JSONArray();
|
JSONArray moveArr = new JSONArray();
|
||||||
@@ -2991,7 +2984,6 @@ 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"));
|
allTransactionConsumer.accept(jsonObject.getString("struct_code"));
|
||||||
// 创建任务
|
// 创建任务
|
||||||
JSONObject param = new JSONObject();
|
JSONObject param = new JSONObject();
|
||||||
@@ -3060,6 +3052,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
canAdd = false;
|
canAdd = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
create_rows.add(jsonNext);
|
||||||
// 查询此任务组最后一个生成的任务
|
// 查询此任务组最后一个生成的任务
|
||||||
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);
|
||||||
// 创建任务并添加到任务组
|
// 创建任务并添加到任务组
|
||||||
@@ -3109,6 +3102,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (canOut) {
|
if (canOut) {
|
||||||
// 下发当前任务组
|
// 下发当前任务组
|
||||||
outTask.immediateNotifyAcs(null);
|
outTask.immediateNotifyAcs(null);
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
package org.nl.wms.util;
|
package org.nl.wms.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
import org.springframework.transaction.TransactionDefinition;
|
import org.springframework.transaction.TransactionDefinition;
|
||||||
import org.springframework.transaction.TransactionStatus;
|
import org.springframework.transaction.TransactionStatus;
|
||||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||||
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -22,40 +25,50 @@ public class TranUtil {
|
|||||||
public static Object openTransaction(BiFunction<JSONArray, Consumer<String>, List> function, JSONArray request) {
|
public static Object openTransaction(BiFunction<JSONArray, Consumer<String>, List> function, JSONArray request) {
|
||||||
PlatformTransactionManager txManager = SpringContextHolder.getBean(PlatformTransactionManager.class);
|
PlatformTransactionManager txManager = SpringContextHolder.getBean(PlatformTransactionManager.class);
|
||||||
Map<String, TransactionStatus> statusMap = new HashMap<>();
|
Map<String, TransactionStatus> statusMap = new HashMap<>();
|
||||||
Collection<TransactionStatus> commits = new ArrayList<>();
|
LinkedList<TransactionStatus> commits = new LinkedList<>();
|
||||||
|
List errTask = new ArrayList();
|
||||||
|
|
||||||
DefaultTransactionDefinition external = new DefaultTransactionDefinition();
|
DefaultTransactionDefinition external = new DefaultTransactionDefinition();
|
||||||
external.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
external.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||||
|
external.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
|
||||||
TransactionStatus externalStatus = txManager.getTransaction(external);
|
TransactionStatus externalStatus = txManager.getTransaction(external);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//创建所有事务集合
|
//创建所有事务集合
|
||||||
Consumer<String> allTransactionConsumer = task -> {
|
Consumer<String> allTransactionConsumer = task -> {
|
||||||
|
System.out.println(TransactionSynchronizationManager.getCurrentTransactionName());
|
||||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||||
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||||
|
def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED);
|
||||||
TransactionStatus status = txManager.getTransaction(def);
|
TransactionStatus status = txManager.getTransaction(def);
|
||||||
statusMap.put(task, status);
|
statusMap.put(task, status);
|
||||||
|
commits.addLast(status);
|
||||||
};
|
};
|
||||||
//业务
|
//业务
|
||||||
List errTask = function.apply(request, allTransactionConsumer);
|
errTask = function.apply(request, allTransactionConsumer);
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
TransactionStatus transactionStatus = commits.removeLast();
|
||||||
|
txManager.rollback(transactionStatus);
|
||||||
|
throw new BadRequestException(ex.getMessage());
|
||||||
|
} finally {
|
||||||
//过滤异常事务的任务id
|
//过滤异常事务的任务id
|
||||||
|
/*List finalErrTask = errTask;
|
||||||
List<TransactionStatus> collect = statusMap.entrySet().stream()
|
List<TransactionStatus> collect = statusMap.entrySet().stream()
|
||||||
.filter(tmap -> !errTask.contains(tmap.getKey()))
|
.filter(tmap -> finalErrTask.contains(tmap.getKey()))
|
||||||
.map(tmap -> tmap.getValue())
|
.map(tmap -> tmap.getValue())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
commits = statusMap.values();
|
commits.removeAll(collect);*/
|
||||||
commits.removeAll(collect);
|
for (TransactionStatus status : commits) {
|
||||||
for (TransactionStatus status : collect) {
|
|
||||||
txManager.commit(status);
|
txManager.commit(status);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
//释放剩余资源
|
|
||||||
if (!CollectionUtils.isEmpty(commits)) {
|
|
||||||
for (TransactionStatus commit : commits) {
|
|
||||||
txManager.rollback(commit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
txManager.commit(externalStatus);
|
txManager.commit(externalStatus);
|
||||||
|
/* //释放剩余资源
|
||||||
|
if (!CollectionUtils.isEmpty(collect)) {
|
||||||
|
for (TransactionStatus err : collect) {
|
||||||
|
txManager.rollback(err);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
<el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column prop="value" label="值" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="value" label="值" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column v-permission="['admin','param:edit','param:del']" label="操作" width="150px" align="center">
|
<el-table-column label="操作" width="150px" align="center">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<udOperation
|
<udOperation
|
||||||
:data="scope.row"
|
:data="scope.row"
|
||||||
@@ -99,9 +99,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
permission: {
|
permission: {
|
||||||
add: ['admin', 'param:add'],
|
|
||||||
edit: ['admin', 'param:edit'],
|
|
||||||
del: ['admin', 'param:del']
|
|
||||||
},
|
},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
|
|||||||
Reference in New Issue
Block a user