1.添加提交单据到第三方系统接口

2.增加第三方系统单据类型名称和编码
master
x_z 3 years ago
parent d53d819a74
commit c3d3a7a4d9

@ -200,7 +200,10 @@ public class BasicThirdSysController {
basicThirdSysBusApiEntity.setName(bussinessOriginTypeEntity.getName());
basicThirdSysBusApiEntity.setType(filterBasicThirdSysDetailRequest.getType());
basicThirdSysBusApiService.insertSysBusApi(basicThirdSysBusApiEntity);
if (filterBasicThirdSysDetailRequest.getType() == 1) {
basicThirdSysBusApiService.insertSysBusApi(basicThirdSysBusApiEntity);
}
}
basicThirdSysEntities = basicThirdSysBusApiService.filterSysBusApi(filterBasicThirdSysDetailRequest);
}
@ -218,7 +221,6 @@ public class BasicThirdSysController {
@PostMapping("/udiwms/basic/thirdsys/saveBusTypeDetail")
public BaseResponse saveBusTypeDetail(@RequestBody @Valid BasicThirdSysBusApiEntity basicThirdSysBusApiEntity,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}

@ -448,6 +448,12 @@ public class StockOrderController {
return ResultVOUtils.success();
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/stock/order/error/submitStockOrderToThirdSys")
public BaseResponse submitStockOrderToThirdSys(@RequestParam("id") String id) {
return stockOrderService.submitOrderToThirdys(id);
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/stock/order/qrcode/generate/text")
public BaseResponse generateStockOrderQRCodeText(@RequestBody StockOrderIdsRequest stockOrderIdsRequest) {

@ -54,4 +54,11 @@ public interface BussinessTypeDao {
*/
void updateSupplementOrderType(@Param("supplementOrderType") String supplementOrderType, @Param("action") String action);
/**
*
*
* @param localAction
* @return
*/
String selectInoutTypebByLocalAction(@Param("localAction") String localAction);
}

@ -16,4 +16,12 @@ public interface UnitMaintainDao {
boolean deleteById(@Param("id") String id);
UnitMaintainEntity selectById(@Param("id") String id);
/**
* erpId
*
* @param erpId
* @return
*/
UnitMaintainEntity selectThirdInfoByErpId(@Param("erpId") String erpId);
}

@ -40,4 +40,12 @@ public interface StockOrderDao {
* @return
*/
List<StockOrderEntity> selectSupplementOrderList();
/**
* ID
*
* @param id
* @return
*/
StockOrderEntity findById(@Param("id") String id);
}

@ -8,6 +8,8 @@ public class BasicThirdSysBusApiEntity {
private Integer id;
private String code;
private String name;
private String thirdBuyName; //第三方系统单据类型名称
private String thirdBuyCode; //第三方系统单据类型代码
private String thirdSys;
private String url;
private Integer type;

@ -12,14 +12,16 @@ import com.glxp.api.admin.req.inout.USignRequest;
import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.res.inout.ErpOrderResponse;
import com.glxp.api.admin.service.basic.BasicThirdSysService;
import com.glxp.api.admin.util.DateUtil;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.common.res.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* ERP
@ -100,7 +102,7 @@ public class ErpOrderClient {
public BaseResponse submitOrder(UdiwmsOrderRequest udiwmsOrderRequest) {
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysService.selectByThirdId(udiwmsOrderRequest.getThirdSys());
String url = basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders";
String response = HttpClient.uCloudPost(url, udiwmsOrderRequest, basicThirdSysEntity);
String response = HttpClient.uCloudPost(url, udiwmsOrderRequest);
try {
BaseResponse<PageSimpleResponse<ErpOrderResponse>> responseBaseResponse =
JSONObject.parseObject(response, new TypeReference<BaseResponse<PageSimpleResponse<ErpOrderResponse>>>() {

@ -8,19 +8,24 @@ import java.math.BigDecimal;
public class UdiwmsOrderDetail {
private String productId; //产品编码
private String productName; //产品名称
private BigDecimal price; //单价
private String batchNo; //批次号
private String expireDate; //失效日期
private String productDate; //生产日期
private String standard; //规格型号
private String productName; //产品名称
private String billNo; //单据号
private String secSalesInvNo;//销售发票号(第二票)
private String invoiceDate;//发票日期
private String secSalesListNo; //第二票销售清单号
private String firstSalesInvNo; //销售发票号(第一票)
private String registerNo; //注册/备案证号
private String manufactory; //生产厂家
private Integer count; //数量
private Integer reCount; //数量
private String remark; //备注
private String remark1; //备注1/规格型号ID
private String remark2; //备注2/型号
private String remark3; //备注3/规格
//阳光采购平台 耗材目录规格id
private String productSpecId;
}

@ -2,40 +2,21 @@ package com.glxp.api.admin.httpclient.req;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public class UdiwmsOrderRequest {
private String startDate; //起始日期
private String endDate; //结束日期
private String billNo; //单据号
private String billFlag; //单据状态,0.未签字1.已签字
private String billAction;
private String action;
private Integer limit;
private Integer page;
private Integer inoutType;
private Integer inoutType; //出入库类型 1.入库 2.出库
private String billDate; //单据日期
private String billType; //单据类型
private Integer createUser;
private Integer reviewUser;
private String remark; //备注
private String address; //地址
private String linkMan; //联系人
private String linkTel; //电话
private String corpId; //第三方单据往来单位ID
private String corpName; //往来单位
private String detailCode; //明细编码
private String thirdSys; //第三方系统ID
private String status; //单据状态
private List<UdiwmsOrderDetail> items; //单据详情数组
}

@ -6,6 +6,7 @@ import com.glxp.api.admin.entity.business.StockOrderPrintEntity;
import com.glxp.api.admin.req.business.StockOrderFilterRequest;
import com.glxp.api.admin.req.business.StockOrderQueryRequest;
import com.glxp.api.admin.res.business.StockOrderExportResponse;
import com.glxp.api.common.res.BaseResponse;
import java.util.List;
@ -54,4 +55,6 @@ public interface StockOrderService {
* @return
*/
List<StockOrderEntity> getSupplementOrderBillNoList();
BaseResponse submitOrderToThirdys(String id);
}

@ -2,20 +2,37 @@ package com.glxp.api.admin.service.business.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.admin.constant.ConstantType;
import com.glxp.api.admin.dao.basic.BasicThirdSysBusApiDao;
import com.glxp.api.admin.dao.basic.BasicThirdSysDao;
import com.glxp.api.admin.dao.basic.BussinessTypeDao;
import com.glxp.api.admin.dao.basic.UnitMaintainDao;
import com.glxp.api.admin.dao.business.StockOrderDao;
import com.glxp.api.admin.dao.business.StockOrderDetailDao;
import com.glxp.api.admin.dao.inout.OrderDao;
import com.glxp.api.admin.entity.basic.BasicThirdSysBusApiEntity;
import com.glxp.api.admin.entity.basic.BasicThirdSysEntity;
import com.glxp.api.admin.entity.basic.UnitMaintainEntity;
import com.glxp.api.admin.entity.business.StockOrderDetailEntity;
import com.glxp.api.admin.entity.business.StockOrderEntity;
import com.glxp.api.admin.entity.business.StockOrderPrintEntity;
import com.glxp.api.admin.httpclient.req.UdiwmsOrderDetail;
import com.glxp.api.admin.httpclient.req.UdiwmsOrderRequest;
import com.glxp.api.admin.req.business.StockOrderDetailFilterRequest;
import com.glxp.api.admin.req.business.StockOrderFilterRequest;
import com.glxp.api.admin.req.business.StockOrderQueryRequest;
import com.glxp.api.admin.res.business.StockOrderDetailEntityVo;
import com.glxp.api.admin.res.business.StockOrderExportResponse;
import com.glxp.api.admin.service.business.StockOrderService;
import com.glxp.api.admin.util.HttpClient;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
@ -29,6 +46,16 @@ public class StockOrderServiceImpl implements StockOrderService {
StockOrderDao stockOrderDao;
@Resource
StockOrderDetailDao stockOrderDetailDao;
@Resource
private BasicThirdSysBusApiDao thirdSysBusApiDao;
@Resource
private UnitMaintainDao unitMaintainDao;
@Resource
private BussinessTypeDao bussinessTypeDao;
@Resource
private BasicThirdSysDao basicThirdSysDao;
@Resource
private OrderDao orderDao;
@Override
public List<StockOrderEntity> listStockOrders(StockOrderQueryRequest stockOrderQueryRequest) {
@ -144,4 +171,66 @@ public class StockOrderServiceImpl implements StockOrderService {
public List<StockOrderEntity> getSupplementOrderBillNoList() {
return stockOrderDao.selectSupplementOrderList();
}
@Transactional(rollbackFor = Exception.class)
@Override
public BaseResponse submitOrderToThirdys(String id) {
//查询单据和详情信息,组装第三方系统接口参数所需数据
StockOrderEntity stockOrderEntity = stockOrderDao.findById(id);
StockOrderDetailFilterRequest orderDetailFilterRequest = new StockOrderDetailFilterRequest();
orderDetailFilterRequest.setOrderIdFk(id);
List<StockOrderDetailEntity> stockOrderDetailEntities = stockOrderDetailDao.filterStockOrderDetail(orderDetailFilterRequest);
UdiwmsOrderRequest udiwmsOrderRequest = new UdiwmsOrderRequest();
udiwmsOrderRequest.setBillDate(stockOrderEntity.getBilldate()); //单据日期
udiwmsOrderRequest.setBillNo(stockOrderEntity.getBillNo()); //单号
//查询往来单位第三方系统对照编码
UnitMaintainEntity unitMaintainEntity = unitMaintainDao.selectThirdInfoByErpId(stockOrderEntity.getCorpId());
udiwmsOrderRequest.setCorpId(unitMaintainEntity.getThirdId()); //往来单位编码需转换为第三方系统的ID
udiwmsOrderRequest.setCorpName(unitMaintainEntity.getThirdName()); //往来单位名称,需转换为第三方系统的名称
udiwmsOrderRequest.setBillFlag(stockOrderEntity.getBillFlag());//单据状态
//查询第三方系统的单据ID及第三方系统标识
BasicThirdSysBusApiEntity thirdSysBusApiEntity = thirdSysBusApiDao.selectByCode(stockOrderEntity.getBillType());
udiwmsOrderRequest.setThirdSys(thirdSysBusApiEntity.getThirdSys()); //第三方系统标识
udiwmsOrderRequest.setBillType(thirdSysBusApiEntity.getThirdBuyName());
//查询单据出入库类型
String mainAction = bussinessTypeDao.selectInoutTypebByLocalAction(stockOrderEntity.getBillType());
if (ConstantType.TYPE_PUT.equals(mainAction)) {
udiwmsOrderRequest.setInoutType(1); //出入库类型:入库
} else if (ConstantType.TYPE_OUT.equals(mainAction)) {
udiwmsOrderRequest.setInoutType(2); //出入库类型:出库
}
udiwmsOrderRequest.setRemark("udi管理系统提交单据"); //备注
//组装明细数据
List<UdiwmsOrderDetail> items = new ArrayList<>(stockOrderDetailEntities.size());
for (StockOrderDetailEntity stockOrderDetailEntity : stockOrderDetailEntities) {
UdiwmsOrderDetail item = new UdiwmsOrderDetail();
BeanUtil.copyProperties(stockOrderDetailEntity, item);
items.add(item);
}
udiwmsOrderRequest.setItems(items);
//提交单据到第三方服务
BasicThirdSysEntity basicThirdSysEntity = basicThirdSysDao.selectByThirdId(thirdSysBusApiEntity.getThirdSys());
String response = HttpClient.uCloudPost(basicThirdSysEntity.getThridUrl() + "/udiwms/erp/submitOrders", udiwmsOrderRequest);
if (StrUtil.isNotBlank(response)) {
try {
BaseResponse baseResponse = JSONUtil.toBean(response, BaseResponse.class);
if (baseResponse.getCode().equals(20000)) {
//提交成功,更新导出状态
orderDao.updateExportStatus(stockOrderEntity.getOrderIdFk(), 1);
return ResultVOUtils.success("提交成功");
}
return ResultVOUtils.error(500, "提交失败");
} catch (Exception e) {
return ResultVOUtils.error(500, "提交失败");
}
} else {
return ResultVOUtils.error(500, "提交失败");
}
}
}

@ -309,7 +309,9 @@ public class OrderServiceImpl implements OrderService {
for (StockOrderResponse stockOrderResponse : orderResponseList) {
if (!actions.contains(stockOrderResponse.getBillType())) {
BasicThirdSysBusApiEntity basicThirdSysBusApiEntity = basicThirdSysBusApiDao.selectByCode(stockOrderResponse.getBillType());
actions.add(basicThirdSysBusApiEntity.getCode());
if (StrUtil.isNotBlank(basicThirdSysBusApiEntity.getThirdBuyName())) {
actions.add(basicThirdSysBusApiEntity.getCode());
}
}
if (actions.contains(stockOrderResponse.getBillType())) {

@ -29,10 +29,7 @@ public class HttpClient {
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/x-www-form-urlencoded");
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(postParameters, headers);
String response = restTemplate.postForObject(UdidConfig.apiUrl + url, httpEntity, String.class);
System.out.println(response);
return response;
return restTemplate.postForObject(UdidConfig.apiUrl + url, httpEntity, String.class);
}
public static String postU8(String url, Object object) {

@ -8,6 +8,8 @@
<trim prefix="set" suffixOverrides=",">
<if test="code != null">code=#{code},</if>
<if test="name != null">`name`=#{name},</if>
<if test="thirdBuyName != null">`thirdBuyName`=#{thirdBuyName},</if>
<if test="thirdBuyCode != null">`thirdBuyCode`=#{thirdBuyCode},</if>
<if test="thirdSys != null">thirdSys=#{thirdSys},</if>
<if test="url != null">url=#{url},</if>
<if test="type != null">`type`=#{type},</if>
@ -42,18 +44,17 @@
<insert id="insertSysBusApi" keyProperty="id"
parameterType="com.glxp.api.admin.entity.basic.BasicThirdSysBusApiEntity">
insert
ignore
ignore
INTO basic_third_sys_bus_api
(`code`,`name`,`thirdSys`,url,`type`,remark)
values
(
#{code},
#{name},
#{thirdSys},
#{url},
#{type},
#{remark}
)
(`code`, `name`, thirdBuyName, thirdBuyCode, `thirdSys`, url, `type`, remark)
values (#{code},
#{name},
#{thirdBuyName},
#{thirdBuyCode},
#{thirdSys},
#{url},
#{type},
#{remark})
</insert>
<insert id="saveBusTypes">
@ -63,6 +64,8 @@
(
#{item.code},
#{item.name},
#{item.thirdBuyName},
#{item.thirdBuyCode},
#{item.thirdSys},
#{item.type}
)

@ -348,4 +348,11 @@
or supplementOrderType = '')
and corpType = 1
</select>
<select id="selectInoutTypebByLocalAction" resultType="java.lang.String">
select mainAction
from basic_bussiness_type
where localAction = #{localAction}
</select>
</mapper>

@ -49,4 +49,10 @@
<select id="selectById" parameterType="Map" resultType="com.glxp.api.admin.entity.basic.UnitMaintainEntity">
select * FROM basic_corp WHERE id = #{id}
</select>
<select id="selectThirdInfoByErpId" resultType="com.glxp.api.admin.entity.basic.UnitMaintainEntity">
select thirdId, thirdName
from basic_corp
where erpId = #{erpId}
</select>
</mapper>

@ -257,4 +257,10 @@
or supplementNo = ''
</select>
<select id="findById" resultType="com.glxp.api.admin.entity.business.StockOrderEntity">
select *
from stock_order
where id = #{id}
</select>
</mapper>
Loading…
Cancel
Save