Browse Source

opt: 与ACS通信与数据返回处理

master
李永德 1 year ago
parent
commit
d5d20f04ef
  1. 13
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java
  2. 44
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/ResultForAcs.java
  3. 1
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/PutActionRequest.java
  4. 10
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  5. 33
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java
  6. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/ISysInteractRecordService.java
  7. 17
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/impl/SysInteractRecordServiceImpl.java
  8. 9
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/controller/PdmBdWorkorderController.java
  9. 6
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java
  10. 57
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java
  11. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java
  12. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java
  13. 76
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/AcsUtil.java
  14. 13
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java
  15. 1
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQKTask.java
  16. 7
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java
  17. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java
  18. 24
      lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/PointCreate.java
  19. 23
      lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue
  20. 10
      lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js

13
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/WmsToAcsService.java

@ -1,9 +1,22 @@
package org.nl.wms.ext.acs.service;
import com.alibaba.fastjson.JSONArray;
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import java.util.Map;
/**
* @Author: lyd
* @Description: Wms请求Acs
* @Date: 2023/6/30
*/
public interface WmsToAcsService {
/**
* 下发工单
* @param workorder
* @return
*/
ResultForAcs order(PdmBdWorkorder workorder);
}

44
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/ResultForAcs.java

@ -0,0 +1,44 @@
package org.nl.wms.ext.acs.service.dto;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
/**
* @Author: lyd
* @Description: 统一接口返回 - 请求ACS返回的数据类型
* @Date: 2023/7/28
*/
@Data
public class ResultForAcs {
private int status;
private String message;
private String timestamp;
private JSONObject data;
public static ResultForAcs requestRefuse(String message) {
ResultForAcs result = new ResultForAcs();
result.setStatus(HttpStatus.HTTP_BAD_REQUEST);
result.setMessage(message);
result.setTimestamp(DateUtil.now());
return result;
}
public static ResultForAcs requestOk() {
ResultForAcs result = new ResultForAcs();
result.setStatus(HttpStatus.HTTP_OK);
result.setMessage("请求成功");
result.setTimestamp(DateUtil.now());
return result;
}
public static ResultForAcs requestOk(String message, JSONObject data) {
ResultForAcs result = new ResultForAcs();
result.setStatus(HttpStatus.HTTP_OK);
result.setMessage(message);
result.setTimestamp(DateUtil.now());
result.setData(data);
return result;
}
}

1
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/dto/to/acs/PutActionRequest.java

