代码修改

This commit is contained in:
2023-03-23 10:37:15 +08:00
parent 8e5e73b41b
commit a2ad0deafe
12 changed files with 120 additions and 116 deletions

View File

@@ -14,6 +14,8 @@ import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.WqlUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
@@ -96,78 +98,79 @@ public class GenCodeServiceImpl implements GenCodeService {
}
@Override
public synchronized String codeDemo(Map form) {
@Transactional(propagation=Propagation.REQUIRES_NEW)
public String codeDemo(Map form) {
String code = (String) form.get("code");
String id = this.queryIdByCode(code);
//如果flag=1就执行更新数据库的操作
String flag = (String) form.get("flag");
WQLObject wo = WQLObject.getWQLObject("sys_code_rule_detail");
JSONArray ja = wo.query("code_rule_id = '" + id + "'", " sort_num").getResultJSONArray(0);
String demo = "";
boolean is_same = true;
for (int i = 0; i < ja.size(); i++) {
String value = "";
JSONObject jo = ja.getJSONObject(i);
//固定直接取值
if (jo.getString("type").equals("01")) {
value = jo.getString("init_value");
}
//日期判断数据库的值与当前值是否相同来决定顺序的值
if (jo.getString("type").equals("02")) {
String current_value = jo.getString("current_value");
Date date = DateUtil.date();
String format = jo.getString("format");
String now_date = DateUtil.format(date, format);
if (!now_date.equals(current_value)) {
is_same = false;
String id = this.queryIdByCode(code);
//如果flag=1就执行更新数据库的操作
String flag = (String) form.get("flag");
WQLObject wo = WQLObject.getWQLObject("sys_code_rule_detail");
JSONArray ja = wo.query("code_rule_id = '" + id + "'", " sort_num").getResultJSONArray(0);
String demo = "";
boolean is_same = true;
for (int i = 0; i < ja.size(); i++) {
String value = "";
JSONObject jo = ja.getJSONObject(i);
//固定直接取值
if (jo.getString("type").equals("01")) {
value = jo.getString("init_value");
}
if (flag.equals("1")) {
jo.put("init_value", now_date);
jo.put("current_value", now_date);
//日期判断数据库的值与当前值是否相同来决定顺序的值
if (jo.getString("type").equals("02")) {
String current_value = jo.getString("current_value");
Date date = DateUtil.date();
String format = jo.getString("format");
String now_date = DateUtil.format(date, format);
if (!now_date.equals(current_value)) {
is_same = false;
}
if (flag.equals("1")) {
jo.put("init_value", now_date);
jo.put("current_value", now_date);
}
value = now_date;
}
value = now_date;
}
//顺序的值:如果日期一样就+步长,等于最大值就归为初始值;日期不一样就归为初始值
if (jo.getString("type").equals("03")) {
String num_value = "";
int step = jo.getInteger("step");
Long max_value = jo.getLong("max_value");
if (!is_same || (jo.getLongValue("current_value") + step > max_value)) {
num_value = jo.getString("init_value");
} else {
num_value = (jo.getInteger("current_value") + step) + "";
}
int size = num_value.length();
int length = jo.getInteger("length");
String fillchar = jo.getString("fillchar");
for (int m = 0; m < (length - size); m++) {
value += fillchar;
}
value += num_value;
if (flag.equals("1")) {
if (!is_same) {
int init_value = jo.getInteger("init_value");
if (StrUtil.isEmpty((init_value + ""))) {
throw new BadRequestException("请完善编码数值的初始值!");
}
jo.put("current_value", init_value + "");
//顺序的值:如果日期一样就+步长,等于最大值就归为初始值;日期不一样就归为初始值
if (jo.getString("type").equals("03")) {
String num_value = "";
int step = jo.getInteger("step");
Long max_value = jo.getLong("max_value");
if (!is_same || (jo.getLongValue("current_value") + step > max_value)) {
num_value = jo.getString("init_value");
} else {
int num_curr = jo.getInteger("current_value");
if (num_curr >= max_value) {
num_curr = jo.getInteger("init_value");
jo.put("current_value", num_curr + "");
}else{
jo.put("current_value", (num_curr + step) + "");
num_value = (jo.getInteger("current_value") + step) + "";
}
int size = num_value.length();
int length = jo.getInteger("length");
String fillchar = jo.getString("fillchar");
for (int m = 0; m < (length - size); m++) {
value += fillchar;
}
value += num_value;
if (flag.equals("1")) {
if (!is_same) {
int init_value = jo.getInteger("init_value");
if (StrUtil.isEmpty((init_value + ""))) {
throw new BadRequestException("请完善编码数值的初始值!");
}
jo.put("current_value", init_value + "");
} else {
int num_curr = jo.getInteger("current_value");
if (num_curr >= max_value) {
num_curr = jo.getInteger("init_value");
jo.put("current_value", num_curr + "");
}else{
jo.put("current_value", (num_curr + step) + "");
}
}
}
}
demo += value;
if (flag.equals("1")) {
wo.update(jo,"id = '"+jo.getString("id")+"'");
}
}
demo += value;
if (flag.equals("1")) {
wo.update(jo,"id = '"+jo.getString("id")+"'");
}
}
return demo;
return demo;
}
@Override

View File

@@ -8,11 +8,14 @@ import java.util.HashMap;
public class CodeUtil {
public static String getNewCode(String ruleCode){
String flag = "1";
HashMap<String,String> map = new HashMap<>();
map.put("flag",flag);
map.put("code",ruleCode);
return SpringContextHolder.getBean(GenCodeService.class).codeDemo(map);
synchronized (ruleCode){
String flag = "1";
HashMap<String,String> map = new HashMap<>();
map.put("flag",flag);
map.put("code",ruleCode);
return SpringContextHolder.getBean(GenCodeService.class).codeDemo(map);
}
}
}

View File

@@ -57,7 +57,10 @@ public class AcsToWmsController {
@Log("二次申请任务")
@ApiOperation("二次申请任务")
@SaIgnore
public ResponseEntity<Object> againApply(@RequestBody String task_id) {
return new ResponseEntity<>(acsToWmsService.againApply(task_id), HttpStatus.OK);
public ResponseEntity<Object> againApply(@RequestBody JSONObject task) {
JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value());
result.put("device_code", acsToWmsService.againApply(task.getString("task_id")));
return new ResponseEntity<>(result, HttpStatus.OK);
}
}

View File

@@ -37,7 +37,7 @@ public class LokiLogAspect {
* @return
*/
@Around("operatorLog()")
public synchronized Object around(ProceedingJoinPoint pjp) throws Throwable {
public Object around(ProceedingJoinPoint pjp) throws Throwable {
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletRequest request = attributes.getRequest();
// HttpServletResponse response = attributes.getResponse();

View File

@@ -332,7 +332,7 @@ public class YqxhcqCallMaterialTask extends AbstractAcsTask {
materialPoint.put("lock_type", "2");
pointTab.update(materialPoint);
// 点位处理
//养生A区发给ACS需要新的点位(2101-03-1----->21011-03-1)
//养生A区发给ACS需要新的点位(2101-03-1----->21011-03-1)2812
String newPoint = pointCode.substring(0, 4) + "2" + pointCode.substring(4, 10);
return newPoint;
}

View File

@@ -90,7 +90,9 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
pointTab.update(jsonStart);
}
taskTab.delete("task_id = '" + task_id + "'");
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
taskObj.put("remark", "已取消");
taskTab.update(taskObj);
}
if (StrUtil.equals(status, "1")) {

View File

@@ -13,12 +13,14 @@ import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.log.LokiLogType;
import org.nl.wms.sch.SchTaskDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.tasks.AcsTaskDto;
import org.nl.wms.sch.tasks.utils.PointUpdateUtil;
import org.nl.wms.util.IdUtil;
import org.slf4j.MDC;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -57,12 +59,11 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
taskObj.put("remark", "已取消");
taskTab.update(taskObj);
//释放相关电位信息
JSONObject param1 = new JSONObject();
param1.put("lock_type", "1");
param1.put("task_id", "");
param1.put("material_id", "");
pointTab.update(param1, "task_id = '" + taskObj.getString("task_id") + "'");
String point_code2 = taskObj.getString("point_code2");
if (ObjectUtil.isEmpty(point_code2)) return;
JSONObject object = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
object.put("lock_type", "1");
pointTab.update(object);
}
if ("1".equals(status)) {
@@ -74,15 +75,6 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
}
if (StrUtil.equals(status, "2")) {
//判断状态,
// if (StrUtil.equals("2", taskObj.getString("task_status"))) {
// // 更改任务状态为完成
// taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
// taskObj.put("update_time", DateUtil.now());
// taskTab.update(taskObj);
// return;
// }
// 更改任务状态为完成
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
taskObj.put("update_time", DateUtil.now());
@@ -160,6 +152,7 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
//判断共挤线是否有执行中的任务,如果任务数>=3,则不生成任务
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject orderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder");
String reminder = "";
/**
* 根据业务找对应的终点
*/
@@ -228,12 +221,11 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
if (ObjectUtil.isNotEmpty(json1)) { // json1: 对应相同物料的点位
Integer block_num = json1.getInteger("block_num");
Integer col_num = json1.getInteger("col_num");
Integer row_num = json1.getInteger("row_num");
if (col_num != 1) {
// 因为找到的是对应相同的物料点,所以是下一个位置
JSONObject firstRow = pointTab.query("block_num = '" + block_num + "' and row_num = '" + row_num + "'and col_num = '" + (col_num - 1) +"' and lock_type = '1' and point_status = '1' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(firstRow)) throw new BadRequestException("数据错误,请校验!");
Integer col_num = json1.getInteger("col_num"); // 列
Integer row_num = json1.getInteger("row_num"); // 排
// 因为找到的是对应相同的物料点,所以是下一个位置
JSONObject firstRow = pointTab.query("block_num = '" + block_num + "' and row_num = '" + row_num + "'and col_num = '" + (col_num - 1) +"' and lock_type = '1' and point_status = '1' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(firstRow)) {
taskObj.put("point_code2", firstRow.getString("point_code"));
taskObj.put("update_time", DateUtil.now());
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
@@ -244,12 +236,17 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
point.put("lock_type", "2");
pointTab.update(point, "point_code = '" + firstRow.getString("point_code") + "'");
continue;
// JSONObject point = new JSONObject();
// point.put("lock_type", "2");
// point.put("task_id", taskObj.getString("task_id"));
// pointTab.update(point, "block_num = '" + block_num + "' and row_num = '" + row_num + "' and col_num <= '" + (col_num - 1) + "'");
}
try {
MDC.put("log_file_type", LokiLogType.DEFAULT.getDesc());
log.info("异常日志:" + "" + block_num + "" + row_num + "" + (col_num - 1) + "列被锁,重新安排一排.");
} catch (Exception e) {
e.printStackTrace();
} finally {
MDC.remove("log_file_type");
}
// 下一列被锁住,给提示
reminder = "" + block_num + "" + row_num + "" + (col_num - 1) + "列被锁,重新安排一排.";
}
//找空位入: 物料点查找在第一列或者是没有找到物料点
if (ObjectUtil.isNotEmpty(taskIngs) && taskIngs.size() > 1) {
@@ -266,7 +263,7 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
//1、查找整列为空的货位
JSONObject json2 = WQL.getWO("QSCH_gjxSendMaterial_01").addParamMap(param2).process().uniqueResult(0);
if (ObjectUtil.isEmpty(json2)) {
taskObj.put("remark", "养生A区无可用货位");
taskObj.put("remark", ObjectUtil.isNotEmpty(reminder) ? reminder : "养生A区无可用货位");
taskObj.put("update_time", DateUtil.now());
taskTab.update(taskObj);
} else {
@@ -277,16 +274,13 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
taskObj.put("point_code2", firstRow.getString("point_code"));
//二楼普通任务
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
taskObj.put("remark", ObjectUtil.isNotEmpty(reminder) ? reminder : "");
taskObj.put("update_time", DateUtil.now());
taskTab.update(taskObj);
//锁住相关货位
JSONObject point = new JSONObject();
point.put("lock_type", "2");
pointTab.update(point, "point_code = '" + firstRow.getString("point_code") + "'");
// JSONObject point = new JSONObject();
// point.put("lock_type", "2");
// point.put("task_id", taskObj.getString("task_id"));
// pointTab.update(point, "block_num = '" + block_num + "' and row_num = '" + row_num + "' and col_num <= '" + sum + "'"); // 9
}
}

View File

@@ -68,7 +68,7 @@
p.can_vehicle_type like "%" 输入.vehicle_type "%"
ENDOPTION
AND '3' <> (SELECT p2.point_status FROM SCH_BASE_Point p2 WHERE p2.block_num = p.block_num AND p2.row_num = p.row_num
AND p2.col_num = (SELECT MIN(p3.col_num) FROM SCH_BASE_Point p3 WHERE p3.block_num = p2.block_num AND p3.row_num = p2.row_num AND p3.is_used = '1' AND p3.is_delete = '0'))
AND p2.col_num = (SELECT MIN(p3.col_num) FROM SCH_BASE_Point p3 WHERE p3.block_num = p2.block_num AND p3.row_num = p2.row_num AND p3.is_used = '1' AND p3.is_delete = '0' AND p3.lock_type = '1'))
ORDER BY block_num,row_num,col_num
ENDSELECT
ENDQUERY

View File

@@ -26,7 +26,7 @@ https://juejin.cn/post/6844903775631572999
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
<charset>${log.charset}</charset>
<!-- <charset>${log.charset}</charset>-->
</encoder>
</appender>
@@ -77,7 +77,7 @@ https://juejin.cn/post/6844903775631572999
<!--开发环境:打印控制台-->
<springProfile name="dev">
<root level="debug">
<root level="off">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="lokiAppender" />
</root>
@@ -122,7 +122,7 @@ https://juejin.cn/post/6844903775631572999
<!--生产环境:打印控制台和输出到文件-->
<springProfile name="prod">
<root level="info">
<root level="debug">
<appender-ref ref="asyncFileAppender"/>
<appender-ref ref="lokiAppender"/>
</root>

View File

@@ -46,7 +46,7 @@ router.beforeEach((to, from, next) => {
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
next()
} else {
next(`/login?redirect=www.baidu.com`) // 否则全部重定向到登录页
next(`/login`) // 否则全部重定向到登录页
NProgress.done()
}
}
@@ -54,7 +54,6 @@ router.beforeEach((to, from, next) => {
export const loadMenus = (next, to) => {
buildMenus().then(res => {
debugger
const sdata = JSON.parse(JSON.stringify(res))
const rdata = JSON.parse(JSON.stringify(res))
const sidebarRoutes = filterAsyncRouter(sdata)

View File

@@ -354,7 +354,7 @@
{{ scope.row.is_used == '1' ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column prop="update_optname" label="修改人" />
<el-table-column prop="update_name" label="修改人" />
<el-table-column prop="update_time" label="修改时间" width="150" />
<el-table-column
v-permission="[]"
@@ -409,8 +409,8 @@ const defaultForm = {
create_id: null,
create_name: null,
create_time: null,
update_optid: null,
update_optname: null,
update_id: null,
update_name: null,
update_time: null
}
export default {