Browse Source

更新

master
gengby 2 years ago
parent
commit
f8e0813e2b
  1. 7
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java
  2. 2
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsZDService.java
  3. 334
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java
  4. 5
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java
  5. 8
      hd/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java
  6. 2
      hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java
  7. 2
      hd/nladmin-system/src/main/resources/config/application-dev.yml
  8. 2
      hd/nladmin-system/src/main/resources/config/application.yml
  9. 12
      qd/src/views/acs/instruction/index.vue
  10. 7
      qd/src/views/acs/route/routeLine/index.vue

7
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsZDController.java

@ -46,4 +46,11 @@ public class AcsToWmsZDController {
public ResponseEntity<Object> taskDeprecate(@RequestBody Map whereJson) throws Exception {
return new ResponseEntity<>(acsToWmsZDService.taskDeprecate(whereJson), HttpStatus.OK);
}
@PostMapping("/checkDeviceStatus")
@Log("设备状态获取")
@ApiOperation("设备状态获取")
public ResponseEntity<Object> checkDeviceStatus(@RequestBody Map whereJson) throws Exception {
return new ResponseEntity<>(acsToWmsZDService.checkDeviceStatus(whereJson), HttpStatus.OK);
}
}

2
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsZDService.java

@ -36,5 +36,5 @@ public interface AcsToWmsZDService {
*
* @return Map<String, Object>
*/
HttpResponse deviceStatusQuery(JSONObject whereJson) throws Exception;
Map<String, Object> checkDeviceStatus(Map whereJson) throws Exception;
}

334
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java

