Browse Source

add: 新增创建任务策略实现

master
yanps 12 months ago
parent
commit
4960be53d0
  1. 23
      hd/nladmin-system/pom.xml
  2. 8
      hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java
  3. 8
      hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java
  4. 29
      hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
  5. 1
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java
  6. 5
      hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java
  7. 1
      hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageDto.java
  8. 24
      hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

23
hd/nladmin-system/pom.xml

@ -8,7 +8,6 @@
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nladmin-system</artifactId>
<name>核心模块</name>
@ -28,6 +27,28 @@
<groupId>org.openscada.utgard</groupId>
<artifactId>org.openscada.opc.lib</artifactId>
<version>1.5.0</version>
<exclusions>
<exclusion>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>com.hynnet</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12.1</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.50</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>

8
hd/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java

@ -441,4 +441,12 @@ public class DeviceController {
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("惠氏任务生成选择终点")
@ApiOperation("惠氏任务生成选择终点")
@GetMapping(value = "/endPoint")
public ResponseEntity<Object> selectEndPoint(String start_code) throws Exception {
List<String> endPoints = deviceService.selectEndPoint(start_code);
return new ResponseEntity<>(endPoints, HttpStatus.OK);
}
}

8
hd/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java

@ -296,4 +296,12 @@ public interface DeviceService {
List<Device> findCacheDevice();
void updateBarcode(JSONObject json) throws Exception;
/**
* 查询设备终端
*
* @param start_code 设备标识
* @return
*/
List<String> selectEndPoint(String start_code);
}

29
hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java

@ -34,6 +34,8 @@ import org.nl.acs.device_driver.yzja_special.YzjaSpecialDeviceDriver;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
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.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
@ -75,6 +77,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
private final AcsConfigService acsConfigService;
@Autowired
TaskService taskService;
@Autowired
RouteLineService routeLineService;
List<StorageCellDto> storageCells = new ArrayList<>();
private Map<String, Integer> storage_address = new HashMap();
@ -496,7 +500,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
@Override
public JSONArray selectDeviceListThree() {
//设备基础信息表【acs_device】
JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region = '1'", "seq_num").getResultJSONArray(0);
JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND region IN ('1', '6')", "seq_num").getResultJSONArray(0);
JSONArray result = new JSONArray();
for (int i = 0; i < arr.size(); i++) {
JSONObject obj = arr.getJSONObject(i);
@ -515,6 +519,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
json.put("remark", standardOrdinarySiteDeviceDriver.getRemark());
json.put("islock",standardOrdinarySiteDeviceDriver.getIslock());
json.put("hasGood",standardOrdinarySiteDeviceDriver.getHasGoods());
json.put("next_code",standardOrdinarySiteDeviceDriver.getNext_code());
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
@ -523,6 +528,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
json.put("remark", standardInspectSiteDeviceDriver.getRemark());
json.put("islock",standardInspectSiteDeviceDriver.getIslock());
json.put("hasGood",standardInspectSiteDeviceDriver.getHasGoods());
json.put("next_code",standardInspectSiteDeviceDriver.getNext_code());
}
result.add(json);
}
@ -1243,6 +1249,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
//物料类型
String material_type = form.optString("material_type");
String remark = form.optString("remark");
String next_code = form.optString("next_code");
Integer hasGoods = 0;
if (!StrUtil.equals(material_type,"")) {
hasGoods = 2;
@ -1256,10 +1263,12 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardOrdinarySiteDeviceDriver.setMaterial(material_type);
standardOrdinarySiteDeviceDriver.setRemark(remark);
standardOrdinarySiteDeviceDriver.setHasGoods(hasGoods);
standardOrdinarySiteDeviceDriver.setNext_code(next_code);
device.setMaterial_type(material_type);
device.setQuantity(quantity);
device.setRemark(remark);
device.setHas_goods(hasGoods);
device.setNext_code(next_code);
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
@ -1267,10 +1276,12 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardInspectSiteDeviceDriver.setMaterial(material_type);
standardInspectSiteDeviceDriver.setRemark(remark);
standardInspectSiteDeviceDriver.setHasGoods(hasGoods);
standardInspectSiteDeviceDriver.setNext_code(next_code);
device.setMaterial_type(material_type);
device.setQuantity(quantity);
device.setRemark(remark);
device.setHas_goods(hasGoods);
device.setNext_code(next_code);
}
}
@ -1501,6 +1512,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardOrdinarySiteDeviceDriver.setMaterial("");
standardOrdinarySiteDeviceDriver.setQty("");
standardOrdinarySiteDeviceDriver.setRemark("");
standardOrdinarySiteDeviceDriver.setNext_code("");
JSONObject jsonjo = new JSONObject();
jsonjo.put("device_code", device_code);
jsonjo.put("hasGoodStatus", "0");
@ -1511,6 +1523,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardInspectSiteDeviceDriver.setMaterial("");
standardInspectSiteDeviceDriver.setQty("");
standardInspectSiteDeviceDriver.setRemark("");
standardInspectSiteDeviceDriver.setNext_code("");
}
}
}
@ -2043,4 +2056,18 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
}
}
@Override
public List<String> selectEndPoint(String start_code) {
if(StrUtil.isEmpty(start_code)){
throw new RuntimeException("起点设备为空");
}
List<RouteLineDto> normal = routeLineService.getShortPathLinesByCode(start_code, "normal");
List<String> list = new ArrayList<>();
for (RouteLineDto routeLineDto : normal) {
list.add(routeLineDto.getNext_device_code());
}
return list;
}
}

