rev 修改

This commit is contained in:
2023-05-19 13:15:46 +08:00
parent 36ee02b1d7
commit 9b3622cf44
8 changed files with 154 additions and 135 deletions

View File

@@ -140,7 +140,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
public DeviceDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_device");
JSONObject json = wo.query("device_code ='" + code + "'").uniqueResult(0);
final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class);
final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class);
return obj;
}
@@ -189,7 +189,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
dto.setUpdate_by(currentUsername);
WQLObject wo = WQLObject.getWQLObject("acs_device");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.update(json);
}
@@ -234,7 +234,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
Iterator<Device> iterator = allDevice.iterator();
while (iterator.hasNext()) {
Device device = iterator.next();
if (StrUtil.equals(device.getDevice_code(),device_code)) {
if (StrUtil.equals(device.getDevice_code(), device_code)) {
iterator.remove();
}
}
@@ -915,13 +915,15 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONObject updatejson = (JSONObject) JSONObject.toJSON(obj);
runpointwo.update(updatejson, "device_code = '" + device_code + "'");
}
}
else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
standardInspectSiteDeviceDriver.setMaterial(material_type);
standardInspectSiteDeviceDriver.setBatch(batch);
device.setMaterial_type(material_type);
device.setBatch(batch);
} else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver();
standardCoveyorControlWithScannerDeviceDriver.setDeviceStatus(form);
}
}
@@ -1131,7 +1133,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
result.put("form", extraObj);
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
String opc_id = dto.getOpc_server_id();
@@ -1162,14 +1164,14 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONArray rs = WQLObject.getWQLObject("acs_device_extra").query("filed_type='02' and device_id = '" + device_id + "'", "order_seq").getResultJSONArray(0);
JSONArray r_arry = new JSONArray();
//先获取模板
if(ObjectUtil.isNotEmpty(opcDeviceDriverDefination)){
if (ObjectUtil.isNotEmpty(opcDeviceDriverDefination)) {
List<ItemDto> readableItemDtos = opcDeviceDriverDefination.getReadableItemDtos();
List<JSONObject> readableItemJsons = new ArrayList<>();
for (int i = 0; i < readableItemDtos.size(); i++) {
ItemDto itemDto = readableItemDtos.get(i);
JSONObject readableItemJson = new JSONObject();
readableItemJson.put("code",itemDto.getCode());
readableItemJson.put("name",itemDto.getName());
readableItemJson.put("code", itemDto.getCode());
readableItemJson.put("name", itemDto.getName());
// readableItemJson.put("db",itemDto.getDb());
readableItemJsons.add(readableItemJson);
}
@@ -1180,7 +1182,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String code = split[split.length - 1];
robj.put("code", code);
robj.put("name", rs.getJSONObject(i).getString("remark"));
if (readableItemJsons.contains(robj)){
if (readableItemJsons.contains(robj)) {
robj.put("code", rs.getJSONObject(i).getString("extra_code"));
robj.put("db", rs.getJSONObject(i).getString("extra_name"));
r_arry.add(robj);
@@ -1194,16 +1196,16 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
code = split[split.length - 1];
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", code);
jsonObject.put("name",rJson.getString("name"));
jsonObject.put("name", rJson.getString("name"));
rarry.add(jsonObject);
}
for (int i = 0; i < readableItemDtos.size(); i++) {
ItemDto itemDto = readableItemDtos.get(i);
JSONObject readableItemJson = new JSONObject();
readableItemJson.put("code",itemDto.getCode());
readableItemJson.put("name",itemDto.getName());
if (!rarry.contains(readableItemJson)){
readableItemJson.put("db",itemDto.getDb());
readableItemJson.put("code", itemDto.getCode());
readableItemJson.put("name", itemDto.getName());
if (!rarry.contains(readableItemJson)) {
readableItemJson.put("db", itemDto.getDb());
r_arry.add(readableItemJson);
}
}
@@ -1214,8 +1216,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
for (int i = 0; i < writeableItemDtos.size(); i++) {
ItemDto itemDto = writeableItemDtos.get(i);
JSONObject writeableItemJson = new JSONObject();
writeableItemJson.put("code",itemDto.getCode());
writeableItemJson.put("name",itemDto.getName());
writeableItemJson.put("code", itemDto.getCode());
writeableItemJson.put("name", itemDto.getName());
//writeableItemJson.put("db",itemDto.getDb());
writeableItemJsons.add(writeableItemJson);
}
@@ -1226,7 +1228,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONObject robj = new JSONObject();
robj.put("code", code);
robj.put("name", ws.getJSONObject(i).getString("remark"));
if (writeableItemJsons.contains(robj)){
if (writeableItemJsons.contains(robj)) {
robj.put("code", ws.getJSONObject(i).getString("extra_code"));
robj.put("db", ws.getJSONObject(i).getString("extra_name"));
w_arry.add(robj);
@@ -1239,17 +1241,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String[] split = code.split("\\.");
code = split[split.length - 1];
JSONObject jsonObject = new JSONObject();
jsonObject.put("code",code);
jsonObject.put("name",wJson.getString("name"));
jsonObject.put("code", code);
jsonObject.put("name", wJson.getString("name"));
warry.add(jsonObject);
}
for (int i = 0; i < writeableItemDtos.size(); i++) {
ItemDto itemDto = writeableItemDtos.get(i);
JSONObject writeableItemJson = new JSONObject();
writeableItemJson.put("code",itemDto.getCode());
writeableItemJson.put("name",itemDto.getName());
if (!warry.contains(writeableItemJson)){
writeableItemJson.put("db",itemDto.getDb());
writeableItemJson.put("code", itemDto.getCode());
writeableItemJson.put("name", itemDto.getName());
if (!warry.contains(writeableItemJson)) {
writeableItemJson.put("db", itemDto.getDb());
w_arry.add(writeableItemJson);
}
}
@@ -1570,34 +1572,34 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONArray rss = param.getJSONArray("rs");
JSONArray wss = param.getJSONArray("ws");
int numberSize = Integer.parseInt(form.getString("device_number"));
List<Map<String,Object>> list = new LinkedList<>();
List<Map<String, Object>> list = new LinkedList<>();
if (type.equals("db")){
if (type.equals("db")) {
for (int i = 0; i < numberSize; i++) {
int dbInterval = db_interval * i;
Integer deviceCode = device_code + i;
for (int j = 0; j <= rss.size(); j++) {
Map<String,Object> map = new ListOrderedMap<>();
if (j == rss.size()){
map.put("设备编码","");
map.put("读取地址","");
map.put("读取意义","");
map.put("","");
map.put("写入地址","");
map.put("写入意义","");
Map<String, Object> map = new ListOrderedMap<>();
if (j == rss.size()) {
map.put("设备编码", "");
map.put("读取地址", "");
map.put("读取意义", "");
map.put("", "");
map.put("写入地址", "");
map.put("写入意义", "");
list.add(map);
continue;
}
if (i == 0 && j ==0){
map.put("设备编码","");
}else {
map.put("设备编码",deviceCode);
if (i == 0 && j == 0) {
map.put("设备编码", "");
} else {
map.put("设备编码", deviceCode);
}
JSONObject rs = rss.getJSONObject(j);
String db = rs.getString("db");
String name = rs.getString("name");
if (i > 0){
if (name.equals("心跳")){
if (i > 0) {
if (name.equals("心跳")) {
continue;
}
}
@@ -1605,55 +1607,55 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String startDB = dbs[0];
String endDB = dbs[1];
String endDBFirst = endDB.substring(0, 1);
Integer endDBEnd =Integer.parseInt(endDB.substring(1, endDB.length())) ;
Integer endDBEnd = Integer.parseInt(endDB.substring(1, endDB.length()));
endDBEnd = endDBEnd + dbInterval;
db = startDB + "." + endDBFirst + endDBEnd;
map.put("读取地址",db);
map.put("读取意义",name);
Map<String, Object> value = getValue(wss, j, dbInterval,i);
map.put("读取地址", db);
map.put("读取意义", name);
Map<String, Object> value = getValue(wss, j, dbInterval, i);
map.putAll(value);
list.add(map);
System.out.println(map);
}
}
}else if (type.equals("v")){
} else if (type.equals("v")) {
for (int i = 0; i < numberSize; i++) {
int dbInterval = db_interval * i;
Integer deviceCode = device_code + i;
for (int j = 0; j <= rss.size(); j++) {
Map<String,Object> map = new ListOrderedMap<>();
if (j == rss.size()){
map.put("设备编码","");
map.put("读取地址","");
map.put("读取意义","");
map.put("","");
map.put("写入地址","");
map.put("写入意义","");
Map<String, Object> map = new ListOrderedMap<>();
if (j == rss.size()) {
map.put("设备编码", "");
map.put("读取地址", "");
map.put("读取意义", "");
map.put("", "");
map.put("写入地址", "");
map.put("写入意义", "");
list.add(map);
continue;
}
if (i == 0 && j ==0){
map.put("设备编码","");
}else {
map.put("设备编码",deviceCode);
if (i == 0 && j == 0) {
map.put("设备编码", "");
} else {
map.put("设备编码", deviceCode);
}
JSONObject rs = rss.getJSONObject(j);
String db = rs.getString("db");
String name = rs.getString("name");
if (i > 0){
if (name.equals("心跳")){
if (i > 0) {
if (name.equals("心跳")) {
continue;
}
}
//String[] dbs = db.split("\\.");
String startDB = db.substring(0,2);
String endDB = db.substring(2,db.length());
Integer endDBEnd =Integer.parseInt(endDB) ;
String startDB = db.substring(0, 2);
String endDB = db.substring(2, db.length());
Integer endDBEnd = Integer.parseInt(endDB);
endDBEnd = endDBEnd + dbInterval;
db = startDB + endDBEnd + "";
map.put("读取地址",db);
map.put("读取意义",name);
Map<String, Object> value = getValue1(wss, j, dbInterval,i);
map.put("读取地址", db);
map.put("读取意义", name);
Map<String, Object> value = getValue1(wss, j, dbInterval, i);
map.putAll(value);
list.add(map);
System.out.println(map);
@@ -1665,17 +1667,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
FileUtil.downloadExcel(list, response);
}
public Map<String,Object> getValue(JSONArray wss, int j, Integer dbInterval, int i){
public Map<String, Object> getValue(JSONArray wss, int j, Integer dbInterval, int i) {
int size = wss.size();
Map<String,Object> map = new ListOrderedMap<>();
if (i == 0 && j == 0){
map.put("","");
map.put("写入地址","");
map.put("写入意义","");
Map<String, Object> map = new ListOrderedMap<>();
if (i == 0 && j == 0) {
map.put("", "");
map.put("写入地址", "");
map.put("写入意义", "");
return map;
}
if (i == 0 && j > 0){
if (j - 1 < size){
if (i == 0 && j > 0) {
if (j - 1 < size) {
JSONObject ws = wss.getJSONObject(j - 1);
String db = ws.getString("db");
String name = ws.getString("name");
@@ -1683,19 +1685,19 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String startDB = dbs[0];
String endDB = dbs[1];
String endDBFirst = endDB.substring(0, 1);
Integer endDBEnd =Integer.parseInt(endDB.substring(1, endDB.length())) ;
Integer endDBEnd = Integer.parseInt(endDB.substring(1, endDB.length()));
endDBEnd = endDBEnd + dbInterval;
db = startDB + "." + endDBFirst + endDBEnd;
map.put("","");
map.put("写入地址",db);
map.put("写入意义",name);
map.put("", "");
map.put("写入地址", db);
map.put("写入意义", name);
return map;
}
}
if ( i > 0){
j = j -1;
if (i > 0) {
j = j - 1;
}
if (j < size){
if (j < size) {
JSONObject ws = wss.getJSONObject(j);
String db = ws.getString("db");
String name = ws.getString("name");
@@ -1703,17 +1705,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String startDB = dbs[0];
String endDB = dbs[1];
String endDBFirst = endDB.substring(0, 1);
Integer endDBEnd =Integer.parseInt(endDB.substring(1, endDB.length())) ;
Integer endDBEnd = Integer.parseInt(endDB.substring(1, endDB.length()));
endDBEnd = endDBEnd + dbInterval;
db = startDB + "." + endDBFirst + endDBEnd;
map.put("","");
map.put("写入地址",db);
map.put("写入意义",name);
map.put("", "");
map.put("写入地址", db);
map.put("写入意义", name);
return map;
} else {
map.put("","");
map.put("写入地址","");
map.put("写入意义","");
map.put("", "");
map.put("写入地址", "");
map.put("写入意义", "");
return map;
}
}
@@ -1806,52 +1808,52 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
ExportCSVUtil.responseSetProperties(fileName, bytes, response);
}
public Map<String,Object> getValue1(JSONArray wss, int j, Integer dbInterval, int i){
public Map<String, Object> getValue1(JSONArray wss, int j, Integer dbInterval, int i) {
int size = wss.size();
Map<String,Object> map = new ListOrderedMap<>();
if (i == 0 && j == 0){
map.put("","");
map.put("写入地址","");
map.put("写入意义","");
Map<String, Object> map = new ListOrderedMap<>();
if (i == 0 && j == 0) {
map.put("", "");
map.put("写入地址", "");
map.put("写入意义", "");
return map;
}
if (i == 0 && j > 0){
if (j - 1 < size){
if (i == 0 && j > 0) {
if (j - 1 < size) {
JSONObject ws = wss.getJSONObject(j - 1);
String db = ws.getString("db");
String name = ws.getString("name");
//String[] dbs = db.split("\\.");
String startDB = db.substring(0, 2);
String endDB = db.substring(2,db.length());
Integer endDBEnd =Integer.parseInt(endDB) ;
String endDB = db.substring(2, db.length());
Integer endDBEnd = Integer.parseInt(endDB);
endDBEnd = endDBEnd + dbInterval;
db = startDB + endDBEnd + "";
map.put("","");
map.put("写入地址",db);
map.put("写入意义",name);
map.put("", "");
map.put("写入地址", db);
map.put("写入意义", name);
return map;
}
}
if ( i > 0){
j = j -1;
if (i > 0) {
j = j - 1;
}
if (j < size){
if (j < size) {
JSONObject ws = wss.getJSONObject(j);
String db = ws.getString("db");
String name = ws.getString("name");
String startDB = db.substring(0, 2);
String endDB = db.substring(2,db.length());
Integer endDBEnd =Integer.parseInt(endDB) ;
String endDB = db.substring(2, db.length());
Integer endDBEnd = Integer.parseInt(endDB);
endDBEnd = endDBEnd + dbInterval;
db = startDB + endDBEnd + "";
map.put("","");
map.put("写入地址",db);
map.put("写入意义",name);
map.put("", "");
map.put("写入地址", db);
map.put("写入意义", name);
return map;
} else {
map.put("","");
map.put("写入地址","");
map.put("写入意义","");
map.put("", "");
map.put("写入地址", "");
map.put("写入意义", "");
return map;
}
}

View File

@@ -645,12 +645,20 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("task", this.getTask());
jo.put("requireSucess", requireSucess == true ? "1" : "0");
jo.put("barcode", this.getBarcode());
jo.put("is_click", true);
jo.put("driver_type", "standard_conveyor_control_with_scanner");
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
String requireSucess = data.getString("requireSucess");
if (requireSucess.equals("1")){
this.requireSucess = true;
} else if (requireSucess.equals("0")){
this.requireSucess = false;
}
}
}

View File

@@ -14,6 +14,7 @@ import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.stereotype.Component;
@@ -151,6 +152,7 @@ public class AutoCreateInst {
}
Instruction instdto = new Instruction();
//instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
instdto.setInstruction_type(acsTask.getTask_type());
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);

View File

@@ -27,6 +27,7 @@ import org.nl.modules.quartz.service.QuartzJobService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.quartz.QuartzJobBean;
@@ -43,6 +44,7 @@ import java.util.concurrent.ThreadPoolExecutor;
@SuppressWarnings({"unchecked", "all"})
@Slf4j
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class ExecutionJob extends QuartzJobBean {
/**

View File

@@ -15,6 +15,8 @@ import org.nl.modules.wql.util.WqlUtil;
import org.springframework.cache.annotation.CacheConfig;
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;
@@ -58,8 +60,8 @@ public class GenCodeServiceImpl implements GenCodeService {
String now = DateUtil.now();
String code = (String) form.get("code");
JSONObject jo = wql.query("code = '" + code + "'").uniqueResult(0);
if (jo != null){
throw new BadRequestException("该编码code已存在请校验");
if (jo != null) {
throw new BadRequestException("该编码code已存在请校验");
}
json.put("id", id);
json.put("code", form.get("code"));
@@ -86,8 +88,8 @@ public class GenCodeServiceImpl implements GenCodeService {
WQLObject wql = WQLObject.getWQLObject("sys_code_rule");
String code = json.getString("code");
String id = json.getString("id");
JSONObject jo = wql.query("id<>'"+id+"code = '" + code + "'").uniqueResult(0);
if (jo != null){
JSONObject jo = wql.query("id<>'" + id + "code = '" + code + "'").uniqueResult(0);
if (jo != null) {
throw new BadRequestException("该编码code已存在请校验");
}
String now = DateUtil.now();
@@ -98,6 +100,7 @@ public class GenCodeServiceImpl implements GenCodeService {
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public String codeDemo(Map form) {
String code = (String) form.get("code");
String id = this.queryIdByCode(code);
@@ -158,7 +161,7 @@ public class GenCodeServiceImpl implements GenCodeService {
if (num_curr >= max_value) {
num_curr = jo.getInteger("init_value");
jo.put("current_value", num_curr + "");
}else{
} else {
jo.put("current_value", (num_curr + step) + "");
}
}

View File

@@ -2,18 +2,20 @@ package org.nl.modules.system.util;
import org.nl.modules.system.service.GenCodeService;
import org.nl.modules.system.service.impl.GenCodeServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
import java.util.HashMap;
public class CodeUtil {
public static synchronized String getNewCode(String ruleCode){
GenCodeService service=new GenCodeServiceImpl();
String flag = "1";
HashMap<String,String> map = new HashMap<>();
map.put("flag",flag);
map.put("code",ruleCode);
return service.codeDemo(map);
public static String getNewCode(String ruleCode){
synchronized (ruleCode.intern()){
String flag = "1";
HashMap<String,String> map = new HashMap<>();
map.put("flag",flag);
map.put("code",ruleCode);
return SpringContextHolder.getBean(GenCodeService.class).codeDemo(map);
}
}
}