@ -8,30 +8,26 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.nl.acs.config.AcsConfig;
import org.nl.acs.config.server.AcsConfigService;
import org.nl.acs.device.address.service.AddressService;
import org.nl.acs.device.address.service.dto.AddressDto;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.device_driver.standard_conveyor_line.StandardConveyorLineDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsZDService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.LogServer;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
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.exception.BadRequestException;
import org.nl.exception.WDKException;
import org.nl.utils.SpringContextHolder;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -40,6 +36,8 @@ import java.util.Map;
@Slf4j
public class AcsToWmsZDServiceImpl implements AcsToWmsZDService {
private final DeviceAppService deviceAppService;
@Autowired
RouteLineService routeLineService;
@ -64,121 +62,117 @@ public class AcsToWmsZDServiceImpl implements AcsToWmsZDService {
@Override
public Map<String, Object> taskCreate(JSONObject whereJson) {
JSONObject resultJson = new JSONObject();
Map<String, Object> map = new HashMap<>();
log.info("taskCreate--------------:输入参数:" + whereJson.toString());
try {
JSONArray errArr = new JSONArray();
//获取甲方wcs传过来的参数
String houseCode = whereJson.optString("houseCode");
String systemCode = whereJson.optString("systemCode");
JSONObject parameters = whereJson.optJSONObject("parameters");
String taskCode = whereJson.optString("taskCode");
String taskType = whereJson.optString("taskType");
String taskCreateDatetime = whereJson.optString("taskCreateDatetime");
String containerCode = whereJson.optString("containerCode");
String containerType = whereJson.optString("containerType");
String start_point_code = whereJson.optString("locationFrom");
String next_point_code = whereJson.optString("locationTo");
String priority = whereJson.optString("priority");
String start_device_code = "";
String next_device_code = "";
//判断必填项是否为空
if (StrUtil.isEmpty(taskCode)) {
throw new WDKException("任务号不能为空");
}
if (StrUtil.isEmpty(start_point_code)) {
throw new WDKException("起点不能为空");
}
if (StrUtil.isEmpty(next_point_code)) {
throw new WDKException("终点不能为空");
}
if (StrUtil.isEmpty(containerCode)) {
throw new WDKException("容器编号不能为空");
}
if (start_point_code.indexOf("-") > 0) {
String str[] = start_point_code.split("-");
start_device_code = str[0];
} else {
start_device_code = start_point_code;
}
//获取甲方wcs传过来的参数
String houseCode = whereJson.optString("houseCode");
String systemCode = whereJson.optString("systemCode");
JSONObject parameters = whereJson.optJSONObject("parameters");
String taskCode = whereJson.optString("taskCode");
String taskType = whereJson.optString("taskType");
String taskCreateDatetime = whereJson.optString("taskCreateDatetime");
String containerCode = whereJson.optString("containerCode");
String containerType = whereJson.optString("containerType");
String start_point_code = whereJson.optString("locationFrom");
String next_point_code = whereJson.optString("locationTo");
String priority = whereJson.optString("priority");
if (next_point_code.indexOf("-") > 0) {
String str[] = next_point_code.split("-");
next_device_code = str[0];
} else {
next_device_code = next_point_code;
}
String start_device_code = "";
String next_device_code = "";
//判断必填项是否为空
if (StrUtil.isEmpty(taskCode)) {
map.put("responseCode", 1);
map.put("responseMessage", "任务号不能为空");
return map;
}
if (StrUtil.isEmpty(start_point_code)) {
map.put("responseCode", 1);
map.put("responseMessage", "起点不能为空");
return map;
}
if (StrUtil.isEmpty(next_point_code)) {
map.put("responseCode", 1);
map.put("responseMessage", "终点不能为空");
return map;
}
if (StrUtil.isEmpty(containerCode)) {
map.put("responseCode", 1);
map.put("responseMessage", "容器编号不能为空");
return map;
}
//查询wcs传过来的起点终点路由
List<RouteLineDto> list = routeLineService.getShortPathLines(start_device_code, next_device_code, "normal");
if (ObjectUtil.isEmpty(list)) {
throw new WDKException("路由不通!");
}
//查询任务编码是否重复
TaskDto taskDto = taskService.findByCodeFromCache(taskCode);
if (taskDto != null) {
throw new WDKException("不能存在相同的任务号!");
}
//判断载具编码是否相同
if (!StrUtil.isEmpty(containerCode)) {
TaskDto vehicle_dto = taskService.findByContainer(containerCode);
if (vehicle_dto != null) {
throw new WDKException("已存在该容器号的任务!");
}
}
if (start_point_code.indexOf("-") > 0) {
String str[] = start_point_code.split("-");
start_device_code = str[0];
} else {
start_device_code = start_point_code;
}
JSONObject jo = new JSONObject();
jo.put("task_code", taskCode);
jo.put("start_point_code", start_point_code);
jo.put("next_point_code", next_point_code);
jo.put("start_parent_code", start_point_code);
jo.put("next_parent_code", next_point_code);
jo.put("start_device_code", start_device_code);
jo.put("next_device_code", next_device_code);
jo.put("priority", priority);
jo.put("vehicle_code", containerCode);
jo.put("vehicle_type", containerType);
jo.put("create_time", taskCreateDatetime);
jo.put("task_type", taskType);
TaskDto task_dto = (TaskDto) JSONObject.toBean(jo, TaskDto.class);
try {
taskService.create(task_dto);
} catch (Exception e) {
e.printStackTrace();
JSONObject json = new JSONObject();
json.put("task_code", taskCode);
json.put("message", e.getMessage());
errArr.add(json);
}
if (next_point_code.indexOf("-") > 0) {
String str[] = next_point_code.split("-");
next_device_code = str[0];
} else {
next_device_code = next_point_code;
}
if (ObjectUtil.isEmpty(errArr)) {
resultJson.put("responseCode", 0);
resultJson.put("responseMessage", "操作成功");
} else {
resultJson.put("responseCode", 400);
resultJson.put("responseMessage", "操作失败");
//查询wcs传过来的起点终点路由
List<RouteLineDto> list = routeLineService.getShortPathLines(start_device_code, next_device_code, "normal");
if (ObjectUtil.isEmpty(list)) {
map.put("responseCode", 1);
map.put("responseMessage", "路由不通!");
return map;
}
//查询任务编码是否重复
TaskDto taskDto = taskService.findByCodeFromCache(taskCode);
if (taskDto != null) {
map.put("responseCode", 1);
map.put("responseMessage", "不能存在相同的任务号!");
return map;
}
//判断载具编码是否相同
if (!StrUtil.isEmpty(containerCode)) {
TaskDto vehicle_dto = taskService.findByContainer(containerCode);
if (vehicle_dto != null) {
map.put("responseCode", 1);
map.put("responseMessage", "已存在该容器号的任务!");
return map;
}
resultJson.put("parameters", errArr);
log.info("taskCreate--------------:输出参数:" + resultJson.toString());
}
JSONObject jo = new JSONObject();
jo.put("task_code", taskCode);
jo.put("start_point_code", start_point_code);
jo.put("next_point_code", next_point_code);
jo.put("start_parent_code", start_point_code);
jo.put("next_parent_code", next_point_code);
jo.put("start_device_code", start_device_code);
jo.put("next_device_code", next_device_code);
jo.put("priority", priority);
jo.put("vehicle_code", containerCode);
jo.put("vehicle_type", containerType);
jo.put("create_time", taskCreateDatetime);
jo.put("task_type", taskType);
TaskDto task_dto = (TaskDto) JSONObject.toBean(jo, TaskDto.class);
try {
taskService.create(task_dto);
} catch (Exception e) {
resultJson.put("responseCode", 400);
resultJson.put("parameters", e.getMessage());
resultJson.put("responseMessage", "操作失败");
log.info("taskCreate--------------:输出参数:" + resultJson.toString());
e.printStackTrace();
map.put("responseCode", 1);
map.put("responseMessage", e.getMessage());
return map;
}
return resultJson;
map.put("responseCode", 0);
map.put("responseMessage", "创建任务成功!");
map.put("parameters", new HashMap<>());
return map;
}
@Override
public Map<String, Object> taskFeedback(Map whereJson){
public Map<String, Object> taskFeedback(Map whereJson) {
log.info("taskFeedback-----请求参数{}", whereJson.toString());
String taskCode = (String) whereJson.get("task_code");
String vehicle_code = (String) whereJson.get("carId");
String taskCode = MapUtil.getStr(whereJson, "taskCode");
String carId = MapUtil.getStr(whereJson, "carId");
HttpResponse result = null;
AddressDto addressDto = addressService.findByCode("taskFeedback");
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WCSURL);
@ -189,47 +183,22 @@ public class AcsToWmsZDServiceImpl implements AcsToWmsZDService {
.header("Authorization", token).body(String.valueOf(whereJson))
.execute();
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
logServer.log(taskCode, "taskFeedback", "error", whereJson.toString(), msg, String.valueOf(result.getStatus()), url, vehicle_code);
log.info("taskFeedback-----异常输出参数{}", msg);
}
String type = "";
if(!ObjectUtil.isEmpty(result)){
if (result.getStatus() == 0) {
type = "info";
} else {
type = "error";
}
} else {
type = "error";
logServer.log(taskCode, "taskFeedback", "error", whereJson.toString(), result.body(), String.valueOf(result.getStatus()), url, carId);
Map<String, Object> map = new HashMap<>();
map.put("responseCode", 1);
map.put("responseMessage", e.getMessage());
map.put("parameters", new HashMap<>());
return map;
}
logServer.log(taskCode, "taskFeedback", type, whereJson.toString(), result.body(), String.valueOf(result.getStatus()), url, vehicle_code);
logServer.log(taskCode, "taskFeedback", "success", whereJson.toString(), result.body(), String.valueOf(result.getStatus()), url, carId);
JSONObject jo = JSONObject.fromObject(result.body());
log.info("taskFeedback-----输出参数{}", jo.toString());
return jo;
}
@Override
public Map<String, Object> taskDeprecate(Map whereJson) throws Exception {
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
public Map<String, Object> taskDeprecate(Map whereJson) {
log.info("taskDeprecate--------------:输入参数" + whereJson.toString());
String taskCode = MapUtil.getStr(whereJson,"task_code");
String houseCode =MapUtil.getStr(whereJson,"taskhouseCode_code");
Object parameters = whereJson.get("parameters");
String systemCode = MapUtil.getStr(whereJson,"systemCode");
String reason = MapUtil.getStr(whereJson,"reason");
if(ObjectUtil.isEmpty(taskCode)){
throw new BadRequestException("任务编号不能为空");
}
JSONObject map = new JSONObject();
map.put("houseCode",houseCode);
map.put("systemCode",systemCode);
map.put("parameters",parameters);
map.put("taskCode",taskCode);
map.put("reason",reason);
String taskCode = MapUtil.getStr(whereJson, "task_code");
HttpResponse result = null;
AddressDto addressDto = addressService.findByCode("deprecateTask");
String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WCSURL);
@ -240,50 +209,57 @@ public class AcsToWmsZDServiceImpl implements AcsToWmsZDService {
.header("Authorization", token).body(String.valueOf(whereJson))
.execute();
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
logServer.log(taskCode, "taskFeedback", "error", whereJson.toString(), msg, String.valueOf(result.getStatus()), url, "");
log.info("taskFeedback-----异常输出参数{}", msg);
}
String type = "";
if(!ObjectUtil.isEmpty(result)){
if (result.getStatus() == 0) {
type = "info";
} else {
type = "error";
}
} else {
type = "error";
e.printStackTrace();
logServer.log(taskCode, "taskFeedback", "error", whereJson.toString(), e.getMessage(), String.valueOf(result.getStatus()), url, "");
Map<String, Object> map = new HashMap<>();
map.put("responseCode", 1);
map.put("responseMessage", e.getMessage());
return map;
}
logServer.log(taskCode, "taskDeprecate", type, whereJson.toString(), result.body(), String.valueOf(result.getStatus()), url, "");
logServer.log(taskCode, "taskDeprecate", "success", whereJson.toString(), result.body(), String.valueOf(result.getStatus()), url, "");
JSONObject jo = JSONObject.fromObject(result.body());
log.info("taskDeprecate-----输出参数{}", jo.toString());
return jo;
}
@Override
public HttpResponse deviceStatusQuery(JSONObject whereJson) throws Exception {
String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
AddressDto addressDto = addressService.findByCode("deviceStatusQuery");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
HttpResponse result = null;
log.info("feedWeighing----请求参数{}", whereJson);
public Map<String, Object> checkDeviceStatus(Map whereJson) throws Exception {
Map<String, Object> map = new HashMap<>();
String systemCode = MapUtil.getStr(whereJson, "systemCode");
String houseCode = MapUtil.getStr(whereJson, "houseCode");
String parameters = MapUtil.getStr(whereJson, "parameters");
String deviceCode = MapUtil.getStr(whereJson, "deviceCode");
if (StrUtil.isEmpty(deviceCode)) {
map.put("responseCode", 1);
map.put("responseMessage", "请求设备号不能为空!");
map.put("parameters", new HashMap<>());
return map;
}
Device device = deviceAppService.findDeviceByCode(deviceCode);
StandardConveyorLineDeviceDriver standardConveyorLineDeviceDriver;
int status = 0;
Boolean hasGoods = false;
String statusDescription = "正常";
if (device.getDeviceDriver() instanceof StandardConveyorLineDeviceDriver) {
standardConveyorLineDeviceDriver = (StandardConveyorLineDeviceDriver) device.getDeviceDriver();
status = standardConveyorLineDeviceDriver.getError();
int move = standardConveyorLineDeviceDriver.getMove();
if (status != 0) {
statusDescription = "异常";
}
if (move == 1) {
hasGoods = true;
}
} else if (1 == 1) {
try {
result = HttpRequest.post(url)
.body(String.valueOf(whereJson))
.execute();
System.out.println(result);
log.info("feedWeighing----返回参数{}", result);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
}
return result;
map.put("responseCode", 0);
map.put("responseMessage", "响应成功!");
map.put("parameters", new HashMap<>());
map.put("status", status);
map.put("statusDescription", statusDescription);
map.put("hasGoods", hasGoods);
return map;
}
}

5
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java

@ -34,7 +34,6 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
@Override
public Map<String, Object> waitpointRequest(JSONObject param) {
// TODO 待定
String inst_code = param.getString("task_code");
String address = param.getString("address");
StandardConveyorLineDeviceDriver standardConveyorLineDeviceDriver;
@ -44,7 +43,6 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
map.put("status", 400);
map.put("message", "请求失败,指令为空!");
logServer.log("", "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", "");
// return map;
throw new BadRequestException("请求失败,指令为空!");
}
String task_code = instructionDto.getTask_code();
@ -156,7 +154,7 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
logServer.log(task_code, "waitpointRequest", type, param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code());
throw new BadRequestException("请求失败,终点位置无货!");
} else {
standardConveyorLineDeviceDriver.writing(1, 2);
standardConveyorLineDeviceDriver.writing(1, 3);
feedMap.put("feedbackStatus", "putFinish");
Map<String, Object> feedback = acsToWmsZDService.taskFeedback(feedMap);
int responseCode = (int) feedback.get("responseCode");
@ -182,6 +180,5 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
map.put("message", "请求失败,IN OUT 站点错误!");
logServer.log(task_code, "waitpointRequest", "erro", param.toString(), String.valueOf(map), "400", "api/agv/waitpointRequest", instructionDto.getVehicle_code());
throw new BadRequestException("请求失败,终点位置无货!");
//return map;
}
}

8
hd/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java

@ -108,6 +108,14 @@ public class InstructionController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("强制取消指令")
@ApiOperation("强制取消指令")
@PostMapping(value = "/forceCancel/{id}")
public ResponseEntity<Object> forceCancel(@RequestBody String id) throws Exception {
instructionService.cancelNOSendAgv(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("导出指令")
@ApiOperation("导出指令")
@GetMapping(value = "/download")

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

@ -774,7 +774,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
JSONObject map = new JSONObject();
map.put("task_code",entity.getTask_code());
// map.put("reason",entity.getTask_code());
map.put("reason","acs手动取消!");
acsToWmsZDService.taskDeprecate(map);
}
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code());

2
hd/nladmin-system/src/main/resources/config/application-dev.yml

@ -60,7 +60,7 @@ spring:
multi-statement-alagvslow: true
redis:
#数据库索引
database: ${REDIS_DB:0}
database: ${REDIS_DB:11}
host: ${REDIS_HOST:127.0.0.1}
port: ${REDIS_PORT:6379}
password: ${REDIS_PWD:}

2
hd/nladmin-system/src/main/resources/config/application.yml

@ -2,7 +2,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: prod
active: dev
jackson:
time-zone: GMT+8
data:

12
qd/src/views/acs/instruction/index.vue

@ -159,6 +159,7 @@
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'a')">完成</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'b')">取消</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'c')">强制取消</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
@ -290,6 +291,14 @@ export default {
console.log(err.response.data.message)
})
},
forceCancel(index, row) {
crudInstruction.forceCancel(row.instruction_id).then(res => {
this.crud.toQuery()
this.crud.notify('强制取消成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
}).catch(err => {
console.log(err.response.data.message)
})
},
reload() {
crudInstruction.reload().then(res => {
this.crud.toQuery()
@ -313,6 +322,9 @@ export default {
case 'b'://
this.cancel(command.index, command.row)
break
case 'c'://
this.forceCancel(command.index, command.row)
break
}
}

7
qd/src/views/acs/route/routeLine/index.vue

@ -315,6 +315,13 @@ export default {
this.form.next_device_code = Array.of(data.form.next_device_code.split('').join(''))
return true
},
[CRUD.HOOK.beforeSubmit](data) {
if (this.crud.status.edit === 1) {
this.form.device_code = data.form.device_code.join('')
this.form.next_device_code = data.form.next_device_code.join('')
}
return true
},
//
changeEnabled(data) {
var msg = '停用'

Loading…
Cancel
Save