1
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java

@ -73,6 +73,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
int last_task = 0;
Boolean isonline = true;
int hasGoods = 0;
String next_code = "";
String message = null;
Boolean iserror = false;

5
hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java

@ -47,6 +47,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
Integer hasGoods = 0;
String next_code = "";
int error = 0;
Boolean iserror = false;
Boolean islock = false;
@ -107,8 +108,8 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
hasGoods = this.getDevice().getHas_goods();
batch = this.getDevice().getBatch();
devicecode = this.getDeviceCode();
if (branchProtocol != last_branchProtocol) {
requireSucess = false;
if("WLFZW05".equals(devicecode)){
hasGoods = 1;
}
switch (branchProtocol) {
case 1:

1
hd/nladmin-system/src/main/java/org/nl/acs/opc/DeviceManageDto.java

@ -12,6 +12,7 @@ public class DeviceManageDto {
private Boolean is_require_task;
private String location;
private Integer has_goods = 0;
private String next_code;
private String material_type;
private String quantity;
private String remark;

24
hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -626,7 +626,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void hssavetask(JSONObject json) throws Exception {
public synchronized void hssavetask(JSONObject json) throws Exception {
JSONArray array = json.optJSONArray("data");
if (array.size() == 0) {
@ -673,11 +673,29 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
// if (ObjectUtil.isNotEmpty(this.findByStartCode(device_code))) {
// throw new RuntimeException("设备:" + device_code + " 已存在该起点的任务");
// }
list.sort(new Comparator<RouteLineDto>() {
@Override
public int compare(RouteLineDto o1, RouteLineDto o2) {
String s1 = o1.getNext_device_code().substring(o1.getNext_device_code().length() - 2);
String s2 = o2.getNext_device_code().substring(o2.getNext_device_code().length() - 2);
return Integer.compare(Integer.parseInt(s1), Integer.parseInt(s2));
}
});
String next_code = arrjo.getString("next_code");
Boolean isFirst = true;
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
for (int j = 0; j < list.size(); j++) {
RouteLineDto routeLineDto = list.get(j);
next_device_code = routeLineDto.getNext_device_code();
//包材接驳位策略
//包材取货位放到物料放置位的策略
String prefix = "BCQHW";
boolean result = StrUtil.startWithIgnoreCase(device_code, prefix);
if (result && StrUtil.isNotEmpty(next_code) && isFirst) {
next_device_code = next_code;
}
//物料放置位货物放到成品放置位策略
Device device = deviceAppService.findDeviceByCode(next_device_code);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
@ -688,6 +706,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
break;
} else {
next_device_code = "";
isFirst = false;
}
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
@ -723,7 +742,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
try {
create(dto);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("任务生成失败");
// e.printStackTrace();
}
}
}

Loading…
Cancel
Save