Browse Source

更新

master
gengby 2 years ago
parent
commit
18461c31aa
  1. 4
      acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java
  2. 2
      acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
  3. 9
      acs/nladmin-system/src/main/java/org/nl/acs/hand/NumUtil.java
  4. 189
      acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/rest/AMHandController.java
  5. 126
      acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/AMHandService.java
  6. 80
      acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/dto/HandDto.java
  7. 842
      acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java
  8. 175
      acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/wql/QJN_QUERY001.wql
  9. 3
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java
  10. 12
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  11. 41
      acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java
  12. 23
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java
  13. 6
      acs/nladmin-system/src/main/resources/config/application-dev.yml
  14. 100
      acs/nladmin-ui/src/views/acs/task/index.vue

4
acs/nladmin-system/src/main/java/org/nl/acs/auto/run/TwoNDCSocketConnectionAutoRun.java

@ -78,8 +78,8 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
ip = paramService.findByCode(AcsConfig.AGVURL2).getValue();
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
ip = paramService.findByCode(AcsConfig.AGVURL).getValue();
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT).getValue());
byte[] b = new byte[1028];
s = new Socket(ip, port);
System.out.println("2楼1区域Agv链接成功");

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

@ -323,7 +323,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
@Override
public JSONArray selectList() {
//设备基础信息表【acs_device】
JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND is_config = 'true'").getResultJSONArray(0);
JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' AND is_config = 'true'","device_code,seq_num").getResultJSONArray(0);
JSONArray result = new JSONArray();
for (int i = 0; i < arr.size(); i++) {
JSONObject obj = arr.getJSONObject(i);

9
acs/nladmin-system/src/main/java/org/nl/acs/hand/NumUtil.java

@ -0,0 +1,9 @@
package org.nl.acs.hand;
/**
* @author: geng by
* @createDate: 2023/1/16
*/
public class NumUtil {
public static Integer NUM = 11;
}

189
acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/rest/AMHandController.java

@ -0,0 +1,189 @@
package org.nl.acs.hand.amb.rest;
import cn.dev33.satoken.annotation.SaIgnore;
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.acs.hand.amb.service.AMHandService;
import org.nl.modules.logging.annotation.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author qxuan
* @date 2021-07-21
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "手持接口")
@RequestMapping("/api/hand")
@Slf4j
public class AMHandController {
private final AMHandService HandService;
@PostMapping("/queryArea")
@Log("查询区域")
@ApiOperation("查询区域")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> query() {
return new ResponseEntity<>(HandService.queryArea(null), HttpStatus.OK);
}
@PostMapping("/queryPointByArea/{areaCode}")
@Log("根据区域查询点位")
@ApiOperation("根据区域查询点位")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryPointByArea(@PathVariable String areaCode) {
return new ResponseEntity<>(HandService.queryPointByArea(areaCode), HttpStatus.OK);
}
@PostMapping("/queryMaterial")
@Log("查询物料信息")
@ApiOperation("查询物料信息")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryMaterial() {
return new ResponseEntity<>(HandService.queryMaterial(), HttpStatus.OK);
}
@PostMapping("/bindPoint")
@Log("点位绑定")
@ApiOperation("点位绑定")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> bindPoint(@RequestBody Map<String, String> reqParam) {
return new ResponseEntity<>(HandService.bindPoint(reqParam), HttpStatus.OK);
}
@PostMapping("/point")
@Log("查询设备编号及状态")
@ApiOperation("查询设备编号及状态")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryPoint(@RequestBody Map<String, String> whereJson) {
String region = (String) whereJson.get("region");
return new ResponseEntity<>(HandService.queryPointByArea(region), HttpStatus.OK);
}
@PostMapping("/point/storage")
@Log("查询设备扩展属性")
@ApiOperation("查询设备扩展属性")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryDeviceAugmentabilityByCode(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryDeviceAugmentabilityByCode(whereJson), HttpStatus.OK);
}
@PostMapping("/task_type")
@Log("查询任务类型")
@ApiOperation("查询任务类型")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
//@RequestBody JSONObject json
public ResponseEntity<Object> queryTaskType() {
return new ResponseEntity<>(HandService.queryTaskType(), HttpStatus.OK);
}
@PostMapping("/tasks")
@Log("查询任务")
@ApiOperation("查询任务")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryTask(whereJson), HttpStatus.OK);
}
@PostMapping("/insts")
@Log("查询指令")
@ApiOperation("查询指令")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryInst(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.queryInst(whereJson), HttpStatus.OK);
}
@PostMapping("/routeplan_type")
@Log("查询路由类型")
@ApiOperation("查询路由类型")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryRouteplanType() {
return new ResponseEntity<>(HandService.queryRouteplanType(), HttpStatus.OK);
}
@PostMapping("/task")
@Log("创建任务")
@ApiOperation("创建任务")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createTask(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.createTask(whereJson), HttpStatus.OK);
}
@PostMapping("/inst")
@Log("指令操作")
@ApiOperation("指令操作")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Instoperation(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.Instoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/taskoperation")
@Log("任务操作")
@ApiOperation("任务操作")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> Taskoperation(@RequestBody Map<String, String> whereJson) throws Exception {
return new ResponseEntity<>(HandService.Taskoperation(whereJson), HttpStatus.OK);
}
@PostMapping("/deviceStatus")
@Log("修改设备状态")
@ApiOperation("修改设备状态")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> updateDeviceStatus(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.updateDeviceStatus(whereJson), HttpStatus.OK);
}
@PostMapping("/handlogin")
@Log("手持登陆验证")
@ApiOperation("手持登陆验证")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> handlogin(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.handleLogin(whereJson), HttpStatus.OK);
}
@PostMapping("/task2")
@Log("创建任务")
@ApiOperation("创建任务")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> createTask2(@RequestBody Map<String, String> whereJson) {
return new ResponseEntity<>(HandService.createTask2(whereJson), HttpStatus.OK);
}
@PostMapping("/callTask")
@Log("工位呼叫管理")
@ApiOperation("工位呼叫管理")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> callTask(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(HandService.callTask(whereJson), HttpStatus.OK);
}
}

