Prechádzať zdrojové kódy

销售订单 强制同步接口保存

liuchaohui 2 rokov pred
rodič
commit
7072a21098

+ 47 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/controller/SySOAndOMController.java

@@ -8,14 +8,21 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.documents.orderData.entity.SyOrderData;
+import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
 import org.jeecg.modules.documents.orderData.entity.SySOAndOM;
+import org.jeecg.modules.documents.orderData.service.ISyOrderDataItemService;
+import org.jeecg.modules.documents.orderData.service.ISyOrderDataService;
 import org.jeecg.modules.documents.orderData.service.ISySOAndOMService;
-import org.jeecg.modules.documents.orderData.service.impl.SySOAndOMServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 
 @Slf4j
 @Api(tags="订单数据同步接口")
@@ -23,7 +30,11 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/orderData/sySOAndOM")
 public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMService> {
     @Autowired
-    private SySOAndOMServiceImpl sySOAndOMService;
+    private ISySOAndOMService sySOAndOMService;
+    @Autowired
+    private ISyOrderDataService syOrderDataService;
+    @Autowired
+    private ISyOrderDataItemService syOrderDataItemService;
 
     @AutoLog(value = "订单数据同步接口-分页列表查询销售订单")
     @ApiOperation(value="订单数据同步接口-分页列表查询销售订单", notes="订单数据同步接口-分页列表查询销售订单")
@@ -41,6 +52,9 @@ public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMSe
                 sySOAndOM.getAccount().equals("903")){
             Page<SySOAndOM> page = new Page<SySOAndOM>(pageNo, pageSize);
             IPage<SySOAndOM> pageList = sySOAndOMService.querySOList(sySOAndOM,page);
+            if(pageList.getRecords().size()==0){
+                return Result.error("没找到对应单据!!!");
+            }
             return Result.OK(pageList);
         }else {
             return Result.error("请选择账套号!!!");
@@ -61,7 +75,38 @@ public class SySOAndOMController extends JeecgController<SySOAndOM, ISySOAndOMSe
         }
         Page<SySOAndOM> page = new Page<SySOAndOM>(pageNo, pageSize);
         IPage<SySOAndOM> pageList = sySOAndOMService.queryOMList(sySOAndOM,page);
+        if(pageList.getRecords().size()==0){
+            return Result.error("没找到对应单据!!!");
+        }
         return Result.OK(pageList);
     }
 
+    @AutoLog(value = "订单数据同步接口-新增")
+    @ApiOperation(value="订单数据同步接口-新增", notes="订单数据同步接口-新增")
+    @RequestMapping(value = "/addSOAndOM")
+    public Result<?> addSOAndOM(List<SySOAndOM> sySOAndOM) {
+        //检查参数
+        if(sySOAndOM==null){
+            return Result.error("请不要保存错误数据!!!");
+        }
+        //判断新增单据是否已入单证
+        Map<String,Object> columnMap = new HashMap<String,Object>();
+        columnMap.put("account",sySOAndOM.get(0).getAccount());
+        columnMap.put("orderNumber",sySOAndOM.get(0).getOrderNumber());
+        List list = syOrderDataService.listByMap(columnMap);
+        if(list.size()>0){
+            return Result.error("同步单据已入单证!!!");
+        }
+        //进入新增 1.查询U8 2.保存
+        SyOrderData syOrderData = sySOAndOMService.queryOrderByCode(sySOAndOM.get(0));
+        syOrderDataService.save(syOrderData);
+        for (SySOAndOM sy:sySOAndOM) {
+            SyOrderDataItem syOrderDataItem = sySOAndOMService.queryOrderItemByCode(sy);
+            syOrderDataItemService.save(syOrderDataItem);
+        }
+        //回写U8
+        sySOAndOMService.updateSO(sySOAndOM.get(0));
+        return Result.OK("同步成功!!!");
+    }
+
 }

