对接智业第三方单据上传修改
							parent
							
								
									f8930c428c
								
							
						
					
					
						commit
						f8ddbffd77
					
				| @ -0,0 +1,184 @@ | ||||
| package com.glxp.mipsdl.admin.client.http; | ||||
| 
 | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.alibaba.fastjson.TypeReference; | ||||
| import com.glxp.mipsdl.admin.config.ThirdSysConfig; | ||||
| import com.glxp.mipsdl.admin.dao.phxyy.BasicThirdSysDetailDao; | ||||
| import com.glxp.mipsdl.admin.entity.phxyy.BasicThirdSysBusApiEntity; | ||||
| import com.glxp.mipsdl.admin.entity.phxyy.BasicThirdSysDetailEntity; | ||||
| import com.glxp.mipsdl.admin.req.UdiwmsOnhandRequest; | ||||
| import com.glxp.mipsdl.admin.req.UdiwmsOrderRequest; | ||||
| import com.glxp.mipsdl.admin.req.UdiwmsPreInOrderRequest; | ||||
| import com.glxp.mipsdl.admin.req.ZaxzyyOrderRequest; | ||||
| import com.glxp.mipsdl.admin.req.phxyy.PhBusTypeRequest; | ||||
| import com.glxp.mipsdl.admin.req.phxyy.PhProductRequest; | ||||
| import com.glxp.mipsdl.admin.req.phxyy.PhUnitRequest; | ||||
| import com.glxp.mipsdl.admin.req.phxyy.PhWarehouseRequest; | ||||
| import com.glxp.mipsdl.admin.res.phxyy.BussinessOriginTypeResponse; | ||||
| import com.glxp.mipsdl.admin.service.phxyy.BasicThirdSysBusApiService; | ||||
| import com.glxp.mipsdl.admin.service.phxyy.BussinessOriginTypeService; | ||||
| import com.glxp.mipsdl.admin.util.HttpClient; | ||||
| import com.glxp.mipsdl.common.res.BaseResponse; | ||||
| import com.glxp.mipsdl.common.util.ResultVOUtils; | ||||
| import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| import javax.annotation.Resource; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| @Service | ||||
| public class ZaxyyClient { | ||||
| 
 | ||||
|     @Resource | ||||
|     private ThirdSysConfig thirdSysConfig; | ||||
|     @Resource | ||||
|     private HttpClient httpClient; | ||||
| 
 | ||||
| 
 | ||||
|     String[] getHeaderArray() { | ||||
|         List<String> headArray = new ArrayList<>(); | ||||
|         headArray.add("Content-Type"); | ||||
|         headArray.add("application/json"); | ||||
|         if (StrUtil.isNotEmpty(thirdSysConfig.getThirdSysConfig().getApikey())) { | ||||
|             headArray.add("api_key"); | ||||
|             headArray.add(thirdSysConfig.getThirdSysConfig().getApikey()); | ||||
|         } | ||||
|         if (StrUtil.isNotEmpty(thirdSysConfig.getThirdSysConfig().getSecretkey())) { | ||||
|             headArray.add("secret_key"); | ||||
|             headArray.add(thirdSysConfig.getThirdSysConfig().getSecretkey()); | ||||
|         } | ||||
|         String[] strArray = new String[headArray.size()]; | ||||
|         headArray.toArray(strArray); | ||||
|         return strArray; | ||||
|     } | ||||
| 
 | ||||
|     @Resource | ||||
|     private BasicThirdSysBusApiService basicThirdSysBusApiService; | ||||
|     @Resource | ||||
|     private BussinessOriginTypeService bussinessOriginTypeService; | ||||
|     @Resource | ||||
|     private BasicThirdSysDetailDao basicThirdSysDetailDao; | ||||
| 
 | ||||
| 
 | ||||
|     public BaseResponse testConnect() { | ||||
|         PhUnitRequest phUnitRequest = new PhUnitRequest(); | ||||
|         phUnitRequest.setPage(1); | ||||
|         phUnitRequest.setLimit(1); | ||||
|         BaseResponse baseResponse = getUnit(phUnitRequest); | ||||
|         if (baseResponse.getCode() == 20000) { | ||||
|             return ResultVOUtils.success("连接成功!"); | ||||
|         } else { | ||||
|             return ResultVOUtils.error(500, "连接失败"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public BaseResponse getUnit(PhUnitRequest unitRequest) { | ||||
|         BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("corpUrl", thirdSysConfig.getThirdSysConfig().getThirdId()); | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), unitRequest, getHeaderArray()); | ||||
|         BaseResponse baseResponse = | ||||
|                 JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                 }); | ||||
|         return baseResponse; | ||||
|     } | ||||
| 
 | ||||
|     public BaseResponse getProducts(PhProductRequest udiwmsProductRequest) { | ||||
|         BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("piQueryUrl", thirdSysConfig.getThirdSysConfig().getThirdId()); | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), udiwmsProductRequest, getHeaderArray()); | ||||
|         BaseResponse baseResponse = | ||||
|                 JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                 }); | ||||
|         return baseResponse; | ||||
|     } | ||||
| 
 | ||||
|     public BaseResponse getOrderTypes(PhBusTypeRequest udiwmsBusTypeRequest) { | ||||
|         BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("busTypeQueryUrl", thirdSysConfig.getThirdSysConfig().getThirdId()); | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), udiwmsBusTypeRequest, getHeaderArray()); | ||||
|         BaseResponse baseResponse = | ||||
|                 JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                 }); | ||||
|         return baseResponse; | ||||
|     } | ||||
| 
 | ||||
|     public BaseResponse getOrders(UdiwmsOrderRequest udiwmsOrderRequest) { | ||||
|         if (StrUtil.isEmpty(udiwmsOrderRequest.getBillType())) { | ||||
|             return ResultVOUtils.error(500, "单据类型不能未空"); | ||||
|         } | ||||
|         if (StrUtil.isEmpty(udiwmsOrderRequest.getThirdSys())) { | ||||
|             return ResultVOUtils.error(500, "第三方系统ID不能为空"); | ||||
|         } | ||||
|         BussinessOriginTypeResponse bussinessOriginTypeResponse = bussinessOriginTypeService.findByKey(udiwmsOrderRequest.getBillType(), thirdSysConfig.getThirdSysConfig().getThirdId()); | ||||
|         udiwmsOrderRequest.setBillType(bussinessOriginTypeResponse.getThirdAction()); | ||||
|         BasicThirdSysBusApiEntity basicThirdSysBusApiEntity = basicThirdSysBusApiService.selectByKey(bussinessOriginTypeResponse.getThirdAction(), bussinessOriginTypeResponse.getThirdSys(), 1); | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysBusApiEntity.getUrl(), udiwmsOrderRequest, getHeaderArray()); | ||||
|         BaseResponse baseResponse = | ||||
|                 JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                 }); | ||||
|         return baseResponse; | ||||
|     } | ||||
| 
 | ||||
|     public BaseResponse submitOrders(ZaxzyyOrderRequest udiwmsOrderRequest) { | ||||
|         if (StrUtil.isEmpty(udiwmsOrderRequest.getBillType())) { | ||||
|             return ResultVOUtils.error(500, "单据类型不能未空"); | ||||
|         } | ||||
|         BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByOrderType("orderSubmitUrl", thirdSysConfig.getThirdSysConfig().getThirdId(), udiwmsOrderRequest.getBillType()); | ||||
| 
 | ||||
| 
 | ||||
|         String interStr = ""; | ||||
|         if (StrUtil.isNotEmpty(basicThirdSysDetailEntity.getOrderTypeUrl())) { | ||||
|             interStr = basicThirdSysDetailEntity.getOrderTypeUrl(); | ||||
| 
 | ||||
|         } else { | ||||
|             interStr = basicThirdSysDetailEntity.getValue(); | ||||
|         } | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + interStr, udiwmsOrderRequest, getHeaderArray()); | ||||
|         try { | ||||
|             BaseResponse baseResponse = | ||||
|                     JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                     }); | ||||
|             return baseResponse; | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
| 
 | ||||
|         return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果"); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public BaseResponse submitPreInOrders(UdiwmsPreInOrderRequest udiwmsPreInOrderRequest) { | ||||
|         BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("preInOrderSubmit", thirdSysConfig.getThirdSysConfig().getThirdId()); | ||||
|         String interStr = ""; | ||||
|         interStr = basicThirdSysDetailEntity.getValue(); | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + interStr, udiwmsPreInOrderRequest, getHeaderArray()); | ||||
|         try { | ||||
|             BaseResponse baseResponse = | ||||
|                     JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                     }); | ||||
|             return baseResponse; | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
| 
 | ||||
