Browse Source

【越加红】纷享销客 crm对接修改

wub 3 years ago
parent
commit
f26255822f

+ 0 - 74
src/main/java/com/uas/eis/core/support/SpringDynamicCronTask.java

@@ -1,74 +0,0 @@
-package com.uas.eis.core.support;
-
-
-import com.uas.eis.task.ScheduleTask;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.SchedulingConfigurer;
-import org.springframework.scheduling.config.ScheduledTaskRegistrar;
-import org.springframework.stereotype.Component;
-
-import java.lang.reflect.Method;
-
-@Configuration
-@EnableScheduling
-@Component
-public class SpringDynamicCronTask implements SchedulingConfigurer {
-
-	private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-
-	@Autowired
-	private Environment env;
-
-	@Autowired
-	private ScheduleTask scheduleTask;
-
-	@Override
-	public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
-		String activeProFiles = env.getActiveProfiles()[0];
-		if("dev".equals(activeProFiles)) {
-			logger.info(String.format("运行环境:%s;注册TASK:%s",activeProFiles,env.getProperty("Task.SyncProductsMethod")));
-			taskRegistrar.addCronTask(() -> {
-				//业务逻辑
-				try {
-					Method method = scheduleTask.getClass().getMethod(env.getProperty("Task.SyncProductsMethod"));
-					method.invoke(scheduleTask);
-				}catch (Exception e){
-					e.printStackTrace();
-				}
-			}, env.getProperty("Task.SyncProductsCron"));
-            taskRegistrar.addCronTask(() -> {
-                //业务逻辑
-                try {
-                    Method method = scheduleTask.getClass().getMethod(env.getProperty("Task.SyncMakeBasesMethod"));
-                    method.invoke(scheduleTask);
-                }catch (Exception e){
-                    e.printStackTrace();
-                }
-            }, env.getProperty("Task.SyncMakeBasesCron"));
-            taskRegistrar.addCronTask(() -> {
-                //业务逻辑
-                try {
-                    Method method = scheduleTask.getClass().getMethod(env.getProperty("Task.SyncMakeBaseDetailsMethod"));
-                    method.invoke(scheduleTask);
-                }catch (Exception e){
-                    e.printStackTrace();
-                }
-            }, env.getProperty("Task.SyncMakeBaseDetailsCron"));
-			taskRegistrar.addCronTask(() -> {
-				//业务逻辑
-				try {
-					Method method = scheduleTask.getClass().getMethod(env.getProperty("Task.syncMakematerialReplaceMethod"));
-					method.invoke(scheduleTask);
-				}catch (Exception e){
-					e.printStackTrace();
-				}
-			}, env.getProperty("Task.syncMakematerialReplaceCron"));
-		}
-	}
-}

+ 0 - 269
src/main/java/com/uas/eis/service/Impl/ScheduleTaskServiceImpl.java

