|
@@ -0,0 +1,89 @@
|
|
|
|
|
+package com.dk.mnls_mp.service.mnls;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.dk.mnls_mp.infrastructure.base.ResponseCodeEnum;
|
|
|
|
|
+import com.dk.mnls_mp.infrastructure.util.HttpHelper;
|
|
|
|
|
+import com.dk.mnls_mp.infrastructure.util.XmlUtil;
|
|
|
|
|
+import com.dk.mnls_mp.mapper.basic.CustomerMapper;
|
|
|
|
|
+import com.dk.mnls_mp.mapper.basic.WCFinfoMapper;
|
|
|
|
|
+import com.dk.mnls_mp.model.command.PurchaseOrderCreateCommand;
|
|
|
|
|
+import com.dk.mnls_mp.model.dto.IBOSSDTO;
|
|
|
|
|
+import com.dk.mnls_mp.model.pojo.basic.Customer;
|
|
|
|
|
+import com.dk.mnls_mp.model.pojo.basic.WCFinfo;
|
|
|
|
|
+import com.dongke.base.exceptionHandler.BaseBusinessException;
|
|
|
|
|
+import com.dongke.base.exceptionHandler.ResponseResultUtil;
|
|
|
|
|
+import com.dongke.base.exceptionHandler.ResponseResultVO;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @desc : 订单接口业务类
|
|
|
|
|
+ * @author : 张潇木
|
|
|
|
|
+ * @date : 2022/10/9 14:22
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Service
|
|
|
|
|
+@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+public class IBOSSOrderService{
|
|
|
|
|
+
|
|
|
|
|
+ private static final String WEBSERVICE_INTERFACE_POSTFIX = "/WebService/DKIWebServiceInterfaceDocking.asmx/";
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CustomerMapper customerMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WCFinfoMapper wcFinfoMapper;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @desc : 新建采购订单
|
|
|
|
|
+ * @author : 张潇木
|
|
|
|
|
+ * @date : 2022/10/10 10:44
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResponseResultVO createPurchaseOrder(PurchaseOrderCreateCommand command) {
|
|
|
|
|
+ //根据经销商编码查询经销商信息
|
|
|
|
|
+ Customer customer = customerMapper.selectByCode(command.getDealerCode());
|
|
|
|
|
+ if(customer!=null){
|
|
|
|
|
+ //调用iBOSS接口参数accountCode/userCode 赋值
|
|
|
|
|
+ command.setAccountCode(customer.getDongkeaccountcode()).setUserCode(customer.getUniqueCode());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return ResponseResultUtil.error(ResponseCodeEnum.CUSTOMER_CODE_NOT_EXIST.getCode(),ResponseCodeEnum.CUSTOMER_CODE_NOT_EXIST.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ //查询客户webservice信息
|
|
|
|
|
+ WCFinfo wcFinfo = wcFinfoMapper.selectById(customer.getWcfid());
|
|
|
|
|
+ if (wcFinfo == null) {
|
|
|
|
|
+ throw new BaseBusinessException(666,"没有找到此客户的webService信息,客户信息=>"+customer);
|
|
|
|
|
+ }
|
|
|
|
|
+ //拼接url 区别于恒洁中台 直接调用iBOSS的webservice接口
|
|
|
|
|
+ String url = "http://"+wcFinfo.getWcfip() + ":" + wcFinfo.getWcfport() + WEBSERVICE_INTERFACE_POSTFIX +"DK_SaveProcurementOrder_MP";
|
|
|
|
|
+
|
|
|
|
|
+ log.info("=*=*=*=*=*=*=*=*=" + "参数:" + JSON.toJSONString(command) + "=*=*=*=*=*=*=*=*=");
|
|
|
|
|
+ //调用接口
|
|
|
|
|
+ ResponseResultVO resultVO = HttpHelper.callIBOSSWebservice(url, command,null);
|
|
|
|
|
+
|
|
|
|
|
+ //成功后插入数据
|
|
|
|
|
+ if (ResponseCodeEnum.SUCCESS.getCode()==resultVO.getCode()) {
|
|
|
|
|
+ //XML转map
|
|
|
|
|
+ Map<String, Object> resJson = XmlUtil.xmlToJson(resultVO.getData().toString());
|
|
|
|
|
+ //map转DTO
|
|
|
|
|
+ IBOSSDTO IBOSSDTO = JSON.parseObject(resJson.get("string").toString(), IBOSSDTO.class);
|
|
|
|
|
+ if(0==IBOSSDTO.getStatus()){
|
|
|
|
|
+ log.info("新建采购订单成功,单号=>{}",command.getOrderNo());
|
|
|
|
|
+ return ResponseResultUtil.success(200,"新建采购订单成功,单号=>"+command.getOrderNo());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ log.info("新建采购订单失败,iBOSS接口状态码不等于0,单号=>{},接口返回值=>{}",command.getOrderNo(),IBOSSDTO);
|
|
|
|
|
+ return ResponseResultUtil.error(666,"新建采购订单失败,iBOSS接口状态码不等于0,单号=>"+command.getOrderNo());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("新建采购订单失败,http状态码不等于200,单号=>{},接口返回值=>{}",command.getOrderNo(),resultVO);
|
|
|
|
|
+ return ResponseResultUtil.error(666,"新建采购订单失败,http状态码不等于200,单号=>"+command.getOrderNo());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("新建采购订单异常,单号=>{},异常信息=>{}"+command.getOrderNo(), e);
|
|
|
|
|
+ return ResponseResultUtil.error(666,"新建采购订单异常,单号=>"+command.getOrderNo());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|