Browse Source

【越加红】【销售月数据统计接口调整】

samhoo 3 years ago
parent
commit
b8a264c517
1 changed files with 44 additions and 4 deletions
  1. 44 4
      src/main/java/com/uas/eis/task/SaleMonthDataTask.java

+ 44 - 4
src/main/java/com/uas/eis/task/SaleMonthDataTask.java

@@ -1,6 +1,8 @@
 package com.uas.eis.task;
 
+import com.uas.eis.beans.result.BaseResult;
 import com.uas.eis.beans.result.CrmAddResult;
+import com.uas.eis.beans.result.Product;
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.dao.SqlRowList;
 import com.uas.eis.manager.CommonManager;
@@ -33,12 +35,15 @@ public class SaleMonthDataTask {
     @Resource(name = "configuration")
     private Configuration configuration;
 
-    //每月1日凌晨10分执行
-    @Scheduled(cron = "0 10 0 1 * ?")
-    public void syncProducts() {
-        SqlRowList rs = baseDao.queryForRowSet("select * from (select * from saleMonthData left join customer on SM_CUSTCODE=CU_CODE where nvl(cu_fxxkid,' ')<>' ' and nvl(SM_SENDSTATUS,' ')='待上传' order by sm_id) where rownum<=200");
+    //每天0时每10分执行一次
+    @Scheduled(cron = "0 0/10 0 * * ?")
+    public void syncSaleMonthData() {
+        SqlRowList rs = baseDao.queryForRowSet("select * from (select * from saleMonthData left join customer on SM_CUSTCODE=CU_CODE left join employee on em_code=cu_sellercode where nvl(cu_fxxkid,' ')<>' ' and nvl(SM_SENDSTATUS,' ')='待上传' order by sm_id) where rownum<=500");
         String openUserId = configuration.getOpenUserId();
         while (rs.next()){
+            if(!"".equals(rs.getGeneralString("em_fxxkid"))){
+                openUserId=rs.getGeneralString("em_fxxkid");
+            }
             Map<String,Object> data = new HashMap<>();
             Map<String,Object> map = new HashMap<>();
             List<String> owner = new ArrayList<>();
@@ -82,6 +87,41 @@ public class SaleMonthDataTask {
         }
     }
 
+    @Scheduled(cron = "0 0 1 * * ?")
+    public void syncUpdateSaleMonthData() {
+        SqlRowList rs = baseDao.queryForRowSet("select * from saleMonthData left join customer on SM_CUSTCODE=CU_CODE where nvl(cu_fxxkid,' ')<>' ' and nvl(SM_ISUPDATE,0)=-1 and (SM_YEARMONTH=case when to_char(sysdate,'dd')='01' then to_char(add_months(sysdate,-1),'yyyymm') else to_char(add_months(sysdate,0),'yyyymm') end) order by sm_id");
+        //SqlRowList rs = baseDao.queryForRowSet("select * from saleMonthData left join customer on SM_CUSTCODE=CU_CODE where nvl(cu_fxxkid,' ')<>' ' and nvl(SM_ISUPDATE,0)=-1 and (SM_YEARMONTH=case when to_char(to_date('20220501','yyyymmdd'),'dd')='01' then to_char(add_months(to_date('20220501','yyyymmdd'),-1),'yyyymm') else to_char(add_months(to_date('20220501','yyyymmdd'),0),'yyyymm') end) order by sm_id");
+        //SqlRowList rs = baseDao.queryForRowSet("select * from saleMonthData left join customer on SM_CUSTCODE=CU_CODE where nvl(cu_fxxkid,' ')<>' ' and sm_id=654 order by sm_id");
+        while (rs.next()) {
+            Map<String, Object> data = new HashMap<>();
+            Map<String, Object> map = new HashMap<>();
+            map.put("field_6secE__c", rs.getGeneralDouble("sm_salesum"));//接单金额
+            map.put("field_C71qd__c", rs.getGeneralDouble("sm_saleoutsum"));//出货金额
+            map.put("field_m2ypV__c", rs.getGeneralDouble("sm_paysum"));//应收货款
+            map.put("_id", rs.getGeneralString("sm_fxxkdataid"));//应收货款
+            map.put("dataObjectApiName", "object_8r53c__c");
+            data.put("object_data", map);
+            try {
+                BaseResult baseResult = commonManager.updateCommonOfCustom(data);
+                int errorCode = baseResult.getErrorCode();
+                if (errorCode == 0) {
+                    baseDao.execute("update saleMonthData set SM_UPDATESTATUS='已更新',SM_UPDATEDATE=sysdate where sm_id=" + rs.getInt("sm_id"));
+                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'销售月数据统计更新成功','销售月数据统计更新','" + rs.getGeneralString("sm_yearmonth") + rs.getString("sm_custcode") + "')");
+                } else {
+                    baseDao.execute("update saleMonthData set SM_UPDATESTATUS='更新失败' where sm_id=" + rs.getInt("sm_id"));
+                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'" + baseResult.getErrorMessage() + "','销售月数据统计更新','" + rs.getGeneralString("sm_yearmonth") + rs.getString("sm_custcode") + "')");
+                    logger.info("异常信息:" + baseResult.getErrorMessage());
+                }
+            } catch (Exception e) {
+                baseDao.execute("update saleMonthData set SM_SENDSTATUS='更新失败' where sm_id=" + rs.getInt("sm_id"));
+                baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'" + e.getMessage() + "','销售月数据统计更新','" + rs.getGeneralString("sm_yearmonth") + rs.getString("sm_custcode") + "')");
+                logger.info("异常信息:" + e.getMessage());
+                e.printStackTrace();
+            }
+
+        }
+    }
+
     private String getValueField(String MODULEAPINAME, String APINAME, String DISPLAYFIELD){
         String result ="";
         if(DISPLAYFIELD !=null && !"".equals(DISPLAYFIELD)){