126
acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/AMHandService.java

@ -0,0 +1,126 @@
package org.nl.acs.hand.amb.service;
import com.alibaba.fastjson.JSONObject;
import java.util.Map;
/**
* @author qxuan
* @description 服务接口
* @date 2021-07-21
**/
public interface AMHandService {
/**
* 查询区域
*
* @param whereJson 条件
* @return Map<String, Object>
*/
Map<String, Object> queryArea(Map whereJson);
/**
* 查询设备编号及状态
*
* @return Map<String, Object>
*/
Map<String, Object> queryPointByArea(String areaCode);
/**
* 查询设备扩展性
*
* @param deviceCode
* @return
*/
Map<String, Object> queryDeviceAugmentabilityByCode(Map deviceCode);
/**
* 查询任务状态
*
* @return
*/
Map<String, Object> queryTaskType();
/**
* 查询路由类型
*
* @return
*/
Map<String, Object> queryRouteplanType();
/**
* 查询指令
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> queryInst(Map<String, String> jsonObject);
/**
* 创建任务
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> createTask(Map<String, String> jsonObject);
/**
* 查询任务
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> queryTask(Map<String, String> jsonObject);
/**
* 修改设备状态
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> updateDeviceStatus(Map<String, String> jsonObject);
/**
* 手持登陆
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> handleLogin(Map<String, String> jsonObject);
/**
* 指令操作
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> Instoperation(Map<String, String> jsonObject);
/**
* 任务操作
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> Taskoperation(Map<String, String> jsonObject) throws Exception;
/**
* 查询物料
*
* @return Map<String, Object>
*/
Map<String, Object> queryMaterial();
Map<String, Object> bindPoint(Map<String, String> reqParam);
Map<String, Object> createTask2(Map<String, String> whereJson);
/**
* 工位呼叫管理
* @param whereJson
* @return
*/
Map<String, Object> callTask(JSONObject whereJson);
}

80
acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/dto/HandDto.java

@ -0,0 +1,80 @@
package org.nl.acs.hand.amb.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @author qxuan
* @description /
* @date 2021-07-21
**/
@Data
public class HandDto implements Serializable {
/**
* 库区标识
*/
private String sect_uuid;
/**
* 库区编码
*/
private String sect_code;
/**
* 库区名称
*/
private String sect_name;
/**
* 库区简称
*/
private String simple_name;
/**
* 库区类型
*/
private String sect_type;
/**
* 顺序号
*/
private BigDecimal order_seq;
/**
* 仓库标识
*/
private String store_uuid;
/**
* 是否启用
*/
private String is_active;
/**
* 是否删除
*/
private String is_delete;
/**
* 创建者
*/
private String create_by;
/**
* 创建时间
*/
private String create_time;
/**
* 修改者
*/
private String update_by;
/**
* 修改时间
*/
private String update_time;
}

842
acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/service/impl/AMHandServiceImpl.java

