oms-gw推送-物料管理 修改企业国别字段类型
This commit is contained in:
@@ -99,4 +99,11 @@ public interface WmsServiceFeign {
|
||||
@ApiOperation("oms查询物料列表")
|
||||
@GetMapping("/materialBaseInfoApi/list")
|
||||
public AjaxResult getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO);
|
||||
|
||||
@ApiOperation("oms物料列表推送-更新推送信息")
|
||||
@PostMapping("/materialBaseInfoApi/updatePushStatus")
|
||||
public AjaxResult<?> updateMaterialPushStatus(@RequestParam("materialBaseInfoId") Long materialBaseInfoId,
|
||||
@RequestParam("pushStatus") Integer pushStatus,
|
||||
@RequestParam("pushTime") String pushTime,
|
||||
@RequestParam("pushBy") Long pushBy);
|
||||
}
|
||||
@@ -12,9 +12,18 @@ import lombok.Data;
|
||||
@ApiModel(description = "物料信息查询DTO")
|
||||
public class MaterialInfoDTO {
|
||||
|
||||
@ApiModelProperty("物料id")
|
||||
private Long materialBaseInfoId;
|
||||
|
||||
@ApiModelProperty("物料id")
|
||||
private String materialCode;
|
||||
|
||||
@ApiModelProperty("物料名称")
|
||||
private String materialName;
|
||||
|
||||
@ApiModelProperty("货物类型 0-料件 1-半成品 2-成品")
|
||||
private Integer goodsType;
|
||||
|
||||
@ApiModelProperty("组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
|
||||
+5
@@ -74,6 +74,11 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<WmsServiceFeign
|
||||
public AjaxResult getMaterialBaseInfoList(MaterialInfoDTO materialInfoDTO) {
|
||||
return AjaxResult.error(cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult<?> updateMaterialPushStatus(Long materialBaseInfoId, Integer pushStatus, String pushTime, Long pushBy) {
|
||||
return AjaxResult.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -177,7 +177,7 @@ public class ErpCountryApplicationService{
|
||||
entity.setPushTime(pushTime);
|
||||
}
|
||||
if (pushBy != null) {
|
||||
entity.setPushBy(String.valueOf(pushBy));
|
||||
entity.setPushBy(pushBy);
|
||||
}
|
||||
erpCountryMapper.updateById(entity);
|
||||
}
|
||||
|
||||
+133
@@ -1,19 +1,42 @@
|
||||
package com.mhd.oms.application.service.materialInfo;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.core.web.page.TableDataInfo;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.oms.domain.gwLog.entity.GwLog;
|
||||
import com.mhd.oms.domain.gwLog.repository.mapper.GwLogMapper;
|
||||
import com.mhd.system.api.WmsServiceFeign;
|
||||
import com.mhd.system.api.domain.MaterialInfoDTO;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class MaterialInfoApplicationService {
|
||||
|
||||
private static final String PUSH_API_URL = "http://10.33.0.100/ktms-erp-api/transfer/pushData";
|
||||
private static final String API_NAME = "saveOrgGoods";
|
||||
|
||||
@Resource
|
||||
private GwLogMapper gwLogMapper;
|
||||
|
||||
private final WmsServiceFeign wmsServiceFeign;
|
||||
|
||||
@@ -35,4 +58,114 @@ public class MaterialInfoApplicationService {
|
||||
tableDataInfo.setMsg("查询失败");
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
public AjaxResult batchPush(List<MaterialInfoDTO> dtoList) {
|
||||
if (dtoList == null || dtoList.isEmpty()) {
|
||||
return AjaxResult.error("没有数据需要推送");
|
||||
}
|
||||
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long pushBy = loginUser != null ? loginUser.getUserid() : null;
|
||||
Long organizationId = loginUser != null ? loginUser.getUserPo().getOrganizationId() : null;
|
||||
Long topOrganizationId = loginUser != null ? loginUser.getUserPo().getTopOrganizationId() : null;
|
||||
String organizationName = loginUser != null ? loginUser.getUserPo().getOrganizationName() : null;
|
||||
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
StringBuilder failMsg = new StringBuilder();
|
||||
|
||||
for (MaterialInfoDTO dto : dtoList) {
|
||||
Map<String, String> body = new HashMap<>();
|
||||
body.put("goodsCode", dto.getMaterialCode());
|
||||
|
||||
String goodsTypeString;
|
||||
if(dto.getGoodsType() == 0){
|
||||
goodsTypeString = "0";
|
||||
}else if(dto.getGoodsType() == 1){
|
||||
goodsTypeString = "1";
|
||||
}else if(dto.getGoodsType() == 2){
|
||||
goodsTypeString = "2";
|
||||
}else{
|
||||
throw new ServiceException("货物类型不存在");
|
||||
}
|
||||
body.put("goodsType", goodsTypeString);
|
||||
body.put("erpName", dto.getMaterialName());
|
||||
|
||||
|
||||
GwLog gwLog = new GwLog();
|
||||
gwLog.setType("物料管理");
|
||||
gwLog.setBusinessId(String.valueOf(dto.getMaterialBaseInfoId()));
|
||||
gwLog.setRequestBody(JSONObject.toJSONString(body));
|
||||
gwLog.setResponseBody("");
|
||||
gwLog.setStatus(1);
|
||||
gwLog.setSendTime(new Date());
|
||||
gwLog.setOrganizationId(organizationId);
|
||||
gwLog.setTopOrganizationId(topOrganizationId);
|
||||
gwLog.setOrganizationName(organizationName);
|
||||
gwLog.setCreateBy(pushBy);
|
||||
gwLog.setCreateTime(new Date());
|
||||
gwLog.setDelFlag(1);
|
||||
gwLogMapper.insert(gwLog);
|
||||
|
||||
updatePushStatus(dto.getMaterialBaseInfoId(), 2, new Date(), pushBy);
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(PUSH_API_URL);
|
||||
StringEntity postingString = new StringEntity(JSONObject.toJSONString(body), "UTF-8");
|
||||
httpPost.setEntity(postingString);
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
httpPost.setHeader("apiName", API_NAME);
|
||||
|
||||
try {
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
gwLog.setResponseBody(responseString);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
gwLog.setStatus(2);
|
||||
updatePushStatus(dto.getMaterialBaseInfoId(), 3, new Date(), pushBy);
|
||||
successCount++;
|
||||
} else {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(responseString);
|
||||
updatePushStatus(dto.getMaterialBaseInfoId(), 4, new Date(), pushBy);
|
||||
failCount++;
|
||||
failMsg.append("materialCode:").append(dto.getMaterialCode()).append("失败;");
|
||||
}
|
||||
gwLogMapper.updateById(gwLog);
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(e.getMessage());
|
||||
gwLogMapper.updateById(gwLog);
|
||||
updatePushStatus(dto.getMaterialBaseInfoId(), 4, new Date(), pushBy);
|
||||
failCount++;
|
||||
failMsg.append("materialCode:").append(dto.getMaterialCode()).append("异常:").append(e.getMessage()).append(";");
|
||||
log.error("物料推送异常: id={}, error={}", dto.getMaterialBaseInfoId(), e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (Exception e) {
|
||||
log.error("关闭httpClient异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String resultMsg = "推送完成: 成功" + successCount + "条, 失败" + failCount + "条";
|
||||
if (failCount > 0) {
|
||||
resultMsg += "[" + failMsg.toString() + "]";
|
||||
}
|
||||
return AjaxResult.success(resultMsg);
|
||||
}
|
||||
|
||||
private void updatePushStatus(Long materialBaseInfoId, Integer pushStatus, Date pushTime, Long pushBy) {
|
||||
try {
|
||||
String pushTimeStr = pushTime != null ? DateUtil.format(pushTime, "yyyy-MM-dd HH:mm:ss") : null;
|
||||
wmsServiceFeign.updateMaterialPushStatus(materialBaseInfoId, pushStatus, pushTimeStr, pushBy);
|
||||
log.info("更新返回结果: materialBaseInfoId={}", materialBaseInfoId);
|
||||
} catch (Exception e) {
|
||||
log.info("更新推送状态失败: materialBaseInfoId={}, error={}", materialBaseInfoId, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ErpCountry implements Serializable {
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushBy;
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("所属组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ErpCountryPO {
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushBy;
|
||||
private Long pushBy;
|
||||
|
||||
@ApiModelProperty("所属组织ID")
|
||||
private Long organizationId;
|
||||
|
||||
+8
-3
@@ -2,16 +2,16 @@ package com.mhd.oms.interfaces.facade.materialInfo;
|
||||
|
||||
|
||||
import com.mhd.common.core.web.controller.BaseController;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.core.web.page.TableDataInfo;
|
||||
import com.mhd.oms.application.service.materialInfo.MaterialInfoApplicationService;
|
||||
import com.mhd.system.api.domain.MaterialInfoDTO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Api(tags = "物料信息管理")
|
||||
@@ -30,6 +30,11 @@ public class MaterialInfoApi extends BaseController {
|
||||
return materialInfoApplicationService.queryList(materialInfoDTO);
|
||||
}
|
||||
|
||||
@ApiOperation("批量推送物料")
|
||||
@PostMapping("/batchPush")
|
||||
public AjaxResult batchPush(@RequestBody List<MaterialInfoDTO> dtoList) {
|
||||
return materialInfoApplicationService.batchPush(dtoList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+12
@@ -20,6 +20,7 @@ import com.mhd.wms.domain.materialBarCode.service.MaterialBarCodeDomainService;
|
||||
import com.mhd.wms.domain.materialBarCode.repository.todo.MaterialBarCodeDO;
|
||||
import com.mhd.wms.domain.materialBaseInfo.entity.MaterialBaseInfo;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.facade.IMaterialBaseInfoService;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.po.MaterialBaseInfoPO;
|
||||
import com.mhd.wms.domain.materialBaseInfo.repository.todo.MaterialBaseInfoDO;
|
||||
import com.mhd.wms.domain.materialBaseInfo.service.MaterialBaseInfoDomainService;
|
||||
@@ -49,6 +50,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -97,6 +99,8 @@ public class MaterialBaseInfoApplicationService {
|
||||
@Autowired
|
||||
private IMaterialWarehouseControlService materialWarehouseControlService;
|
||||
|
||||
@Resource
|
||||
private MaterialBaseInfoMapper materialBaseInfoMapper;
|
||||
/**
|
||||
* 分页查询物料基础信息列表
|
||||
*/
|
||||
@@ -1148,4 +1152,12 @@ public class MaterialBaseInfoApplicationService {
|
||||
return orgCandidates;
|
||||
}
|
||||
|
||||
public int updatePushStatus(Long materialBaseInfoId, Integer pushStatus, Date pushTimeDate, Long pushBy) {
|
||||
MaterialBaseInfo materialBaseInfo = new MaterialBaseInfo();
|
||||
materialBaseInfo.setMaterialBaseInfoId(materialBaseInfoId);
|
||||
materialBaseInfo.setPushStatus(pushStatus);
|
||||
materialBaseInfo.setPushTime(pushTimeDate);
|
||||
materialBaseInfo.setPushBy(pushBy);
|
||||
return materialBaseInfoMapper.updateById(materialBaseInfo);
|
||||
}
|
||||
}
|
||||
|
||||
+15
-1
@@ -1,7 +1,9 @@
|
||||
package com.mhd.wms.interfaces.facadeApi.materialBaseInfo;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.mhd.common.core.domain.entity.R;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.web.controller.BaseController;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.core.web.page.TableDataInfo;
|
||||
@@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -109,7 +112,18 @@ public class MaterialBaseInfoApi extends BaseController {
|
||||
return materialBaseInfoApplicationService.importData(file);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("物料管理更新推送信息")
|
||||
@PostMapping("/updatePushStatus")
|
||||
public AjaxResult<?> updateMaterialPushStatus(@RequestParam("materialBaseInfoId") Long materialBaseInfoId,
|
||||
@RequestParam("pushStatus") Integer pushStatus,
|
||||
@RequestParam("pushTime") String pushTime,
|
||||
@RequestParam("pushBy") Long pushBy){
|
||||
Date pushTimeDate = null;
|
||||
if (StringUtils.isNotBlank(pushTime)) {
|
||||
pushTimeDate = DateUtil.parse(pushTime);
|
||||
}
|
||||
return toAjax(materialBaseInfoApplicationService.updatePushStatus(materialBaseInfoId, pushStatus, pushTimeDate, pushBy));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user