ソースを参照

内网签约居民同步线程改造

huangwenjie 7 年 前
コミット
08b6414e0c

+ 8 - 7
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadNewSignThread.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.sign.common.thread;
package com.yihu.wlyy.sign.common.thread;
import com.yihu.wlyy.sign.common.util.DateUtil;
import com.yihu.wlyy.sign.common.util.SpringContextHolder;
import com.yihu.wlyy.sign.common.util.SpringContextHolder;
import com.yihu.wlyy.sign.service.SignZYService;
import com.yihu.wlyy.sign.service.SignZYService;
import com.yihu.wlyy.sign.service.SystemDictService;
import com.yihu.wlyy.sign.service.SystemDictService;
@ -28,8 +29,8 @@ public class LoadNewSignThread implements Runnable {
                Date now = new Date();
                Date now = new Date();
                //判断非空闲时候
                //判断非空闲时候
                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)
                {
//                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)
//                {
                    //签约更新
                    //签约更新
                    SignZYService signZYService = (SignZYService) SpringContextHolder.getSpringBean("SignZYService");
                    SignZYService signZYService = (SignZYService) SpringContextHolder.getSpringBean("SignZYService");
                    SystemDictService systemDictService = (SystemDictService) SpringContextHolder.getSpringBean("SystemDictService");
                    SystemDictService systemDictService = (SystemDictService) SpringContextHolder.getSpringBean("SystemDictService");
@ -37,7 +38,7 @@ public class LoadNewSignThread implements Runnable {
                    {
                    {
                        Boolean running = systemDictService.getLoadRunning();
                        Boolean running = systemDictService.getLoadRunning();
                        if(running) {
                        if(running) {
                            //System.out.print(DateUtil.dateToStrLong(now) + " 开始采集新增签约...\r\n");
                            System.out.print(DateUtil.dateToStrLong(now) + " 开始采集新增签约...\r\n");
                            try {
                            try {
                                signZYService.loadNewSignFamilyThread();
                                signZYService.loadNewSignFamilyThread();
                            }
                            }
@ -46,7 +47,7 @@ public class LoadNewSignThread implements Runnable {
                                e.printStackTrace();
                                e.printStackTrace();
                            }
                            }
                            //System.out.print(DateUtil.dateToStrLong(new Date()) + " 采集新增签约结束。\r\n");
                            System.out.print(DateUtil.dateToStrLong(new Date()) + " 采集新增签约结束。\r\n");
                        }
                        }
                        continue;
                        continue;
@ -55,9 +56,9 @@ public class LoadNewSignThread implements Runnable {
                        Thread.sleep(retryTime);
                        Thread.sleep(retryTime);
                        continue;
                        continue;
                    }
                    }
                }
                Thread.sleep(sleepTime);
//                }
//
//                Thread.sleep(sleepTime);
            } catch (Exception ex) {
            } catch (Exception ex) {
                ex.printStackTrace();
                ex.printStackTrace();
                try {
                try {

+ 6 - 6
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadThread.java

@ -29,8 +29,8 @@ public class LoadThread implements Runnable {
                Date now = new Date();
                Date now = new Date();
                //判断非空闲时候
                //判断非空闲时候
                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)
                {
//                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)
//                {
                    //签约更新
                    //签约更新
                    SignZYService signZYService = (SignZYService) SpringContextHolder.getSpringBean("SignZYService");
                    SignZYService signZYService = (SignZYService) SpringContextHolder.getSpringBean("SignZYService");
                    SystemDictService systemDictService = (SystemDictService) SpringContextHolder.getSpringBean("SystemDictService");
                    SystemDictService systemDictService = (SystemDictService) SpringContextHolder.getSpringBean("SystemDictService");
@ -51,16 +51,16 @@ public class LoadThread implements Runnable {
                            System.out.print(DateUtil.dateToStrLong(new Date()) + " 采集签约结束。\r\n");
                            System.out.print(DateUtil.dateToStrLong(new Date()) + " 采集签约结束。\r\n");
                        }
                        }
                        Thread.sleep(sleepTime*1000);//间隔三分钟
                        Thread.sleep(sleepTime*1000);//间隔3分钟
                        continue;
                        continue;
                    }
                    }
                    else{
                    else{
                        Thread.sleep(retryTime);
                        Thread.sleep(retryTime);
                        continue;
                        continue;
                    }
                    }
                }
                Thread.sleep(sleepTime*1000);