@ -0,0 +1,842 @@
package org.nl.acs.hand.amb.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
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.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.MagicAgvService;
import org.nl.acs.agv.server.impl.MagicAgvServiceImpl;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.hand.NumUtil;
import org.nl.acs.hand.amb.service.AMHandService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.instruction.service.dto.InstructionDto;
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
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.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.impl.TaskServiceImpl;
import org.nl.modules.common.config.RsaProperties;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RsaUtils;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.system.service.UserService;
import org.nl.modules.system.service.dto.UserDto;
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.springframework.stereotype.Service;
import java.util.*;
/**
* @author qxuan
* @description 服务实现
* @date 2021-07-21
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class AMHandServiceImpl implements AMHandService {
private final UserService userService;
private final DeviceService deviceService;
private final DeviceAppService deviceAppService;
InstructionService instructionService = null;
@Override
public Map<String, Object> queryArea(Map whereJson) {
JSONObject jo = new JSONObject();
JSONArray resultJSONArray = WQL.getWO("QJN_QUERY001").addParam("flag", "1").process().getResultJSONArray(0);
jo.put("code", "1");
jo.put("desc", "查询成功");
jo.put("result", resultJSONArray);
return jo;
}
@Override
public Map<String, Object> queryPointByArea(String areaCode) {
JSONArray respArr = new JSONArray();
JSONObject resultJson = new JSONObject();
if (StrUtil.isEmpty(areaCode)) {
throw new BadRequestException("区域编码不能空!");
}
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
WQLObject wo_device = WQLObject.getWQLObject("acs_device");
WQLObject wo_runPoint = WQLObject.getWQLObject("acs_device_runpoint");
JSONArray deviceArrayByArea = wo_device.query("region = '" + areaCode + "' and is_delete = '0' and is_active = '1'", "seq_num").getResultJSONArray(0);
for (int i = 0; i < deviceArrayByArea.size(); i++) {
JSONObject device = deviceArrayByArea.getJSONObject(i);
String device_id = device.getString("device_id");
String device_code = device.getString("device_code");
String device_name = device.getString("device_name");
JSONObject deviceRunPoint = wo_runPoint.query("device_id = '" + device_id + "'").uniqueResult(0);
Integer hasgoods = deviceRunPoint.getInteger("hasgoods");
String material_type = deviceRunPoint.getString("material_type");
//点位状态status对应status_name 0空 1有货 2有任务
String status = "0";
String status_name = "无货";
String input_material = "0";
String allow_update = "0";
TaskDto taskDto = taskService.findByStartAndNextCode(device_code);
if (ObjectUtil.isNotEmpty(taskDto) && hasgoods == 1) {
status = "2";
status_name = "有任务";
} else if (hasgoods == 1) {
status = "1";
status_name = "有货";
}
Device device_driver = deviceAppService.findDeviceByCode(device_code);
if (device_driver.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
input_material = "1";
allow_update = "1";
}
JSONObject map = new JSONObject();
map.put("device_id", device_id);
map.put("device_code", device_code);
map.put("device_name", device_name);
map.put("status", status);
map.put("status_name", status_name);
map.put("input_material", input_material);
map.put("allow_update", allow_update);
map.put("material_type", material_type);
respArr.add(map);
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", respArr);
return resultJson;
}
@Override
public Map<String, Object> queryDeviceAugmentabilityByCode(Map whereMap) {
String deviceCode = whereMap.get("device_code").toString();
JSONObject resultJson = new JSONObject();
JSONObject jo = new JSONObject();
JSONObject acs_device = WQLObject.getWQLObject("ACS_DEVICE").query("device_code = '" + deviceCode + "'").pageResult();
JSONObject acsDevice = (JSONObject) acs_device.getJSONArray("content").get(0);
//判断设备类型是不是storage
if (!"storage".equals(acsDevice.getString("device_type"))) {
resultJson.put("code", "0");
resultJson.put("desc", "该设备不是货架");
resultJson.put("result", "");
return resultJson;
}
JSONObject jsonObject = deviceService.queryStorageExtra(deviceCode);
jo.put("device_id", acsDevice.getString("device_id"));
jo.put("device_code", deviceCode);
jo.put("device_name", acsDevice.getString("device_name"));
jo.put("device_type", acsDevice.getString("device_type"));
jo.put("maxY", jsonObject.getString("maxY"));
jo.put("minY", jsonObject.getString("minY"));
jo.put("maxZ", jsonObject.getString("maxZ"));
jo.put("minZ", jsonObject.getString("minZ"));
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", jo);
return resultJson;
}
@Override
public Map<String, Object> queryRouteplanType() {
JSONObject resultJson = new JSONObject();
JSONObject jo = WQLObject.getWQLObject("acs_route_plan").query().pageResult();
JSONArray arr = new JSONArray();
JSONArray content = jo.getJSONArray("content");
for (int i = 0; i < content.size(); i++) {
JSONObject jsonObject = (JSONObject) content.get(i);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("value", jsonObject.getString("plan_code"));
jsonObject1.put("label", jsonObject.getString("plan_name"));
arr.add(jsonObject1);
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", arr);
return resultJson;
}
@Override
public Map<String, Object> queryTaskType() {
JSONObject resultJson = new JSONObject();
JSONObject jo = WQLObject.getWQLObject("sys_dict_detail").query("name = 'task_type'").pageResult();
JSONArray arr = new JSONArray();
JSONArray content = jo.getJSONArray("content");
for (int i = 0; i < content.size(); i++) {
JSONObject jsonObject = (JSONObject) content.get(i);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("value", jsonObject.getString("value"));
jsonObject1.put("label", jsonObject.getString("label"));
arr.add(jsonObject1);
}
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", arr);
return resultJson;
}
@Override
public Map<String, Object> queryInst(Map<String, String> jsonObject) {
//查询位完成的指令
JSONObject resultJson = new JSONObject();
HashMap<String, String> map = new HashMap<>();
String key = jsonObject.get("keyword");
String start_point = jsonObject.get("start_devicecode");
String next_point = jsonObject.get("next_devicecode");
map.put("flag", "4");
if (StrUtil.isNotEmpty(key)) {
map.put("key", "%" + key + "%");
}
if (StrUtil.isNotEmpty(start_point)) {
map.put("start_point", "%" + start_point + "%");
}
if (StrUtil.isNotEmpty(next_point)) {
map.put("next_point", "%" + next_point + "%");
}
JSONArray resultArr = WQL.getWO("QJN_QUERY001").addParamMap(map).addParamMap((HashMap) jsonObject).process().getResultJSONArray(0);
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", resultArr);
return resultJson;
}
@Override
public Map<String, Object> createTask(Map<String, String> jsonObject) {
String start_devicecode = jsonObject.get("start_devicecode");
String next_devicecode = jsonObject.get("next_devicecode");
String material_type = jsonObject.get("material_type");
String task_type = jsonObject.get("task_type");
String priority = jsonObject.get("priority");
String carrier = jsonObject.get("carrier");
JSONObject resultJson = new JSONObject();
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device startDevice = appService.findDeviceByCode(start_devicecode);
Device nextDevice = appService.findDeviceByCode(next_devicecode);
if (StrUtil.isEmpty(start_devicecode)) {
resultJson.put("code", "0");
resultJson.put("desc", "起点不能为空");
resultJson.put("result", "");
return resultJson;
}
if (StrUtil.isEmpty(next_devicecode)) {
resultJson.put("code", "0");
resultJson.put("desc", "终点不能为空");
resultJson.put("result", "");
return resultJson;
}
// if (ObjectUtil.isNotEmpty(taskService.findByStartCode(start_devicecode)) ||
// ObjectUtil.isNotEmpty(taskService.findByStartCode(next_devicecode))) {
// resultJson.put("code", "2");
// resultJson.put("desc", "已存在该起点或终点的任务!");
// resultJson.put("result", "");
// return resultJson;
// }
//判断起点有货,终点为空
if (ObjectUtil.isEmpty(startDevice.getMaterial_type()) || Integer.parseInt(startDevice.getMaterial_type()) == 0) {
resultJson.put("code", "0");
resultJson.put("desc", "起点必须有货");
resultJson.put("result", "");
return resultJson;
}
if (!ObjectUtil.isEmpty(nextDevice.getMaterial_type()) && !StrUtil.equals(nextDevice.getMaterial_type(), "0")) {
resultJson.put("code", "0");
resultJson.put("desc", "终点必须为空");
resultJson.put("result", "");
return resultJson;
}
if (Boolean.parseBoolean(startDevice.getIslock()) || Boolean.parseBoolean(nextDevice.getIslock())) {
resultJson.put("code", "0");
resultJson.put("desc", "起点或终点设备已被锁定");
resultJson.put("result", "");
return resultJson;
}
if (StrUtil.isEmpty(priority)) {
priority = "1";
}
if (start_devicecode.equals(next_devicecode)) {
resultJson.put("code", "0");
resultJson.put("desc", "起点和终点不能是同一设备【" + next_devicecode + "】");
resultJson.put("result", "");
return resultJson;
}
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
TaskDto dto = new TaskDto();
dto.setIs_active("1");
dto.setIs_delete("0");
dto.setMaterial(material_type);
dto.setStart_point_code(start_devicecode);
dto.setNext_point_code(next_devicecode);
dto.setMaterial(material_type);
dto.setTask_type(task_type);
dto.setPriority(priority);
dto.setVehicle_code(carrier);
try {
taskService.create(dto);
startDevice.setIslock("true");
nextDevice.setIslock("true");
} catch (Exception e) {
resultJson.put("code", "2");
resultJson.put("desc", e.getMessage());
resultJson.put("result", "");
return resultJson;
}
resultJson.put("code", "1");
resultJson.put("desc", "生成成功!");
resultJson.put("result", "");
return resultJson;
}
@Override
public Map<String, Object> queryTask(Map<String, String> jsonObject) {
String key = jsonObject.get("keyword");
String start_point = jsonObject.get("start_devicecode");
String next_point = jsonObject.get("next_devicecode");
HashMap<String, String> map = new HashMap<>();
map.put("flag", "2");
if (StrUtil.isNotEmpty(key)) {
map.put("key", "%" + key + "%");
}
if (StrUtil.isNotEmpty(start_point)) {
map.put("start_point", "%" + start_point + "%");
}
if (StrUtil.isNotEmpty(next_point)) {
map.put("next_point", "%" + next_point + "%");
}
//查询有任务 但是没有指令的任务
JSONArray result = WQL.getWO("QJN_QUERY001").addParamMap(map).process().getResultJSONArray(0);
JSONObject resultJson = new JSONObject();
resultJson.put("code", "1");
resultJson.put("desc", "查询成功");
resultJson.put("result", result);
return resultJson;
}
@Override
public Map<String, Object> updateDeviceStatus(Map<String, String> jsonObject) {
//修改任务的状态
String device_code = jsonObject.get("device_code");
String type = jsonObject.get("type");
String status = jsonObject.get("status");
String material_type = jsonObject.get("material_type");
String batch = jsonObject.get("batch");
JSONObject resultJson = new JSONObject();
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device device = appService.findDeviceByCode(device_code);
//无光电普通站点
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
DeviceDto dto = deviceService.findByCode(device_code);
if (Boolean.parseBoolean(device.getIslock())) {
resultJson.put("code", "0");
resultJson.put("desc", "已有任务无法绑定!");
resultJson.put("result", new JSONObject());
return resultJson;
}
//修改
if (type.equals("1")) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if (StrUtil.equals("0", material_type)) {
status = "0";
}
if (StrUtil.equals("1", material_type)) {
status = "1";
}
if ("2,3,4,5".contains(material_type)) {
status = "2";
}
standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(status));
device.setHas_goods(Integer.parseInt(status));
JSONObject jo = new JSONObject();
jo.put("device_code", device_code);
jo.put("hasGoodStatus", status);
jo.put("batch", batch);
jo.put("material_type", material_type);
deviceService.changeDeviceStatus(jo);
if (!StrUtil.isEmpty(material_type)) {
standardOrdinarySiteDeviceDriver.setMaterial(material_type);
}
if (!StrUtil.isEmpty(batch)) {
standardOrdinarySiteDeviceDriver.setBatch(batch);
}
}
}
//清空
if (type.equals("2")) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setHasGoods(0);
device.setHas_goods(0);
JSONObject jo = new JSONObject();
jo.put("device_code", device_code);
jo.put("hasGoodStatus", "0");
jo.put("batch", "");
jo.put("material_type", "");
deviceService.changeDeviceStatus(jo);
standardOrdinarySiteDeviceDriver.setMaterial("");
standardOrdinarySiteDeviceDriver.setBatch("");
}
}
resultJson.put("code", "1");
resultJson.put("desc", "更新成功");
resultJson.put("result", new JSONObject());
return resultJson;
}
@SneakyThrows
@Override
public Map<String, Object> handleLogin(Map<String, String> jsonObject) {
JSONObject resultJson = new JSONObject();
String user = jsonObject.get("user");
String password = jsonObject.get("password");
if (StrUtil.isEmpty("user")) {
resultJson.put("code", "1");
resultJson.put("desc", "用户不能为空");
return resultJson;
}
if (StrUtil.isEmpty("password")) {
resultJson.put("code", "1");
resultJson.put("desc", "密码不能为空!");
return resultJson;
}
boolean is_match = false;
Long account_id = 0L;
try {
String pwd = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, password);
UserDto userDto = userService.findByName(user);
account_id = userDto.getId();
//is_match = passwordEncoder.matches(pwd, userDto.getPassword());
} catch (Exception e) {
e.printStackTrace();
}
if (is_match) {
resultJson.put("code", "1");
resultJson.put("desc", "登陆成功");
} else {
resultJson.put("code", "2");
resultJson.put("desc", "登陆失败!");
}
JSONObject jo = new JSONObject();
jo.put("user_name", user);
jo.put("account_id", account_id);
resultJson.put("result", jo);
return resultJson;
}
@Override
public Map<String, Object> Instoperation(Map<String, String> jsonObject) {
JSONObject jo = new JSONObject();
String type = jsonObject.get("type");
String inst_uuid = jsonObject.get("inst_uuid");
JSONObject instwo = WQLObject.getWQLObject("acs_instruction").query("instruction_id='" + inst_uuid + "'").uniqueResult(0);
if (instwo == null) {
jo.put("code", "2");
jo.put("desc", "未找到该指令!");
jo.put("result", "");
return jo;
}
if (StrUtil.equals(instwo.getString("instruction_status"), "2") ||
StrUtil.equals(instwo.getString("instruction_status"), "3")) {
jo.put("code", "2");
jo.put("desc", "指令已完成或已取消,无法操作");
jo.put("result", "");
return jo;
}
String task_id = instwo.getString("task_id");
Instruction instdto = (Instruction) instwo.toJavaObject(Instruction.class);
MagicAgvService agvService = SpringContextHolder.getBean(MagicAgvServiceImpl.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
/* 1 指令撤销
2 重新下发
3 强制完成*/
if (type.equals("1")) {
//调用agv删除任务的接口
try {
//agvService.deleteAgvInst(instwo.getString("instruction_code"));
if (StrUtil.isEmpty(instdto.getAgv_jobno())) {
instructionService.cancelNOSendAgv(inst_uuid);
} else {
agvService.deleteAgvInst(instdto.getInstruction_code());
}
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", "下发agv失败");
jo.put("result", "");
return jo;
}
}
if (type.equals("2")) {
try {
agvService.sendAgvInstToMagic(instdto);
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", "下发agv失败");
jo.put("result", "");
return jo;
}
}
if (type.equals("3")) {
//完成指令
try {
instructionService.finish(inst_uuid);
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", e.getMessage());
jo.put("result", "");
return jo;
}
}
jo.put("code", "1");
jo.put("desc", "操作成功");
jo.put("result", new JSONObject());
return jo;
}
@Override
public Map<String, Object> Taskoperation(Map<String, String> jsonObject) throws Exception {
JSONObject jo = new JSONObject();
String task_uuid = jsonObject.get("inst_uuid");
String type = jsonObject.get("type");
JSONObject taskjo = WQLObject.getWQLObject("acs_task").query("task_id='" + task_uuid + "'").uniqueResult(0);
String task_code = taskjo.getString("task_code");
String start_point_code = taskjo.getString("start_point_code");
String next_point_code = taskjo.getString("next_point_code");
String task_id = taskjo.getString("task_id");
if (StrUtil.isEmpty(task_uuid)) {
throw new BadRequestException("id不能为空!");
}
if (StrUtil.isEmpty(type)) {
throw new BadRequestException("操作类型不能为空!");
}
if (StrUtil.equals(taskjo.getString("task_status"), "2") ||
StrUtil.equals(taskjo.getString("task_status"), "3")) {
jo.put("code", "2");
jo.put("desc", "任务已完成或已取消,无法操作");
jo.put("result", "");
return jo;
}
//重新生成
if (type.equals("1")) {
//重新生产指令
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
instdto.setRemark(taskjo.getString("remark"));
instdto.setMaterial(taskjo.getString("material"));
instdto.setTask_id(taskjo.getString("task_id"));
instdto.setTask_code(taskjo.getString("task_code"));
instdto.setVehicle_code(taskjo.getString("vehicle_code"));
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_point_code(taskjo.getString("start_point_code"));
instdto.setNext_point_code(taskjo.getString("next_point_code"));
instdto.setStart_device_code(taskjo.getString("start_device_code"));
instdto.setNext_device_code(taskjo.getString("next_device_code"));
instdto.setInstruction_status("0");
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
JSONObject instcheckjson = instwo.query(" instruction_status < 2 and next_point_code= '" + next_point_code + "'" + " and start_point_code = '" + start_point_code + "'" + " and task_id = '" + task_id + "'").uniqueResult(0);
if (instcheckjson != null) {
jo.put("code", "2");
jo.put("desc", "操作失败");
jo.put("result", task_code + ":该任务已存在待完成指令!");
return jo;
}
try {
instructionService.create(instdto);
} catch (Exception e) {
jo.put("code", "2");
jo.put("desc", e.getMessage());
jo.put("result", "");
return jo;
}
instdto.setExecute_device_code(taskjo.getString("start_point_code"));
//下发指令给agv
// AgvService agvserver = SpringContextHolder.getBean("agvServiceImpl");
// try {
// agvserver.sendAgvInstToMagic(instdto);
// } catch (Exception e) {
// jo.put("code", "2");
// jo.put("desc", e.getMessage());
// jo.put("result", "");
// return jo;
// }
}
//强制完成
if (type.equals("2")) {
//手工完成
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
TaskDto acsTask = taskjo.toJavaObject(TaskDto.class);
InstructionService instructionservice = SpringContextHolder.getBean(InstructionServiceImpl.class);
InstructionDto instdto = instructionservice.findByTaskid(acsTask.getTask_id(), "instruction_status <2 ");
if (instdto != null) {
jo.put("code", "0");
jo.put("desc", "有指令未完成!");
jo.put("result", new JSONObject());
return jo;
}
taskService.finish(acsTask.getTask_id());
Device startDevice = deviceAppService.findDeviceByCode(acsTask.getStart_device_code());
Device nextDevice = deviceAppService.findDeviceByCode(acsTask.getNext_device_code());
startDevice.setIslock("false");
nextDevice.setIslock("false");
}
jo.put("code", "1");
jo.put("desc", "操作成功");
jo.put("result", new JSONObject());
return jo;
}
@Override
public Map<String, Object> queryMaterial() {
JSONArray resultArr = WQL.getWO("QJN_QUERY001").addParam("flag", "5").process().getResultJSONArray(0);
JSONObject jo = new JSONObject();
jo.put("code", "1");
jo.put("desc", "查询成功");
jo.put("result", resultArr);
return jo;
}
@Override
public Map<String, Object> bindPoint(Map<String, String> reqParam) {
WQLObject wo_runPoint = WQLObject.getWQLObject("acs_device_runpoint");
String device_code = MapUtil.getStr(reqParam, "device_code");
String material_type = MapUtil.getStr(reqParam, "material_type");
String type = MapUtil.getStr(reqParam, "type");
String status = MapUtil.getStr(reqParam, "status");
JSONObject jo = new JSONObject();
if (StrUtil.isEmpty(type)) {
jo.put("code", "0");
jo.put("desc", "失败,操作类型不能为空!");
return jo;
}
if (StrUtil.isEmpty(device_code)) {
jo.put("code", "0");
jo.put("desc", "失败,设备号不能为空!");
return jo;
}
if (StrUtil.isNotEmpty(material_type) && StrUtil.equals(status, "0")) {
jo.put("code", "0");
jo.put("desc", "失败,点位带有物料信息与无货状态不符合!");
return jo;
} else if (StrUtil.isEmpty(material_type) && !StrUtil.equals(status, "0")) {
jo.put("code", "0");
jo.put("desc", "失败,点位无物料信息与有货状态不符合!");
return jo;
}
JSONObject map = new JSONObject();
if (StrUtil.equals(type, "0")) {
map.put("material_type", "");
map.put("hasgoods", "0");
} else {
map.put("material_type", material_type);
map.put("hasgoods", status);
}
wo_runPoint.update(map, "device_code = '" + device_code + "'");
jo.put("code", "1");
jo.put("desc", "成功");
return jo;
}
@Override
public Map<String, Object> createTask2(Map<String, String> whereJson) {
String type = whereJson.get("type");
String material_type = whereJson.get("material_type");
String batch = whereJson.get("batch");
String start_device_code = whereJson.get("start_devicecode");
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device startdevice = appService.findDeviceByCode(start_device_code);
if (Boolean.parseBoolean(startdevice.getIslock())) {
JSONObject jo = new JSONObject();
jo.put("code", "0");
jo.put("desc", "起点设备已被锁定");
return jo;
}
if (StrUtil.isEmpty(type)) {
throw new BadRequestException("操作类型不能为空!");
}
if (StrUtil.isEmpty(start_device_code)) {
throw new BadRequestException("起点不能为空!");
}
String plan_code = "";
if (StrUtil.equals(type, "1")) {
plan_code = "normal";
} else if (StrUtil.equals(type, "2")) {
plan_code = "one";
}
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + plan_code + "'").uniqueResult(0).getString("plan_uuid");
JSONArray ja = routelineserver.queryNextLine(start_device_code, plan_uuid);
if (ObjectUtil.isEmpty(ja)) {
JSONObject jo = new JSONObject();
jo.put("code", "0");
jo.put("desc", "未找到对应路由");
return jo;
}
JSONObject form = new JSONObject();
form.put("type", type);
form.put("material_type", material_type);
form.put("batch", batch);
form.put("start_device_code", start_device_code);
deviceService.autoCreateTask(form);
JSONObject jo = new JSONObject();
jo.put("code", "1");
jo.put("desc", "创建成功");
// try{
// Thread.sleep(1000);
//
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
return jo;
}
@Override
public Map<String, Object> callTask(JSONObject whereJson) {
JSONObject jo = new JSONObject();
WQLObject wo_runPoint = WQLObject.getWQLObject("acs_device_runpoint");
//获取前端传入的起点数组
JSONArray start_device_codes = MapUtil.get(whereJson, "start_device_codes", JSONArray.class);
String next_device_code = MapUtil.getStr(whereJson, "next_device_code");
if (ObjectUtil.isEmpty(start_device_codes) || StrUtil.isEmpty(next_device_code)) {
jo.put("code", "0");
jo.put("desc", "呼叫失败,起点或终点不能为空!");
return jo;
}
//将数组转换为集合判断是否为同一排的库位,并按照库位顺序号排序
List<String> start_device_code_list = JSONArray.parseArray(start_device_codes.toJSONString(), String.class);
Collections.sort(start_device_code_list, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
String start_i = s1.split("_")[0];
String start_j = s2.split("_")[0];
if (!StrUtil.equals(start_i, start_j)) {
throw new BadRequestException("请选择同一排待塑区库位!");
}
int end_i = Integer.parseInt(s1.split("_")[s1.split("_").length - 1]);
int end_j = Integer.parseInt(s2.split("_")[s2.split("_").length - 1]);
if (end_i > end_j) {
return 1;
} else if (end_i < end_j) {
return -1;
}
return 0;
}
});
start_device_codes = JSONArray.parseArray(JSON.toJSONString(start_device_code_list));
int start_size = start_device_codes.size();
if (start_size > 0) {
//获取起点点位数组的第一个点位
String start_device_code = (String) start_device_codes.get(0);
//将首个设备点位起点以_分割 获得对应的排数和列数
String[] split_codes = start_device_code.split("_");
//列数
int code_num = Integer.parseInt(split_codes[split_codes.length - 1]);
//判断选择的当前排列数是否大于当前排最大列数
if (code_num + start_size - 1 > NumUtil.NUM.intValue()) {
jo.put("code", "0");
jo.put("desc", "呼叫失败,超出同一排待塑区最大列数!");
return jo;
} else {
//获取拍好序的起点点位最后点位
String start_device_code_end = (String) start_device_codes.get(start_size - 1);
//获取拍好序的起点点位最后点位的列数
int end_num = Integer.parseInt(start_device_code_end.split("_")[start_device_code_end.split("_").length - 1]);
//判断同一排的起始列数 + 第一个点位个数 - 1 是否等于 最后选择的同一排的最后一个点位列数 如果等于说明是按照顺序选择起点点位
if (code_num + start_size - 1 == end_num) {
for (int i = 0; i < start_device_codes.size(); i++) {
JSONObject jsonObject = wo_runPoint.query("device_code = '" + start_device_codes.getString(i) + "'").uniqueResult(0);
TaskDto taskDto = new TaskDto();
taskDto.setTask_id(IdUtil.simpleUUID());
taskDto.setTask_code(CodeUtil.getNewCode("TASK_NO"));
taskDto.setStart_device_code(start_device_codes.getString(i));
taskDto.setStart_point_code(start_device_codes.getString(i));
taskDto.setStart_parent_code(start_device_codes.getString(i));
taskDto.setNext_device_code(next_device_code);
taskDto.setNext_point_code(next_device_code);
taskDto.setNext_parent_code(next_device_code);
taskDto.setCreate_by(SecurityUtils.getCurrentUsername());
taskDto.setUpdate_by(SecurityUtils.getCurrentUsername());
taskDto.setRoute_plan_code("normal");
taskDto.setTask_type("3");
taskDto.setTask_status("0");
taskDto.setPriority("1");
taskDto.setCreate_time(DateUtil.now());
taskDto.setUpdate_time(DateUtil.now());
taskDto.setRemark("手持创建任务!");
taskDto.setAgv_system_type("2");
taskDto.setMaterial(jsonObject.getString("material"));
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
try {
taskService.create(taskDto);
} catch (Exception e) {
jo.put("code", "0");
jo.put("desc", e.getMessage());
return jo;
}
}
} else {
jo.put("code", "0");
jo.put("desc", "呼叫失败,请按照顺序选择起点!");
return jo;
}
}
}
jo.put("code", "1");
jo.put("desc", "呼叫成功!");
return jo;
}
}

