Explorar el Código

科翔图片文件同步

zhouy hace 3 años
padre
commit
3e32aeb14f

+ 17 - 0
src/main/java/com/uas/eis/service/ToolService.java

@@ -0,0 +1,17 @@
+package com.uas.eis.service;
+
+/**
+ * @author: zhouy
+ * @date: 2021/11/26 11:21
+ * @desc: 畅想工具导出
+ */
+public interface ToolService {
+    /**
+     * 产品资料
+     * */
+    void getProdPic();
+    /**
+     * 客户产品资料
+     * */
+    void getCustProdPic();
+}

+ 62 - 0
src/main/java/com/uas/eis/serviceImpl/Test.java

@@ -0,0 +1,62 @@
+package com.uas.eis.serviceImpl;
+
+import java.io.*;
+
+/**
+ * @author: zhouy
+ * @date: 2021/11/26 16:10
+ * @desc:
+ */
+public class Test {
+    public static void main(String[] args) throws Exception {
+        InputStream is=new FileInputStream("C:\\Picture\\a.txt");
+        InputStreamReader isr = new InputStreamReader(is);
+        BufferedReader br = new BufferedReader(isr);
+        String str = null;
+        StringBuilder sb = new StringBuilder();
+        while ((str = br.readLine()) != null) {
+            System.out.println(str);
+            sb.append(str);
+        }
+        saveToImgFile(sb.toString().toUpperCase(),"C:\\Picture\\p7.jpg");
+     /*  DataOutputStream sos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("C:\\\\Picture\\\\p5.jpg")));
+       InputStream in  = new FileInputStream("C:\\Picture\\a.txt");
+        int len = 0;
+        byte[] b = new byte[1024];
+
+        while ((len = in.read(b)) != -1) {
+            System.out.println("write");
+            sos.write(b,0,len);
+
+        }
+
+        sos.close();
+
+        in.close();*/
+
+    }
+    public static void saveToImgFile(String src,String output){
+        if(src==null||src.length()==0){
+            return;
+        }
+        try{
+            FileOutputStream out = new FileOutputStream(new File(output));
+            byte[] bytes = src.getBytes();
+            for(int i=0;i<bytes.length;i+=2){
+                out.write(charToInt(bytes[i])*16+charToInt(bytes[i+1]));
+            }
+            out.close();
+        }catch(Exception e){
+            e.printStackTrace();
+        }
+    }
+    private static int charToInt(byte ch){
+        int val = 0;
+        if(ch>=0x30&&ch<=0x39){
+            val=ch-0x30;
+        }else if(ch>=0x41&&ch<=0x46){
+            val=ch-0x41+10;
+        }
+        return val;
+    }
+}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 25 - 0
src/main/java/com/uas/eis/serviceImpl/ToolServiceImpl.java


+ 0 - 168
src/main/java/com/uas/eis/task/CustomerTask.java