|         return ResultVOUtils.error(500, "网络错误,或远程服务器异常无法返回正确结果"); | ||||
|     } | ||||
| 
 | ||||
|     public BaseResponse getInvProducts(UdiwmsOnhandRequest udiwmsOnhandRequest) { | ||||
|         BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("invPiUrl", thirdSysConfig.getThirdSysConfig().getThirdId()); | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), udiwmsOnhandRequest, getHeaderArray()); | ||||
|         BaseResponse baseResponse = | ||||
|                 JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                 }); | ||||
|         return baseResponse; | ||||
|     } | ||||
| 
 | ||||
|     public BaseResponse getWarehouse(PhWarehouseRequest udiwmsWarehouseRequest) { | ||||
|         BasicThirdSysDetailEntity basicThirdSysDetailEntity = basicThirdSysDetailDao.selectByKey("warehouseQueryUrl", thirdSysConfig.getThirdSysConfig().getThirdId()); | ||||
|         String response = httpClient.postJson(thirdSysConfig.getThirdSysConfig().getThirdSysUrl() + basicThirdSysDetailEntity.getValue(), udiwmsWarehouseRequest, getHeaderArray()); | ||||
|         BaseResponse baseResponse = | ||||
|                 JSONObject.parseObject(response, new TypeReference<BaseResponse>() { | ||||
|                 }); | ||||
|         return baseResponse; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,69 @@ | ||||
| package com.glxp.mipsdl.admin.req; | ||||
| 
 | ||||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| @NoArgsConstructor | ||||
| @Data | ||||
| public class UdiwmsPreInOrderRequest { | ||||
| 
 | ||||
| 
 | ||||
|     @JsonProperty("billNo") | ||||
|     private String billNo; | ||||
|     @JsonProperty("billdate") | ||||
|     private String billdate; | ||||
|     @JsonProperty("corpId") | ||||
|     private String corpId; | ||||
|     @JsonProperty("corpName") | ||||
|     private String corpName; | ||||
|     @JsonProperty("locInvCode") | ||||
|     private String locInvCode; | ||||
|     @JsonProperty("locInvName") | ||||
|     private String locInvName; | ||||
|     @JsonProperty("actor") | ||||
|     private String actor; | ||||
|     @JsonProperty("remark") | ||||
|     private String remark; | ||||
|     @JsonProperty("item") | ||||
|     private List<ItemDTO> items; | ||||
| 
 | ||||
|     @NoArgsConstructor | ||||
|     @Data | ||||
|     public static class ItemDTO { | ||||
|         @JsonProperty("code") | ||||
|         private String code; | ||||
|         @JsonProperty("productId") | ||||
|         private String productId; | ||||
|         @JsonProperty("productName") | ||||
|         private String productName; | ||||
|         @JsonProperty("standard") | ||||
|         private String standard; | ||||
|         @JsonProperty("expireDate") | ||||
|         private String expireDate; | ||||
|         @JsonProperty("productDate") | ||||
|         private String productDate; | ||||
|         @JsonProperty("batchNo") | ||||
|         private String batchNo; | ||||
|         @JsonProperty("count") | ||||
|         private Integer count; | ||||
|         @JsonProperty("measname") | ||||
|         private String measname; | ||||
|         @JsonProperty("registerNo") | ||||
|         private String registerNo; | ||||
|         @JsonProperty("price") | ||||
|         private Double price; | ||||
|         @JsonProperty("secSalesInvNo") | ||||
|         private String secSalesInvNo; | ||||
|         @JsonProperty("invoiceDate") | ||||
|         private String invoiceDate; | ||||
|         @JsonProperty("secSalesListNo") | ||||
|         private String secSalesListNo; | ||||
|         @JsonProperty("firstSalesInvNo") | ||||
|         private String firstSalesInvNo; | ||||
|         @JsonProperty("remark") | ||||
|         private String remark; | ||||
|     } | ||||
| } | ||||
					Loading…
					
					
				
		Reference in New Issue