175
acs/nladmin-system/src/main/java/org/nl/acs/hand/amb/wql/QJN_QUERY001.wql

@ -0,0 +1,175 @@
[交易说明]
交易名: 手持接口查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.key TYPEAS s_string
输入.keyword TYPEAS s_string
输入.start_point TYPEAS s_string
输入.next_point TYPEAS s_string
输入.detail_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
dtl.detail_id as region_id,
dtl.label as region_name,
dtl.value as region_code
FROM
sys_dict sys
LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id
WHERE
sys.NAME = "region_type"
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
task.task_id AS task_uuid,
task.task_code AS task_no,
task.start_point_code AS start_devicecode,
task.next_point_code AS next_devicecode,
task.task_type AS task_type,
task.material AS material_type,
sys2.label AS material_type_name,
task.task_status AS task_status,
sys.label AS task_status_name,
task.vehicle_code AS carrier,
task.create_time,
task.priority
FROM
acs_task task
INNER JOIN sys_dict_detail AS sys ON sys.VALUE = task.task_status
AND sys.NAME = 'task_status'
LEFT JOIN sys_dict_detail AS sys2 ON sys2.VALUE = task.material
AND sys2.NAME = 'material_type'
where
( task.task_status ='1' or task.task_status ='0' )
and
( task.task_id IN (select inst.task_id FROM acs_instruction inst where inst.is_delete<>1 and (instruction_status<>'1' and instruction_status <>'2' and instruction_status <>'0')) or task.task_id not in (select inst.task_id FROM acs_instruction inst where inst.is_delete<>1
))
OPTION 输入.key <> ""
task.task_code like 输入.key
ENDOPTION
OPTION 输入.start_point <> ""
task.start_point_code like 输入.start_point
ENDOPTION
OPTION 输入.next_point <> ""
task.next_point_code like 输入.next_point
ENDOPTION
ORDER BY task.create_time
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
*
FROM
sys_dict_detail detl
WHERE
1=1
OPTION 输入.detail_id <> ""
detl.detail_id = 输入.detail_id
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
inst.instruction_id AS inst_uuid,
inst.task_code AS task_no,
inst.instruction_code AS inst_no,
inst.start_point_code AS start_devicecode,
inst.next_point_code AS next_devicecode,
inst.instruction_status AS inst_status,
dtl.label AS inst_status_name,
inst.execute_message AS inst_step,
inst.vehicle_code AS carrier,
inst.carno,
inst.priority,
inst.send_status,
inst.create_time,
inst.material AS material_type,
dtl2.label AS material_type_name,
dtl3.label AS send_status_name
FROM
acs_instruction inst
LEFT JOIN sys_dict_detail AS dtl ON dtl.VALUE = inst.instruction_status
AND dtl.NAME = 'inst_status'
LEFT JOIN sys_dict_detail dtl2 ON dtl2.VALUE = inst.material
AND dtl2.NAME = 'material_type'
LEFT JOIN sys_dict_detail dtl3 ON dtl3.VALUE = inst.send_status
AND dtl3.NAME = 'send_status'
WHERE
inst.is_delete = '0'
AND inst.instruction_status <> '2'
AND inst.instruction_status < '2'
OPTION 输入.key <> ""
inst.instruction_code like 输入.key
ENDOPTION
OPTION 输入.start_point <> ""
inst.start_point_code like 输入.start_point
ENDOPTION
OPTION 输入.next_point <> ""
inst.next_point_code like 输入.next_point
ENDOPTION
ORDER BY
inst.create_time DESC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
detl.label AS label,
detl.VALUE AS value
FROM
sys_dict_detail detl
WHERE
detl.name = 'material_type'
order by
dict_sort
ENDSELECT
ENDQUERY
ENDIF