@@ -1,168 +0,0 @@
-package com.uas.eis.task;
-
-import com.uas.eis.beans.result.BaseResult;
-import com.uas.eis.beans.result.CrmQueryResult;
-import com.uas.eis.beans.result.Customer;
-import com.uas.eis.dao.BaseDao;
-import com.uas.eis.dao.SqlRowList;
-import com.uas.eis.manager.CustomerManager;
-import com.uas.eis.utils.Constant;
-import com.uas.eis.utils.DateUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-@Component
-@EnableAsync
-@EnableScheduling
-public class CustomerTask {
-
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    @Autowired
-    private BaseDao baseDao;
-    @Autowired
-    private CustomerManager customerManager;
-
-    @Scheduled(cron = "0 0/15 * * * ?")
-    public void syncCustomers() {
-        try {
-            List<String> field_values = new ArrayList<>();
-            SqlRowList rs = baseDao.queryForRowSet("select ml_syncTime from (select * from FXXKDockingErrorlog where nvl(ML_TYPE,' ')='客户资料下载' and ML_SYNCTIME is not null order by ml_date desc) where rownum=1");
-            if(rs.next()){
-                String ml_syncTime = rs.getGeneralString("ml_syncTime");
-                field_values.add(ml_syncTime);
-                CrmQueryResult crmQueryResult = customerManager.queryCustomer(field_values);
-                int errorCode = crmQueryResult.getErrorCode();
-                if(errorCode == 0){
-                    Map<String, Object> data = crmQueryResult.getData();
-                    List<Map<String, Object>> dataList = (List<Map<String,Object>>) data.get("dataList");
-                    //m:成功条数 n:失败条数
-                    int m=0,n=0;
-                    if(dataList.size()>0){
-                        //最后(即最近)一次同步时间
-                        Long create_time_Last = Long.parseLong(new BigDecimal(dataList.get(dataList.size()-1).get("create_time").toString()).toPlainString());
-                        for (int i = 0; i < dataList.size(); i++) {
-                            Object _id = dataList.get(i).get("_id");
-                            Object name = dataList.get(i).get("name");
-                            SimpleDateFormat sdf = new SimpleDateFormat(Constant.YMD_HMS);
-                            if(baseDao.checkIf("PreCustomer", "cu_name='" + name + "'")){
-                                baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'客户名称已存在','客户资料下载','"+name+"')");
-                                logger.info("异常信息:客户名称已存在");
-                                n++;
-                                continue;
-                            }
-                            try {
-                                Object em_code = baseDao.getFieldDataByCondition("employee", "max(em_code) em_code", "em_name='" + dataList.get(i).get("field_w9e4q__c") + "'");
-                                Object cu_sellercode = baseDao.getFieldDataByCondition("employee", "max(em_code) em_code", "em_name='" + dataList.get(i).get("relevant_team__r") + "'");
-                                Long create_time = Long.parseLong(new BigDecimal(dataList.get(i).get("create_time").toString()).toPlainString());
-                                Long last_modified_time = Long.parseLong(new BigDecimal(dataList.get(i).get("last_modified_time").toString()).toPlainString());
-                                String cuKind = getDisplayField(dataList, i, "account_type", "客户类型");
-                                String wbsk_user = getDisplayField(dataList, i, "UDSSel1__c", "收款方式");//外部收款方式
-                                Object[] pa_data = baseDao.getFieldsDataByCondition("Payments", new String[]{"pa_id","pa_code"}, "nvl(pa_class,' ')='收款方式' and pa_name='" + wbsk_user + "'");//获取收款方式编号
-                                String paID = (pa_data == null || pa_data[0] == null) ? "" : pa_data[0].toString();
-                                String paCode = (pa_data == null || pa_data[1] == null) ? "" : pa_data[1].toString();
-                                String cu_level = getDisplayField(dataList, i, "account_level", "客户级别");
-                                String cu_turnSAP = getDisplayField(dataList, i, "field_RYzRf__c", "是否转正式客户在SAP内建档");
-                                String cu_currency = getDisplayField(dataList, i, "field_e2HeP__c", "货币");
-                                String cu_recordType = getDisplayField(dataList, i, "record_type", "业务类型");
-                                String cu_industry = getDisplayField(dataList, i, "field_00Ijp__c", "所属行业");
-                                String cu_code = baseDao.sGetMaxNumber("PreCustomer", 2);
-                                //field_giBJk__c:收货人 UDSText5__c:送货地址 UDSText1__c:法定代表人 UDSText2__c:注册资金
-                                String sql="insert into PreCustomer(cu_id,cu_code,cu_name,cu_shortname,cu_add2,cu_sellercode,cu_sellername,cu_servicecode,cu_servicename,cu_kind," +
-                                        "cu_contact,cu_add1,cu_lawman,cu_regamount,cu_rate,cu_wbsk_user,cu_paymentid,cu_paymentscode,cu_payments,cu_level,cu_industry,cu_mainbusiness,cu_turnSAP,cu_currency,cu_taxrate," +
-                                        "cu_dealstatus,cu_Shipmentamount,cu_receivable,cu_businessRegister,cu_recordType," +
-                                        "cu_mobile,cu_email,cu_recordman,cu_recorddate,cu_lastdate,cu_auditstatus,cu_auditstatuscode,cu_remark,CU_FXXKID)" +
-                                        "values(PRECUSTOMER_SEQ.nextval,'"+cu_code+"','"+name+"','"+dataList.get(i).get("UDSText3__c")+"','"+ dataList.get(i).get("address")+"'," +
-                                        "'"+(cu_sellercode==null?"":cu_sellercode)+"','"+getNotNull(dataList,i,"relevant_team__r")+"','"+em_code+"','"+dataList.get(i).get("field_w9e4q__c")+"','"+cuKind+"'," +
-                                        "'"+getNotNull(dataList,i,"field_giBJk__c")+"','"+getNotNull(dataList,i,"UDSText5__c")+"'," +
-                                        "'"+getNotNull(dataList,i,"UDSText1__c")+"','"+getNotNull(dataList,i,"UDSText2__c")+"','" +
-                                        getNotNull(dataList,i,"field_1l3xo__c")+"','"+wbsk_user+"','"+paID+"','"+paCode+"','"+wbsk_user+"','"+cu_level+"','"+cu_industry+"'," +
-                                        "'"+getNotNull(dataList,i,"UDSText4__c")+"','"+cu_turnSAP+"','"+cu_currency+"',13,'"+getNotNull(dataList,i,"deal_status")+"'," +
-                                        "'"+getNotNull(dataList,i,"field_Ezg0w__c")+"','"+getNotNull(dataList,i,"field_59oLF__c")+"','"+getNotNull(dataList,i,"biz_reg_name")+"','"+cu_recordType+"',"+
-                                        "'"+dataList.get(i).get("tel")+"','"+dataList.get(i).get("email")+"'," +
-                                        "'CRM',"+DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(create_time)))+"," +
-                                        DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(last_modified_time)))+",'已审核','AUDITED','"+getNotNull(dataList,i,"remark")+"','"+_id+"')";
-                                baseDao.execute(sql);
-                                m++;
-                            }catch (Exception e){
-                                baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','客户资料下载','"+name+"')");
-                                logger.info("异常信息:"+e);
-                                n++;
-                            }
-                        }
-                        baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_syncTime) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'下载记录"+dataList.size()+"条,成功"+m+"条,失败"+n+"条','客户资料下载','"+create_time_Last+"')");
-                    }
-                }else{
-                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','客户资料下载','')");
-                    logger.info("异常信息:"+crmQueryResult.getErrorMessage());
-                }
-            }
-        }catch (Exception e){
-            baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+e.getMessage()+"','客户资料下载','')");
-            logger.info("异常信息:"+e.getMessage());
-            e.printStackTrace();
-        }
-    }
-
-    @Scheduled(cron = "0 0 23 * * ?")
-    public void syncUpdateCustomers() {
-        SqlRowList rs = baseDao.queryForRowSet("select * from (select distinct cui_code from customerUpdInfo where trunc(cui_date)=trunc(sysdate)) left join precustomer on cui_code=cu_code where nvl(cu_name,' ')<>' ' order by cu_id");
-        while (rs.next()){
-            try {
-                Customer customer = new Customer();
-                String valueField = getValueField("客户资料", "客户级别", rs.getGeneralString("cu_level"));
-                customer.setDataObjectApiName("AccountObj");
-                customer.set_id(rs.getGeneralString("cu_fxxkid"));
-                customer.setName(rs.getGeneralString("cu_name"));
-                customer.setAccount_level(valueField);
-                customer.setField_w9e4q__c(rs.getGeneralString("cu_servicename"));
-                BaseResult baseResult = customerManager.updateCustomer(customer);
-                int errorCode = baseResult.getErrorCode();
-                if(errorCode == 0){
-                    baseDao.execute("update customerUpdInfo set cui_updatestatus='已更新',cui_updatedate=sysdate where cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
-                }else{
-                    baseDao.execute("update customerUpdInfo set cui_error='"+baseResult.getErrorMessage()+"' where cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
-                    logger.info("异常信息:"+baseResult.getErrorMessage());
-                }
-            }catch (Exception e){
-                baseDao.execute("update customerUpdInfo set cui_error='"+e.getMessage()+"' where cui_code='"+rs.getGeneralString("cui_code")+"' and trunc(cui_date)=trunc(sysdate)");
-                logger.info("异常信息:"+e.getMessage());
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private String getDisplayField(List<Map<String, Object>> dataList, int i, String Field, String APINAME){
-        String ValueField ="";
-        Object account_type = dataList.get(i).get(Field);
-        if(account_type !=null && !"".equals(account_type.toString())){
-            Object DISPLAYFIELD = baseDao.getFieldDataByCondition("comboData", "DISPLAYFIELD", "VALUEFIELD='" + account_type + "' and APINAME='"+APINAME+"' and MODULEAPINAME='客户资料'");
-            ValueField= DISPLAYFIELD==null? "" :DISPLAYFIELD.toString();
-        }
-        return ValueField;
-    }
-
-    private String getValueField(String MODULEAPINAME, String APINAME, String DISPLAYFIELD){
-        String result ="";
-        if(DISPLAYFIELD !=null && !"".equals(DISPLAYFIELD)){
-            Object VALUEFIELD = baseDao.getFieldDataByCondition("comboData", "VALUEFIELD", "MODULEAPINAME='" + MODULEAPINAME + "' and APINAME='"+APINAME+"' and DISPLAYFIELD='"+DISPLAYFIELD+"'");
-            result = VALUEFIELD==null? "" :VALUEFIELD.toString();
-        }
-        return result;
-    }
-
-    private String getNotNull(List<Map<String, Object>> dataList, int i, String Field){
-        return (dataList.get(i).get(Field)==null?"":dataList.get(i).get(Field)).toString();
-    }
-}

+ 55 - 0
src/main/java/com/uas/eis/task/ProductMITask.java

@@ -0,0 +1,55 @@
+package com.uas.eis.task;
+
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.dao.SqlRowList;
+import com.uas.eis.manager.ProductManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author: zhouy
+ * @date: 2022/5/6 17:18
+ * @desc: 型号MI路径更新
+ */
+@Component
+@EnableAsync
+@EnableScheduling
+public class ProductMITask {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Autowired
+    private BaseDao baseDao;
+
+    @Scheduled(cron = "0 0/5 * * * ?")
+    public void syncProductMIImg() {
+        SqlRowList sl = baseDao.queryForRowSet("SELECT PR_MIIMG,PR_CODE FROM ZN_P.PRODUCT WHERE PR_GROUPCODE='成品' AND PR_MIIMG IS NULL ORDER BY PR_ID DESC ");
+        File file = null;
+        List<String> sqls = new ArrayList<>();
+        String prCode = " ";
+        logger.info("更新型号开始");
+        while (sl.hasNext()) {
+             prCode = sl.getGeneralString("PR_CODE");
+             file = new File("/app/MI/ZN/PPE/KaiLiaoImages/"+prCode+".jpg");
+             if(file.exists()){
+                 sqls.add("UPDATE ZN_P.PRODUCT SET PR_MIIMG='"+prCode+"' WHERE PR_CODE='"+prCode+"'");
+                 logger.info("更新生产型号:{}, IMG:{}",prCode,prCode);
+             }else{
+                 file = new File("/app/MI/ZN/PPE/KaiLiaoImages/"+prCode.toLowerCase()+".jpg");
+                 if(file.exists()){
+                     sqls.add("UPDATE ZN_P.PRODUCT SET PR_MIIMG='"+prCode.toLowerCase()+"' WHERE PR_CODE='"+prCode+"'");
+                     logger.info("更新生产型号:{}, IMG:{}",prCode,prCode.toLowerCase());
+                 }
+             }
+        }
+    }
+}

+ 0 - 96
src/main/java/com/uas/eis/task/ProductTask.java

@@ -1,96 +0,0 @@
-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.ProductManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-@Component
-@EnableAsync
-@EnableScheduling
-public class ProductTask {
-
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    @Autowired
-    private BaseDao baseDao;
-    @Autowired
-    private ProductManager productManager;
-
-    @Scheduled(cron = "0 0/15 * * * ?")
-    public void syncProducts() {
-        SqlRowList rs = baseDao.queryForRowSet("select * from (select * from product where nvl(pr_statuscode,' ')='AUDITED' and nvl(pr_sfjszy_user,' ')<>'是' and nvl(pr_sendstatus,' ')='待上传' order by pr_id) where rownum<=200");
-        while (rs.next()){
-            Product product = setProduct(rs);
-            product.set_id("");
-            try {
-                CrmAddResult crmAddResult = productManager.addProducts(product);
-                int errorCode = crmAddResult.getErrorCode();
-                String dataId = crmAddResult.getDataId();
-                if(errorCode == 0){
-                    baseDao.execute("update product set pr_sendstatus='已上传',PR_FXXKDATAID='"+dataId+"' where pr_id="+rs.getInt("pr_id"));
-                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'物料资料上传成功','物料资料上传','"+rs.getString("pr_code")+"')");
-                }else{
-                    baseDao.execute("update product set pr_sendstatus='未上传成功' where pr_id="+rs.getInt("pr_id"));
-                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmAddResult.getErrorMessage()+"','物料资料上传','"+rs.getString("pr_code")+"')");
-                    logger.info("异常信息:"+crmAddResult.getErrorMessage());
-                }
-            }catch (Exception e){
-                baseDao.execute("update product set pr_sendstatus='未上传成功' where pr_id="+rs.getInt("pr_id"));
-                baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+e.getMessage()+"','物料资料上传','"+rs.getString("pr_code")+"')");
-                logger.info("异常信息:"+e.getMessage());
-                e.printStackTrace();
-            }
-        }
-    }
-
-    @Scheduled(cron = "0 0 23 * * ?")
-    public void syncUpdateProducts() {
-        SqlRowList rs = baseDao.queryForRowSet("select * from (select distinct pis_prodcode from productInfoSync where trunc(pis_date)=trunc(sysdate)) left join product on pis_prodcode=pr_code where nvl(pr_statuscode,' ')='AUDITED' and nvl(pr_sfjszy_user,' ')<>'是' order by pr_id");
-        while (rs.next()){
-            Product product = setProduct(rs);
-            try {
-                BaseResult baseResult = productManager.updateGoods(product);
-                int errorCode = baseResult.getErrorCode();
-                if(errorCode == 0){
-                    baseDao.execute("update productInfoSync set pis_updatestatus='已更新',pis_updatedate=sysdate where pis_prodcode='"+rs.getGeneralString("pis_prodcode")+"' and trunc(pis_date)=trunc(sysdate)");
-                }else{
-                    baseDao.execute("update productInfoSync set pis_error='"+baseResult.getErrorMessage()+"' where pis_prodcode='"+rs.getGeneralString("pis_prodcode")+"' and trunc(pis_date)=trunc(sysdate)");
-                    logger.info("异常信息:"+baseResult.getErrorMessage());
-                }
-            }catch (Exception e){
-                baseDao.execute("update productInfoSync set pis_error='"+e.getMessage()+"' where pis_prodcode='"+rs.getGeneralString("pis_prodcode")+"' and trunc(pis_date)=trunc(sysdate)");
-                logger.info("异常信息:"+e.getMessage());
-                e.printStackTrace();
-            }
-        }
-    }
-
-    private Product setProduct(SqlRowList rs){
-        Product product = new Product();
-        product.setDataObjectApiName("ProductObj");
-        product.set_id(rs.getGeneralString("pr_fxxkdataid"));
-        product.setField_ea4Nh__c(rs.getGeneralDouble("pr_lastpurcprice_user"));
-        product.setField_i0v47__c(rs.getGeneralString("pr_YPstock"));
-        product.setField_iW998__c(rs.getGeneralString("pr_PLstock"));
-        product.setField_dioys__c(rs.getGeneralString("pr_wlfl_user"));
-        product.setProduct_code(rs.getGeneralString("pr_code"));
-        product.setUDSText1__c(rs.getGeneralString("pr_brand"));
-        product.setField_cwppk__c(rs.getGeneralString("pr_fz_user"));
-        product.setField_r02le__c(rs.getGeneralString("pr_zxbzs"));
-        product.setUnit(rs.getGeneralString("pr_unit"));
-        product.setName(rs.getGeneralString("pr_brand")+"~"+rs.getGeneralString("pr_spec"));
-        product.setPrice(rs.getGeneralDouble("pr_standardprice"));
-        product.setCategory("6");
-        return product;
-    }
-}

+ 0 - 200
src/main/java/com/uas/eis/task/SampleApplyTask.java

@@ -1,200 +0,0 @@
-package com.uas.eis.task;
-
-import com.uas.eis.beans.result.CrmQueryResult;
-import com.uas.eis.dao.BaseDao;
-import com.uas.eis.dao.SqlRowList;
-import com.uas.eis.manager.CommonManager;
-import com.uas.eis.utils.Configuration;
-import com.uas.eis.utils.Constant;
-import com.uas.eis.utils.DateUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-@Component
-@EnableAsync
-@EnableScheduling
-public class SampleApplyTask {
-
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    @Autowired
-    private BaseDao baseDao;
-    @Autowired
-    private CommonManager commonManager;
-    @Resource(name = "configuration")
-    private Configuration configuration;
-
-
-    @Scheduled(cron = "0 0/15 * * * ?")
-    public void syncSampleApply() {
-        try {
-            List<String> field_values = new ArrayList<>();
-            SqlRowList rs = baseDao.queryForRowSet("select ml_syncTime from (select * from FXXKDockingErrorlog where nvl(ML_TYPE,' ')='样品申请主表下载' and ML_SYNCTIME is not null order by ml_date desc) where rownum=1");
-            if(rs.next()){
-                String ml_syncTime = rs.getGeneralString("ml_syncTime");
-                field_values.add(ml_syncTime);
-                //样品申请主表下载
-                CrmQueryResult crmQueryResult = commonManager.queryCommon("create_time", field_values, "GT", "create_time", true, 50, "object_83m40__c", true);
-                int errorCode = crmQueryResult.getErrorCode();
-                if(errorCode == 0){
-                    Map<String, Object> data = crmQueryResult.getData();
-                    List<Map<String, Object>> dataList = (List<Map<String,Object>>) data.get("dataList");
-                    //m:成功条数 n:失败条数
-                    int m=0,n=0;
-                    if(dataList.size()>0){
-                        //最后(即最近)一次同步时间
-                        Long create_time_Last = Long.parseLong(new BigDecimal(dataList.get(dataList.size()-1).get("create_time").toString()).toPlainString());
-                        for (int i = 0; i < dataList.size(); i++) {
-                            Object _id = dataList.get(i).get("_id");
-                            Object name = dataList.get(i).get("name");
-                            SimpleDateFormat sdf = new SimpleDateFormat(Constant.YMD_HMS);
-                            try {
-                                String MAUser="";
-                                String username = configuration.getUsername();
-                                //根据申请抬头取得对应的子账套 若没有值则取资料中心
-                                Object field_h73i7__c = dataList.get(i).get("field_h73i7__c");
-                                if(field_h73i7__c!=null && !"".equals(field_h73i7__c.toString())){
-                                    Object DISPLAYFIELD = baseDao.getFieldDataByCondition("comboData", "DISPLAYFIELD", "VALUEFIELD='" + field_h73i7__c + "' and APICODE='field_h73i7__c' and MODULEAPINAME='样品申请单'");
-                                    if(DISPLAYFIELD!=null && !"".equals(DISPLAYFIELD.toString())){
-                                        Object MA_USER = baseDao.getFieldDataByCondition("master", "MA_USER", "MA_FUNCTION='" + DISPLAYFIELD + "'");
-                                        MAUser = (MA_USER == null || "".equals(MA_USER.toString()))?username:MA_USER.toString();
-                                    }
-                                }
-                                if(baseDao.checkIf(MAUser+".ProdInOutApply", "pi_code='" + name + "'")){
-                                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'样品申请编号已存在','样品申请主表下载','"+name+"')");
-                                    logger.info("异常信息:样品申请编号已存在");
-                                    n++;
-                                    continue;
-                                }
-
-                                Object cu_code = baseDao.getFieldDataByCondition("customer", "max(cu_code) cu_code", "CU_FXXKID='" + dataList.get(i).get("field_l6W5b__c") + "' or cu_name='"+dataList.get(i).get("field_l6W5b__c__r")+"'");
-                                String cuCode =cu_code == null ? "" : cu_code.toString();
-                                //默认样品仓
-                                Object wh_description = baseDao.getFieldDataByCondition("Warehouse", "max(wh_description) wh_description", "wh_code='W02'");
-                                String pi_whname =wh_description == null ? "" : wh_description.toString();
-
-                                Object life_status = dataList.get(i).get("life_status");
-                                Object record_type = dataList.get(i).get("record_type");
-
-                                String lifeStatus = "normal".equals(life_status) ? "正常": (life_status==null? "" : life_status.toString());
-                                String recordType = "default__c".equals(record_type) ? "预设业务类型": (record_type==null? "" : record_type.toString());
-                                //负责人编号、名称
-                                Map<String,Object> owner__r =(Map<String,Object>) dataList.get(i).get("owner__r");
-                                Object owner_code = baseDao.getFieldDataByCondition(MAUser+".employee", "max(em_code) em_code", "em_name='" + owner__r.get("name") + "'");
-                                //创建人编号、名称
-                                Map<String,Object> created_by__r =(Map<String,Object>) dataList.get(i).get("created_by__r");
-                                Object created_by_code = baseDao.getFieldDataByCondition(MAUser+".employee", "max(em_code) em_code", "em_name='" + created_by__r.get("name") + "'");
-                                //最后更新人编号、名称
-                                Map<String,Object> last_modified_by__r =(Map<String,Object>) dataList.get(i).get("last_modified_by__r");
-                                Object last_modified_by_code = baseDao.getFieldDataByCondition(MAUser+".employee", "max(em_code) em_code", "em_name='" + last_modified_by__r.get("name") + "'");
-                                //申请日期
-                                Long field_lp4Q1__c = Long.parseLong(new BigDecimal(dataList.get(i).get("field_lp4Q1__c").toString()).toPlainString());
-                                Long create_time = Long.parseLong(new BigDecimal(dataList.get(i).get("create_time").toString()).toPlainString());
-                                Long last_modified_time = Long.parseLong(new BigDecimal(dataList.get(i).get("last_modified_time").toString()).toPlainString());
-                                //客户联系人:pi_purposename 电话:pi_expresscode
-                                int pi_id = baseDao.getSeqId(MAUser+".PRODINOUTAPPLY_SEQ");
-                                String sql="insert into "+MAUser+".ProdInOutApply(pi_id,pi_code,pi_class,pi_date,pi_status,pi_statuscode,pi_whcode,pi_whname,pi_cardcode,pi_title,pi_emcode,pi_emname,pi_recordman,pi_recorddate," +
-                                        "pi_updateman,pi_updatedate,pi_purposename,pi_expresscode,pi_address,pi_email_user,pi_remark,pi_field_Il1e1,pi_record_type,pi_life_status,PI_FXXKID)" +
-                                        "values("+pi_id+",'"+name+"','其它出库申请单',"+DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(field_lp4Q1__c)))+"," +
-                                        "'已审核','AUDITED','W02','"+pi_whname+"','"+cuCode+"','"+dataList.get(i).get("field_l6W5b__c__r")+"','"+owner_code+"','"+owner__r.get("name")+"','"+ created_by__r.get("name")+"'," +
-                                        DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(create_time)))+",'"+last_modified_by__r.get("name")+"',"+
-                                        DateUtil.parseDateToOracleString(Constant.YMD_HMS,sdf.parse(sdf.format(last_modified_time)))+",'" +dataList.get(i).get("field_DzO73__c__r")+"',"+
-                                        "'"+dataList.get(i).get("field_57196__c")+"','"+(dataList.get(i).get("field_Z2afs__c")==null?"":dataList.get(i).get("field_Z2afs__c"))+"','"+(dataList.get(i).get("field_1NKlv__c")==null?"":dataList.get(i).get("field_1NKlv__c"))+"'," +
-                                        "'"+(dataList.get(i).get("field_lyGrw__c")==null?"":dataList.get(i).get("field_lyGrw__c"))+"','"+dataList.get(i).get("field_Il1e1__c")+"','"+recordType+"','"+lifeStatus+"','"+_id+"')";
-                                baseDao.execute(sql);
-                                //更新样品单中的核算部门
-                                baseDao.execute("update ProdInOutApply set (pi_departmentcode,pi_departmentname)=(select em_departmentcode,em_depart from employee where em_code=pi_emcode) where nvl(pi_emcode,' ')<>' ' and pi_id="+pi_id);
-                                //样品申请明细下载
-                                syncSampleApplyDetail(_id.toString(),pi_id,MAUser);
-                                m++;
-                            }catch (Exception e){
-                                baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','样品申请主表下载','"+name+"')");
-                                logger.info("异常信息:"+e);
-                                n++;
-                            }
-                        }
-                        baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_syncTime) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'下载记录"+dataList.size()+"条,成功"+m+"条,失败"+n+"条','样品申请主表下载','"+create_time_Last+"')");
-                    }
-                }else{
-                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','样品申请主表下载','')");
-                    logger.info("异常信息:"+crmQueryResult.getErrorMessage());
-                }
-            }
-        }catch (Exception e){
-            baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+e.getMessage()+"','样品申请主表下载','')");
-            logger.info("异常信息:"+e.getMessage());
-            e.printStackTrace();
-        }
-    }
-
-    private void syncSampleApplyDetail(String SampleApply_id,int pi_id,String MAUser){
-        List<String> field_values_Detail = new ArrayList<>();
-        field_values_Detail.add(SampleApply_id);
-        try {
-            CrmQueryResult crmQueryResult = commonManager.queryCommon("field_8019j__c", field_values_Detail, "EQ", "create_time", true, 100, "object_Q55Nj__c", true);
-            int errorCode = crmQueryResult.getErrorCode();
-            if(errorCode == 0){
-                Map<String, Object> data = crmQueryResult.getData();
-                List<Map<String, Object>> dataList = (List<Map<String,Object>>) data.get("dataList");
-                //默认样品仓
-                Object wh_description = baseDao.getFieldDataByCondition("Warehouse", "max(wh_description) wh_description", "wh_code='W02'");
-                String pi_whname =wh_description == null ? "" : wh_description.toString();
-                //m:成功条数 n:失败条数
-                int m=0,n=0;
-                if(dataList.size()>0){
-                    //最后(即最近)一次同步时间
-                    Long create_time_Last = Long.parseLong(new BigDecimal(dataList.get(dataList.size()-1).get("create_time").toString()).toPlainString());
-                    for (int i = 0; i < dataList.size(); i++) {
-                        Object _id = dataList.get(i).get("_id");
-                        Object name = dataList.get(i).get("name");
-                        SimpleDateFormat sdf = new SimpleDateFormat(Constant.YMD_HMS);
-                        if(baseDao.checkIf(MAUser+".ProdIOApplyDetail", "pd_code='" + name + "' and pd_piid="+pi_id)){
-                            baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'样品申请明细编号已存在','样品申请明细表下载','"+name+"')");
-                            logger.info("异常信息:样品申请明细编号已存在");
-                            n++;
-                            continue;
-                        }
-                        try {
-                            //负责人编号、名称
-                            Map<String,Object> owner__r =(Map<String,Object>) dataList.get(i).get("owner__r");
-                            Object owner_code = baseDao.getFieldDataByCondition(MAUser+".employee", "max(em_code) em_code", "em_name='" + owner__r.get("name") + "'");
-
-                            String sql="insert into "+MAUser+".ProdIOApplyDetail(pd_id,pd_piid,pd_pdno,pd_code,pd_piclass,pd_whcode,pd_whname,pd_picode,pd_ownercode,pd_owner,pd_prodcode,pd_detail,pd_sepc,pd_brand,pd_outqty,YPonhand,PD_FXXKID)" +
-                                    "values("+MAUser+".PRODIOAPPLYDETAIL_SEQ.nextval,"+pi_id+","+(i+1)+",'"+name+"','其它出库申请单','W02','"+pi_whname+"','"+dataList.get(i).get("field_8019j__c__r")+"'," +
-                                    "'"+owner_code+"','"+owner__r.get("name")+"','"+ (dataList.get(i).get("field_2Lq6Y__c")==null?"":dataList.get(i).get("field_2Lq6Y__c")) +"','"+(dataList.get(i).get(" field_utezf__c__r")==null?"":dataList.get(i).get(" field_utezf__c__r"))+"'," +
-                                    "'"+(dataList.get(i).get("field_21Suz__c")==null?"":dataList.get(i).get("field_21Suz__c"))+"','"+(dataList.get(i).get("field_y5dz2__c")==null?"":dataList.get(i).get("field_y5dz2__c"))+"','" +dataList.get(i).get("field_7uspZ__c")+"',"+
-                                    "'"+dataList.get(i).get("field_lzxe2__c")+"','"+_id+"')";
-                            baseDao.execute(sql);
-                            m++;
-                        }catch (Exception e){
-                            baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','样品申请明细表下载','"+name+"')");
-                            logger.info("异常信息:"+e);
-                            n++;
-                        }
-                    }
-                    baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_syncTime) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'下载记录"+dataList.size()+"条,成功"+m+"条,失败"+n+"条','样品申请明细表下载','"+create_time_Last+"')");
-                }
-            }else{
-                baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+crmQueryResult.getErrorMessage()+"','样品申请明细表下载','')");
-                logger.info("异常信息:"+crmQueryResult.getErrorMessage());
-            }
-        }catch (Exception e){
-            baseDao.execute("insert into FXXKDockingErrorlog(ml_id,ml_date,ml_result,ml_type,ml_code) values(FXXKDOCKINGERRORLOG_SEQ.nextval,sysdate,'"+e.getMessage()+"','样品申请明细表下载','')");
-            logger.info("异常信息:"+e.getMessage());
-            e.printStackTrace();
-        }
-
-    }
-}

