|
|
|
@ -1,10 +1,14 @@
|
|
|
|
|
package com.op.wms.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
|
|
|
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
|
|
import com.alibaba.nacos.shaded.com.google.gson.JsonSyntaxException;
|
|
|
|
|
import com.op.common.core.constant.Constants;
|
|
|
|
|
import com.op.common.core.domain.R;
|
|
|
|
|
import com.op.system.api.RemoteSapService;
|
|
|
|
|
import com.op.wms.mapper.BaseTeamUserMapper;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -31,6 +35,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.error;
|
|
|
|
|
import static com.op.common.core.web.domain.AjaxResult.success;
|
|
|
|
|
|
|
|
|
@ -48,7 +53,8 @@ public class BaseEquipmentServiceImpl implements IBaseEquipmentService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private BaseTeamUserMapper baseTeamUserMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteSapService remoteSapService;
|
|
|
|
|
/**
|
|
|
|
|
* 查询设备管理
|
|
|
|
|
*
|
|
|
|
@ -633,4 +639,58 @@ public class BaseEquipmentServiceImpl implements IBaseEquipmentService {
|
|
|
|
|
public List<BaseEquipment> getEquipmentTypeDeptList(BaseEquipment baseEquipment) {
|
|
|
|
|
return baseEquipmentMapper.getEquipmentTypeDeptList(baseEquipment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@DS("#header.poolName")
|
|
|
|
|
public AjaxResult sapSyncBaseEquipment(Long equipmentId) {
|
|
|
|
|
|
|
|
|
|
/**查询设备信息*/
|
|
|
|
|
BaseEquipment baseEquipment = baseEquipmentMapper.selectBaseEquipmentByEquipmentId(equipmentId);
|
|
|
|
|
|
|
|
|
|
Map P_SERNR=new HashMap<>();
|
|
|
|
|
P_SERNR.put("P_SERNR",baseEquipment.getEquipmentCode());
|
|
|
|
|
R r = remoteSapService.sapZmesAnlaGet(P_SERNR);
|
|
|
|
|
if (Constants.SUCCESS.equals(r.getCode())) {
|
|
|
|
|
Object data = r.getData();
|
|
|
|
|
|
|
|
|
|
// 条件1:data 不为空
|
|
|
|
|
if (data != null) {
|
|
|
|
|
Gson gson = new Gson();
|
|
|
|
|
try {
|
|
|
|
|
// 将 data 转换为 Map
|
|
|
|
|
Map<String, Object> map = gson.fromJson(
|
|
|
|
|
gson.toJson(data),
|
|
|
|
|
new TypeToken<Map<String, Object>>(){}.getType()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 条件2:map 不为空且包含 ANLN1 字段
|
|
|
|
|
if (map != null && map.containsKey("ANLN1")) {
|
|
|
|
|
Object anln1Obj = map.get("ANLN1");
|
|
|
|
|
// 条件3:ANLN1 字段值不为空且可转为字符串
|
|
|
|
|
if (anln1Obj != null) {
|
|
|
|
|
String ANLN1 = anln1Obj.toString();
|
|
|
|
|
if (StringUtils.isNotEmpty(ANLN1)) {
|
|
|
|
|
baseEquipment.setFixedAssetCode(
|
|
|
|
|
ANLN1.substring(Math.max(0, ANLN1.length() - 6))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
baseEquipmentMapper.updateBaseEquipment(baseEquipment);
|
|
|
|
|
}
|
|
|
|
|
} catch (JsonSyntaxException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return AjaxResult.error("同步失败"+e.getMessage());
|
|
|
|
|
// 处理 JSON 转换异常
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success("同步成功");
|
|
|
|
|
} else {
|
|
|
|
|
// data 为空时的处理(如日志警告)
|
|
|
|
|
System.out.println("data is null");
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
return AjaxResult.error(r.getMsg());
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success("同步成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|