@ -18,6 +18,7 @@ public class PutActionRequest extends BaseRequest {
* 设备号
*/
private String device_code;
private String vehicle_type;
/**
* 信号数据

10
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java

@ -554,7 +554,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
abstractTask.updateTaskStatus(taskCode, status);
} catch (Exception e) {
log.error("任务状态更新失败:{}", message);
log.error("任务状态更新失败: {}", message);
return BaseResponse.responseError(requestNo, "任务:[" + taskCode + "]状态更新失败," + message);
}
return BaseResponse.responseOk(requestNo, "任务状态反馈成功!");
@ -587,7 +587,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String requestNo = actionRequest.getRequestNo();
String deviceCode = actionRequest.getDevice_code();
List<SignalData> list = actionRequest.getList();
// String vehicleType = actionRequest.getVehicle_type();
String vehicleType = actionRequest.getVehicle_type();
if (deviceCode == null) {
return BaseResponse.responseError(requestNo, "设备编码不能为空");
}
@ -610,9 +610,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
&& move.equals(PointStatusEnum.EMPTY_VEHICLE.getCode())) || (pointStatus.equals(move))) { // 不做操作
return BaseResponse.responseOk(requestNo);
}
// if (vehicleType != null) {
// schBasePoint.setVehicle_type(vehicleType);
// }
if (vehicleType != null) {
schBasePoint.setVehicle_type(vehicleType);
}
schBasePoint.setPoint_status(move);
PointUtils.setUpdateByAcs(schBasePoint);
pointService.updateById(schBasePoint);

33
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/WmsToAcsServiceImpl.java

@ -1,15 +1,46 @@
package org.nl.wms.ext.acs.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpStatus;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
import org.nl.wms.ext.record.service.ISysInteractRecordService;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.task.AcsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: lyd
* @Description:
* @Description: WMS请求ACS - 业务开发
* @Date: 2023/6/30
*/
@Slf4j
@Service
public class WmsToAcsServiceImpl implements WmsToAcsService {
@Autowired
private ISysInteractRecordService interactRecordService;
@Override
public ResultForAcs order(PdmBdWorkorder workorder) {
String api = "api/wms/order";
List<PdmBdWorkorder> list = new ArrayList<>();
list.add(workorder);
ResultForAcs resultForAcs = ResultForAcs.requestOk();
try {
resultForAcs = AcsUtil.notifyAcs(api, list);
} catch (Exception e) {
log.error(api + ": {}", e.getMessage());
resultForAcs.setTimestamp(DateUtil.now());
resultForAcs.setStatus(HttpStatus.HTTP_BAD_REQUEST);
resultForAcs.setMessage(e.getMessage());
}
// 记录日志
interactRecordService.saveRecord(workorder, resultForAcs, GeneralDefinition.LMS_ACS);
return resultForAcs;
}
}

4
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/ISysInteractRecordService.java

@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.query.PageQuery;
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
import org.nl.wms.ext.acs.service.dto.to.BaseResponse;
import org.nl.wms.ext.record.service.dao.SysInteractRecord;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import java.util.Map;
import java.util.Set;
@ -47,4 +49,6 @@ public interface ISysInteractRecordService extends IService<SysInteractRecord> {
* 创建记录
*/
void saveRecord(Object request, BaseResponse response, String direction);
void saveRecord(PdmBdWorkorder workorder, ResultForAcs resultForAcs, String lmsAcs);
}

17
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/record/service/impl/SysInteractRecordServiceImpl.java

@ -11,10 +11,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
import org.nl.wms.ext.acs.service.dto.to.BaseResponse;
import org.nl.wms.ext.record.service.ISysInteractRecordService;
import org.nl.wms.ext.record.service.dao.mapper.SysInteractRecordMapper;
import org.nl.wms.ext.record.service.dao.SysInteractRecord;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -77,4 +79,19 @@ public class SysInteractRecordServiceImpl extends ServiceImpl<SysInteractRecordM
sysInteractRecordMapper.insert(entity);
}
@Override
public void saveRecord(PdmBdWorkorder workorder, ResultForAcs resultForAcs, String lmsAcs) {
SysInteractRecord entity = new SysInteractRecord();
entity.setInteract_id(IdUtil.getSnowflake(1, 1).nextIdStr());
entity.setInteract_code(workorder.getWorkorder_code());
entity.setCode(resultForAcs.getStatus());
entity.setMessage(resultForAcs.getMessage());
entity.setRecord_time(DateUtil.now());
entity.setDirection(lmsAcs);
entity.setRequest_param(JSONObject.toJSONString(workorder));
entity.setResponse_param(JSONObject.toJSONString(resultForAcs));
entity.setIs_success(resultForAcs.getStatus() == HttpStatus.HTTP_OK);
sysInteractRecordMapper.insert(entity);
}
}

9
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/controller/PdmBdWorkorderController.java

