feat(工单状态查询接口):新增接口
This commit is contained in:
parent
d85a8ab55f
commit
f8ba207464
@ -0,0 +1,29 @@
|
||||
package com.foreverwin.iep.integration.dto;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 工单状态查询接口DTO
|
||||
*
|
||||
* @author hechuan.liao
|
||||
* @date 2024-11-13 13:06:57
|
||||
*/
|
||||
@Data
|
||||
public class SapOrderStatusDTO {
|
||||
|
||||
/**
|
||||
* 站点
|
||||
*/
|
||||
private String site;
|
||||
|
||||
/**
|
||||
* 接口批次ID
|
||||
*/
|
||||
private String batchId;
|
||||
|
||||
/**
|
||||
* 工单
|
||||
*/
|
||||
private String shopOrder;
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
package com.foreverwin.iep.integration.handler.def.sap;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.foreverwin.iep.integration.constant.Msg;
|
||||
import com.foreverwin.iep.integration.domain.InvokeRequest;
|
||||
import com.foreverwin.iep.integration.domain.InvokeResponse;
|
||||
import com.foreverwin.iep.integration.dto.SapOrderStatusDTO;
|
||||
import com.foreverwin.iep.integration.service.HandlerService;
|
||||
import com.foreverwin.iep.integration.utils.JS;
|
||||
import com.foreverwin.iep.prd.entity.ZSapOrderStatusItf;
|
||||
import com.foreverwin.iep.prd.feign.RemoteOrderStatusService;
|
||||
import com.foreverwin.mom.common.core.constant.SecurityConstants;
|
||||
import com.foreverwin.mom.common.core.util.I18nUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工单状态查询接口
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Service("SAP_ORDER_STATUS")
|
||||
public class SapOrderStatus implements HandlerService {
|
||||
|
||||
private final RemoteOrderStatusService remoteOrderStatusService;
|
||||
|
||||
@Override
|
||||
public InvokeResponse call(InvokeRequest invokeRequest) {
|
||||
JSONObject jsonObject = JS.parseObject(invokeRequest.getMessageContent());
|
||||
LocalDateTime nowLocalDateTime = LocalDateTime.now();
|
||||
List<ZSapOrderStatusItf> zSapOrderStatusItfList = new ArrayList<>();
|
||||
JSONArray jsonArray = JS.parseArray(jsonObject.getString(Msg.MESSAGE_CONTENT));
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = JS.parseObject(jsonArray.getString(i));
|
||||
SapOrderStatusDTO sapOrderStatusDTO = new SapOrderStatusDTO();
|
||||
sapOrderStatusDTO.setSite(invokeRequest.getSite());
|
||||
sapOrderStatusDTO.setBatchId(invokeRequest.getTransSid());
|
||||
sapOrderStatusDTO.setShopOrder(object.getString("SHOP_ORDER"));
|
||||
ZSapOrderStatusItf zSapOrderStatusItf = new ZSapOrderStatusItf();
|
||||
// 属性copy
|
||||
BeanUtils.copyProperties(sapOrderStatusDTO, zSapOrderStatusItf);
|
||||
zSapOrderStatusItf.setHandle(StrUtil.uuid());
|
||||
zSapOrderStatusItf.setCreator(Msg.SAP);
|
||||
zSapOrderStatusItf.setDateCreate(nowLocalDateTime);
|
||||
zSapOrderStatusItf.setResponseStatus(Msg.S);
|
||||
zSapOrderStatusItf.setResponseDescription(Msg.SUCCESS);
|
||||
zSapOrderStatusItfList.add(zSapOrderStatusItf);
|
||||
}
|
||||
|
||||
JSONObject object = remoteOrderStatusService.remoteReadOrderStatus(zSapOrderStatusItfList, SecurityConstants.FROM_IN).getData();
|
||||
|
||||
InvokeResponse response = new InvokeResponse(invokeRequest);
|
||||
response.setTransTime(nowLocalDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
if (Msg.S.equals(object.getString("responseStatus"))) {
|
||||
response.setResult(Msg.S);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("工单【");
|
||||
List<String> shopOrderList = JS.parseArray(object.getString("responseDescription")).toJavaList(String.class);
|
||||
if (CollectionUtils.isNotEmpty(shopOrderList)) {
|
||||
for (int i = 0; i < shopOrderList.size(); i++) {
|
||||
if (i == shopOrderList.size() - 1) {
|
||||
stringBuilder.append(shopOrderList.get(i));
|
||||
} else {
|
||||
stringBuilder.append(shopOrderList.get(i)).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
stringBuilder.append("】可关闭");
|
||||
response.setMessageContent(stringBuilder.toString());
|
||||
} else {
|
||||
response.setResult(Msg.E);
|
||||
response.setMessageContent(object.getString("responseDescription"));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String validation(InvokeRequest invokeRequest) {
|
||||
JSONObject jsonObject = JS.parseObject(invokeRequest.getMessageContent());
|
||||
JSONArray jsonArray = JS.parseArray(jsonObject.getString(Msg.MESSAGE_CONTENT));
|
||||
if (jsonArray.isEmpty()) {
|
||||
return I18nUtil.getI18nText("int.invoke.iMES.in.error1");
|
||||
}
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject object = JS.parseObject(jsonArray.getString(i));
|
||||
if (StrUtil.isBlank(object.getString("SHOP_ORDER"))) {
|
||||
msg.append("SHOP_ORDER不能为空!");
|
||||
}
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user