@@ -1,269 +0,0 @@
-package com.uas.eis.service.Impl;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import com.uas.eis.core.support.TokenProperties;
-import com.uas.eis.dao.BaseDao;
-import com.uas.eis.dao.SqlRowList;
-import com.uas.eis.entity.Make;
-import com.uas.eis.entity.MakeMaterial;
-import com.uas.eis.entity.Product;
-import com.uas.eis.service.ScheduleTaskService;
-import com.uas.eis.utils.MD5Util;
-import com.uas.eis.utils.PSHttpUtils;
-import com.uas.eis.utils.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author koul
- * @email koul@usoftchina.com
- * @date 2021-12-23 15:30
- */
-@Service
-public class ScheduleTaskServiceImpl implements ScheduleTaskService {
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-    private static Map<String,String> tokenConfig = TokenProperties.getAllProperty();
-
-    @Autowired
-    private BaseDao baseDao;
-
-    /**
-     * STATUS(W等待执行,F执行失败,D已执行)
-     *
-     */
-    @Override
-    public void syncProducts() {
-        try {
-            SqlRowList rs = baseDao.queryForRowSet("select id from mes_product where status='W' order by id");
-            while (rs.next()){
-                Product product = baseDao.getJdbcTemplate().queryForObject("select case when pr_kh_user='柏英特' or nvl(pr_kh_user,' ')=' ' then 'BYT' else nvl(cu_mescode,cu_code) end pr_kh_user,pr_code ,pr_detail ,replace(PR_SPEC,'''','''''') pr_spec,nvl(pr_unit,'PCS') pr_unit,nvl(pr_cop,'BYT') pr_cop,nvl(pr_version,'0') pr_version,case when nvl(pr_kind,'')='半成品' or nvl(pr_kind,' ')='成品' then  'product' else 'raw' end pr_serial,nvl(pr_validdays,'0') pr_validdays,pr_msdlevel ,pr_kind3 ,pr_f_115 ,pr_f_116 ,pr_f_102,pr_kind,flag,pr_statuscode,pr_status from mes_product left join customer on pr_kh_user=cu_shortname where id=?",
-                        new BeanPropertyRowMapper<Product>(Product.class), rs.getInt("id"));
-                product.setMesUser(tokenConfig.get("mesUser"));
-                product.setMesPwd(MD5Util.encodeByMD5(tokenConfig.get("mesPwd")));
-                Map<String, Object> map = syncMES(JSON.toJSONString(product, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncProduct"));
-                if ("ZG".equals(StringUtil.nvl(product.getPr_kh_user(),""))){
-                    product.setPr_kh_user("ZGSDC");
-                    Map<String, Object> map1 =
-                            syncMES(JSON.toJSONString(product, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncProduct"));
-                    if (map1!=null) {
-                        int code1 = Integer.parseInt(StringUtil.nvl(map1.get("code"), "100"));
-                        if (code1>0) {
-                            int flag = product.getFlag();
-                            if (flag == 1) {
-                                product.setFlag(0);
-                            } else if (flag == 0) {
-                                product.setFlag(1);
-                            }
-                            Map<String, Object> map2 =
-                                    syncMES(JSON.toJSONString(product, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncProduct"));
-                            if (map2 != null) {
-                                int code2 = Integer.parseInt(StringUtil.nvl(map1.get("code"), "100"));
-                                if (code2 > 0) {
-                                    baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_type) values (MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncProduct") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + product.getPr_code() + "','物料资料')");
-                                }
-                            }
-                        }
-                    }
-                }
-                if (map!=null){
-                    int code = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
-                    if (code==0){
-                        baseDao.updateByCondition("mes_product","status='D'","status='W' and id="+rs.getInt("id"));
-                    }else {
-                        int flag = product.getFlag();
-                        if (flag == 1) {
-                            product.setFlag(0);
-                        } else if (flag == 0) {
-                            product.setFlag(1);
-                        }
-                        Map<String, Object> map1 = syncMES(JSON.toJSONString(product, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncProduct"));
-                        if (map1!=null){
-                            int code1 = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
-                            if (code1==0){
-                                baseDao.updateByCondition("mes_product","status='D'","status='W' and id="+rs.getInt("id"));
-                            }else {
-                                baseDao.updateByCondition("mes_product","status='F'","status='W' and id="+rs.getInt("id"));
-                                baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_type) values (MESERRORLOG_SEQ.NEXTVAL,'"+tokenConfig.get("syncProduct")+"','"+StringUtil.nvl(map.get("msg"),"")+"',sysdate,'"+product.getPr_code()+"','物料资料')");
-                            }
-                        }
-                    }
-                }
-            }
-        }catch (Exception e){
-            logger.info("物料资料异常信息:"+e.getMessage());
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void syncMakeBases() {
-        try {
-            SqlRowList rs = baseDao.queryForRowSet("select id,ma_code from mes_make where status='W' order by id");
-            while (rs.next()) {
-                int count = baseDao.getCount("select count(1) from make where ma_statuscode='FINISH' and ma_code='" + rs.getString("ma_code") + "'");
-                String status = "S";
-                if (count > 0) {
-                    status = "C";
-                }
-                Make make = baseDao.getJdbcTemplate().queryForObject("select ma_code,ma_prodcode,ma_qty,nvl(cu_mescode,'BYT') ma_custcode,pr_unit,pr_detail,replace(PR_SPEC,'''','''''') pr_spec,nvl(ma_zgrwl,ma_salecode) ma_salecode,to_char(ma_planbegindate,'yyyy-MM-dd') ma_planbegindate,to_char(ma_planenddate,'yyyy-MM-dd') ma_planenddate,nvl(ma_cop,'BYT') ma_cop,'" + status + "' status,to_char(ma_date,'yyyy-MM-dd HH24:mi:ss') ma_date,ma_recorder,nvl(ma_version,0) ma_version,erpid,wc_id,nvl(mk_id,0) ma_kind,to_char(ma_modifydate,'yyyy-MM-dd HH24:mi:ss') ma_modifydate,ma_modifier,flag from mes_make left join MakeKind on ma_kind=mk_name left join product on ma_prodcode=pr_code left join workcenter on ma_wccode=wc_code left join customer on pr_kh_user=cu_shortname where id=?", new BeanPropertyRowMapper<Make>(Make.class), rs.getInt("id"));
-                make.setMesPwd(MD5Util.encodeByMD5(tokenConfig.get("mesPwd")));
-                make.setMesUser(tokenConfig.get("mesUser"));
-                Map<String, Object> map = syncMES(JSON.toJSONString(make, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBase"));
-                if (map != null) {
-                    int code = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
-                    if (code == 0) {
-                        baseDao.updateByCondition("mes_make", "status='D'", "status='W' and id=" + rs.getInt("id"));
-                    } else {
-                        int flag = make.getFlag();
-                        if (flag == 1) {
-                            make.setFlag(0);
-                        } else if (flag == 0) {
-                            make.setFlag(1);
-                        }
-                        Map<String, Object> map1 = syncMES(JSON.toJSONString(make,
-                                SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBase"));
-                        if (map1 != null) {
-                            int code1 = Integer.parseInt(StringUtil.nvl(map1.get("code"), "-1"));
-                            if (code1 == 0) {
-                                baseDao.updateByCondition("mes_makematerial", "status='D'", "status='W' and id=" + rs.getInt("id"));
-                            } else {
-                                baseDao.updateByCondition("mes_make", "status='F'", "status='W' and id=" + rs.getInt("id"));
-                                baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_type) values (MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncMakeBase") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + make.getMa_code() + "','工单')");
-                            }
-                        }
-                    }
-                }
-            }
-        }catch (Exception e){
-                logger.info("同步工单异常信息:"+e.getMessage());
-                e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void syncMakeBaseDetails() {
-        try {
-            SqlRowList rs = baseDao.queryForRowSet("select id,mm_code,mm_detno from mes_makematerial where status='W' order by id");
-            while (rs.next()) {
-            int count = baseDao.getCount("select count(1) from mes_make where status='D' and ma_code='" + rs.getGeneralString("mm_code") + "'");
-            if (count > 0) {
-                MakeMaterial makeMaterial = baseDao.getJdbcTemplate().queryForObject("select mm_code,erpid,mm_prodcode,pr_detail,replace(PR_SPEC,'''','''''') pr_spec,pr_unit,mm_oneuseqty qty,mm_qty,mm_oneuseqty,'main' type,bo_recorder,to_char(bo_date,'yyyy-MM-dd HH24:mi:ss') bo_date,nvl(bo_version,0) bo_version,nvl(bo_cop,'BYT') bo_cop,mm_prodcode mm_repprodcode,mm_balance,(select nvl(cu_mescode,'BYT') from Product left join customer on pr_kh_user=cu_shortname where pr_code=ma_prodcode) ma_custcode,to_char(mc_indate,'yyyy-MM-dd HH24:mi:ss') mc_indate,mc_recorder,flag,0 rpid from mes_makematerial left join make on ma_id=mm_maid left join Product on mm_prodcode=pr_code left join bom on bo_id=mm_bomid left join (select max(mc_indate) mc_indate,max(mc_recorder) mc_recorder,max(md_mmdetno) md_mmdetno,max(md_makecode) md_makecode from MakeMaterialChangeDet left join MakeMaterialChange on mc_id=md_mcid) on md_makecode=ma_code and md_mmdetno=mm_detno where id=? order by mm_detno", new BeanPropertyRowMapper<MakeMaterial>(MakeMaterial.class), rs.getInt("id"));
-                makeMaterial.setMesUser(tokenConfig.get("mesUser"));
-                makeMaterial.setMesPwd(MD5Util.encodeByMD5(tokenConfig.get("mesPwd")));
-                Map<String, Object> map = syncMES(JSON.toJSONString(makeMaterial, SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBaseDetail"));
-                if (map != null) {
-                    int code = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
-                    if (code == 0) {
-                        baseDao.updateByCondition("mes_makematerial", "status='D'", "status='W' and id=" + rs.getInt("id"));
-                        } else {
-                            int flag = makeMaterial.getFlag();
-                            if (flag==1) {
-                                makeMaterial.setFlag(0);
-                            }else if (flag==0) {
-                                makeMaterial.setFlag(1);
-                            }
-                            Map<String, Object> map1 = syncMES(JSON.toJSONString(makeMaterial,
-                                    SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBaseDetail"));
-                            if (map1 != null) {
-                                int code1 = Integer.parseInt(StringUtil.nvl(map1.get("code"), "-1"));
-                                if (code1 == 0) {
-                                    baseDao.updateByCondition("mes_makematerial", "status='D'", "status='W' and id=" + rs.getInt("id"));
-                                }else {
-                                    baseDao.updateByCondition("mes_makematerial", "status='F'", "status='W' and id=" + rs.getInt("id"));
-                                    baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_djdetno,mel_type) values(MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncMakeBaseDetail") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + rs.getGeneralString("mm_code") + "'," + rs.getInt("mm_detno") + ",'工单BOM')");
-                                }
-                            }
-
-                        }
-                    }
-                }
-            }
-        }catch (Exception e){
-            logger.info("同步工单BOM异常信息:"+e.getMessage());
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void syncMakematerialReplace() {
-        try {
-            SqlRowList rs = baseDao.queryForRowSet("select id,mp_mmcode, mp_mmdetno,mp_mmid from mes_makematerialreplace where status='W' order by id");
-            while (rs.next()) {
-            int count =
-                    baseDao.getCount("select count(1) from mes_makematerial where status='D' and " + "erpid=" + rs.getInt("mp_mmid"));
-            if (count > 0) {
-                    MakeMaterial makeMaterial = baseDao.getJdbcTemplate().queryForObject("select mm.mm_code,mm.erpid,mr.mp_prodcode mm_prodcode,pr_detail,replace(PR_SPEC,'''','''''') pr_spec,pr_unit,mm.mm_oneuseqty qty,mr.mp_canuseqty mm_qty,mm.mm_oneuseqty,'alternative' type,bo_recorder,to_char(bo_date,'yyyy-MM-dd HH24:mi:ss') bo_date,nvl(bo_version,0) bo_version,nvl(bo_cop,'BYT') bo_cop,mm.mm_prodcode mm_repprodcode,mm.mm_balance,(select nvl(cu_mescode,'BYT') from Product left join customer on pr_kh_user=cu_shortname where pr_code=ma_prodcode) ma_custcode,to_char(mc_indate,'yyyy-MM-dd HH24:mi:ss') mc_indate,mc_recorder,mr.flag,mr.erpid rpid from mes_makematerialreplace mr left join mes_makematerial mm on mr.mp_mmid=mm.erpid left join make on mm.mm_maid=ma_id left join Product on mr.mp_prodcode=pr_code left join bom on bo_id=mm.mm_bomid left join (select max(mc_indate) mc_indate,max(mc_recorder) mc_recorder,max(md_mmdetno) md_mmdetno,max(md_makecode) md_makecode from MakeMaterialChangeDet left join MakeMaterialChange on mc_id=md_mcid) on md_makecode=ma_code and md_mmdetno=mm.mm_detno where mr.id=?",
-                            new BeanPropertyRowMapper<MakeMaterial>(MakeMaterial.class), rs.getInt("id"));
-                    makeMaterial.setMesUser(tokenConfig.get("mesUser"));
-                    makeMaterial.setMesPwd(MD5Util.encodeByMD5(tokenConfig.get("mesPwd")));
-                    Map<String, Object> map = syncMES(JSON.toJSONString(makeMaterial,
-                            SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBaseDetail"));
-                    if (map != null) {
-                        int code = Integer.parseInt(StringUtil.nvl(map.get("code"), "-1"));
-                        if (code == 0) {
-                            baseDao.updateByCondition("mes_makematerialreplace", "status='D'", "status='W' and id=" + rs.getInt("id"));
-                        } else {
-                            int flag = makeMaterial.getFlag();
-                            if (flag==1) {
-                                makeMaterial.setFlag(0);
-                            }else if (flag==0) {
-                                makeMaterial.setFlag(1);
-                            }
-                            Map<String, Object> map1 = syncMES(JSON.toJSONString(makeMaterial,
-                                    SerializerFeature.WriteMapNullValue).replace("null", "\"\""), tokenConfig.get("syncMakeBaseDetail"));
-                            if (map1 != null) {
-                                int code1 = Integer.parseInt(StringUtil.nvl(map1.get("code"), "-1"));
-                                if (code1 == 0) {
-                                    baseDao.updateByCondition("mes_makematerialreplace", "status='D'", "status='W' and id=" + rs.getInt("id"));
-                                } else {
-                                    baseDao.updateByCondition("mes_makematerialreplace", "status='F'", "status='W' and id=" + rs.getInt("id"));
-                                    baseDao.execute("insert into meserrorlog (mel_id,mel_url,mel_error,mel_indate,mel_djcode,mel_djdetno,mel_type) values(MESERRORLOG_SEQ.NEXTVAL,'" + tokenConfig.get("syncMakeBaseDetail") + "','" + StringUtil.nvl(map.get("msg"), "") + "',sysdate,'" + rs.getGeneralString("mp_mmcode") + "'," + rs.getInt("mp_mmdetno") + ",'工单BOM替代料')");
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }catch (Exception e){
-            logger.info("同步替代料异常信息:"+e.getMessage());
-            e.printStackTrace();
-        }
-    }
-
-    private Map<String, Object> syncMES(String params,String url){
-        Map<String, Object> map = new HashMap<>();
-        map.put("code",-1);
-        logger.info("params:"+params);
-        try {
-            String post = PSHttpUtils.sendPost(tokenConfig.get("mesHttp") + url, params);
-            logger.info("post:"+post);
-            JSONObject jsonObject = JSON.parseObject(post);
-            int code = jsonObject.getIntValue("result");
-            logger.info("code:"+code);
-            if (code==0){
-                map.put("code",code);
-                map.put("msg","同步MES成功");
-            }else if(code==1){
-                map.put("code",code);
-                logger.info("msg:"+jsonObject.getString("message"));
-                map.put("msg",jsonObject.getString("message"));
-            }else {
-                map.put("code",-1);
-                map.put("msg","接口调用异常,请联系MES处理!");
-            }
-        }catch (Exception e){
-            map.put("msg","接口调用异常,请联系MES处理!");
-            logger.info("异常信息:"+e.getMessage());
-            e.printStackTrace();
-        }
-        return map;
-    }
-}

+ 0 - 19
src/main/java/com/uas/eis/service/ScheduleTaskService.java

@@ -1,19 +0,0 @@
-package com.uas.eis.service;
-
-/**
- * @author koul
- * @email koul@usoftchina.com
- * @date 2021-12-23 15:27
- */
-public interface ScheduleTaskService {
-
-    void syncProducts();
-
-    void syncMakeBases();
-
-    void syncMakeBaseDetails();
-
-    void syncMakematerialReplace();
-
-
-}

+ 5 - 3
src/main/java/com/uas/eis/task/CustomerTask.java

@@ -62,6 +62,7 @@ public class CustomerTask {
                             }
                             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 = getValueField(dataList, i, "account_type", "客户类型");
@@ -74,13 +75,14 @@ public class CustomerTask {
                                 String cu_currency = getValueField(dataList, i, "field_e2HeP__c", "货币");
                                 String cu_recordType = getValueField(dataList, i, "record_type", "业务类型");
                                 String cu_industry = getValueField(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_kind," +
+                                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_FXXKID)" +
-                                        "values(PRECUSTOMER_SEQ.nextval,'"+dataList.get(i).get("account_no")+"','"+name+"','"+dataList.get(i).get("UDSText3__c")+"','"+ dataList.get(i).get("address")+"'," +
-                                        "'"+em_code+"','"+dataList.get(i).get("field_w9e4q__c")+"','"+cuKind+"'," +
+                                        "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+"'," +

+ 7 - 11
src/main/java/com/uas/eis/task/ProductTask.java

@@ -2,7 +2,6 @@ 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.Goods;
 import com.uas.eis.beans.result.Product;
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.dao.SqlRowList;
@@ -15,11 +14,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 @Component
 @EnableAsync
 @EnableScheduling
@@ -32,7 +26,7 @@ public class ProductTask {
     @Autowired
     private ProductManager productManager;
 
-    @Scheduled(cron = "0 0/5 * * * ?")
+    @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_sendstatus,' ')='待上传' order by pr_id) where rownum<=200");
         while (rs.next()){
@@ -46,10 +40,12 @@ public class ProductTask {
                     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();
@@ -57,18 +53,18 @@ public class ProductTask {
         }
     }
 
-    @Scheduled(cron = "*/10 * * * * ?")
+    @Scheduled(cron = "0 0 23 * * ?")
     public void syncUpdateProducts() {
-        SqlRowList rs = baseDao.queryForRowSet("select * from (select distinct pis_prodcode from productInfoSync where 1=2 and trunc(pis_date)=trunc(sysdate)) left join product on pis_prodcode=pr_code order by pr_id");
+        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 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.getInt("pis_prodcode")+"' and trunc(pis_date)=trunc(sysdate)");
+                    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.getInt("pis_prodcode")+"' and trunc(pis_date)=trunc(sysdate)");
+                    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){

+ 14 - 8
src/main/java/com/uas/eis/task/SampleApplyTask.java

@@ -4,6 +4,7 @@ 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;
@@ -14,6 +15,7 @@ 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;
@@ -31,17 +33,20 @@ public class SampleApplyTask {
     private BaseDao baseDao;
     @Autowired
     private CommonManager commonManager;
+    @Resource(name = "configuration")
+    private Configuration configuration;
 
-    @Scheduled(cron = "*/10 * * * * ?")
+
+    @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 1=2 and nvl(ML_TYPE,' ')='样品申请主表下载' and ML_SYNCTIME is not null order by ml_date desc) where rownum=1");
+            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, 5, "object_83m40__c", true);
+                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();
@@ -56,14 +61,15 @@ public class SampleApplyTask {
                             Object name = dataList.get(i).get("name");
                             SimpleDateFormat sdf = new SimpleDateFormat(Constant.YMD_HMS);
                             try {
-                                String MAUser="DATACENTER";
+                                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()))?"YJH_T":MA_USER.toString();
+                                        MAUser = (MA_USER == null || "".equals(MA_USER.toString()))?username:MA_USER.toString();
                                     }
                                 }
                                 if(baseDao.checkIf(MAUser+".ProdInOutApply", "pi_code='" + name + "'")){
@@ -100,12 +106,13 @@ public class SampleApplyTask {
                                 //客户联系人: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_field_Il1e1,pi_record_type,pi_life_status,PI_FXXKID)" +
+                                        "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_6OcTn__c")==null?"":dataList.get(i).get("field_6OcTn__c"))+"','"+dataList.get(i).get("field_Il1e1__c")+"','"+recordType+"','"+lifeStatus+"','"+_id+"')";
+                                        "'"+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);
                                 //样品申请明细下载
                                 syncSampleApplyDetail(_id.toString(),pi_id,MAUser);
@@ -162,7 +169,6 @@ public class SampleApplyTask {
                             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") + "'");
 
-                            //客户联系人:pi_purposename 电话:pi_expresscode
                             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"))+"'," +

+ 0 - 68
src/main/java/com/uas/eis/task/ScheduleTask.java

@@ -1,68 +0,0 @@
-package com.uas.eis.task;
-
-import com.uas.eis.service.ScheduleTaskService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-
-/**
- * @author koul
- * @email koul@usoftchina.com
- * @date 2021-12-23 15:27
- */
-@Component("scheduleTask")
-public class ScheduleTask {
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    @Autowired
-    private ScheduleTaskService scheduleTaskService;
-
-
-    /**
-     * 同步物料资料
-     */
-    public void syncProducts() {
-        logger.info("同步物料资料开始");
-        Date date = new Date();
-        scheduleTaskService.syncProducts();
-        logger.info("同步物料资料结束:用时" + ((System.currentTimeMillis() - date.getTime()) / 1000));
-
-    }
-
-    /**
-     * 同步工单
-     */
-    public void syncMakeBases() {
-        logger.info("同步工单开始");
-        Date date = new Date();
-        scheduleTaskService.syncMakeBases();
-        logger.info("同步工单结束:用时" + ((System.currentTimeMillis() - date.getTime()) / 1000));
-
-    }
-
-    /**
-     * 同步工单BOM
-     */
-    public void syncMakeBaseDetails() {
-        logger.info("同步工单BOM开始");
-        Date date = new Date();
-        scheduleTaskService.syncMakeBaseDetails();
-        logger.info("同步工单BOM:用时" + ((System.currentTimeMillis() - date.getTime()) / 1000));
-
-    }
-
-    /**
-     * 同步替代料
-     */
-    public void syncMakematerialReplace() {
-        logger.info("同步替代料开始");
-        Date date = new Date();
-        scheduleTaskService.syncMakematerialReplace();
-        logger.info("同步替代料:用时" + ((System.currentTimeMillis() - date.getTime()) / 1000));
-
-    }
-
-}

+ 11 - 0
src/main/java/com/uas/eis/utils/Configuration.java

@@ -55,6 +55,17 @@ public class Configuration {
     @Value("${fs.openUserId}")
     private String openUserId;
 
+    @Value("${spring.datasource.username}")
+    private String username;
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
     public String getAppId() {
         return appId;
     }