//                }
//
//                Thread.sleep(sleepTime*1000);
            } catch (Exception ex) {
            } catch (Exception ex) {
                ex.printStackTrace();
                ex.printStackTrace();
                try {
                try {

+ 3 - 2
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/UploadRenewThread.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.sign.common.thread;
package com.yihu.wlyy.sign.common.thread;
import com.yihu.wlyy.sign.common.util.DateUtil;
import com.yihu.wlyy.sign.common.util.SpringContextHolder;
import com.yihu.wlyy.sign.common.util.SpringContextHolder;
import com.yihu.wlyy.sign.service.SignRenewZYService;
import com.yihu.wlyy.sign.service.SignRenewZYService;
import com.yihu.wlyy.sign.service.SystemDictService;
import com.yihu.wlyy.sign.service.SystemDictService;
@ -35,7 +36,7 @@ public class UploadRenewThread implements Runnable {
                {
                {
                    Boolean running = systemDictService.getUploadRenewRunning();
                    Boolean running = systemDictService.getUploadRenewRunning();
                    if(running) {
                    if(running) {
                        //System.out.print(DateUtil.dateToStrLong(now) + " 开始上传续签记录...\r\n");
                        System.out.print(DateUtil.dateToStrLong(now) + " 开始上传续签记录...\r\n");
                        try {
                        try {
                            service.uploadRenewSignFamily();
                            service.uploadRenewSignFamily();
                        }
                        }
@ -44,7 +45,7 @@ public class UploadRenewThread implements Runnable {
                            e.printStackTrace();
                            e.printStackTrace();
                        }
                        }
                        //System.out.print(DateUtil.dateToStrLong(new Date()) + " 上传续签记录结束。\r\n");
                        System.out.print(DateUtil.dateToStrLong(new Date()) + " 上传续签记录结束。\r\n");
                    }
                    }
                    Thread.sleep(sleepTime);
                    Thread.sleep(sleepTime);

+ 7 - 3
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/SignRenewZYService.java

@ -355,7 +355,7 @@ public class SignRenewZYService {
                }
                }
                //////////////$$$$$ 20170616 hzp 特殊写死 /////////////////////////////////////
                //////////////$$$$$ 20170616 hzp 特殊写死 /////////////////////////////////////
                String signYear = "2017";
	            String signYear = "2018";
                /*map.get("SIGN_YEAR");
                /*map.get("SIGN_YEAR");
                if(signYear.length()!=4)
                if(signYear.length()!=4)
                {
                {
@ -879,7 +879,7 @@ public class SignRenewZYService {
                String patientBirthday = map.get("BIRTHDAY");  //患者生日
                String patientBirthday = map.get("BIRTHDAY");  //患者生日
                String patientCardNo = map.get("CARD_NO");  //患者社保卡号
                String patientCardNo = map.get("CARD_NO");  //患者社保卡号
                ////////////// 20170616 hzp 特殊写死 $$$$$/////////////////////////////////////
                ////////////// 20170616 hzp 特殊写死 $$$$$/////////////////////////////////////
                String signYear = "2017";//map.get("SIGN_YEAR"); //签约年份
                String signYear = "2018";//map.get("SIGN_YEAR"); //签约年份
                //社保卡号过长存-1
                //社保卡号过长存-1
                if(!StringUtil.isEmpty(patientCardNo) && patientCardNo.length()>20)
                if(!StringUtil.isEmpty(patientCardNo) && patientCardNo.length()>20)
                {
                {
@ -1627,7 +1627,11 @@ public class SignRenewZYService {
                } else {
                } else {
                    log.setNeedUpload("1");
                    log.setNeedUpload("1");
                }
                }
                log.setUploadLog(content + "\r\n" + msg);
                String errorMsg = content + "\r\n" + msg;
                if(errorMsg.length() > 4000){
                    errorMsg = errorMsg.substring(0,3990);
                }
                log.setUploadLog(errorMsg);
            }
            }
            else //成功
            else //成功
            {
            {

+ 53 - 16
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/SignZYService.java

@ -339,7 +339,7 @@ public class SignZYService {
        String msg = "";
        String msg = "";
        SignFamily sign = null;
        SignFamily sign = null;
        //**续签对接临时方案***
        //**续签对接临时方案***
        if(!"2017".equals(signYear))
        if(!"2018".equals(signYear))
        {
        {
            return false;
            return false;
        }
        }
@ -1215,15 +1215,28 @@ public class SignZYService {
     */
     */
    public void loadSignFamilyThread() throws Exception
    public void loadSignFamilyThread() throws Exception
    {
    {
        String startTime =  systemDictService.getLoadSignTime();   //上次执行时间
        /*Date start = DateUtil.getNextMin(DateUtil.strToDate(startTime), -1);   //重复采集前1分钟
        startTime = DateUtil.dateToStrLong(start);*/
        String endTime = DateUtil.dateToStrLong(new Date());
        System.out.print(DateUtil.getCurrentString()+ " update sign family start..");
        loadSignFamilyBatch(startTime, endTime);
        Date end = new Date();
        do {
            String startTime =  systemDictService.getLoadSignTime();   //上次执行时间
            Date start = DateUtil.getNextMin(DateUtil.strToDate(startTime), -1);   //重复采集前1分钟
            startTime = DateUtil.dateToStrLong(start);
    
            String endTime = DateUtil.dateToStrLong(new Date());
    
            System.out.println("采集时间:start="+startTime);
    
            end = DateUtil.getNextMin(DateUtil.strToDate(startTime), 30);//采集30分钟后的数据
            
            if(end.before(new Date())){
                endTime = DateUtil.dateToStrLong(end);
            }
            System.out.print(DateUtil.getCurrentString()+ " update sign family start..");
            loadSignFamilyBatch(startTime, endTime);
    
            //更新下次采集签约时间
            systemDictService.saveLoadSignTime(endTime);
        //更新下次采集签约时间
        systemDictService.saveLoadSignTime(endTime);
        }while (end.before(new Date()));
    }
    }
    /**
    /**
@ -1231,15 +1244,39 @@ public class SignZYService {
     */
     */
    public void loadNewSignFamilyThread() throws Exception
    public void loadNewSignFamilyThread() throws Exception
    {
    {
    
        Date end = new Date();
//        do {
        String startTime =  systemDictService.getLoadNewSignTime();   //上次执行时间
        String startTime =  systemDictService.getLoadNewSignTime();   //上次执行时间
        Date start = DateUtil.getNextMin(DateUtil.strToDate(startTime), -1);   //重复采集前1分钟
        Date start = DateUtil.getNextMin(DateUtil.strToDate(startTime), -1);   //重复采集前1分钟
        startTime = DateUtil.dateToStrLong(start);
        startTime = DateUtil.dateToStrLong(start);
    
        String endTime = DateUtil.dateToStrLong(new Date());
        String endTime = DateUtil.dateToStrLong(new Date());
    
        System.out.println("采集时间:start="+startTime);
    
        end = DateUtil.getNextMin(DateUtil.strToDate(startTime), 30);//采集30分钟后的数据
    
        if(end.before(new Date())){
            endTime = DateUtil.dateToStrLong(end);
        }
        System.out.println("采集时间:end="+endTime);
        loadNewSignFamilyBatch(startTime,endTime);
        loadNewSignFamilyBatch(startTime,endTime);
        //更新下次采集签约时间
        //更新下次采集签约时间
        systemDictService.saveLoadNewSignTime(endTime);
        systemDictService.saveLoadNewSignTime(endTime);
        
//        }while (end.before(new Date()));
        
//        String startTime =  systemDictService.getLoadNewSignTime();   //上次执行时间
//        Date start = DateUtil.getNextMin(DateUtil.strToDate(startTime), -1);   //重复采集前1分钟
//        startTime = DateUtil.dateToStrLong(start);
//        String endTime = DateUtil.dateToStrLong(new Date());
//
//        loadNewSignFamilyBatch(startTime,endTime);
//
//        //更新下次采集签约时间
//        systemDictService.saveLoadNewSignTime(endTime);
    }
    }
    /************************************* 公开接口 ************************************************/
    /************************************* 公开接口 ************************************************/
@ -1663,18 +1700,18 @@ public class SignZYService {
                        total += htotal;
                        total += htotal;
                        error += herror;
                        error += herror;
                    }
                    }
                    //System.out.print(startTime +"~" + endTime +"【"+hm.getName()+"】总采集"+htotal+"条,失败"+herror+"条。");
                    System.out.print("遍历机构更新签约数据   (更新)"+startTime +"~" + endTime +"【"+hm.getName()+"】总采集"+htotal+"条,失败"+herror+"条。");
                }
                }
                catch (Exception e)
                catch (Exception e)
                {
                {
                    //System.out.print(startTime +"~" + endTime +"【"+hm.getName()+"】全部采集失败。");
                    System.out.print("遍历机构更新签约数据   (更新)"+startTime +"~" + endTime +"【"+hm.getName()+"】全部采集失败。");
                }
                }
            }
            }
        }
        }
        if(error != 0)
        if(error != 0)
        {
        {
            //System.out.print(startTime +"~" + endTime +"批量更新签约数据,总条数"+total+"条,失败"+error+"条。");
            System.out.print("遍历机构更新签约数据   (更新)"+startTime +"~" + endTime +"批量更新签约数据,总条数"+total+"条,失败"+error+"条。");
        }
        }
    }
    }
@ -1723,18 +1760,18 @@ public class SignZYService {
                        total += htotal;
                        total += htotal;
                        error += herror;
                        error += herror;
                    }
                    }
                    //System.out.print(startTime +"~" + endTime +"【"+hm.getName()+"】总采集"+htotal+"条,失败"+herror+"条。");
                    System.out.print("遍历机构更新签约数据   (新增)"+startTime +"~" + endTime +"【"+hm.getName()+"】总采集"+htotal+"条,失败"+herror+"条。");
                }
                }
                catch (Exception e)
                catch (Exception e)
                {
                {
                    //System.out.print(startTime +"~" + endTime +"【"+hm.getName()+"】全部采集失败。");
                    System.out.print("遍历机构更新签约数据   (新增)"+startTime +"~" + endTime +"【"+hm.getName()+"】全部采集失败。");
                }
                }
            }
            }
        }
        }
        if(error != 0)
        if(error != 0)
        {
        {
            //System.out.print(startTime +"~" + endTime +"批量更新签约数据,总条数"+total+"条,失败"+error+"条。");
            System.out.print("遍历机构更新签约数据   (新增)"+startTime +"~" + endTime +"批量更新签约数据,总条数"+total+"条,失败"+error+"条。");
        }
        }
    }
    }