+ 2 - 30
src/main/resources/application-prod.yml

@@ -4,41 +4,13 @@ spring:
         driverClassName: oracle.jdbc.OracleDriver
         username: DATACENTER
         password: select!#%*(
-        url: jdbc:oracle:thin:@172.16.0.5:1521:orcl
-    redis:
-        host: 10.1.81.208
-        port: 26379
+        url: jdbc:oracle:thin:@10.100.100.25:1521:orcl
 server:
     tomcat:
         uri_encoding: UTF-8
     context-path:
         /EIS
-Task:
-    SyncProductsMethod: syncProducts
-    SyncProductsCron: 0 0/1 * * * ?
-    SyncMakeBasesMethod: syncMakeBases
-    SyncMakeBasesCron: 0 0/1 * * * ?
-    SyncMakeBaseDetailsMethod: syncMakeBaseDetails
-    SyncMakeBaseDetailsCron: 0 0/1 * * * ?
-    syncMakematerialReplaceMethod: syncMakematerialReplace
-    syncMakematerialReplaceCron: 0 0/1 * * * ?
 
 action:
     api_action: /EIS/api,/EIS/mes,/EIS/erp
-    public_actions: /EIS/logout,/EIS/hello1
-
-extral:
-    kingdee:
-        url: http://183.62.131.97:9880/k3cloud/
-        dbId: 614562cfb7a481
-        uid: admin1
-        pwd: 123456789
-        lang: 2052
-fs:
-    appId: FSAID_131a7cb
-    appSecret: 2a21342635174202809295bd02e2acae
-    permanentCode: 62ADF2C84B8405E6155D2C054B826896
-    token: 1493db0d00b74e86a30b1457497c6988
-    encodingAesKey: YmFhZjE4YmQ5MmQ2NDE0MTg1MmJlNjZjYzJmMmQ0ZjM
-    authorize.url: https://open.fxiaoke.com/oauth2/authorize
-    openUserId: FSUID_EEB3F8D8C2186EB4AFFB5D97F1AA4FCD
+    public_actions: /EIS/logout,/EIS/hello1

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio