diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/rest/YYHandController.java b/acs/nladmin-system/src/main/java/org/nl/hand/rest/YYHandController.java new file mode 100644 index 0000000..4aa3d7e --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/rest/YYHandController.java @@ -0,0 +1,103 @@ + +package org.nl.hand.rest; + + +import cn.dev33.satoken.annotation.SaIgnore; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.hand.service.YYHandService; +import org.nl.modules.logging.annotation.Log; +import org.nl.modules.system.service.UserService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +/** + * @author qxuan + * @date 2021-07-21 + **/ +@RestController +@RequiredArgsConstructor +@Api(tags = "手持接口") +@RequestMapping("/api/axr/hand") +@Slf4j +public class YYHandController { + private final UserService userService; + private final YYHandService HandService; + + @PostMapping("/task") + @Log("创建任务") + @ApiOperation("创建任务") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity createTask(@RequestBody Map whereJson) { + return new ResponseEntity<>(HandService.createTask(whereJson), HttpStatus.OK); + } + + @PostMapping("/matrial") + @Log("查询物料信息") + @ApiOperation("查询物料信息") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryMaterial() { + return new ResponseEntity<>(HandService.queryMaterial(), HttpStatus.OK); + } + + @PostMapping("/routeplan_type") + @Log("查询路由类型") + @ApiOperation("查询路由类型") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity queryRouteplanType() { + return new ResponseEntity<>(HandService.queryRouteplanType(), HttpStatus.OK); + } + + + @PostMapping("/point") + @Log("查询设备编号及状态") + @ApiOperation("查询设备编号及状态") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + //@RequestBody JSONObject json + public ResponseEntity queryPoint() { + return new ResponseEntity<>(HandService.queryPointByArea(), HttpStatus.OK); + } + + @PostMapping("/point/storage") + @Log("查询设备扩展属性") + @ApiOperation("查询设备扩展属性") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + //@RequestBody JSONObject json + public ResponseEntity queryDeviceAugmentabilityByCode(@RequestBody Map 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 queryTaskType() { + return new ResponseEntity<>(HandService.queryTaskType(), HttpStatus.OK); + } + + @PostMapping("/handlogin") + @Log("手持登陆验证") + @ApiOperation("手持登陆验证") + @SaIgnore + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity handlogin(@RequestBody Map whereJson) { + return new ResponseEntity<>(HandService.handleLogin(whereJson), HttpStatus.OK); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/service/YYHandService.java b/acs/nladmin-system/src/main/java/org/nl/hand/service/YYHandService.java new file mode 100644 index 0000000..5d28941 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/service/YYHandService.java @@ -0,0 +1,62 @@ + +package org.nl.hand.service; + + +import java.util.Map; + +/** + * @author qxuan + * @description 服务接口 + * @date 2021-07-21 + **/ +public interface YYHandService { + + + /** + * 根据区域查点位 + * + * @return Map + */ + Map queryPointByArea(); + + /** + * 查询设备扩展性 + * + * @param deviceCode + * @return + */ + Map queryDeviceAugmentabilityByCode(Map deviceCode); + + /** + * 查询任务状态 + * + * @return + */ + Map queryTaskType(); + + /** + * 查询路由类型 + * + * @return + */ + Map queryRouteplanType(); + + + /** + * 查询任务 + * + * @param jsonObject 条件 + * @return Map + */ + Map createTask(Map jsonObject); + + /** + * 查询无聊 + * + * @return Map + */ + Map queryMaterial(); + + public Map handleLogin(Map jsonObject); + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/service/dto/HandDto.java b/acs/nladmin-system/src/main/java/org/nl/hand/service/dto/HandDto.java new file mode 100644 index 0000000..e705856 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/service/dto/HandDto.java @@ -0,0 +1,80 @@ +package org.nl.hand.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; +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/service/impl/YYHandServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/hand/service/impl/YYHandServiceImpl.java new file mode 100644 index 0000000..149524d --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/service/impl/YYHandServiceImpl.java @@ -0,0 +1,253 @@ + +package org.nl.hand.service.impl; + + +import cn.hutool.core.util.StrUtil; +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.device.service.DeviceService; +import org.nl.acs.instruction.service.InstructionService; +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.hand.service.YYHandService; +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.system.service.UserService; +import org.nl.modules.system.service.dto.UserDto; +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.Map; + + +/** + * @author qxuan + * @description 服务实现 + * @date 2021-07-21 + **/ +@Service +@RequiredArgsConstructor +@Slf4j +public class YYHandServiceImpl implements YYHandService { + private final UserService userService; + private final DeviceService deviceService; + InstructionService instructionService = null; + + @Override + public Map queryPointByArea() { + JSONArray resultArr = new JSONArray(); + JSONObject resultJson = new JSONObject(); + //根据value值去查所有的设备 + //JSONArray acs_deviceja = WQLObject.getWQLObject("ACS_DEVICE").query("device_type='conveyor'", "seq_num,device_name").getResultJSONArray(0); + JSONArray acs_deviceja = WQLObject.getWQLObject("ACS_DEVICE").query("", "seq_num,device_name").getResultJSONArray(0); + JSONArray acs_storage = WQLObject.getWQLObject("acs_storage_cell").query("x>0 AND y>0 AND z>0 AND is_active = '1' AND is_delete = '0'", "address").getResultJSONArray(0); +// JSONArray storage_rows = new JSONArray(); +// for (int i = 0; i < acs_storage.size(); i++) { +// JSONObject acs_jo = acs_storage.getJSONObject(i); +// acs_jo.put("device_code", acs_jo.getString("storage_code")); +// acs_jo.put("device_id", acs_jo.getString("storage_id")); +// storage_rows.add(acs_jo); +// } +// acs_deviceja.addAll(storage_rows); + for (int i = 0; i < acs_deviceja.size(); i++) { + JSONObject jo = new JSONObject(); + JSONObject devicejo = acs_deviceja.getJSONObject(i); + jo.put("device_id", devicejo.getString("device_id")); + jo.put("device_code", devicejo.getString("device_code")); + jo.put("device_name", devicejo.getString("device_name")); + jo.put("device_type", devicejo.getString("device_type")); + resultArr.add(jo); + } + resultJson.put("code", "1"); + resultJson.put("desc", "查询成功"); + resultJson.put("result", resultArr); + return resultJson; + } + + @Override + public Map 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 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 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 createTask(Map 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 routeplan_type = jsonObject.get("routeplan_type"); + String priority = jsonObject.get("priority"); + String carrier = jsonObject.get("carrier"); + JSONObject resultJson = new JSONObject(); + if (StrUtil.isEmpty(start_devicecode)) { + throw new BadRequestException("起点不能为空!"); + } + if (StrUtil.isEmpty(next_devicecode)) { + throw new BadRequestException("终点点不能为空!"); + } + if (StrUtil.isEmpty(routeplan_type)) { + throw new BadRequestException("路由方案类型不能为空!"); + } + 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.setRoute_plan_code(routeplan_type); + dto.setPriority(priority); + dto.setVehicle_code(carrier); + try { + taskService.create(dto); + } 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 queryMaterial() { + JSONArray resultArr = WQL.getWO("QHAND_QUERY002").addParam("flag", "5").process().getResultJSONArray(0); + JSONObject jo = new JSONObject(); + jo.put("code", "1"); + jo.put("desc", "查询成功"); + jo.put("result", resultArr); + return jo; + } + + @SneakyThrows + @Override + public Map handleLogin(Map 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 = true; + + } 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; + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/wql/QHAND_QUERY002.wql b/acs/nladmin-system/src/main/java/org/nl/hand/wql/QHAND_QUERY002.wql new file mode 100644 index 0000000..ee8a980 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/wql/QHAND_QUERY002.wql @@ -0,0 +1,174 @@ +[交易说明] + 交易名: 手持接口查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.key TYPEAS s_string + 输入.keyword TYPEAS s_string + 输入.start_devicecode TYPEAS s_string + 输入.next_devicecode 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, + sys2.VALUE AS material_type_name, + sys2.label AS material_type, + sys.VALUE AS task_status_name, + sys.label AS task_status, + task.vehicle_code AS carrier, + task.create_time, + task.priority + FROM + acs_task task + LEFT JOIN sys_dict_detail sys ON sys.label = task.task_status + AND sys.NAME = 'task_status' + LEFT JOIN sys_dict_detail 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 or task.task_status like 输入.key) + ENDOPTION + OPTION 输入.start_point <> "" + task.start_point_code = 输入.start_point + ENDOPTION + OPTION 输入.next_point <> "" + task.next_point_code = 输入.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.VALUE AS inst_status_name, + inst.execute_message AS inst_step, + inst.vehicle_code AS carrier, + inst.carno, + inst.priority, + inst.create_time, + inst.material AS material_type, + dtl2.VALUE AS material_type_name + FROM + acs_instruction inst + LEFT JOIN sys_dict_detail AS dtl ON dtl.label = inst.instruction_status + AND dtl.NAME = 'inst_status' + LEFT JOIN sys_dict_detail AS dtl2 ON dtl2.label = inst.material + AND dtl2.NAME = 'material_type' + WHERE + inst.is_delete = '0' + AND inst.instruction_status <> '2' + AND inst.instruction_status <> '3' + OPTION 输入.keyword <> "" + (inst.instruction_code like 输入.keyword + or + inst.task_code like 输入.keyword + or inst.execute_device_code like 输入.keyword) + ENDOPTION + OPTION 输入.start_devicecode <> "" + inst.start_point_code = 输入.start_devicecode + ENDOPTION + OPTION 输入.next_devicecode <> "" + inst.next_point_code = 输入.next_devicecode + 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 diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls b/acs/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls index a73514e..c77a753 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls and b/acs/nladmin-system/src/main/java/org/nl/modules/system/wql/sys.xls differ