进出口原始单证 查询/批量推送 删改单申请(部分)
This commit is contained in:
+178
-1
@@ -1,21 +1,39 @@
|
||||
package com.mhd.oms.application.service.businessDocumentOrder;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCargoMulti;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.entity.BusinessDocumentOrder;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.mapper.BusinessDocumentOrderMapper;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.po.BusinessDocumentOrderPO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.repository.todo.BusinessDocumentOrderDO;
|
||||
import com.mhd.oms.domain.businessDocumentOrder.service.BusinessDocumentOrderDomainService;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount;
|
||||
import com.mhd.oms.domain.businessOrderAccount.repository.mapper.BusinessOrderAccountMapper;
|
||||
import com.mhd.oms.domain.gwLog.entity.GwLog;
|
||||
import com.mhd.oms.domain.gwLog.repository.mapper.GwLogMapper;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessAuditDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentOrder.BusinessDocumentOrderDTO;
|
||||
import com.mhd.oms.interfaces.dto.originalImportExportDocument.OrderWithMaterialDTO;
|
||||
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.ehcache.shadow.org.terracotta.context.extractor.ObjectContextExtractor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】ApplicationService
|
||||
*
|
||||
@@ -25,6 +43,11 @@ import java.util.List;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BusinessDocumentOrderApplicationService {
|
||||
|
||||
private static final String PUSH_API_URL = "http://10.33.0.100/ktms-erp-api/transfer/pushData";
|
||||
private static final String API_NAME_I = "saveBill_i";
|
||||
private static final String API_NAME_E = "saveBill_e";
|
||||
|
||||
@Autowired
|
||||
private BusinessDocumentOrderDomainService businessDocumentOrderDomainService;
|
||||
|
||||
@@ -32,6 +55,12 @@ public class BusinessDocumentOrderApplicationService {
|
||||
private BusinessOrderAccountMapper businessOrderAccountMapper;
|
||||
|
||||
|
||||
@Resource
|
||||
private BusinessDocumentOrderMapper businessDocumentOrderMapper;
|
||||
|
||||
@Resource
|
||||
private GwLogMapper gwLogMapper;
|
||||
|
||||
/**
|
||||
* 分页查询【请填写功能名称】列表
|
||||
*/
|
||||
@@ -113,4 +142,152 @@ public class BusinessDocumentOrderApplicationService {
|
||||
}
|
||||
return businessDocumentOrderDomainService.queryListAndMaterial(businessDocumentOrderDO);
|
||||
}
|
||||
|
||||
public void reviseApply(BusinessDocumentOrderDTO businessDocumentOrderDTO) {
|
||||
BusinessDocumentOrder businessDocumentOrder = new BusinessDocumentOrder();
|
||||
BeanUtils.copyProperties(businessDocumentOrder,businessDocumentOrderDTO);
|
||||
businessDocumentOrderMapper.updateById(businessDocumentOrder);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public AjaxResult batchPushForOriginalImportExportDocument(List<BusinessDocumentOrderDTO> businessDocumentOrderDTOList) {
|
||||
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();
|
||||
|
||||
for (BusinessDocumentOrderDTO pushData : businessDocumentOrderDTOList) {
|
||||
// 1. 构建推送数据
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("erpBillNo", String.valueOf(pushData.getId()));
|
||||
body.put("billDate", pushData.getDocumentDate());
|
||||
body.put("goodsType", pushData.getGoodsType());
|
||||
body.put("ieFlag", pushData.getIeType() != null ? String.valueOf(pushData.getIeType()) : null);
|
||||
body.put("corpCode", pushData.getAppointShipperId() != null ? pushData.getAppointShipperId().toString() : null);
|
||||
|
||||
List<Map<String, Object>> billList = new ArrayList<>();
|
||||
int gNo = 1;
|
||||
for(OrderWithMaterialDTO orderWithMaterialDTO : pushData.getOrderWithMaterialDTOList()){
|
||||
Map<String, Object> billMap = new HashMap<>();
|
||||
billMap.put("gNo", gNo++);
|
||||
billMap.put("goodsCode", orderWithMaterialDTO.getMaterialCode() != null ? orderWithMaterialDTO.getMaterialCode().toString() : null);
|
||||
billMap.put("netWt", orderWithMaterialDTO.getWeightLimit());
|
||||
billMap.put("grossWt", orderWithMaterialDTO.getGrossWeight());
|
||||
billMap.put("packNo", orderWithMaterialDTO.getCargoNum());
|
||||
billMap.put("erpQty", orderWithMaterialDTO.getCargoNum());
|
||||
billList.add(billMap);
|
||||
}
|
||||
body.put("billList",billList);
|
||||
|
||||
if (pushData.getId() != null) {
|
||||
updatePushStatus(pushData.getId(), 2, null, String.valueOf(pushBy), pushByName);
|
||||
}
|
||||
|
||||
|
||||
// 2. 记录日志
|
||||
GwLog gwLog = new GwLog();
|
||||
gwLog.setType("进出口原始单证-物料推送");
|
||||
gwLog.setBusinessId(pushData.getMaterialCode());
|
||||
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);
|
||||
|
||||
// 3. 调用推送接口
|
||||
try {
|
||||
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");
|
||||
if(pushData.getIeType().equals("I"))
|
||||
{
|
||||
httpPost.setHeader("apiName", API_NAME_I);
|
||||
}
|
||||
else if (pushData.getIeType().equals("E")) {
|
||||
httpPost.setHeader("apiName", API_NAME_E);
|
||||
}else{
|
||||
AjaxResult.error("进出口方式错误");
|
||||
}
|
||||
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
gwLog.setResponseBody(responseString);
|
||||
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
gwLog.setStatus(2);
|
||||
if (pushData.getId() != null) {
|
||||
updatePushStatus(pushData.getId(), 3, new Date(), String.valueOf(pushBy), pushByName);
|
||||
}
|
||||
successCount++;
|
||||
} else {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(responseString);
|
||||
if (pushData.getId() != null) {
|
||||
updatePushStatus(pushData.getId(), 4, new Date(), String.valueOf(pushBy), pushByName);
|
||||
}
|
||||
failCount++;
|
||||
failMsg.append("物料编码:").append(pushData.getMaterialCode()).append("失败:");
|
||||
}
|
||||
gwLogMapper.updateById(gwLog);
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
gwLog.setStatus(3);
|
||||
gwLog.setErrorMsg(e.getMessage());
|
||||
gwLogMapper.updateById(gwLog);
|
||||
if (pushData.getId() != null) {
|
||||
updatePushStatus(pushData.getId(), 4, new Date(), String.valueOf(pushBy), pushByName);
|
||||
}
|
||||
failCount++;
|
||||
failMsg.append("物料编码:").append(pushData.getMaterialCode()).append("异常:").append(e.getMessage());
|
||||
log.error("GW推送异常:materialCode={}, error={}", pushData.getMaterialCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
String resultMsg = "推送完成:成功" + successCount + "条,失败" + failCount + "条";
|
||||
if (failCount > 0) {
|
||||
resultMsg += "[" + failMsg.toString() + "]";
|
||||
}
|
||||
return AjaxResult.success(resultMsg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updatePushStatus(Long id, Integer pushStatus, Date pushTime, String pushBy, String pushByName) {
|
||||
try {
|
||||
BusinessDocumentOrder update = new BusinessDocumentOrder();
|
||||
update.setId(id);
|
||||
update.setPushStatus(pushStatus);
|
||||
if (pushTime != null) {
|
||||
update.setPushTime(pushTime);
|
||||
}
|
||||
if (pushBy != null) {
|
||||
update.setPushBy(pushBy);
|
||||
}
|
||||
if (pushByName != null) {
|
||||
update.setPushByName(pushByName);
|
||||
}
|
||||
businessDocumentOrderMapper.updateById(update);
|
||||
} catch (Exception e) {
|
||||
log.error("更新推送状态失败: id={}, error={}", id, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+13
@@ -760,4 +760,17 @@ public class BusinessDocumentOrder extends BaseVOEntity{
|
||||
@ApiModelProperty("进出口方式:I-进口,E-出口")
|
||||
private String ieType;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送 2-推送中 3-推送成功 4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
}
|
||||
|
||||
+14
@@ -774,6 +774,20 @@ public class BusinessDocumentOrderPO extends BaseVOEntity{
|
||||
@ApiModelProperty("进出口方式:I-进口,E-出口")
|
||||
private String ieType;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送 2-推送中 3-推送成功 4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
|
||||
@ApiModelProperty("执行单")
|
||||
private List<ExecuteOrder> executeOrderList;
|
||||
|
||||
|
||||
+14
@@ -793,6 +793,20 @@ public class BusinessDocumentOrderDO extends BaseVOEntity{
|
||||
@ApiModelProperty("进出口方式:I-进口,E-出口")
|
||||
private String ieType;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送 2-推送中 3-推送成功 4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
|
||||
@ApiModelProperty("费用科目明细")
|
||||
private List<BusinessOrderAccount> businessOrderAccountList;
|
||||
|
||||
|
||||
+41
@@ -7,6 +7,7 @@ import com.mhd.oms.domain.businessDocumentCargoMulti.entity.BusinessDocumentCarg
|
||||
import com.mhd.oms.domain.businessOrderAccount.BusinessOrderAccount;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentAddressMulti.BusinessDocumentAddressMultiDTO;
|
||||
import com.mhd.oms.interfaces.dto.businessDocumentCargoMulti.BusinessDocumentCargoMultiDTO;
|
||||
import com.mhd.oms.interfaces.dto.originalImportExportDocument.OrderWithMaterialDTO;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -671,6 +672,8 @@ public class BusinessDocumentOrderDTO extends BaseVOEntity{
|
||||
|
||||
@ApiModelProperty("$column.columnComment")
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date documentDate;
|
||||
|
||||
|
||||
@@ -780,6 +783,20 @@ public class BusinessDocumentOrderDTO extends BaseVOEntity{
|
||||
@ApiModelProperty("进出口方式:I-进口,E-出口")
|
||||
private String ieType;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送 2-推送中 3-推送成功 4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
|
||||
@ApiModelProperty("业务单地址集合")
|
||||
private List<BusinessDocumentAddressMultiDTO> businessDocumentAddressMultiDTOList;
|
||||
|
||||
@@ -799,4 +816,28 @@ public class BusinessDocumentOrderDTO extends BaseVOEntity{
|
||||
@ApiModelProperty("费用科目明细")
|
||||
private List<BusinessOrderAccount> businessOrderAccountList;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "物料编码")
|
||||
private String materialCode;
|
||||
|
||||
@ApiModelProperty(value = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
@ApiModelProperty(value = "净重")
|
||||
private BigDecimal weightLimit;
|
||||
|
||||
@ApiModelProperty(value = "毛重")
|
||||
private BigDecimal grossWeight;
|
||||
|
||||
@ApiModelProperty(value = "单价")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
@ApiModelProperty(value = "申报单位")
|
||||
private String declarationUnit;
|
||||
|
||||
@ApiModelProperty(value = "原产国")
|
||||
private String originCountry;
|
||||
|
||||
@ApiModelProperty(value = "物料明细列表")
|
||||
private List<OrderWithMaterialDTO> orderWithMaterialDTOList;
|
||||
}
|
||||
|
||||
+23
@@ -781,4 +781,27 @@ public class OrderWithMaterialDTO {
|
||||
@ApiModelProperty("仓库负责人电话")
|
||||
private String directorPhone;
|
||||
|
||||
@ApiModelProperty("仓库负责人电话")
|
||||
private BigDecimal CargoNum;
|
||||
|
||||
@ApiModelProperty("币制")
|
||||
private BigDecimal currency;
|
||||
|
||||
@ApiModelProperty("包装规格")
|
||||
private BigDecimal packName;
|
||||
|
||||
@ApiModelProperty("推送状态:1-未推送 2-推送中 3-推送成功 4-推送失败")
|
||||
private Integer pushStatus;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("推送时间")
|
||||
private Date pushTime;
|
||||
|
||||
@ApiModelProperty("推送人")
|
||||
private String pushBy;
|
||||
|
||||
@ApiModelProperty("推送人姓名")
|
||||
private String pushByName;
|
||||
|
||||
}
|
||||
|
||||
+30
-5
@@ -17,11 +17,8 @@ import com.mhd.system.api.domain.MaterialInfoDTO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
@@ -63,6 +60,34 @@ public class OriginalImportExportDocumentApi extends BaseController {
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
@ApiOperation("删改单申请")
|
||||
@PostMapping("/reviseApply")
|
||||
public AjaxResult reviseApply(@RequestParam BusinessDocumentOrderDTO businessDocumentOrderDTO){
|
||||
|
||||
businessDocumentOrderApplicationService.reviseApply(businessDocumentOrderDTO);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ApiOperation("批量推送")
|
||||
@PostMapping("/batchPush")
|
||||
public AjaxResult batchPush(@RequestBody List<BusinessDocumentOrderDTO> businessDocumentOrderDTOList){
|
||||
if(businessDocumentOrderDTOList.isEmpty() || businessDocumentOrderDTOList == null){
|
||||
return AjaxResult.error("没有数据需要推送");
|
||||
}
|
||||
return businessDocumentOrderApplicationService.batchPushForOriginalImportExportDocument(businessDocumentOrderDTOList);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private List<OrderWithMaterialDTO> convertToOrderWithMaterialList(List<BusinessDocumentOrderPO> orderList){
|
||||
List<OrderWithMaterialDTO> resultList = new ArrayList<>();
|
||||
for(BusinessDocumentOrderPO order:orderList){
|
||||
|
||||
+4
@@ -170,6 +170,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="documentDate" column="DOCUMENT_DATE" />
|
||||
<result property="ieType" column="IE_TYPE" />
|
||||
<result property="materialCode" column="MATERIAL_CODE" />
|
||||
<result property="pushBy" column="PUSH_BY" />
|
||||
<result property="pushByName" column="PUSH_BY_NAME" />
|
||||
<result property="pushStatus" column="PUSH_STATUS" />
|
||||
<result property="pushTime" column="PUSH_TIME" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user