+ 11 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/mapper/SySOAndOMMapper.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.documents.orderData.entity.SyOrderData;
+import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
 import org.jeecg.modules.documents.orderData.entity.SySOAndOM;
 
 /**
@@ -19,4 +21,13 @@ public interface SySOAndOMMapper extends BaseMapper<SySOAndOM> {
 
     @DS("multi-three")
     IPage<SySOAndOM> queryOMList(@Param("sy") SySOAndOM sy, Page<SySOAndOM> page);
+
+    @DS("multi-three")
+    SyOrderData queryOrderByCode(@Param("sy") SySOAndOM sy);
+
+    @DS("multi-three")
+    SyOrderDataItem queryOrderItemByCode(@Param("sy") SySOAndOM sy);
+
+    @DS("multi-three")
+    void updateSO(@Param("sy") SySOAndOM sy);
 }

+ 162 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/mapper/xml/SySOAndOMMapper.xml

@@ -41,4 +41,166 @@
         where om.cCode=#{sy.cCode}
     </select>
 
+    <select id="queryOrderByCode" resultType="org.jeecg.modules.documents.orderData.entity.SyOrderData" >
+        <if test="sy.account =='901'">
+            SELECT
+            s.ID AS id,s.cSOCode AS orderNumber,s.dDate AS orderDate,s.cBusType AS businessTypeValue,
+            s.cSTCode AS salesTypeValue,t.cSTName AS salesTypeText,cc.cCusAbbName AS customerAbbreviation,
+            cc.cCusName AS customerName,s.iExchRate AS exchangeRate,de.cDepName AS salesDepartment,
+            pe.cPersonName AS salesman,s.cexch_name AS currencyText,s.cdefine2 AS brandSide,s.cdefine1 AS thirdParty,
+            s.cdefine3 AS customerOrderNumber,s.cdefine11 AS endCustomer,s.cCusCode AS customerCode,
+            s.fbookratio AS depositRatio,s.iMoney AS deposit,s.cMemo AS orderRemarks,
+            s.cDefine14 AS orderChangeDescription,s.cDefine12 AS garmentFactory,v.cVenCode AS garmentFactoryCode,
+            s.cDefine5 AS garmentNmb,s.cMemo AS memo,f.chdefine4 AS priceRemarks,f.chdefine1 AS collaborativeRoute,
+            y.cexch_code AS currencyValue,p.cPayName AS termOfPayment,'901' AS account
+            FROM
+            UFDATA_901_2021.dbo.SO_SOMain s
+            LEFT JOIN UFDATA_901_2021.dbo.SO_SOMain_extradefine f ON s.ID = f.ID
+            LEFT JOIN UFDATA_901_2021.dbo.SaleType t ON s.cSTCode = t.cSTCode
+            LEFT JOIN UFDATA_901_2021.dbo.foreigncurrency y ON s.cexch_name = y.cexch_name
+            LEFT JOIN UFDATA_901_2021.dbo.PayCondition p ON s.cPayCode = p.cPayCode
+            LEFT JOIN UFDATA_901_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+            LEFT JOIN UFDATA_901_2021.dbo.Customer cc ON s.cCusCode = cc.cCusCode
+            LEFT JOIN UFDATA_901_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+            LEFT JOIN UFDATA_901_2021.dbo.Vendor v ON s.cDefine12 = v.cVenName
+            WHERE
+            s.iStatus = 1
+            AND s.cSOCode = #{sy.orderNumber}
+        </if>
+        <if test="sy.account =='902'">
+            SELECT
+            s.ID AS id,s.cSOCode AS orderNumber,s.dDate AS orderDate,s.cBusType AS businessTypeValue,
+            s.cSTCode AS salesTypeValue,t.cSTName AS salesTypeText,cc.cCusAbbName AS customerAbbreviation,
+            cc.cCusName AS customerName,s.iExchRate AS exchangeRate,de.cDepName AS salesDepartment,
+            pe.cPersonName AS salesman,s.cexch_name AS currencyText,s.cdefine2 AS brandSide,s.cdefine1 AS thirdParty,
+            s.cdefine3 AS customerOrderNumber,s.cdefine11 AS endCustomer,s.cCusCode AS customerCode,
+            s.fbookratio AS depositRatio,s.iMoney AS deposit,s.cMemo AS orderRemarks,
+            s.cDefine14 AS orderChangeDescription,s.cDefine12 AS garmentFactory,v.cVenCode AS garmentFactoryCode,
+            s.cDefine5 AS garmentNmb,s.cMemo AS memo,f.chdefine4 AS priceRemarks,f.chdefine1 AS collaborativeRoute,
+            y.cexch_code AS currencyValue,p.cPayName AS termOfPayment,'902' AS account
+            FROM
+            UFDATA_902_2021.dbo.SO_SOMain s
+            LEFT JOIN UFDATA_902_2021.dbo.SO_SOMain_extradefine f ON s.ID = f.ID
+            LEFT JOIN UFDATA_902_2021.dbo.SaleType t ON s.cSTCode = t.cSTCode
+            LEFT JOIN UFDATA_902_2021.dbo.foreigncurrency y ON s.cexch_name = y.cexch_name
+            LEFT JOIN UFDATA_902_2021.dbo.PayCondition p ON s.cPayCode = p.cPayCode
+            LEFT JOIN UFDATA_902_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+            LEFT JOIN UFDATA_902_2021.dbo.Customer cc ON s.cCusCode = cc.cCusCode
+            LEFT JOIN UFDATA_902_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+            LEFT JOIN UFDATA_902_2021.dbo.Vendor v ON s.cDefine12 = v.cVenName
+            WHERE
+            s.iStatus = 1
+            AND s.cSOCode = #{sy.orderNumber}
+        </if>
+        <if test="sy.account =='903'">
+            SELECT
+            s.ID AS id,s.cSOCode AS orderNumber,s.dDate AS orderDate,s.cBusType AS businessTypeValue,
+            s.cSTCode AS salesTypeValue,t.cSTName AS salesTypeText,cc.cCusAbbName AS customerAbbreviation,
+            cc.cCusName AS customerName,s.iExchRate AS exchangeRate,de.cDepName AS salesDepartment,
+            pe.cPersonName AS salesman,s.cexch_name AS currencyText,s.cdefine2 AS brandSide,s.cdefine1 AS thirdParty,
+            s.cdefine3 AS customerOrderNumber,s.cdefine11 AS endCustomer,s.cCusCode AS customerCode,
+            s.fbookratio AS depositRatio,s.iMoney AS deposit,s.cMemo AS orderRemarks,
+            s.cDefine14 AS orderChangeDescription,s.cDefine12 AS garmentFactory,v.cVenCode AS garmentFactoryCode,
+            s.cDefine5 AS garmentNmb,s.cMemo AS memo,f.chdefine4 AS priceRemarks,f.chdefine1 AS collaborativeRoute,
+            y.cexch_code AS currencyValue,p.cPayName AS termOfPayment,'903' AS account
+            FROM
+            UFDATA_903_2021.dbo.SO_SOMain s
+            LEFT JOIN UFDATA_903_2021.dbo.SO_SOMain_extradefine f ON s.ID = f.ID
+            LEFT JOIN UFDATA_903_2021.dbo.SaleType t ON s.cSTCode = t.cSTCode
+            LEFT JOIN UFDATA_903_2021.dbo.foreigncurrency y ON s.cexch_name = y.cexch_name
+            LEFT JOIN UFDATA_903_2021.dbo.PayCondition p ON s.cPayCode = p.cPayCode
+            LEFT JOIN UFDATA_903_2021.dbo.Department de ON s.cDepCode = de.cDepCode
+            LEFT JOIN UFDATA_903_2021.dbo.Customer cc ON s.cCusCode = cc.cCusCode
+            LEFT JOIN UFDATA_903_2021.dbo.Person pe ON s.cPersonCode = pe.cPersonCode
+            LEFT JOIN UFDATA_903_2021.dbo.Vendor v ON s.cDefine12 = v.cVenName
+            WHERE
+            s.iStatus = 1
+            AND s.cSOCode = #{sy.orderNumber}
+        </if>
+    </select>
+
+    <select id="queryOrderItemByCode" resultType="org.jeecg.modules.documents.orderData.entity.SyOrderDataItem" >
+        <if test="sy.account =='901'">
+            SELECT
+            s.AutoID AS id,s.ID AS syOrderDataId,s.cDefine22 AS itemNumber,s.dPreDate AS preDeliveryDate,
+            s.dPreMoDate AS preCompletionDate,s.cDefine32 AS packId,s.cDefine28 AS smallPo,
+            s.cDefine29 AS distributionPoint,s.cInvCode AS inventoryCode,c.cInvCcode AS inventoryCcode,
+            c.cInvName AS inventoryName,s.cFree1 AS colour,s.cFree2 AS size,s.cFree3 AS codingRules,
+            s.cFree4 AS guangpeiGateWidth,s.cFree6 AS weight,s.cDefine35 AS boxNumber,
+            s.iQuantity AS quantity,s.iQuantity AS surplusNum,s.iTaxUnitPrice AS unitPriceIncludingTax,
+            s.iSum AS totalPriceAndTax,s.iTaxRate AS taxRate,s.cMemo AS remarks,
+            d.cComUnitName AS masterMetering,c.cInvStd AS specificationAndModel,
+            CASE
+            WHEN c.cInvDefine14 IS NULL THEN 1 ELSE cInvDefine14 END
+            AS numberOfSets,
+            s.cSCloser AS bankClosedBy,be.cbdefine2 AS ymoney
+            FROM
+            UFDATA_901_2021.dbo.SO_SODetails s
+            JOIN UFDATA_901_2021.dbo.SO_SOMain sm on sm.id=s.id
+            LEFT JOIN UFDATA_901_2021.dbo.Inventory c ON c.cInvCode= s.cInvCode
+            LEFT JOIN UFDATA_901_2021.dbo.ComputationUnit d ON d.cComunitCode= c.cComUnitCode
+            LEFT JOIN UFDATA_901_2021.dbo.SO_SODetails_extradefine be ON be.iSOsID= s.iSOsID
+            WHERE
+            sm.csocode=#{sy.orderNumber} and sd.iRowNo=#{sy.iRowNo}
+        </if>
+        <if test="sy.account =='902'">
+            SELECT
+            s.AutoID AS id,s.ID AS syOrderDataId,s.cDefine22 AS itemNumber,s.dPreDate AS preDeliveryDate,
+            s.dPreMoDate AS preCompletionDate,s.cDefine32 AS packId,s.cDefine28 AS smallPo,
+            s.cDefine29 AS distributionPoint,s.cInvCode AS inventoryCode,c.cInvCcode AS inventoryCcode,
+            c.cInvName AS inventoryName,s.cFree1 AS colour,s.cFree2 AS size,s.cFree3 AS codingRules,
+            s.cFree4 AS guangpeiGateWidth,s.cFree6 AS weight,s.cDefine35 AS boxNumber,
+            s.iQuantity AS quantity,s.iQuantity AS surplusNum,s.iTaxUnitPrice AS unitPriceIncludingTax,
+            s.iSum AS totalPriceAndTax,s.iTaxRate AS taxRate,s.cMemo AS remarks,
+            d.cComUnitName AS masterMetering,c.cInvStd AS specificationAndModel,
+            CASE
+            WHEN c.cInvDefine14 IS NULL THEN 1 ELSE cInvDefine14 END
+            AS numberOfSets,
+            s.cSCloser AS bankClosedBy,be.cbdefine2 AS ymoney
+            FROM
+            UFDATA_902_2021.dbo.SO_SODetails s
+            JOIN UFDATA_902_2021.dbo.SO_SOMain sm on sm.id=s.id
+            LEFT JOIN UFDATA_902_2021.dbo.Inventory c ON c.cInvCode= s.cInvCode
+            LEFT JOIN UFDATA_902_2021.dbo.ComputationUnit d ON d.cComunitCode= c.cComUnitCode
+            LEFT JOIN UFDATA_902_2021.dbo.SO_SODetails_extradefine be ON be.iSOsID= s.iSOsID
+            WHERE
+            sm.csocode=#{sy.orderNumber} and sd.iRowNo=#{sy.iRowNo}
+        </if>
+        <if test="sy.account =='903'">
+            SELECT
+            s.AutoID AS id,s.ID AS syOrderDataId,s.cDefine22 AS itemNumber,s.dPreDate AS preDeliveryDate,
+            s.dPreMoDate AS preCompletionDate,s.cDefine32 AS packId,s.cDefine28 AS smallPo,
+            s.cDefine29 AS distributionPoint,s.cInvCode AS inventoryCode,c.cInvCcode AS inventoryCcode,
+            c.cInvName AS inventoryName,s.cFree1 AS colour,s.cFree2 AS size,s.cFree3 AS codingRules,
+            s.cFree4 AS guangpeiGateWidth,s.cFree6 AS weight,s.cDefine35 AS boxNumber,
+            s.iQuantity AS quantity,s.iQuantity AS surplusNum,s.iTaxUnitPrice AS unitPriceIncludingTax,
+            s.iSum AS totalPriceAndTax,s.iTaxRate AS taxRate,s.cMemo AS remarks,
+            d.cComUnitName AS masterMetering,c.cInvStd AS specificationAndModel,
+            CASE
+            WHEN c.cInvDefine14 IS NULL THEN 1 ELSE cInvDefine14 END
+            AS numberOfSets,
+            s.cSCloser AS bankClosedBy,be.cbdefine2 AS ymoney
+            FROM
+            UFDATA_903_2021.dbo.SO_SODetails s
+            JOIN UFDATA_903_2021.dbo.SO_SOMain sm on sm.id=s.id
+            LEFT JOIN UFDATA_903_2021.dbo.Inventory c ON c.cInvCode= s.cInvCode
+            LEFT JOIN UFDATA_903_2021.dbo.ComputationUnit d ON d.cComunitCode= c.cComUnitCode
+            LEFT JOIN UFDATA_903_2021.dbo.SO_SODetails_extradefine be ON be.iSOsID= s.iSOsID
+            WHERE
+            sm.csocode=#{sy.orderNumber} and sd.iRowNo=#{sy.iRowNo}
+        </if>
+    </select>
+
+    <update id="updateSO" >
+        <if test="sy.account =='901'">
+            UPDATE UFDATA_901_2021.dbo.SO_SOMain SET cdefine15 = '0' WHERE cSOCode = #{sy.orderNumber}
+        </if>
+        <if test="sy.account =='902'">
+            UPDATE UFDATA_902_2021.dbo.SO_SOMain SET cdefine15 = '0' WHERE cSOCode = #{sy.orderNumber}
+        </if>
+        <if test="sy.account =='903'">
+            UPDATE UFDATA_903_2021.dbo.SO_SOMain SET cdefine15 = '0' WHERE cSOCode = #{sy.orderNumber}
+        </if>
+    </update>
+
 </mapper>

+ 8 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/service/ISySOAndOMService.java

@@ -3,10 +3,18 @@ package org.jeecg.modules.documents.orderData.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.documents.orderData.entity.SyOrderData;
+import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
 import org.jeecg.modules.documents.orderData.entity.SySOAndOM;
 
 public interface ISySOAndOMService extends IService<SySOAndOM> {
     IPage<SySOAndOM> querySOList(SySOAndOM sy, Page<SySOAndOM> page);
 
     IPage<SySOAndOM> queryOMList(SySOAndOM sy, Page<SySOAndOM> page);
+
+    SyOrderData queryOrderByCode(SySOAndOM sy);
+
+    SyOrderDataItem queryOrderItemByCode(SySOAndOM sy);
+
+    void updateSO(SySOAndOM sy);
 }

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/orderData/service/impl/SySOAndOMServiceImpl.java

@@ -53,4 +53,19 @@ public class SySOAndOMServiceImpl extends ServiceImpl<SySOAndOMMapper, SySOAndOM
     public IPage<SySOAndOM> queryOMList(SySOAndOM sy, Page<SySOAndOM> page) {
         return sySOAndOMMapper.queryOMList(sy, page);
     }
+
+    @Override
+    public SyOrderData queryOrderByCode(SySOAndOM sy) {
+        return sySOAndOMMapper.queryOrderByCode(sy);
+    }
+
+    @Override
+    public SyOrderDataItem queryOrderItemByCode(SySOAndOM sy) {
+        return sySOAndOMMapper.queryOrderItemByCode(sy);
+    }
+
+    @Override
+    public void updateSO(SySOAndOM sy) {
+        sySOAndOMMapper.updateSO(sy);
+    }
 }