3
acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java

@ -240,6 +240,9 @@ public interface TaskService {
TaskDto findByStartCode(String device_code);
TaskDto findByStartAndNextCode(String device_code);
/**
* 根据起点设备编号查询当前是否有就绪任务
*

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

@ -1161,6 +1161,18 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return null;
}
@Override
public TaskDto findByStartAndNextCode(String device_code) {
Iterator var3 = tasks.iterator();
while (var3.hasNext()) {
TaskDto task = (TaskDto) var3.next();
if (StrUtil.equals(task.getStart_device_code(), device_code) || StrUtil.equals(task.getNext_device_code(), device_code)) {
return task;
}
}
return new TaskDto();
}
@Override
public TaskDto foramte(TaskDto task) {
String start_point_code = task.getStart_point_code();

41
acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java

@ -2,10 +2,13 @@
package org.nl.acs.test.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.test.service.TestService;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import java.io.IOException;
@ -19,12 +22,44 @@ import java.util.Map;
@Service
@RequiredArgsConstructor
@Slf4j
public class TestServiceImpl implements TestService
{
public class TestServiceImpl implements TestService {
@Override
public void test1() throws IOException {
WQLObject wo = WQLObject.getWQLObject("acs_device");
for (int i = 1; i <= 8; i++) {
JSONObject map = new JSONObject();
String recode = "0" + i;
String painame = i + "排";
String pai = "0" + i;
for (int j = 1; j <= 11; j++) {
String lie = "";
String leiname = "";
if (j < 10) {
lie = "0" + j;
leiname = "0" + j + "列";
} else {
lie = j + "";
leiname = j + "列";
}
String device_code = pai + "_" + lie;
String device_name = painame + leiname;
map.put("device_id", IdUtil.simpleUUID());
map.put("device_code", device_code);
map.put("device_name", device_name);
map.put("device_type", "conveyor");
map.put("region", recode);
map.put("is_config", "FALSE");
map.put("is_route", "FALSE");
map.put("driver_code", "standard_ordinary_site");
map.put("seq_num", j);
map.put("create_by", "admin");
map.put("create_time", DateUtil.now());
map.put("update_by", "admin");
map.put("update_time", DateUtil.now());
wo.insert(map);
}
}
}
@Override

23
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java

@ -13,10 +13,13 @@ 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.common.exception.BadRequestException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
@ -37,6 +40,26 @@ public class AutoCreateInst {
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
List<TaskDto> list = taskserver.queryAll("task_status = '0'");
Collections.sort(list, new Comparator<TaskDto>() {
@Override
public int compare(TaskDto t1, TaskDto t2) {
String start_device_code1 = t1.getStart_device_code();
String start_device_code2 = t2.getStart_device_code();
Integer start_1 = Integer.parseInt(start_device_code1.split("_")[0]);
Integer start_2 = Integer.parseInt(start_device_code2.split("_")[0]);
if (start_1 > start_2){
}
int end_i = Integer.parseInt(start_device_code1.split("_")[start_device_code1.split("_").length - 1]);
int end_j = Integer.parseInt(start_device_code2.split("_")[start_device_code2.split("_").length - 1]);
if (end_i > end_j) {
return 1;
} else if (end_i < end_j) {
return -1;
}
return 0;
}
});
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
String taskid = acsTask.getTask_id();

6
acs/nladmin-system/src/main/resources/config/application-dev.yml

@ -8,11 +8,11 @@ spring:
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_one_wcs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lnam_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root}
# password: ${DB_PWD:P@ssw0rd}
# password: ${DB_PWD:Root.123456}
password: ${DB_PWD:123456}
password: ${DB_PWD:password}
# 初始连接数
initial-size: 5
@ -57,7 +57,7 @@ spring:
multi-statement-allow: true
redis:
#数据库索引
database: ${REDIS_DB:15}
database: ${REDIS_DB:3}
host: ${REDIS_HOST:127.0.0.1}
port: ${REDIS_PORT:6379}
password: ${REDIS_PWD:}

100
acs/nladmin-ui/src/views/acs/task/index.vue

@ -117,7 +117,7 @@
/>
</el-select>
</el-form-item>
<el-form-item label="立库任务类型" v-if = "form.task_type == '7'">
<el-form-item v-if="form.task_type == '7'" label="立库任务类型">
<el-select
v-model="form.storage_task_type"
style="width: 370px;"
@ -264,36 +264,36 @@
/>
</el-select>
</el-form-item>
<el-form-item label="起点2" prop="start_point_code2">
<el-select
v-model="form.start_point_code2"
style="width: 370px;"
filterable
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_code"
:value="item.device_code"
/>
</el-select>
</el-form-item>
<el-form-item label="终点2" prop="next_point_code2">
<el-select
v-model="form.next_point_code2"
style="width: 370px;"
filterable
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_code"
:value="item.device_code"
/>
</el-select>
</el-form-item>
<!-- <el-form-item label="起点2" prop="start_point_code2">-->
<!-- <el-select-->
<!-- v-model="form.start_point_code2"-->
<!-- style="width: 370px;"-->
<!-- filterable-->
<!-- placeholder="请选择"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in deviceList"-->
<!-- :key="item.device_code"-->
<!-- :label="item.device_code"-->
<!-- :value="item.device_code"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="终点2" prop="next_point_code2">-->
<!-- <el-select-->
<!-- v-model="form.next_point_code2"-->
<!-- style="width: 370px;"-->
<!-- filterable-->
<!-- placeholder="请选择"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in deviceList"-->
<!-- :key="item.device_code"-->
<!-- :label="item.device_code"-->
<!-- :value="item.device_code"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="优先级">
<el-input v-model="form.priority" style="width: 370px;" @change="isDisabled=false" />
</el-form-item>
@ -314,33 +314,33 @@
<el-table-column type="selection" width="25" />
<el-table-column v-if="false" prop="task_id" label="任务标识" />
<el-table-column prop="task_code" label="任务号" width="100" />
<el-table-column prop="task_type" label="任务类型" width="120">
<el-table-column prop="task_type" label="任务类型" width="120">
<template slot-scope="scope">
{{ dict.label.task_type[scope.row.task_type] }}
</template>
</el-table-column>
<!-- <el-table-column prop="link_num" label="关联编号" />-->
<el-table-column prop="vehicle_code" label="载具号" width="100" />
<el-table-column prop="task_status" label="任务状态" width="60">
<!-- <el-table-column prop="link_num" label="关联编号" />-->
<!-- <el-table-column prop="vehicle_code" label="载具号" width="100" />-->
<el-table-column prop="task_status" label="任务状态" width="100">
<template slot-scope="scope" width="60">
<span v-if="scope.row.task_status==='0' ">就绪</span>
<span v-if="scope.row.task_status==='1' ">执行中</span>
<span v-if="scope.row.task_status==='2' ">完成</span>
</template>
</el-table-column>
<el-table-column prop="priority" label="优先级" width="100"/>
<el-table-column prop="start_point_code" label="取货点1" width="100px" />
<el-table-column prop="put_point_code" label="倒料点" width="100" />
<el-table-column prop="next_point_code" label="放货点1" width="120px" />
<el-table-column prop="start_point_code2" label="取货点2" width="120px" />
<el-table-column prop="next_point_code2" label="放货点2" width="120px" />
<!-- <el-table-column prop="compound_task" label="复合任务">-->
<!-- <template slot-scope="scope">-->
<!-- <span v-if="scope.row.compound_task==='0' "></span>-->
<!-- <span v-if="scope.row.compound_task==='1' "></span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column prop="compound_task_data" width="200" label="复合路线" />-->
<el-table-column prop="start_point_code" label="取货点" width="100px" />
<!-- <el-table-column prop="put_point_code" label="倒料点" width="100" />-->
<el-table-column prop="next_point_code" label="放货点" width="120px" />
<el-table-column prop="priority" label="优先级" width="100" />
<!-- <el-table-column prop="start_point_code2" label="取货点2" width="120px" />-->
<!-- <el-table-column prop="next_point_code2" label="放货点2" width="120px" />-->
<!-- <el-table-column prop="compound_task" label="复合任务">-->
<!-- <template slot-scope="scope">-->
<!-- <span v-if="scope.row.compound_task==='0' "></span>-->
<!-- <span v-if="scope.row.compound_task==='1' "></span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column prop="compound_task_data" width="200" label="复合路线" />-->
<el-table-column prop="matarial" label="物料" />
<el-table-column prop="quantity" label="数量" />
<el-table-column prop="remark" label="备注" />
@ -460,7 +460,7 @@ export default {
task_id: null,
vehicle_code: null,
vehicle_type: null,
task_type: '1',
task_type: '3',
storage_task_type: '',
task_status: null,
priority: 1,
@ -479,7 +479,7 @@ export default {
to_x: null,
to_y: null,
to_z: null,
agv_system_type: ''
agv_system_type: '2'
},
rules: {
start_point_code: [

Loading…
Cancel
Save