@ -1,5 +1,6 @@
package org.nl.wms.pdm.workorder.controller;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -63,4 +64,12 @@ public class PdmBdWorkorderController {
pdmBdWorkorderService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@PostMapping("/submits")
@Log("工单下发")
@ApiOperation("工单下发")
public ResponseEntity<Object> submits(@RequestBody PdmBdWorkorder entity){
pdmBdWorkorderService.submits(entity);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}

6
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/IPdmBdWorkorderService.java

@ -49,4 +49,10 @@ public interface IPdmBdWorkorderService extends IService<PdmBdWorkorder> {
PdmBdWorkorder getDeviceProductionTask(String deviceCode);
PdmBdWorkorder getByCode(String orderCode);
/**
* 工单下发
* @param entity
*/
void submits(PdmBdWorkorder entity);
}

57
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pdm/workorder/service/impl/PdmBdWorkorderServiceImpl.java

@ -2,6 +2,8 @@ package org.nl.wms.pdm.workorder.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -12,15 +14,21 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.CodeUtil;
import org.nl.common.utils.SecurityUtils;
import org.nl.system.service.notice.ISysNoticeService;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.pdm.workorder.service.dao.mapper.PdmBdWorkorderMapper;
import org.nl.wms.pdm.workorder.service.dto.PdmBdWorkorderQuery;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
import org.nl.wms.sch.task_manage.enums.WorkOrderStatusEnum;
import org.nl.wms.util.TaskUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Set;
/**
@ -35,6 +43,11 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
@Autowired
private PdmBdWorkorderMapper pdmBdWorkorderMapper;
@Autowired
private WmsToAcsService wmsToAcsService;
@Autowired
private ISysNoticeService noticeService;
@Override
public IPage<PdmBdWorkorder> queryAll(PdmBdWorkorderQuery query, PageQuery page){
IPage<PdmBdWorkorder> pages = new Page<>(page.getPage() + 1, page.getSize());
@ -96,4 +109,48 @@ public class PdmBdWorkorderServiceImpl extends ServiceImpl<PdmBdWorkorderMapper,
return pdmBdWorkorderMapper.selectOne(lam);
}
@Override
public void submits(PdmBdWorkorder entity) {
PdmBdWorkorder pdmBdWorkorder = pdmBdWorkorderMapper.selectById(entity.getWorkorder_id());
if (ObjectUtil.isEmpty(pdmBdWorkorder)) {
throw new BadRequestException("工单编码[" + entity.getWorkorder_code() + "]不存在");
}
// 检验是否已经开工
if (pdmBdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.PRODUCING.getCode())) {
throw new BadRequestException("工单已生产");
}
if (pdmBdWorkorder.getWorkorder_status().equals(WorkOrderStatusEnum.COMPLETE.getCode())) {
throw new BadRequestException("工单已完工");
}
// 查找是否有当前设备已经开工的工单
LambdaQueryWrapper<PdmBdWorkorder> lam = new QueryWrapper<PdmBdWorkorder>().lambda();
lam.eq(PdmBdWorkorder::getPoint_code, entity.getPoint_code())
.eq(PdmBdWorkorder::getWorkorder_status, WorkOrderStatusEnum.PRODUCING.getCode())
.eq(PdmBdWorkorder::getIs_delete, false);
PdmBdWorkorder bdWorkorder = pdmBdWorkorderMapper.selectOne(lam);
if (ObjectUtil.isNotEmpty(bdWorkorder)) {
throw new BadRequestException("该设备已有生产工单,不能重复下发");
}
ResultForAcs resultForAcs = null;
try {
resultForAcs = wmsToAcsService.order(pdmBdWorkorder);
} catch (Exception e) {
log.error("工单下发异常:" + e.getMessage());
// 通知
noticeService.createNotice("工单下发失败: " + e.getMessage(), "工单下发失败: "
+ pdmBdWorkorder.getWorkorder_code(), NoticeTypeEnum.EXCEPTION.getCode());
throw new BadRequestException("工单下发失败");
}
if (resultForAcs.getStatus() != HttpStatus.HTTP_OK) {
// 不成功
noticeService.createNotice(resultForAcs.getMessage(), "工单下发失败: " + pdmBdWorkorder.getWorkorder_code(),
NoticeTypeEnum.EXCEPTION.getCode());
throw new BadRequestException("工单下发失败");
}
// 修改工单数据
pdmBdWorkorder.setWorkorder_status(WorkOrderStatusEnum.ISSUED.getCode());
TaskUtils.setWorkOrderUpdateByAcs(pdmBdWorkorder);
pdmBdWorkorderMapper.updateById(pdmBdWorkorder);
}
}

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java

@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.point.service.ISchBasePointService;
@ -57,7 +58,7 @@ public abstract class AbstractTask {
* @author ldjun
* @created 2020年6月12日 下午5:52:28
*/
protected JSONObject renotifyAcs(SchBaseTask task) {
protected ResultForAcs renotifyAcs(SchBaseTask task) {
Assert.notNull(task);
List<SchBaseTask> taskList = new ArrayList<>();
taskList.add(task);
@ -70,7 +71,7 @@ public abstract class AbstractTask {
* @author ldjun
* @created 2020年6月12日 下午5:52:28
*/
protected JSONObject renotifyAcs(List<SchBaseTask> taskList) {
protected ResultForAcs renotifyAcs(List<SchBaseTask> taskList) {
//1、获取任务
//2、根据任务配置补全任务
//3、下发

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java

@ -62,4 +62,9 @@ public class GeneralDefinition {
public static final String UPPER_CONVEYOR_LINE = "3";
/** 下输送线 */
public static final String LOWER_CONVEYOR_LINE = "4";
// 参数名称
/** 是否连接 */
public static final String IS_CONNECT_ACS = "is_connect_acs";
/** ACS路径 */
public static final String ACS_URL = "acs_url";
}

76
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/AcsUtil.java

@ -1,105 +1,67 @@
package org.nl.wms.sch.task_manage.task;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.dao.Param;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.record.service.ISysInteractRecordService;
import org.nl.wms.ext.record.service.impl.SysInteractRecordServiceImpl;
import org.nl.wms.sch.task_manage.AcsTaskDto;
import org.nl.wms.ext.acs.service.dto.ResultForAcs;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.springframework.http.HttpStatus;
import java.util.List;
/**
* ACS连接工具类:
* ACS连接工具类: 不允许直接操作结果将其封装到ResultForAcs由实现类操作
*/
@Slf4j
public class AcsUtil {
/**
* 统一多数据入口
* 统一多数据入口 默认执行的参数都是jsonArray
* @param api
* @param list
* @return
* @param <T>
*/
public static <T> JSONObject notifyAcs(String api, List<T> list) {
public static <T> ResultForAcs notifyAcs(String api, List<T> list) {
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
// list转JSONArray
String s = JSON.toJSONString(list);
//判断是否连接ACS系统
Param isConnectAcs = sysParamService.findByCode("IS_CONNECT_ACS");
Param isConnectAcs = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_ACS);
if (ObjectUtil.isEmpty(isConnectAcs)) {
throw new BadRequestException("参数表中:IS_CONNECT_ACS不存在");
throw new BadRequestException("参数表中:" + GeneralDefinition.IS_CONNECT_ACS + "不存在");
}
String isConnect = isConnectAcs.getValue();
JSONObject result = new JSONObject();
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
result.put("status", HttpStatus.BAD_REQUEST.value());
result.put("message", "未连接ACS!");
result.put("data", new JSONObject());
return result;
}
//ACS地址:127.0.0.1:8010
Param acsUrlObj = sysParamService.findByCode("ACS_URL");
Param acsUrlObj = sysParamService.findByCode(GeneralDefinition.ACS_URL);
if (ObjectUtil.isEmpty(acsUrlObj)) {
throw new BadRequestException("参数表中:ACS_URL不存在");
throw new BadRequestException("参数表中:" + GeneralDefinition.ACS_URL + "不存在");
}
String acsUrl = acsUrlObj.getValue();
String url = acsUrl + api;
log.info("下发acs任务的参数为:{}", list.toString());
try {
String resultMsg = HttpRequest.post(url)
.body(String.valueOf(list))
.execute().body();
result = JSONObject.parseObject(resultMsg);
} catch (Exception e) {
String msg = e.getMessage();
//ConnectException: Connection refused: connect
//网络不通
log.error("连接失败:{}", msg);
result.put("status", HttpStatus.BAD_REQUEST);
result.put("message", "网络不通,操作失败!");
result.put("data", new JSONObject());
}
return result;
}
public static <T> JSONObject notifyAcs(String api, T object) {
//判断是否连接ACS系统
String isConnect = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("IS_CONNECT_ACS").getValue();
JSONObject result = new JSONObject();
JSONObject result;
if (StrUtil.equals(GeneralDefinition.NO, isConnect)) {
result.put("status", HttpStatus.BAD_REQUEST.value());
result.put("message", "未连接ACS!");
result.put("data", new JSONObject());
return result;
return ResultForAcs.requestRefuse("未连接ACS!");
}
//ACS地址:127.0.0.1:8010
String acsUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("ACS_URL").getValue();
String url = acsUrl + api;
log.info("下发acs任务的参数为:{}", object.toString());
log.info("下发acs任务的参数为:{}", list.toString());
ResultForAcs resultForAcs;
try {
String resultMsg = HttpRequest.post(url)
.body(String.valueOf(object))
.body(s)
.execute().body();
result = JSONObject.parseObject(resultMsg);
resultForAcs = JSONObject.toJavaObject(result, ResultForAcs.class);
} catch (Exception e) {
String msg = e.getMessage();
//ConnectException: Connection refused: connect
//网络不通
log.error("连接失败:{}", msg);
result.put("status", HttpStatus.BAD_REQUEST);
result.put("message", "网络不通,操作失败!");
result.put("data", new JSONObject());
return ResultForAcs.requestRefuse("网络不通,操作失败!");
}
// 记录交互表
return result;
return resultForAcs;
}
}

13
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJMKTask.java

@ -73,6 +73,7 @@ public class FJMKTask extends AbstractTask {
String requestParam = task.getRequest_param();// 任务的其他数据
JSONObject jsonObject = JSONObject.parseObject(requestParam);
// 找终点
/** 包装位 */
SchBasePoint packagePoint = findNextPoint(nextRegionStr, jsonObject);
if (ObjectUtil.isEmpty(packagePoint)) {
task.setRemark("包装线不可用!");
@ -87,6 +88,7 @@ public class FJMKTask extends AbstractTask {
// 1 获取点位相应数量
// 2 获取库存数量
// 3 木托盘需要多少块
/** 覆膜机木托盘位 */
SchBasePoint LaminatePoint = findStartPoint(startRegionStr, jsonObject);
if (ObjectUtil.isEmpty(LaminatePoint)) {
task.setRemark("覆膜区不可用!");
@ -101,7 +103,7 @@ public class FJMKTask extends AbstractTask {
// 设置终点并修改创建成功状态
task.setPoint_code3(LaminatePoint.getParent_point_code());
task.setPoint_code4(task.getPoint_code1());
task.setVehicle_code2(vehicleCode);
task.setVehicle_code2(vehicleCode); // 覆膜机下的木托盘编码
task.setTask_status(TaskStatus.CREATED.getCode());
task.setRemark("");
taskService.updateById(task);
@ -109,6 +111,7 @@ public class FJMKTask extends AbstractTask {
packagePoint.setIng_task_code(task.getTask_code());
PointUtils.setUpdateByAcs(packagePoint);
pointService.updateById(packagePoint);
// 覆膜机对接位
SchBasePoint basePoint = pointService.getById(LaminatePoint.getParent_point_code());
basePoint.setIng_task_code(task.getTask_code());
basePoint.setVehicle_code(vehicleCode);
@ -283,15 +286,23 @@ public class FJMKTask extends AbstractTask {
SchBasePoint fjcPointObj = pointService.getById(fjcPoint);
if (ObjectUtil.isNotEmpty(bzxPointObj)) {
// 包装位: 解锁
PointUtils.setUpdateByType(bzxPointObj, taskFinishedType);
PointUtils.clearPoint(bzxPointObj);
// 覆膜位: 解锁 . 清空
PointUtils.setUpdateByType(fmPointObj, taskFinishedType);
PointUtils.clearPoint(fmPointObj);
// 分拣机械手: 清空
PointUtils.setUpdateByType(fjcPointObj, taskFinishedType);
PointUtils.clearPoint(fjcPointObj);
if (ObjectUtil.isNotEmpty(fmPointObj)) {
// 机械手对接位: 赋值
fjcPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode());
fjcPointObj.setVehicle_qty(1);
fjcPointObj.setVehicle_type(taskObj.getVehicle_type());
fjcPointObj.setVehicle_code(taskObj.getVehicle_code2()); // 拿过来的载具编码
PointUtils.setUpdateByType(fjcPointObj, taskFinishedType);
pointService.updateById(fjcPointObj);
}
// 组盘设置已经解绑
SchBaseVehiclematerialgroup vehicleMaterialGroupObj =
vehiclematerialgroupService.getById(taskObj.getGroup_id());

1
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQKTask.java

@ -86,6 +86,7 @@ public class FJQKTask extends AbstractTask {
task.setTask_status(TaskStatus.CREATED.getCode());
// 生产木托盘编码
String vehicleCode = CodeUtil.getNewCode("VEHICLE_CODE");
// todo: 未确认是否放在1还是2,目前规定四点任务空盘的载具编码是2
task.setVehicle_code(vehicleCode);
task.setRemark("");
task.setGroup_id(point.getGroup_id());

7
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJQLTask.java

@ -21,6 +21,7 @@ import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum;
import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
@ -191,6 +192,12 @@ public class FJQLTask extends AbstractTask {
processTracking.setProcess_location(endPoint);
processTracking.setRecord_time(DateUtil.now());
processTrackingService.create(processTracking);
// 终点设置对应的参数
endPointObj.setVehicle_code(startPointObj.getVehicle_code());
endPointObj.setVehicle_type(startPointObj.getVehicle_type());
endPointObj.setPoint_status(PointStatusEnum.FULL_POINT.getCode());
PointUtils.setUpdateByType(endPointObj, taskFinishedType);
pointService.updateById(endPointObj);
}
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());

4
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/util/PointUtils.java

@ -1,6 +1,7 @@
package org.nl.wms.util;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.SpringContextHolder;
@ -39,6 +40,9 @@ public class PointUtils {
* @param point
*/
public static void clearPoint(SchBasePoint point) {
if (ObjectUtil.isEmpty(point)) {
return; // 空直接退出
}
SchBasePointServiceImpl pointService = SpringContextHolder.getBean(SchBasePointServiceImpl.class);
point.setPoint_status(PointStatusEnum.EMPTY_POINT.getCode());
point.setVehicle_type("");

24
lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/PointCreate.java

@ -208,4 +208,28 @@ public class PointCreate {
}
pointService.saveBatch(pointList);
}
@Test
void test07() { // 码垛机械手
// 创建YJ01JLW01
List<SchBasePoint> pointList = new ArrayList<>();
for (int i = 1; i <= 8; i++) {
String pointName = "压制不合格位0";
String pointCode = "YZBHGW0";
String papointCode = "YJ0";
pointName = pointName + i;
pointCode = pointCode + i;
papointCode = papointCode + i;
SchBasePoint point = new SchBasePoint();
point.setPoint_code(pointCode);
point.setPoint_name(pointName);
point.setRegion_code("YZ");
point.setRegion_name("压制区域");
point.setPoint_type("3");
point.setParent_point_code(papointCode);
point.setIs_has_workder(false);
point.setIs_auto(false);
pointList.add(point);
}
pointService.saveBatch(pointList);
}
}

23
lms/nladmin-ui/src/views/wms/pdm/workerorder/index.vue

@ -60,7 +60,19 @@
</el-form>
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission" />
<crudOperation :permission="permission" >
<el-button
slot="right"
class="filter-item"
type="success"
icon="el-icon-position"
size="mini"
:disabled="!(crud.selections[0]) || crud.selections[1]"
@click="submits(crud.selections[0])"
>
开工
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
@ -510,7 +522,14 @@ export default {
this.crud.query.more_order_status = value.toString()
}
this.crud.toQuery()
}
},
//
submits(row) {
crudPdmBdWorkorder.submits(row).then(res => {
this.crud.notify('下发成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.crud.toQuery()
})
},
}
}
</script>

10
lms/nladmin-ui/src/views/wms/pdm/workerorder/pdmBdWorkorder.js

@ -24,4 +24,12 @@ export function edit(data) {
})
}
export default { add, edit, del }
export function submits(param) {
return request({
url: 'api/pdmBdWorkorder/submits',
method: 'post',
data: param
})
}
export default { add, edit, del, submits }

Loading…
Cancel
Save