23 changed files with 888 additions and 25 deletions
@ -0,0 +1,38 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Data |
||||
|
public class BaseRequest { |
||||
|
|
||||
|
/** |
||||
|
* 库编码 |
||||
|
*/ |
||||
|
private String houseCode; |
||||
|
|
||||
|
/** |
||||
|
* 系统编号 |
||||
|
*/ |
||||
|
private String systemCode; |
||||
|
|
||||
|
/** |
||||
|
* 扩展参数:砖型等 |
||||
|
*/ |
||||
|
private JSONObject parameters; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 任务类型 |
||||
|
*/ |
||||
|
private String taskType; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 任务号 |
||||
|
*/ |
||||
|
private String taskCode; |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Builder; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Data |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class BaseResponse { |
||||
|
/** |
||||
|
* 请求结果 |
||||
|
*/ |
||||
|
private int responseCode; |
||||
|
|
||||
|
/** |
||||
|
* 信息 |
||||
|
*/ |
||||
|
private String responseMessage; |
||||
|
|
||||
|
|
||||
|
private Map<String, String> parameters = new HashMap(); |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseRequest; |
||||
|
|
||||
|
@Data |
||||
|
public class CancelTaskRequest extends BaseRequest { |
||||
|
/** |
||||
|
* 作废原因 |
||||
|
*/ |
||||
|
private String reason; |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseResponse; |
||||
|
|
||||
|
@Data |
||||
|
public class CancelTaskResponse extends BaseResponse { |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.createTask; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseRequest; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
public class CreateTaskRequest extends BaseRequest { |
||||
|
/** |
||||
|
* 任务下发时间 |
||||
|
*/ |
||||
|
private Date taskCreateDateTime; |
||||
|
|
||||
|
/** |
||||
|
* 容器编号 |
||||
|
*/ |
||||
|
private String containerCode; |
||||
|
|
||||
|
/** |
||||
|
* 容器类型 |
||||
|
*/ |
||||
|
private String containerType; |
||||
|
|
||||
|
/** |
||||
|
* 任务起点 |
||||
|
*/ |
||||
|
private String locationFrom; |
||||
|
|
||||
|
/** |
||||
|
* 任务终点 |
||||
|
*/ |
||||
|
private String locationTo; |
||||
|
|
||||
|
/** |
||||
|
* 优先级 |
||||
|
*/ |
||||
|
private Integer priority; |
||||
|
|
||||
|
/** |
||||
|
* 路由方案 |
||||
|
*/ |
||||
|
String route_plan_code; |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.createTask; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseResponse; |
||||
|
|
||||
|
@Data |
||||
|
public class CreateTaskResponse extends BaseResponse { |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.deviceStatus; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseRequest; |
||||
|
|
||||
|
@Data |
||||
|
public class DeviceStatusRequest extends BaseRequest { |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.deviceStatus; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseResponse; |
||||
|
|
||||
|
@Data |
||||
|
public class DeviceStatusResponse extends BaseResponse { |
||||
|
private int status; |
||||
|
private String statusDescription; |
||||
|
private Boolean hasGoods; |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.feedBackTaskStatus; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseRequest; |
||||
|
|
||||
|
@Data |
||||
|
public class FeedBackTaskStatusRequest extends BaseRequest { |
||||
|
/** |
||||
|
* 车号 |
||||
|
*/ |
||||
|
private String carId; |
||||
|
|
||||
|
/** |
||||
|
* 任务反馈状态 taking:取货中 applyTake:申请取货 takeFinish:取货完成 puting:放货中 applyPut:申请放货 putFinish:放货完成 |
||||
|
* errorFinish:任务异常完成 exception:异常 deprecate:作废 |
||||
|
*/ |
||||
|
private String feedbackStatus; |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package org.nl.acs.ext.wms.data.WcsToAcsData.feedBackTaskStatus; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.BaseResponse; |
||||
|
|
||||
|
@Data |
||||
|
public class FeedBackTaskStatusResponse extends BaseResponse { |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
package org.nl.acs.ext.wms.rest; |
||||
|
|
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
@RestController |
||||
|
@RequiredArgsConstructor |
||||
|
@RequestMapping("/api/wcs") |
||||
|
@Slf4j |
||||
|
public class AcsToWcsController { |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package org.nl.acs.ext.wms.rest; |
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskRequest; |
||||
|
import org.nl.acs.ext.wms.service.WcsToAcsService; |
||||
|
import org.nl.common.logging.annotation.Log; |
||||
|
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.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequiredArgsConstructor |
||||
|
@RequestMapping("/api/wcs") |
||||
|
@Slf4j |
||||
|
public class WcsToAcsController { |
||||
|
private final WcsToAcsService wcsToAcsService; |
||||
|
|
||||
|
@PostMapping("/task") |
||||
|
@Log(value = "ACS接收WMS任务") |
||||
|
@SaIgnore |
||||
|
public ResponseEntity<Object> createFromWcs(@RequestBody JSONObject whereJson) { |
||||
|
return new ResponseEntity<>(wcsToAcsService.crateTask(whereJson), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,32 @@ |
|||||
|
package org.nl.acs.ext.wms.service; |
||||
|
|
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.deviceStatus.DeviceStatusRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.deviceStatus.DeviceStatusResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.feedBackTaskStatus.FeedBackTaskStatusRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.feedBackTaskStatus.FeedBackTaskStatusResponse; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
public interface AcsToWcsService { |
||||
|
|
||||
|
/** |
||||
|
* ACS向WCS反馈任务状态 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
Map<String, Object> feedTaskStatus(FeedBackTaskStatusRequest param); |
||||
|
|
||||
|
Map<String, Object> cancelTask(CancelTaskRequest param); |
||||
|
|
||||
|
/** |
||||
|
* 设备查询 |
||||
|
* |
||||
|
* |
||||
|
* @return Map<String, Object> |
||||
|
*/ |
||||
|
Map<String, Object> checkDeviceStatus(JSONObject whereJson); |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.nl.acs.ext.wms.service; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.createTask.CreateTaskResponse; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
public interface WcsToAcsService { |
||||
|
|
||||
|
Map<String, Object> crateTask(JSONObject whereJson); |
||||
|
|
||||
|
} |
@ -0,0 +1,183 @@ |
|||||
|
package org.nl.acs.ext.wms.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.map.MapUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import cn.hutool.http.Header; |
||||
|
import cn.hutool.http.HttpRequest; |
||||
|
import cn.hutool.http.HttpResponse; |
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.yomahub.tlog.hutoolhttp.TLogHutoolhttpInterceptor; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.acs.AcsConfig; |
||||
|
import org.nl.acs.address.service.AddressService; |
||||
|
import org.nl.acs.address.service.dto.AddressDto; |
||||
|
import org.nl.acs.ext.wms.data.ApplyPlugPullSitResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.deviceStatus.DeviceStatusRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.deviceStatus.DeviceStatusResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.feedBackTaskStatus.FeedBackTaskStatusRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.feedBackTaskStatus.FeedBackTaskStatusResponse; |
||||
|
import org.nl.acs.ext.wms.service.AcsToWcsService; |
||||
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
||||
|
import org.nl.acs.task.service.TaskService; |
||||
|
import org.nl.config.lucene.service.LuceneExecuteLogService; |
||||
|
import org.nl.config.lucene.service.dto.LuceneLogDto; |
||||
|
import org.nl.system.service.param.ISysParamService; |
||||
|
import org.slf4j.MDC; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
public class AcsToWcsServiceImpl implements AcsToWcsService { |
||||
|
|
||||
|
@Autowired |
||||
|
ISysParamService paramService; |
||||
|
|
||||
|
@Autowired |
||||
|
AddressService addressService; |
||||
|
|
||||
|
@Autowired |
||||
|
TaskService taskService; |
||||
|
|
||||
|
@Autowired |
||||
|
DeviceExecuteLogService logServer; |
||||
|
|
||||
|
@Autowired |
||||
|
LuceneExecuteLogService luceneLogService; |
||||
|
|
||||
|
public String token; |
||||
|
|
||||
|
TLogHutoolhttpInterceptor tLogHutoolhttpInterceptor = new TLogHutoolhttpInterceptor(); |
||||
|
|
||||
|
|
||||
|
private String log_file_type = "log_file_type"; |
||||
|
private String log_type = "ACS请求LMS"; |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> feedTaskStatus(FeedBackTaskStatusRequest param) { |
||||
|
log.info("ACS向WCS反馈任务状态,请求参数{}", param); |
||||
|
String result = ""; |
||||
|
FeedBackTaskStatusResponse feedBackTaskStatusResponse = new FeedBackTaskStatusResponse(); |
||||
|
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); |
||||
|
AddressDto addressDto = addressService.findByCode("feedTaskStatus"); |
||||
|
String methods_url = addressDto.getMethods_url(); |
||||
|
String url = wmsUrl + methods_url; |
||||
|
try { |
||||
|
//
|
||||
|
result = HttpRequest.post(url) |
||||
|
.addInterceptor(tLogHutoolhttpInterceptor) |
||||
|
.header(Header.USER_AGENT, "Hutool http") |
||||
|
.body(JSON.toJSONString(param)) |
||||
|
.execute().body(); |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
feedBackTaskStatusResponse = JSONObject.toJavaObject(jsonObject, FeedBackTaskStatusResponse.class); |
||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "feedTaskStatus", String.valueOf(feedBackTaskStatusResponse.getResponseCode()), |
||||
|
JSON.toJSONString(param), String.valueOf(result), "ACS向WCS反馈任务状态"); |
||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto); |
||||
|
return jsonObject; |
||||
|
} catch (Exception e) { |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
log.info("ACS向WCS反馈任务状态----返回参数{}", e.getMessage()); |
||||
|
feedBackTaskStatusResponse = JSONObject.toJavaObject(jsonObject, FeedBackTaskStatusResponse.class); |
||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "feedTaskStatus", String.valueOf(feedBackTaskStatusResponse.getResponseCode()), |
||||
|
JSON.toJSONString(param), |
||||
|
String.valueOf(result), "ACS向WCS反馈任务状态"); |
||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto); |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", e.getMessage()); |
||||
|
map.put("parameters", new HashMap<>()); |
||||
|
return map; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> cancelTask(CancelTaskRequest param) { |
||||
|
log.info("ACS向WCS申请取消任务,请求参数{}", param); |
||||
|
String result = ""; |
||||
|
CancelTaskResponse cancelTaskResponse = new CancelTaskResponse(); |
||||
|
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); |
||||
|
AddressDto addressDto = addressService.findByCode("cancelTask"); |
||||
|
String methods_url = addressDto.getMethods_url(); |
||||
|
String url = wmsUrl + methods_url; |
||||
|
try { |
||||
|
//
|
||||
|
result = HttpRequest.post(url) |
||||
|
.addInterceptor(tLogHutoolhttpInterceptor) |
||||
|
.header(Header.USER_AGENT, "Hutool http") |
||||
|
.body(JSON.toJSONString(param)) |
||||
|
.execute().body(); |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
cancelTaskResponse = JSONObject.toJavaObject(jsonObject, CancelTaskResponse.class); |
||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "cancelTask", String.valueOf(cancelTaskResponse.getResponseCode()), |
||||
|
JSON.toJSONString(param), String.valueOf(result), "ACS向WCS申请取消任务"); |
||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto); |
||||
|
return jsonObject; |
||||
|
} catch (Exception e) { |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
log.info("ACS向WCS申请取消任务----返回参数{}", e.getMessage()); |
||||
|
cancelTaskResponse = JSONObject.toJavaObject(jsonObject, CancelTaskResponse.class); |
||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "feedTaskStatus", String.valueOf(cancelTaskResponse.getResponseCode()), |
||||
|
JSON.toJSONString(param), |
||||
|
String.valueOf(result), "ACS向WCS申请取消任务"); |
||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto); |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", e.getMessage()); |
||||
|
map.put("parameters", new HashMap<>()); |
||||
|
return map; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> checkDeviceStatus(JSONObject whereJson) { |
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
String result = null; |
||||
|
AddressDto addressDto = addressService.findByCode("checkDeviceStatus"); |
||||
|
String wcsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); |
||||
|
String methods_url = addressDto.getMethods_url(); |
||||
|
String url = wcsurl + methods_url; |
||||
|
String deviceCode = MapUtil.getStr(whereJson, "deviceCode"); |
||||
|
if (StrUtil.isEmpty(deviceCode)) { |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", "请求设备号不能为空!"); |
||||
|
map.put("parameters", new HashMap<>()); |
||||
|
return map; |
||||
|
} |
||||
|
try { |
||||
|
result = HttpRequest.post(url) |
||||
|
.addInterceptor(tLogHutoolhttpInterceptor) |
||||
|
.header(Header.USER_AGENT, "Hutool http") |
||||
|
.body(JSON.toJSONString(whereJson)) |
||||
|
.execute().body(); |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "checkDeviceStatus", String.valueOf(jsonObject.get("responseCode")), |
||||
|
JSON.toJSONString(jsonObject), String.valueOf(result), "ACS向WCS反馈设备状态"); |
||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto); |
||||
|
log.info("checkDeviceStatus-----输出参数{}", jsonObject.toString()); |
||||
|
return jsonObject; |
||||
|
} catch (Exception e) { |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
log.info("ACS向WCS反馈设备状态----返回参数{}", e.getMessage()); |
||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "feedBackDeviceStatus", String.valueOf(jsonObject.get("responseCode")), |
||||
|
JSON.toJSONString(whereJson), |
||||
|
String.valueOf(result), "ACS向WCS反馈设备状态"); |
||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto); |
||||
|
Map<String, Object> map1 = new HashMap<>(); |
||||
|
map1.put("responseCode", 1); |
||||
|
map1.put("responseMessage", e.getMessage()); |
||||
|
map1.put("parameters", new HashMap<>()); |
||||
|
return map1; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,208 @@ |
|||||
|
package org.nl.acs.ext.wms.service.impl; |
||||
|
|
||||
|
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 com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.acs.ext.wms.data.JsonUtl; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.cancelTask.CancelTaskResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.createTask.CreateTaskRequest; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.createTask.CreateTaskResponse; |
||||
|
import org.nl.acs.ext.wms.data.WcsToAcsData.deviceStatus.DeviceStatusResponse; |
||||
|
import org.nl.acs.ext.wms.service.AcsToWcsService; |
||||
|
import org.nl.acs.ext.wms.service.WcsToAcsService; |
||||
|
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.storage_cell.domain.StorageCell; |
||||
|
import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; |
||||
|
import org.nl.acs.task.service.TaskService; |
||||
|
import org.nl.acs.task.service.dto.TaskDto; |
||||
|
import org.nl.config.lucene.service.LuceneExecuteLogService; |
||||
|
import org.nl.config.lucene.service.dto.LuceneLogDto; |
||||
|
import org.slf4j.MDC; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
public class WcsToAcsServiceImpl implements WcsToAcsService { |
||||
|
|
||||
|
@Autowired |
||||
|
private StorageCellMapper storageCellMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
private DeviceAppService deviceAppService; |
||||
|
|
||||
|
@Autowired |
||||
|
private TaskService taskserver; |
||||
|
|
||||
|
@Autowired |
||||
|
private AcsToWcsService acsToWcsService; |
||||
|
|
||||
|
@Autowired |
||||
|
private LuceneExecuteLogService luceneExecuteLogService; |
||||
|
|
||||
|
@Autowired |
||||
|
RouteLineService routeLineService; |
||||
|
|
||||
|
@Override |
||||
|
public Map<String, Object> crateTask(JSONObject whereJson) { |
||||
|
|
||||
|
Map<String, Object> map = new HashMap<>(); |
||||
|
log.info("taskCreate--------------:输入参数:" + whereJson.toString()); |
||||
|
LuceneLogDto logDto = LuceneLogDto.builder() |
||||
|
.device_code("ACS接收WMS任务") |
||||
|
.content("ACS接收WMS任务-----输入参数:" + whereJson) |
||||
|
.build(); |
||||
|
logDto.setLog_level(4); |
||||
|
luceneExecuteLogService.deviceExecuteLog(logDto); |
||||
|
//获取甲方wcs传过来的参数
|
||||
|
String houseCode = whereJson.getString("houseCode"); |
||||
|
String systemCode = whereJson.getString("systemCode"); |
||||
|
JSONObject parameters = whereJson.getJSONObject("parameters"); |
||||
|
String taskCode = whereJson.getString("taskCode"); |
||||
|
String taskType = whereJson.getString("taskType"); |
||||
|
String taskCreateDatetime = whereJson.getString("taskCreateDatetime"); |
||||
|
String containerCode = whereJson.getString("containerCode"); |
||||
|
String containerType = whereJson.getString("containerType"); |
||||
|
String start_point_code = whereJson.getString("locationFrom"); |
||||
|
String next_point_code = whereJson.getString("locationTo"); |
||||
|
String priority = whereJson.getString("priority"); |
||||
|
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; |
||||
|
} |
||||
|
JSONObject jsonObject = new JSONObject(); |
||||
|
jsonObject.put("deviceCode", start_point_code); |
||||
|
JSONObject jsonObject1 = new JSONObject(); |
||||
|
jsonObject1.put("deviceCode", next_point_code); |
||||
|
|
||||
|
Map<String, Object> feedback = acsToWcsService.checkDeviceStatus(jsonObject); |
||||
|
Map<String, Object> feedback1 = acsToWcsService.checkDeviceStatus(jsonObject1); |
||||
|
int responseCode = Integer.parseInt(String.valueOf(feedback.get("responseCode"))); |
||||
|
int responseCode1 = Integer.parseInt(String.valueOf(feedback1.get("responseCode"))); |
||||
|
String fromStatus = String.valueOf(feedback.get("status")); |
||||
|
String toStatus = String.valueOf(feedback1.get("status")); |
||||
|
Boolean fromHasGoods = (Boolean) feedback.get("hasGoods"); |
||||
|
Boolean toHasGoods = (Boolean) feedback1.get("hasGoods"); |
||||
|
|
||||
|
|
||||
|
if (responseCode == 0 && responseCode1 == 0){ |
||||
|
if (fromStatus.equals("0") && toStatus.equals("0")){ |
||||
|
if (fromHasGoods && !toHasGoods){ |
||||
|
log.info("起点设备有货,终点设备无货"); |
||||
|
}else { |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", "起点和终点设备状态异常,请检查起点和终点设备状态!"); |
||||
|
return map; |
||||
|
} |
||||
|
}else { |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", "设备状态异常,请检查起点和终点设备状态!"); |
||||
|
return map; |
||||
|
} |
||||
|
}else { |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", "请求结果代码不为0"); |
||||
|
return map; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
if (start_point_code.indexOf("-") > 0) { |
||||
|
String str[] = start_point_code.split("-"); |
||||
|
start_device_code = str[0]; |
||||
|
} else { |
||||
|
start_device_code = start_point_code; |
||||
|
} |
||||
|
|
||||
|
if (next_point_code.indexOf("-") > 0) { |
||||
|
String str[] = next_point_code.split("-"); |
||||
|
next_device_code = str[0]; |
||||
|
} else { |
||||
|
next_device_code = next_point_code; |
||||
|
} |
||||
|
|
||||
|
//查询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 = taskserver.findByCodeFromCache(taskCode); |
||||
|
if (taskDto != null) { |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", "不能存在相同的任务号!"); |
||||
|
return map; |
||||
|
} |
||||
|
//判断载具编码是否相同
|
||||
|
if (!StrUtil.isEmpty(containerCode)) { |
||||
|
TaskDto vehicle_dto = taskserver.findByContainer(containerCode); |
||||
|
if (vehicle_dto != null) { |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", "已存在该容器号的任务!"); |
||||
|
return map; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
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.parseObject(String.valueOf(jo), TaskDto.class); |
||||
|
try { |
||||
|
taskserver.create(task_dto); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
map.put("responseCode", 1); |
||||
|
map.put("responseMessage", e.getMessage()); |
||||
|
return map; |
||||
|
} |
||||
|
map.put("responseCode", 0); |
||||
|
map.put("responseMessage", "创建任务成功!"); |
||||
|
map.put("parameters", new HashMap<>()); |
||||
|
return map; |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<included> |
||||
|
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/> |
||||
|
<property name="LOG_HOME" value="${logPath}"/> |
||||
|
<!-- 按照每天生成日志文件 --> |
||||
|
<appender name="ACSToWCS" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
|
<!--日志文件输出的文件名--> |
||||
|
<FileNamePattern>${LOG_HOME}/ACS请求WCS/%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
||||
|
<!--日志文件保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
<!--单个日志最大容量 至少10MB才能看得出来--> |
||||
|
<maxFileSize>50MB</maxFileSize> |
||||
|
<!--所有日志最多占多大容量--> |
||||
|
<totalSizeCap>2GB</totalSizeCap> |
||||
|
</rollingPolicy> |
||||
|
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder"> |
||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>${log.charset}</charset> |
||||
|
</encoder> |
||||
|
|
||||
|
</appender> |
||||
|
|
||||
|
<!-- 打印sql --> |
||||
|
<logger name="org.nl.acs.ext.wms.service.impl.AcsToWcsServiceImpl" level="info" additivity="true"> |
||||
|
<appender-ref ref="ACSToWCS"/> |
||||
|
</logger> |
||||
|
</included> |
@ -0,0 +1,29 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<included> |
||||
|
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/> |
||||
|
<property name="LOG_HOME" value="${logPath}"/> |
||||
|
<!-- 按照每天生成日志文件 --> |
||||
|
<appender name="WCSToACS" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> |
||||
|
<!--日志文件输出的文件名--> |
||||
|
<FileNamePattern>${LOG_HOME}/WCS下发ACS/%d{yyyy-MM-dd}.%i.log</FileNamePattern> |
||||
|
<!--日志文件保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
<!--单个日志最大容量 至少10MB才能看得出来--> |
||||
|
<maxFileSize>50MB</maxFileSize> |
||||
|
<!--所有日志最多占多大容量--> |
||||
|
<totalSizeCap>2GB</totalSizeCap> |
||||
|
</rollingPolicy> |
||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> |
||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>${log.charset}</charset> |
||||
|
</encoder> |
||||
|
|
||||
|
</appender> |
||||
|
|
||||
|
<!-- 打印sql --> |
||||
|
<logger name="org.nl.acs.ext.wms.service.impl.WcsToAcsServiceImpl" level="info" additivity="true"> |
||||
|
<appender-ref ref="WCSToACS"/> |
||||
|
</logger> |
||||
|
</included> |
Loading…
Reference in new issue