Merge remote-tracking branch 'origin/dev_WMS20260401' into dev_WMS20260401
This commit is contained in:
+27
@@ -1,13 +1,19 @@
|
||||
package com.mhd.oms.application.service.businessDocumentCargoMulti;
|
||||
|
||||
import com.mhd.common.core.web.page.TableDataInfo;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.mapper.BusinessDocumentCargoMultiMapper;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.po.BusinessDocumentCargoMultiPO;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.todo.BusinessDocumentCargoMultiDO;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.service.BusinessDocumentCargoMultiDomainService;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 【请填写功能名称】ApplicationService
|
||||
@@ -21,6 +27,9 @@ public class BusinessDocumentCargoMultiApplicationService {
|
||||
@Autowired
|
||||
private BusinessDocumentCargoMultiDomainService businessDocumentCargoMultiDomainService;
|
||||
|
||||
@Resource
|
||||
private BusinessDocumentCargoMultiMapper businessDocumentCargoMultiMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询【请填写功能名称】列表
|
||||
@@ -69,4 +78,22 @@ public class BusinessDocumentCargoMultiApplicationService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public TableDataInfo getByOrderId(String orderId) {
|
||||
if (orderId == null ) {
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setData(new ArrayList<>());
|
||||
tableDataInfo.setTotal(0);
|
||||
tableDataInfo.setCode(200);
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
List<BusinessDocumentCargoMultiPO> list = businessDocumentCargoMultiMapper.selectBatchByOrderId(orderId);
|
||||
|
||||
TableDataInfo tableDataInfo = new TableDataInfo();
|
||||
tableDataInfo.setData(list);
|
||||
tableDataInfo.setTotal(list.size());
|
||||
tableDataInfo.setCode(200);
|
||||
return tableDataInfo;
|
||||
}
|
||||
}
|
||||
|
||||
+124
@@ -1,5 +1,6 @@
|
||||
package com.mhd.oms.application.service.businessDocumentOrder;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
@@ -31,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.json.JsonObject;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@@ -48,6 +50,9 @@ public class BusinessDocumentOrderApplicationService {
|
||||
private static final String API_NAME_I = "saveBill_i";
|
||||
private static final String API_NAME_E = "saveBill_e";
|
||||
private static final String VERIFY = "tjPZMT9fwhZRnv+eTXKF75QXmXzCn7phPagmoUQsvsh2ZTWDjuRxHAgcP0GZENHP";
|
||||
private static final String API_NAME = "billAppModify";
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderDomainService businessDocumentOrderDomainService;
|
||||
@@ -297,4 +302,123 @@ public class BusinessDocumentOrderApplicationService {
|
||||
}
|
||||
|
||||
|
||||
public AjaxResult batchPushForReviseApply(BusinessDocumentOrderDTO businessDocumentOrderDTO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long pushBy = loginUser != null ? loginUser.getUserid() : null;
|
||||
//String pushByName = loginUser != null ? loginUser.getUsername() : 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();
|
||||
|
||||
// 构建单个对象
|
||||
Map<String, String> item = new HashMap<>();
|
||||
item.put("erpBillNo", String.valueOf(businessDocumentOrderDTO.getId()));
|
||||
item.put("operateType", String.valueOf(businessDocumentOrderDTO.getReviseApplyType()));
|
||||
item.put("appMan", businessDocumentOrderDTO.getReviseApplyBy());
|
||||
item.put("appMess", businessDocumentOrderDTO.getReviseApplyReason());
|
||||
|
||||
// 2. 记录日志
|
||||
GwLog gwLog = new GwLog();
|
||||
gwLog.setType("删改单申请");
|
||||
gwLog.setBusinessId(Long.valueOf(businessDocumentOrderDTO.getId()));
|
||||
gwLog.setRequestBody(JSONObject.toJSONString(item));
|
||||
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);
|
||||
|
||||
//updateReservationOrder(businessDocumentOrderDTO);
|
||||
// 3. 调用推送接口
|
||||
try {
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(PUSH_API_URL);
|
||||
StringEntity postingString = new StringEntity(JSONObject.toJSONString(item), "UTF-8");
|
||||
httpPost.setEntity(postingString);
|
||||
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
httpPost.setHeader("verify", VERIFY);
|
||||
httpPost.setHeader("apiName", API_NAME);
|
||||
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
gwLog.setResponseBody(responseString);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
JSONObject responseJson = JSONObject.parseObject(responseString);
|
||||
JSONArray dataArray = responseJson.getJSONArray("data");
|
||||
if(dataArray != null && dataArray.size()>0){
|
||||
JSONObject dataObj = dataArray.getJSONObject(0);
|
||||
|
||||
if("1".equals(String.valueOf(dataObj.get("code")))){
|
||||
gwLog.setStatus(2);
|
||||
businessDocumentOrderDTO.setReviseApplyStatus(1);
|
||||
updateReservationOrder(businessDocumentOrderDTO);
|
||||
|
||||
successCount++;
|
||||
}else {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(responseString);
|
||||
|
||||
failCount++;
|
||||
failMsg.append("原始单证Id:").append(businessDocumentOrderDTO.getId()).append("失败:");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(responseString);
|
||||
|
||||
if (businessDocumentOrderDTO.getId() != null) {
|
||||
businessDocumentOrderDTO.setReviseApplyStatus(2);
|
||||
updateReservationOrder(businessDocumentOrderDTO);
|
||||
}
|
||||
failCount++;
|
||||
failMsg.append("原始单证id:").append(businessDocumentOrderDTO.getId()).append("失败:");
|
||||
}
|
||||
gwLogMapper.updateById(gwLog);
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(e.getMessage());
|
||||
gwLog.setResponseBody("请求异常:" + e.getMessage());
|
||||
gwLogMapper.updateById(gwLog);
|
||||
if (businessDocumentOrderDTO.getId() != null) {
|
||||
businessDocumentOrderDTO.setReviseApplyStatus(2);
|
||||
updateReservationOrder(businessDocumentOrderDTO);
|
||||
}
|
||||
failCount++;
|
||||
failMsg.append("单证id:").append(businessDocumentOrderDTO.getId()).append("异常:").append(e.getMessage());
|
||||
log.error("GW推送异常:单证id={}, error={}", businessDocumentOrderDTO.getId(), e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
String resultMsg = "推送完成:成功" + successCount + "条,失败" + failCount + "条";
|
||||
if (failCount > 0) {
|
||||
resultMsg += "[" + failMsg.toString() + "]";
|
||||
}
|
||||
return AjaxResult.success(resultMsg);
|
||||
|
||||
}
|
||||
|
||||
private void updateReservationOrder(BusinessDocumentOrderDTO businessDocumentOrderDTO) {
|
||||
try {
|
||||
BusinessDocumentOrder businessDocumentOrder = new BusinessDocumentOrder();
|
||||
BeanUtils.copyProperties(businessDocumentOrderDTO,businessDocumentOrder);
|
||||
|
||||
|
||||
businessDocumentOrderMapper.updateById(businessDocumentOrder);
|
||||
} catch (Exception e) {
|
||||
log.error("删改单申请更新状态失败失败: id={}, error={}", businessDocumentOrderDTO.getId(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.po.BusinessDocumentCargoMultiPO;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.todo.BusinessDocumentCargoMultiDO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
*
|
||||
@@ -19,4 +22,6 @@ public interface BusinessDocumentCargoMultiMapper extends BaseMapper<BusinessDoc
|
||||
*/
|
||||
public List<BusinessDocumentCargoMultiPO> queryList(BusinessDocumentCargoMultiDO businessDocumentCargoMultiDO);
|
||||
|
||||
|
||||
List<BusinessDocumentCargoMultiPO> selectBatchByOrderId(@Param("orderId") String orderId);
|
||||
}
|
||||
|
||||
+4
@@ -67,5 +67,9 @@ public class BusinessDocumentCargoMultiPO extends BaseVOEntity{
|
||||
|
||||
@ApiModelProperty("物料id")
|
||||
private Long materialBaseInfoId;
|
||||
@ApiModelProperty("订单id")
|
||||
private String OrderId;
|
||||
@ApiModelProperty("货物信息-件数")
|
||||
private BigDecimal CargoNum;
|
||||
|
||||
}
|
||||
|
||||
+6
-8
@@ -4,13 +4,7 @@ import java.util.List;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentCargoMulti.BusinessDocumentCargoMultiDTO;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.todo.BusinessDocumentCargoMultiDO;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.repository.po.BusinessDocumentCargoMultiPO;
|
||||
@@ -89,7 +83,11 @@ public class BusinessDocumentCargoMultiApi extends BaseController{
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiOperation("根据物料ID列表批量查询物料")
|
||||
@GetMapping("/getBatchByOrderId")
|
||||
public TableDataInfo getBatchByIds(@RequestParam("orderId") String orderId) {
|
||||
return businessDocumentCargoMultiApplicationService.getByOrderId(orderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+13
@@ -171,4 +171,17 @@ public class OriginalImportExportDocumentApi extends BaseController {
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("批量推送")
|
||||
@PostMapping("/batchPushForReviseApply")
|
||||
public AjaxResult batchPushForReviseApply(@RequestBody BusinessDocumentOrderDTO businessDocumentOrderDTO){
|
||||
if(businessDocumentOrderDTO == null){
|
||||
return AjaxResult.error("没有数据需要推送");
|
||||
}
|
||||
return businessDocumentOrderApplicationService.batchPushForReviseApply(businessDocumentOrderDTO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user