Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java
wangzhinan 5 years ago
parent
commit
f2a8d07534

+ 25 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseSuperviseDataDictDao.java

@ -0,0 +1,25 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDataDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 
 * 医生职务字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年10月19日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseSuperviseDataDictDao extends PagingAndSortingRepository<BaseSuperviseDataDict, Integer>, JpaSpecificationExecutor<BaseSuperviseDataDict>  {
    @Query("select s from BaseSuperviseDataDict s where s.status=1")
    BaseSuperviseDataDict selectByDictName();
}

+ 25 - 0
business/base-service/src/main/java/com/yihu/jw/dict/dao/BaseSuperviseDictDao.java

@ -0,0 +1,25 @@
package com.yihu.jw.dict.dao;
import com.yihu.jw.entity.base.dict.DictDoctorDutyDO;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 
 * 医生职务字典 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年10月19日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseSuperviseDictDao extends PagingAndSortingRepository<BaseSuperviseDict, Integer>, JpaSpecificationExecutor<BaseSuperviseDict>  {
    @Query("select s from BaseSuperviseDict s where s.status=1")
    BaseSuperviseDict selectByDictName();
}

+ 5 - 0
business/base-service/src/main/java/com/yihu/jw/internet/dao/HospitalImgDao.java

@ -1,11 +1,16 @@
package com.yihu.jw.internet.dao;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import com.yihu.jw.entity.hospital.jgpt.HospitalImgDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2019/11/28.
 */
public interface HospitalImgDao extends PagingAndSortingRepository<HospitalImgDO, String>, JpaSpecificationExecutor<HospitalImgDO> {
    @Query("select s from HospitalImgDO s where s.id=?1 and s.status=1")
    HospitalImgDO selectById(String id);
}

+ 1839 - 0
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetCommonService.java

@ -0,0 +1,1839 @@
package com.yihu.jw.internet.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.BaseSuperviseDataDictDao;
import com.yihu.jw.dict.dao.BaseSuperviseDictDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDataDict;
import com.yihu.jw.entity.hospital.dict.BaseSuperviseDict;
import com.yihu.jw.entity.hospital.jgpt.HospitalImgDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.internet.dao.HospitalImgDao;
import com.yihu.jw.internet.dao.IntUpErrorLogDao;
import com.yihu.jw.internet.dao.InternetUpLogDao;
import com.yihu.jw.internet.entity.InternetUpErrorLogDO;
import com.yihu.jw.internet.entity.InternetUpLogDO;
import com.yihu.jw.internet.wsapi.Wsapi;
import com.yihu.jw.internet.wsapi.WsapiProxy;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.ImgUtils;
import com.yihu.jw.utils.JSONUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.encode.AESUtils;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import nu.xom.jaxen.function.IdFunction;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedCaseInsensitiveMap;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service
public class InternetCommonService extends BaseJpaService<InternetUpErrorLogDO, IntUpErrorLogDao> {
    private org.slf4j.Logger logger = LoggerFactory.getLogger(InternetCommonService.class);
    @Autowired
    private InternetUpErrorLogService internetUpErrorLogService;
    @Autowired
    private InternetUpLogDao internetUpLogDao;
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfs_file_url;
    @Autowired
    private HospitalImgDao hospitalImgDao;
    @Autowired
    private WlyyHospitalSysDictDao dictDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseSuperviseDictDao superviseDictDao;
    @Autowired
    private BaseSuperviseDataDictDao superviseDataDictDao;
    public String userName ;
    public String psw ;
    public String appId ;
    public String AesEncodeKey ;
    public String urlString;  // 正式线路径
 //   static String urlString = "http://fjhlw.bsoft.com.cn:18081/micc/wsapi/1.0?wsdl";   // 测试线路径
    public String method;
    public String token;
    public String orgCode;
    public String orgName;
    public String orgArea;
    public String orgSub ;
    public String imgUrl;
    static String imgPath =File.separator+"usr"+File.separator+"local"+File.separator+"hospital"+File.separator+"svr-internet-hospital-job"+File.separator+"img"+File.separator;
    public ObjectMapper objectMapper;
    public void getBaseSurperviseDict(){
        BaseSuperviseDict superviseDict = superviseDictDao.selectByDictName();
        userName=superviseDict.getUserName();
        psw=superviseDict.getPsw();
        appId=superviseDict.getAppId();
        AesEncodeKey = superviseDict.getAesEncodeKey();
        method = superviseDict.getMethod();
        token = superviseDict.getToken();
        orgArea=superviseDict.getOrgArea();
        orgCode = superviseDict.getOrgCode();
        orgName=superviseDict.getOrgName();
        orgSub=superviseDict.getOrgSub();
        imgUrl=superviseDict.getImgUrl();
    }
    /**
     * 监管平台上传地址
     * @return
     */
    public String getUrl(){
        return dictDao.findByDictName("dataUpload").get(0).getDictCode();
    }
    public String getImUrl(){
        return dictDao.findByDictName("imData").get(0).getDictCode();
    }
    // 0 调用省监管平台接口
    public String postToInter(String token, String api, JSONArray params,String url) throws Exception {
        getBaseSurperviseDict();
        WsapiProxy proxy = new WsapiProxy();
        proxy.setEndpoint(url);
        Wsapi wsapi = proxy.getWsapi();
//        logger.info("postToInter:"+JSONUtils.toString(new String[] {token, params.toString()}));
        String encryptParams = AESUtils.encrypt(JSONUtils.toString(new String[] {token, params.toString()}), AesEncodeKey);
        String result = wsapi.invoke(appId, "", api, method, encryptParams);
        String deResult = AESUtils.decrypt(result, AesEncodeKey);
        logger.info("postToInter:"+JSONUtils.toString(deResult));
        return deResult;
    }
    // 1  接口用户信息,获取TOKEN值	 micc.upNsUserToken   --- 完成
    public String upNsUserToken(String url) throws Exception {
        getBaseSurperviseDict();
        WsapiProxy proxy = new WsapiProxy();
        proxy.setEndpoint(url);
        Wsapi wsapi = proxy.getWsapi();
        String api = "micc.upNsUserToken";
        JSONObject jb = new JSONObject();
        jb.put("cd_user", userName);
        jb.put("pwd_user", psw);
        logger.info("url :"+url);
        logger.info("jb :"+jb.toString());
        String encryptParams = AESUtils.encrypt(JSONUtils.toString(new String[] { jb.toString() }), AesEncodeKey);
        String res = wsapi.invoke(appId, "", api, method, encryptParams);
        logger.info("appId :"+appId);
        logger.info("method :"+method);
        logger.info("encryptParams :"+encryptParams);
        String deResult = AESUtils.decrypt(res, AesEncodeKey);
        logger.info("AesEncodeKey :"+AesEncodeKey);
        JSONObject resJson = (JSONObject) JSONObject.parse(deResult);
        if("200".equals(resJson.get("msg").toString())) {
            token = resJson.get("token").toString();
        }
        logger.info("upNsUserToken : "+token);
        return token;
    }
    // 2  医院基本信息	micc.upNsOrganBas     --- 完成
    public String upNsOrganBas() throws Exception {
        getBaseSurperviseDict();
        BaseSuperviseDataDict superviseDataDict = superviseDataDictDao.selectByDictName();
        String url = getUrl();
        String api = "micc.upNsOrganBase";
        JSONObject jb = new JSONObject();
        jb.put("organ_code", orgCode);
        jb.put("organ_name",orgName);
        jb.put("corporation", superviseDataDict.getCorporation());
        jb.put("no_pra_lic", superviseDataDict.getNoPraLic());
        jb.put("second_organ_name", StringUtils.isNoneBlank(superviseDataDict.getSecondOrganName())?superviseDataDict.getSecondOrganName():"");
        jb.put("charge_person",StringUtils.isNoneBlank(superviseDataDict.getChargePerson())?superviseDataDict.getChargePerson():"");
        jb.put("level", superviseDataDict.getLevel());
        jb.put("economic_type", superviseDataDict.getEconomicType());
        jb.put("organ_type",superviseDataDict.getOrganType());
        jb.put("organ_sub", orgSub);
        jb.put("hospital_district",orgArea);
        jb.put("hospital_address", superviseDataDict.getHospitalAddress());
        jb.put("hospital_phone", superviseDataDict.getHospitalPhone());
     /*   jb.put("hospital_img","");*/
//        jb.put("bus_lic", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"yyzz.jpg"));
//        jb.put("corp_idcord_head", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"a.jpg"));
//        jb.put("corp_idcord_tail", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"b.jpg"));
//        jb.put("pra_lic", ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"zyxkz.jpg"));
/*        jb.put("bus_lic", null);
        jb.put("corp_idcord_head", null);
        jb.put("corp_idcord_tail", null);
        jb.put("pra_lic", null);*/
        String hospitalImg="";
        String busLic="";
        String corpIdcardHead ="";
        String corpIdcardTail="";
        String praLic="";
        HospitalImgDO hospitalImgDO=hospitalImgDao.selectById("hsimg");
        HospitalImgDO hospitalImgDO1=hospitalImgDao.selectById("zyxkz");
        HospitalImgDO hospitalImgDO2=hospitalImgDao.selectById("idcardA");
        HospitalImgDO hospitalImgDO3=hospitalImgDao.selectById("idcardB");
        if (hospitalImgDO!=null){
           hospitalImg=hospitalImgDO.getImg();
        }
        if (hospitalImgDO1!=null){
            busLic=hospitalImgDO1.getImg();
            praLic=hospitalImgDO1.getImg();
        }
        if (hospitalImgDO2!=null){
            corpIdcardHead=hospitalImgDO2.getImg();
        }
        if (hospitalImgDO3!=null){
            corpIdcardTail=hospitalImgDO3.getImg();
        }
        jb.put("hospital_img",hospitalImg );
        jb.put("bus_lic",busLic);
        jb.put("corp_idcord_head",corpIdcardHead);
        jb.put("corp_idcord_tail", corpIdcardTail);
        jb.put("pra_lic", praLic);
        jb.put("secu_level",StringUtils.isNoneBlank(superviseDataDict.getSecuLevel())?superviseDataDict.getSecuLevel():"");
        jb.put("secu_level_cert",ImgUtils.getImageStr(imgPath+"hospital"+File.separator+"dbtp.jpg"));
        jb.put("net_service", superviseDataDict.getNetService());
        jb.put("net_service_ot", "");
        jb.put("service_dept", superviseDataDict.getServiceDept());
        jb.put("txt_introduction", "");
        //用户协议
        jb.put("protocol_type", superviseDataDict.getProtocolType());
        jb.put("protocol_content", superviseDataDict.getProtocolContent());
        jb.put("publish_date",superviseDataDict.getPublishDate());
        jb.put("protocol_name", superviseDataDict.getProtocolName());
        //其他建设信息
        jb.put("quai_mang_dept", "");
        jb.put("info_mang_dept", "");
        jb.put("medi_service_dept", "");
        jb.put("server_type", "");
        jb.put("server_total", "");
        jb.put("server_ip", "");
        jb.put("mp_system_type", "");
        jb.put("mp_system_total", "");
        jb.put("tran_link", "");
        jb.put("tran_link_band", "");
        jb.put("server_system_name", "");
        jb.put("server_system_ip", "");
        jb.put("tech_manual", "");
        jb.put("server_manual", "");
        jb.put("emr_level", "");
        jb.put("emr_level_cert", "");
        jb.put("zone_record_share", "");
        jb.put("prov_monitor", "");
        jb.put("prov_service", "");
        jb.put("server_func", "");
        jb.put("third_compeny_name", "");
        jb.put("third_compeny_code", "");
        jb.put("third_compeny_cert", "");
        jb.put("third_compeny_corp", "");
        jb.put("third_compeny_corp_id", "");
        jb.put("third_compeny_prot", "");
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(jb);
        String token = upNsUserToken(url);
        String res = postToInter(token, api, jsonArray,url);
        return res;
    }
    // 3 医师基本信息	micc.upNsDoctorRecord   --- 完成
    public String upNsDoctorRecord(String keyId) throws Exception {
        getBaseSurperviseDict();
        BaseSuperviseDataDict superviseDataDict = superviseDataDictDao.selectByDictName();
        String url = getUrl();
        String api = "micc.upNsDoctorRecord";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        //  因为要上传的是医师信息,所以针对到注册用户且无部门信息的用户数据不上传
        String sql = "select " +
                "   a.id AS \"id\"," +
                "   a.name AS \"name\"," +
                "   a.idcard AS \"idcard\"," +
                "   a.sex AS \"sex\"," +
                "   a.birthday AS \"birthday\", " +
                "   a.cert_no AS \"cert_no\", " +
                "   a.prac_no AS \"prac_no\"," +
                "   a.mobile AS \"mobile\"," +
                "   b.dept_code AS \"dept_code\"," +
                "   b.dept_name AS \"dept_name\"," +
                "   a.job_title_code AS \"job_title_code\"," +
                "   a.fzrq AS \"fzrq\"" +
                "  from base_doctor a " +
                "      ,base_doctor_hospital b" +
                " where a.id = b.doctor_code" +
                "   AND b.dept_code is NOT NULL " +
                "   AND a.job_title_code is NOT NULL " +
                "   AND a.fzrq IS NOT NULL " +
                "   AND a.cert_no IS NOT NULL " +
                "   AND a.prac_no IS NOT NULL ";
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and a.id = '" + keyId + "' ";
        }
        List list = jdbcTemplate.queryForList(sql);
        total = list.size();
        for(int i=0; i<list.size(); i++){
            LinkedCaseInsensitiveMap info = (LinkedCaseInsensitiveMap)list.get(i);
            Boolean errorFlag = false;
            JSONObject jb = new JSONObject();
            try {
                String[] dept = depToSubject(info.get("dept_code").toString());
                // 中山医院 监管平台  职务字典强转
                String[] dutyInfo = classToduty(info.get("job_title_code").toString());
                jb.put("organ_code", orgCode);
                jb.put("organ_name", orgName);
                jb.put("doc_name", info.get("name")== null ? "0":info.get("name"));
                jb.put("docimg", "");
                jb.put("id_card", info.get("idcard")== null ? "0":info.get("idcard"));
                jb.put("sex", info.get("sex")== null ? "0":info.get("sex"));
                jb.put("birthday", info.get("birthday")  == null?"1900-01-01": DateUtil.dateToStrLong((Date)info.get("birthday")));
                jb.put("subject", dept[0].toString());
                jb.put("subject_name", dept[1].toString());
                jb.put("belong_dept",jb.getString("dept_code"));
                jb.put("belong_dept_name", jb.getString("dept_name"));
                jb.put("doo_tel", info.get("mobile")== null ? "":info.get("mobile"));
                jb.put("title_rec_date", getDateString(info.get("fzrq").toString()));
                jb.put("prac_type", "1");   // 因为上传的是医师的信息,所以该字段全部默认设置为 1 医师
                jb.put("title_code", dutyInfo[0].toString());  // 需要与监管平台的字典进行映射
                jb.put("first_compeny_code", orgCode);
                jb.put("first_compeny_name", orgName);
                jb.put("secd_compeny_code", "");
                jb.put("secd_compeny_name", "");
                jb.put("net_service", superviseDataDict.getDoctorNetService());
                jb.put("cert_no",  info.get("cert_no")== null ? "0":info.get("cert_no"));
                jb.put("prac_no",  info.get("prac_no")== null ? "0":info.get("prac_no"));
                //资格证书
                jb.put("doc_cert",ImgUtils.getImageStr(imgPath+"doctor"+ File.separator+info.get("name")+File.separator+"zg.jpg"));
                //执业证书
                jb.put("cert_doc_prac", ImgUtils.getImageStr(imgPath+"doctor"+ File.separator+info.get("name")+File.separator+"zy.jpg"));
                jb.put("txt_introduction",StringUtils.isNoneBlank(superviseDataDict.getTxtIntroduction())?superviseDataDict.getTxtIntroduction():"");
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"3",info.get("id").toString(),"数据格式错误",1);
                error++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                //上传监管平台
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                res = postToInter(token, api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"3",info.get("id").toString(),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"3",new Date(),new Date(),success,error,dataError,resInfo);
        return resInfo;
    }
    // 4 获取监管平台医师唯一标识	micc.achNsDoctorRecord  --- 完成
    public String achNsDoctorRecord(String idCardNo) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.achNsDoctorRecord";
        JSONObject jb = new JSONObject();
        jb.put("organ_code", orgCode);
        jb.put("organ_name", orgName);
        jb.put("id_card", idCardNo);
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(jb);
        String token = upNsUserToken(url);
        String res = postToInter(token, api, jsonArray,url);
        JSONObject rs = (JSONObject) JSONObject.parse(res);
        String msg = rs.getString("msg");
        if("200".equals(msg)){
            JSONArray reqContent = rs.getJSONArray("reqContent");
            JSONObject req = (JSONObject)reqContent.get(0);
            return req.getString("miccId");
        }
        return "";
    }
    // 5 网上预约挂号	micc.upAppointmentOnline  ----完成
    public String upAppointmentOnline(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upAppointmentOnline";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int dataError = 0;
        int error = 0;
        String token = upNsUserToken(url);
        String sql = "SELECT " +
                "   p.id AS \"id\"," +
                "   p.register_no AS \"register_no\", " +
                "   p.status AS \"status\", " +
                "   p.dept AS \"dept\", " +
                "   p.dept_name AS \"dept_name\"," +
                "   p.patient_name AS \"paName\"," +
                "   p.doctor_name AS \"docName\"," +
                "   p.idcard AS \"idcard\"," +
                "   p.register_date AS \"date\"" +
                "   FROM wlyy_outpatient p " +
                " WHERE 1=1" ;
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and p.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and p.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  p.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i< total; i++){
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try{
                String[] dept = depToSubject(info.get("dept").toString());
                jb.put("id", orgCode +"_"+ (String)info.get("id"));
                jb.put("cd_org", orgCode);
                jb.put("cd_area", orgArea);
                jb.put("cd_orgSub", orgSub);
                jb.put("reg_time", info.get("date") == null?"1900-01-01": DateUtil.dateToStrLong((Date)info.get("date")));
                jb.put("fg_visit",  fgConvent(info.get("status") == null?"-1":info.get("status").toString()));
                jb.put("reg_dep_code",  info.get("dept") == null?"0":info.get("dept"));
                jb.put("reg_dep_name",  info.get("dept_name") == null?"0":info.get("dept_name"));
                jb.put("reg_subject_code",  dept[0].toString());
                jb.put("reg_subject_name", dept[1].toString());
                jb.put("reg_price",  "0");
                jb.put("pt_name", info.get("name") == null?"0":info.get("name"));
                jb.put("ge_code",   IdCardUtil.getSexForIdcard_new(info.get("idcard").toString()));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("idcard").toString()));
                jb.put("card_type", "1");
                jb.put("id_no",  info.get("idcard") == null?"0":info.get("idcard"));
                jb.put("pt_tel",  "00000000000");
                jb.put("crt_date",DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"5",(String)info.get("id"),"网上预约挂号数据格式错误",1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"5",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"5",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 6 在线医技预约 	micc.upMedicalOnline --- 完成
    public String upMedicalOnline(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upMedicalOnline";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String sql ="SELECT " +
                " i.id AS \"id\", " +
                " i.code AS \"code\", " +
                " o.dept AS \"dept\", " +
                " o.doctor AS \"doctor\", " +
                " o.register_date AS \"register_date\", " +
                " i.create_time AS \"create_time\", " +
                " p.name AS \"name\", " +
                " p.idcard AS \"idcard\", " +
                " d.idcard AS \"doctorIdCard\"" +
                "FROM " +
                " wlyy_inspection i " +
                " JOIN wlyy_outpatient o ON o.id = i.outpatient_id  " +
                " JOIN base_patient p ON p.id = o.patient " +
                " JOIN base_doctor d ON d.id = o.doctor " +
                "WHERE " +
                " i.dept is not null" +
                " and o.register_date is not null";
        if(StringUtils.isNotBlank(keyId)){
            sql +=" and i.id = '"+keyId+"'";
        }
        if(StringUtils.isNotBlank(startDate)){
            sql +=" and i.create_time >='"+startDate+"' ";
        }
        if(StringUtils.isNotBlank(endDate)){
            sql +=" and i.create_time <='"+endDate+"' ";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list != null && list.size() > 0){
            total = list.size();
            for(Map<String,Object> ins :list ){
                JSONObject jb = new JSONObject();
                Boolean errorFlag = false;
                try {
                    String[] dept = depToSubject(ins.get("dept").toString());
                    String docInterId = achNsDoctorRecord((String)ins.get("doctorIdCard"));
                    jb.put("id",orgCode +"_"+ (String)ins.get("id"));
                    jb.put("cd_org", orgCode);
                    jb.put("cd_area", orgArea);
                    jb.put("cd_orgSub", orgSub);
                    jb.put("app_time",DateUtil.dateToStr((Date)ins.get("register_date"),"yyyy-MM-dd HH:mm:ss"));
                    jb.put("app_dep_code", dept[0].toString());
                    jb.put("app_class_code", ins.get("code"));
                    jb.put("id_doctor", docInterId);
                    jb.put("fg_handle", "1");
                    jb.put("handle_time", DateUtil.dateToStr((Date)ins.get("create_time"),"yyyy-MM-dd HH:mm:ss"));
                    jb.put("pt_name",ins.get("name").toString());
                    String sex = IdCardUtil.getSexForIdcard_new(ins.get("idcard").toString());
                    jb.put("ge_code", sex=="3"?"9":sex);
                    jb.put("card_type", "1");
                    jb.put("id_no", ins.get("idcard").toString());
                    jb.put("pt_tel", "00000000000");
                    jb.put("crt_date",DateUtil.dateToStrLong(DateUtil.getNow()));
                }catch (Exception e){
                    errorFlag = true;
                    saveErrorLog(upid,"6",(String)ins.get("id"),"在线医技预约格式错误",1);
                    dataError++;
                    logger.error(e.toString());
                }
                if(!errorFlag){
                    JSONArray jsonArray = new JSONArray();
                    jsonArray.add(jb);
                    res = postToInter(token,api, jsonArray,url);
                    JSONObject resJson = (JSONObject) JSONObject.parse(res);
                    if("200".equals(resJson.get("msg").toString())){
                        success++;
                    }else{
                        saveErrorLog(upid,"6",(String)ins.get("id "),res,2);
                        error++;
                    }
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"6",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 7 医生评价信息	micc.upNsDoctorScore  --- 完成
    public String upNsDoctorScore(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsDoctorScore";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        String sql ="SELECT " +
                " a.id AS \"id\", " +
                " a.doctor_name AS \"name\", " +
                " a.score AS \"score\", " +
                " a.patient_name AS \"patient_name\", " +
                " a.create_time AS \"create_time\", " +
                " e.content AS \"content\", " +
                " d.idcard AS \"docIdCard\" " +
                "FROM " +
                " base_evaluate_score a " +
                "JOIN base_evaluate e ON a.id = e.relation_code " +
                "JOIN base_doctor d ON d.id = a.doctor " +
                "WHERE " +
                " e.score_type = '4'";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<list.size(); i++) {
            Map<String,Object> info =list.get(i);
            Boolean errorFlag = false;
            JSONObject jb = new JSONObject();
            try{
                String interId = "";
                String idCard = info.get("docIdCard") == null ? "0":info.get("docIdCard").toString();
                if( info.get("docIdCard") == null){
                    interId = "0";
                }else {
                    interId = achNsDoctorRecord(idCard);
                }
//                String[] dept = depToSubject(info.get("dept_code").toString());
                jb.put("id",orgCode +"_"+ (String)info.get("id"));
                jb.put("id_doctor",interId == null ? "0":interId);
                jb.put("organ_code",orgCode);
                jb.put("organ_name", orgName);
                jb.put("net_service", "4");
                jb.put("net_service_name","在线复诊");
                jb.put("val_score",info.get("score") == null ? "0": info.get("score"));
                jb.put("grader",info.get("patient_name") == null ? "0": info.get("patient_name"));
                jb.put("dt_grade",DateUtil.dateToStrLong((Date)info.get("create_time")));
                jb.put("grade_content", info.get("content") == null ? "0": info.get("content"));
                jb.put("crt_date", DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"7",(String)info.get("id"),"医生评价信息格式错误",2);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"7",info.get("id").toString(),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"7",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 8 网络咨询服务信息	micc.upNsOnlineAsk  --- 完成
    public String upNsOnlineAsk(String startDate, String endDate,String keyId) throws Exception {
        String base = getImUrl();
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsOnlineAsk";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
       String sql = "SELECT\n" +
               "\ta.id as \"id\",\n" +
               "\ta.type as \"type\",\n" +
               "\tc. NAME AS \"docName\",\n" +
               "\tc.idcard AS \"docIdCard\",\n" +
               "\tc.id AS \"docId\",\n" +
               "\tb.patient AS \"patient\",\n" +
               "\tb. NAME AS \"patientName\",\n" +
               "\tb.birthday as \"birthday\",\n" +
               "\ta.czrq as \"czrq\",\n" +
               "\ta.end_time as \"end_time\",\n" +
               "\ta.symptoms as \"symptoms\",\n" +
               "\td.sex AS \"sex\",\n" +
               "\td.mobile AS \"mobile\",\n" +
               "\td.idcard AS \"patIdCard\",\n" +
               "\td.city_code AS \"city_code\",\n" +
               "\te.dept_code AS \"dept_code\",\n" +
               "\te.dept_name AS \"dept_name\",\n" +
               "\tt.id AS \"consult\" \n" +
               "FROM\n" +
               "\twlyy_consult a ,\n" +
               "\twlyy_consult_team b \n" +
               "JOIN base_doctor c ON c.id = b.doctor \n" +
               "JOIN base_patient d ON d.id = b.patient \n" +
               "JOIN base_doctor_hospital e ON e.doctor_code = b.doctor \n" +
               "JOIN "+base+".topics t ON t.id = b.consult\n" +
               "WHERE\n" +
               "\ta.id = b.consult\n" +
               " AND a.symptoms IS NOT NULL AND b.status=1 ";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.czrq >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.czrq <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            String sqlMessage="SELECT\n" +
                    "\tM.sender_name AS \"sender_name\",\n" +
                    "\tM.sender_id AS \"sender_id\",\n" +
                    "\tM.timestamp AS \"timestamp\",\n" +
                    "\tM.content AS \"content\",\n" +
                    "\tM.content_type AS \"content_type\",\n" +
                    "\tT.id AS \"id\",\n" +
                    "\tM.sender_id AS \"session_id\"\n" +
                    "FROM\n" +
                    "\t"+base+".topics T\n" +
                    "JOIN "+base+".muc_messages M ON M.sender_id = T.session_id\n" +
                    "AND M.timestamp >= T.create_time\n" +
                    "AND M.timestamp <= T.end_time\n" +
                    "AND T.id='"+info.get("consult").toString()+"' "+
                    " ORDER BY\n" +
                    "\tM.timestamp ASC";
        /*    String sqlMessage = "SELECT m.sender_name AS \"sender_name\", m.`timestamp` AS \"timestamp\", m.content AS  \"content\", t.id AS \"id\"  FROM topics t " +
                    "JOIN muc_messages m ON m.session_id = t.session_id AND m.`timestamp` >= t.create_time AND m.`timestamp` <= t.end_time " +
                    "AND t.id = '"+info.get("consult").toString()+"' ORDER BY m.`timestamp` ASC";*/
            List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sqlMessage);
            String content="";
            JSONArray array = new JSONArray();
            for (Map<String,Object> map:list1){
                String sql1= "SELECT\n" +
                        "\ts.participant_id as \"participant_id\" \n" +
                        "FROM\n" +
                        "\t"+base+".PARTICIPANTS s \n" +
                        "WHERE\n" +
                        "\t s.SESSION_ID = '"+map.get("session_id").toString()+"' AND S.participant_id<> '"+map.get("sender_id").toString()+"'";
                List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql1);
                JSONObject object =new JSONObject();
                if (list2!=null&&list2.size()!=0){
                    Map<String,Object> map1 = list2.get(0);
                    BaseDoctorDO doctorDO = doctorDao.findById(map1.get("participant_id").toString());
                    if (doctorDO!=null){
                        object.put("receiver",doctorDO.getName());
                    }else {
                        BasePatientDO patientDO = patientDao.findById(map1.get("participant_id").toString());
                        object.put("receiver",patientDO.getName());
                    }
                }
                object.put("sender",map.get("sender_name"));
                object.put("msg",map.get("content"));
                object.put("msg_type",map.get("content_type"));
                object.put("send_time",DateUtil.dateToStr(DateUtil.strToDate(map.get("timestamp").toString(),"yyyy-MM-dd HH:mm:ss"),"yyyy-MM-dd HH:mm:ss"));
                array.add(object);
            }
            info.put("content",array.toJSONString());
        }
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                //基于科室转换成国家诊疗科目代码
                String[] dept = depToSubject(info.get("dept_code").toString());
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord((String)info.get("docIdCard"));
                jb.put("id_online_ask", orgCode+"_"+(String)info.get("id"));
                jb.put("net_service_code", "1");
                jb.put("med_class_code", info.get("type"));
                jb.put("med_pop_code", "1");
                jb.put("org_name",orgName);
                jb.put("org_code", orgCode);
                jb.put("cd_orgSub", orgSub);
                jb.put("cd_area", orgArea);
                jb.put("visit_doc_name",  info.get("docName")== null? "0":info.get("docName"));
                jb.put("visit_doc_id_no",  info.get("docIdCard")== null? "0":info.get("docIdCard"));
                jb.put("visit_doc_code",  visitDocCode);
                jb.put("visit_dept_code", info.get("dept_code") == null?"0":info.get("dept_code"));
                jb.put("visit_dept_name", info.get("dept_name") == null?"0":info.get("dept_name"));
                jb.put("pt_no", info.get("patientName")== null? "0":info.get("patientName"));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("patIdCard").toString()));
                jb.put("cost_type", "");
                jb.put("pt_birthdate", info.get("birthday") == null? "":DateUtil.dateToStrShort((Date)info.get("birthday")));
                jb.put("ge_code", info.get("sex")== null? "0":info.get("sex"));
                jb.put("pt_tel",info.get("mobile") == null ? "0":info.get("mobile"));
                jb.put("card_type", "1");
                jb.put("id_no", info.get("patIdCard")== null? "0":info.get("patIdCard"));
                jb.put("pt_district",info.get("city_code") == null?"":info.get("city_code"));
                jb.put("apply_time", info.get("czrq")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_time", info.get("czrq")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("czrq")));
                jb.put("visit_finish_time", info.get("end_time")==null?"1900-01-01":DateUtil.dateToStrLong((Date)info.get("end_time")));
                jb.put("complaint_content", info.get("content"));
                String procFile="";
                if (info.get("content")!=null){
                    JSONArray array = JSONArray.parseArray(info.get("content").toString());
                    for (int j=0;j<array.size();j++){
                        String type = array.getJSONObject(j).getString("content_type");
                        if (type.equalsIgnoreCase("3")||type.equalsIgnoreCase("12")){
                            procFile=imgUrl+array.getJSONObject(j).getString("content");
                            break;
                        }
                    }
                }
                jb.put("proc_file", procFile);
                jb.put("price", 0);
                jb.put("fg_reply", "1");
                jb.put("crt_time", DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"8",(String)info.get("id"),"网络咨询服务信息格式错误",2);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                String str = jb.toJSONString();
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"8",info.get("id").toString(),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"8",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return null;
    }
    // 9 网络诊疗服务信息 	micc.upNsOnlineMed
    public String upNsOnlineMed(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsOnlineMed";
        String upid = getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        String sql = "select " +
                "       a.id AS \"id\"," +
                "       a.register_no AS \"register_no\", " +
                "       a.type AS \"type\", " +
                "       b.id AS \"docId\", " +
                "       a.doctor_name AS \"doctor_name\", " +
                "       b.idcard AS \"docIdCard\"," +
                "       a.dept AS \"dept\", " +
                "       a.dept_name AS \"dept_name\", " +
                "       c.name AS \"paName\", " +
                "       c.idcard AS \"paId\", " +
                "       c.sex AS \"sex\"," +
                "       c.mobile AS \"mobile\"," +
                "       a.create_time AS \"create_time\"," +
                "       b.charge_type AS \"charge_type\"," +
                "       a.register_date AS \"register_date\", " +
                "       a.end_time AS \"end_time\"," +
                "       a.icd10 AS \"icd10\"," +
                "       a.icd10_name AS \"icd10_name\"," +
                "       a.origin_adm_no AS \"origin_adm_no\"," +
                "       a.card_no AS \"card_no\", " +
                "       a.description AS \"description\"" +
                "  from wlyy_outpatient a " +
                "      join base_doctor b on b.id = a.doctor" +
                "      join base_patient c on c.id = a.patient" +
                " where a.register_no is NOT NULL and a.dept is not null " +
                " and a.register_date is not null " ;
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<list.size(); i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                //基于科室转换成国家诊疗科目代码
                String[] dept = depToSubject(info.get("dept").toString());
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord((String)info.get("docIdCard"));
//                String visitDocCode = achNsDoctorRecord("350102198005012428");
                jb.put("id_online_med", orgCode +"_"+ (String)info.get("id"));
                jb.put("net_service_code", "4");
                jb.put("med_class_code", info.get("type")== ""?"1":info.get("type"));
                jb.put("org_name", orgName);
                jb.put("org_code", orgCode);
                jb.put("cd_orgSub",orgSub);
                jb.put("cd_area",orgArea);
                jb.put("visit_doc_name",  info.get("doctor_name"));
                jb.put("visit_doc_id_no", info.get("docIdCard"));
                jb.put("visit_doc_code", visitDocCode);
                jb.put("visit_subject_code", dept[0].toString());
                jb.put("visit_ subject _name",dept[1].toString());
                jb.put("visit_dept_code", info.get("dept"));
                jb.put("visit_dept_name", info.get("dept_name"));
                jb.put("pt_no", info.get("paName"));
                jb.put("pt_age", IdCardUtil.getAgeForIdcard(info.get("paId").toString()));
//                jb.put("cost_type", info.get("charge_type").toString());
                jb.put("cost_type", "");
                jb.put("pt_birthdate", null);
                String sex = IdCardUtil.getSexForIdcard_new(info.get("paId").toString());
                jb.put("ge_code", sex=="3"?"9":sex);
                jb.put("pt_tel", info.get("moble")==null?"00000000000":info.get("moble").toString());
                jb.put("card_type", "1");
                jb.put("id_no", info.get("paId"));
                jb.put("pt_district", "");
                jb.put("pt_card_type", "");
                jb.put("pt_card_no",info.get("card_no"));
                Date createTime = (Date) info.get("create_time");
                jb.put("apply_time", DateUtil.dateToStr(createTime,"yyyy-MM-dd HH:mm:ss"));
                Date date = (Date) info.get("register_date");
                jb.put("visit_time", DateUtil.dateToStr(date,"yyyy-MM-dd HH:mm:ss"));
                String dateStr = DateUtil.dateToStr(DateUtil.getPreDays(date,1),"yyyy-MM-dd");
                jb.put("visit_finish_time", dateStr+" 00:00:00");
                jb.put("old_diag_code", "");
                jb.put("old_diag_name", "");
                jb.put("diag_code",info.get("icd10"));
                jb.put("diag_name", info.get("icd10_name"));
                jb.put("diseases_type", info.get("origin_adm_no") == null ? "1":"2");
                jb.put("complaint_content", info.get("paName").toString()+DateUtil.dateToStr(date,"yyyy-MM-dd HH:mm:ss")+info.get("description").toString()+"\n");
                jb.put("proc_file", "");
                jb.put("price","0");
                jb.put("fg_reply", "");
                jb.put("crt_time", DateUtil.dateToStrLong(DateUtil.getNow()));
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"9",(String)info.get("id"),"网络诊疗服务信息格式错误",1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"9",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"9",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 10 电子处方表 micc.upPrescription    --- 完成
    public String upPrescription(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upPrescription";
        String upid =getCode();
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String token = upNsUserToken(url);
        String sql = "select " +
                "  a.id AS \"id\"," +
                "  a.real_order AS \"real_order\"," +
                "  a.patient_code AS \"patient_code\"," +
                "  a.outpatient_id AS \"outpatient_id\"," +
                "  a.patient_name AS \"patient_name\"," +
                "  b.idcard AS \"idcard\"," +
                "  b.city_code AS \"city_code\"," +
                "  a.hospital AS \"hospital\"," +
                "  a.hospital_name AS \"hospital_name\"," +
                "  p.icd10 AS \"icd10\"," +
                "  p.icd10_name AS \"icd10_name\"," +
                "  p.dept AS \"dept\"," +
                "  p.dept_name AS \"dept_name\"," +
                "  a.doctor AS \"doctor\"," +
                "  a.doctor_name AS \"doctor_name\"," +
                "  a.his_register_fee AS \"his_register_fee\"," +
                "  c.idcard AS \"docIdcard\"" +
                "  from  wlyy_prescription a" +
                "     JOIN base_patient b on a.patient_code = b.id " +
                "     JOIN base_doctor c on a.doctor = c.id " +
                "     JOIN wlyy_outpatient p on p.id = a.outpatient_id  " +
                "  where  c.idcard is not null  and a.real_order is not null and p.icd10 is not null ";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and a.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and a.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                //基于科室转换成国家诊疗科目代码
                String[] dept = depToSubject(info.get("dept").toString());
                // 获取监管平台唯一标识
                String visitDocCode = achNsDoctorRecord(info.get("docIdcard").toString());
                jb.put("id_prescription", orgCode +"_"+ (String)info.get("id"));
                jb.put("pres_no",info.get("real_order")== null?"0":info.get("real_order"));
                jb.put("pres_class_code", "1");
                jb.put("pres_class_name", "西药");
                jb.put("pt_id", info.get("patient_code"));
                jb.put("med_rd_no", info.get("outpatient_id"));
                jb.put("med_class_code", "4");
                jb.put("med_class_name", "在线复诊");
                jb.put("pt_no", info.get("patient_name"));
                jb.put("ge_code", info.get("sex")== null?"0": info.get("sex"));
                jb.put("pt_age",IdCardUtil.getAgeForIdcard(info.get("idcard").toString()));
                jb.put("birthday", info.get("birthday")  == null?"": DateUtil.dateToStrLong((Date)info.get("birthday")));
                jb.put("card_type", "1");
                jb.put("id_no", info.get("idcard"));
                jb.put("guarder_name", "");
                jb.put("guarder_no", "");
                jb.put("pt_tel",info.get("mobile") == null?"": info.get("mobile"));
                jb.put("pt_district", info.get("city_code")== null?"": info.get("city_code"));
                jb.put("allergic_history", "");
                jb.put("cost_type", "");
                jb.put("ins_class_code", "");
                jb.put("ins_class_name", "");
                jb.put("org_code", orgCode);
                jb.put("org_name",orgName);
                jb.put("pres_subject_code", dept[0].toString());
                jb.put("pres_subject_name", dept[1].toString());
                jb.put("pres_dept_code", info.get("dept")== null?"0":info.get("dept"));
                jb.put("pres_dept_name",info.get("dept_name")== null?"0":info.get("dept_name"));
                jb.put("pres_time", info.get("create_time")== null?"1900-01-01 00:00:00":DateUtil.dateToStrLong((Date)info.get("create_time")));
                jb.put("pres_doc_code", visitDocCode);
                jb.put("pres_doc_name", info.get("doctor_name")== null?"0":info.get("doctor_name"));
                jb.put("pres_doc_id_no", info.get("docIdcard")== null?"0":info.get("docIdcard"));
                jb.put("trial_doc_code", visitDocCode);
                jb.put("trial_doc_name", info.get("doctor_name")== null?"0":info.get("doctor_name"));
                jb.put("trial_doc_id_no",info.get("docIdcard")== null?"0":info.get("docIdcard"));
                jb.put("diag_code", info.get("icd10"));
                jb.put("diag_name", info.get("icd10_name"));
                jb.put("diseases_type", "0");
                jb.put("mobility_flag", "3");
                jb.put("long_medical_flag", "3");
                jb.put("pres_effec_days", 0);
                jb.put("total_price",info.get("his_register_fee")== null?  0 : info.get("his_register_fee"));
                jb.put("upload_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
                jb.put("pres_photo", "");
                jb.put("pres_photos_list", "");
                jb.put("pres_photos", "");
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"10",(String)info.get("id"),"电子处方表格式错误",1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"10",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条";
        saveUpLog(upid,"10",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 11 电子处方_药品明细表	micc.upPrescriptionDrug     --- 完成
    public String upPrescriptionDrug(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upPrescriptionDrug";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String sql = "select " +
                "    b.real_order AS \"real_order\"," +
                "    a.id AS \"id\", " +
                "    a.prescription_id AS \"prescription_id\", " +
                "    a.drug_no AS \"drug_no\"," +
                "    a.drug_name AS \"drug_name\", " +
                "    a.dosage AS \"dosage\"," +
                "    a.unit AS \"unit\"," +
                "    a.quantity AS \"quantity\"," +
                "    a.pack_unit AS \"pack_unit\"," +
                "    a.usage_code AS \"usage_code\"," +
                "    a.supply_code AS \"supply_code\"," +
                "    a.specification AS \"specification\"," +
                "    a.pack_retprice AS \"pack_retprice\"," +
                "    a.pack_retprice AS \"drug_total_price\"" +
                "  from wlyy_prescription_info a " +
                "     JOIN wlyy_prescription b " +
                "     on b.id = a.prescription_id" +
                "  where  a.dosage is not null and b.real_order is not null";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and b.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and b.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  a.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            JSONObject jb = new JSONObject();
            Boolean errorFlag = false;
            try {
                jb.put("id_prescription_drug",orgCode +"_"+ (String)info.get("id"));
                jb.put("pres_no", info.get("real_order") == null? "0": info.get("real_order"));
                jb.put("org_code",orgCode);
                jb.put("appr_drug_code", info.get("drug_no") == null? "0": info.get("drug_no"));
                jb.put("appr_drug_name", info.get("drug_name") == null? "0": info.get("drug_name"));
                jb.put("drug_code", "");
                jb.put("drug_name", "");
                jb.put("drug_form", "");
                jb.put("dosage",info.get("dosage") == null? 0: info.get("dosage"));
                jb.put("dosage_unit", info.get("unit") == null? "0": info.get("unit"));
                jb.put("total_dosage", info.get("quantity") == null? 0: info.get("quantity"));
                jb.put("total_dosage_unit", info.get("pack_unit") == null? "0": info.get("pack_unit"));
                jb.put("medicine_freq", info.get("usage_code") == null? "0": info.get("usage_code"));
                jb.put("drug_use", info.get("supply_code") == null? "0": info.get("supply_code"));
                jb.put("standard_desc", info.get("specification") == null? "0": info.get("specification"));
                jb.put("single_price",info.get("pack_retprice") == null? 0: info.get("pack_retprice"));
                BigDecimal pack_retprice = (BigDecimal)info.get("pack_retprice");
                Long quantity = Long.parseLong((String)info.get("quantity"));
                Double price = pack_retprice.doubleValue()*quantity;
                jb.put("drug_total_price",price);
                jb.put("comments", "");
                jb.put("anti_comments", "");
                jb.put("dec_meth_name", "");
            }catch (Exception e){
                errorFlag = true;
                saveErrorLog(upid,"11",(String)info.get("id"),res,1);
                dataError++;
                logger.error(e.toString());
            }
            if(!errorFlag){
                JSONArray jsonArray = new JSONArray();
                jsonArray.add(jb);
                res = postToInter(token,api, jsonArray,url);
                JSONObject resJson = (JSONObject) JSONObject.parse(res);
                if("200".equals(resJson.get("msg").toString())){
                    success++;
                }else{
                    saveErrorLog(upid,"11",(String)info.get("id"),res,2);
                    error++;
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"11",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 12.在线诊疗服务信息-过程图片上传     --- 完成
    public String upNsOnlineImg(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsOnlineImg";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        String sql = "SELECT " +
                "   p.id AS \"id\"," +
                "   p.disease_img AS \"disease_img\" " +
                " FROM wlyy_outpatient p " +
                " WHERE p.disease_img is not null ";
        Map<String,Object> params = new HashedMap();
        if(StringUtils.isNotBlank(startDate)){
            sql =  sql + "  and p.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            sql =  sql +  "  and p.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(keyId)){
            sql =  sql +  "  and  p.id =:keyId ";
            params.put("keyId",keyId);
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        total = list.size();
        for(int i=0; i<total; i++) {
            Map<String,Object> info = list.get(i);
            String pathimg[] = ((String)info.get("disease_img")).split(",");
            if(pathimg!=null&&pathimg.length>0){
                for(String img:pathimg){
                    JSONObject jb = new JSONObject();
                    Boolean errorFlag = false;
                    try {
                        jb.put("id_online_img",getCode());
                        jb.put("id_onlne_base", orgCode+"_"+info.get("id"));
                        jb.put("online_type","2");
                        String base64 =getImg(img);
                        jb.put("img_path",base64);
                        jb.put("img_sort", i);
                        jb.put("upload_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd hh:mm:ss"));
                    }catch (Exception e){
                        errorFlag = true;
                        saveErrorLog(upid,"12",(String)info.get("id"),res,1);
                        dataError++;
                        logger.error(e.toString());
                    }
                    if(!errorFlag){
                        JSONArray jsonArray = new JSONArray();
                        jsonArray.add(jb);
                        res = postToInter(token,api, jsonArray,url);
                        JSONObject resJson = (JSONObject) JSONObject.parse(res);
                        if("200".equals(resJson.get("msg").toString())){
                            success++;
                        }else{
                            saveErrorLog(upid,"12",(String)info.get("id"),res,2);
                            error++;
                        }
                    }
                }
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"12",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    //13.用户协议信息
    public String upNsOrganProtocol(String startDate, String endDate,String keyId) throws Exception {
        getBaseSurperviseDict();
        BaseSuperviseDataDict superviseDataDict = superviseDataDictDao.selectByDictName();
        String url = getUrl();
        String api = "micc.upNsOrganProtocol";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        JSONObject jb = new JSONObject();
        Boolean errorFlag = false;
        try {
            jb.put("id_organ_protocol",orgCode+"_"+upid);
            jb.put("organ_code", orgCode);
            jb.put("organ_name",orgName);
            jb.put("protocol_type", superviseDataDict.getUserProtocolType());
            jb.put("protocol_content", superviseDataDict.getUserProtocolContent());
            jb.put("publish_date", superviseDataDict.getUserPublishDate());
            jb.put("protocol_name", superviseDataDict.getUserProtocolName());
            jb.put("upload_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            errorFlag = true;
            saveErrorLog(upid,"13",upid,res,1);
            dataError++;
            logger.error(e.toString());
        }
        if(!errorFlag){
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(jb);
            res = postToInter(token,api, jsonArray,url);
            JSONObject resJson = (JSONObject) JSONObject.parse(res);
            if("200".equals(resJson.get("msg").toString())){
                success++;
            }else{
                saveErrorLog(upid,"13",upid,res,2);
                error++;
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"13",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    //14.数据上传汇总信息
    public String upNsInvokeTotal(String startDate, String endDate) throws Exception {
        String base = getImUrl();
        getBaseSurperviseDict();
        String url = getUrl();
        String api = "micc.upNsInvokeTotal";
        String upid = getCode();
        String token = upNsUserToken(url);
        String res = "";
        int total = 0;
        int success = 0;
        int error = 0;
        int dataError = 0;
        //时间参数
        Map<String,Object> params = new HashedMap();
        //5.统计预约量
        String yyghSql = "SELECT " +
                "   count(1) AS \"yyghtotal\"" +
                " FROM wlyy_outpatient p " +
                " WHERE 1=1" ;
        if(StringUtils.isNotBlank(startDate)){
            yyghSql =  yyghSql + "  and p.create_time >=:startDate ";
            params.put("startDate",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"));
        }
        if(StringUtils.isNotBlank(endDate)){
            yyghSql =  yyghSql +  "  and p.create_time <=:endDate";
            params.put("endDate",DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
        }
        List<Map<String,Object>> yygh = hibenateUtils.createSQLQuery(yyghSql,params);
        Long yyghtotal = 0L;
        if(yygh!=null&&yygh.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            yyghtotal = hibenateUtils.objTransformLong(yygh.get(0).get("yyghtotal"));
        }
        //7.医生评价
        String yypjSql ="SELECT " +
                "   count(1) AS \"yypjtotal\"" +
                " FROM " +
                " base_evaluate_score a " +
                " JOIN base_evaluate e ON a.id = e.relation_code " +
                " JOIN base_doctor d ON d.id = a.doctor " +
                " WHERE " +
                " e.score_type = '4'";
        if(StringUtils.isNotBlank(startDate)){
            yypjSql =  yypjSql + "  and a.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            yypjSql =  yypjSql +  "  and a.create_time <=:endDate";
        }
        List<Map<String,Object>> yypj = hibenateUtils.createSQLQuery(yypjSql,params);
        Long yypjtotal = 0L;
        if(yypj!=null&&yypj.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            yypjtotal = hibenateUtils.objTransformLong(yypj.get(0).get("yypjtotal"));
        }
        //8.统计网络咨询
        String wlzxSql = "SELECT\n" +
                "   count(1) AS \"wlzxtotal\"" +
                "FROM\n" +
                "\twlyy_consult a ,\n" +
                "\twlyy_consult_team b \n" +
                "JOIN base_doctor c ON c.id = b.doctor \n" +
                "JOIN base_patient d ON d.id = b.patient \n" +
                "JOIN base_doctor_hospital e ON e.doctor_code = b.doctor \n" +
                "JOIN "+base+".topics t ON t.id = b.consult\n" +
                "WHERE\n" +
                "\ta.id = b.consult\n" +
                "AND a.symptoms IS NOT NULL AND b.status=1";
        if(StringUtils.isNotBlank(startDate)){
            wlzxSql =  wlzxSql + "  and a.czrq >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            wlzxSql =  wlzxSql +  "  and a.czrq <=:endDate";
        }
        List<Map<String,Object>> wlzx = hibenateUtils.createSQLQuery(wlzxSql,params);
        Long wlzxtotal = 0L;
        if(wlzx!=null&&wlzx.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            wlzxtotal = hibenateUtils.objTransformLong(wlzx.get(0).get("wlzxtotal"));
        }
        //9.网络诊疗服务
        String wlzlSql = "select " +
                "   count(1) AS \"wlzltotal\"" +
                "  from wlyy_outpatient a " +
                "      join base_doctor b on b.id = a.doctor" +
                "      join base_patient c on c.id = a.patient" +
                " where a.register_no is NOT NULL and a.dept is not null " +
                " and a.register_date is not null " ;
        if(StringUtils.isNotBlank(startDate)){
            wlzlSql =  wlzlSql + "  and a.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            wlzlSql =  wlzlSql +  "  and a.create_time <=:endDate";
        }
        List<Map<String,Object>> wlzl = hibenateUtils.createSQLQuery(wlzlSql,params);
        Long wlzltotal = 0L;
        if(wlzl!=null&&wlzl.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            wlzltotal = hibenateUtils.objTransformLong(wlzl.get(0).get("wlzltotal"));
        }
        //10.电子处方
        String dzcfsql = "select " +
                "   count(1) AS \"dzcftotal\"" +
                "  from  wlyy_prescription a" +
                "     JOIN base_patient b on a.patient_code = b.id " +
                "     JOIN base_doctor c on a.doctor = c.id " +
                "     JOIN wlyy_outpatient p on p.id = a.outpatient_id  " +
                "  where  c.idcard is not null  and a.real_order is not null and p.icd10 is not null ";
        if(StringUtils.isNotBlank(startDate)){
            dzcfsql =  dzcfsql + "  and a.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            dzcfsql =  dzcfsql +  "  and a.create_time <=:endDate";
        }
        List<Map<String,Object>> dzcf = hibenateUtils.createSQLQuery(dzcfsql,params);
        Long dzcftotal = 0L;
        if(dzcf!=null&&dzcf.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            dzcftotal = hibenateUtils.objTransformLong(dzcf.get(0).get("dzcftotal"));
        }
        //11.电子处方药品明细
        String infosql = "select " +
                "   count(1) AS \"infototal\"" +
                "  from wlyy_prescription_info a " +
                "     JOIN wlyy_prescription b " +
                "     on b.id = a.prescription_id" +
                "  where  a.dosage is not null and b.real_order is not null";
        if(StringUtils.isNotBlank(startDate)){
            infosql =  infosql + "  and b.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            infosql =  infosql +  "  and b.create_time <=:endDate";
        }
        List<Map<String,Object>> info = hibenateUtils.createSQLQuery(infosql,params);
        Long infototal = 0L;
        if(info!=null&&info.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            infototal = hibenateUtils.objTransformLong(info.get(0).get("infototal"));
        }
        //12.过程图片
        String gctpsql = "SELECT " +
                "   count(1) AS \"gctptotal\"" +
                " FROM wlyy_outpatient p " +
                " WHERE p.disease_img is not null ";
        if(StringUtils.isNotBlank(startDate)){
            gctpsql =  gctpsql + "  and p.create_time >=:startDate ";
        }
        if(StringUtils.isNotBlank(endDate)){
            gctpsql =  gctpsql +  "  and p.create_time <=:endDate";
        }
        List<Map<String,Object>> gctp = hibenateUtils.createSQLQuery(gctpsql,params);
        Long gctptotal = 0L;
        if(gctp!=null&&gctp.size()>0){
            //mysql 与 Oracle 聚合函数返回类型不一致,需要判断装换
            gctptotal = hibenateUtils.objTransformLong(gctp.get(0).get("gctptotal"));
        }
        JSONObject jb = new JSONObject();
        Boolean errorFlag = false;
        try {
            jb.put("id_ws_invoke_total",upid);
            jb.put("org_code", orgCode);
            jb.put("org_name",orgName);
            jb.put("wsyy_upload_count", yyghtotal);
            jb.put("zxyj_upload_count", 0);
            jb.put("yspj_upload_count", yypjtotal);
            jb.put("wlzx_upload_count", wlzxtotal);
            jb.put("wlzl_upload_count", wlzltotal);
            jb.put("dzcf_upload_count", dzcftotal);
            jb.put("ypmx_upload_count", infototal);
            jb.put("gctp_upload_count", gctptotal);
            jb.put("ywsj", DateUtil.dateToStr(new Date(),"yyyy-MM-dd"));
            jb.put("crt_time", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            errorFlag = true;
            saveErrorLog(upid,"14",upid,res,1);
            dataError++;
            logger.error(e.toString());
        }
        logger.info(jb.toString());
        if(!errorFlag){
            JSONArray jsonArray = new JSONArray();
            jsonArray.add(jb);
            res = postToInter(token,api, jsonArray,url);
            JSONObject resJson = (JSONObject) JSONObject.parse(res);
            if("200".equals(resJson.get("msg").toString())){
                success++;
            }else{
                saveErrorLog(upid,"14",upid,res,2);
                error++;
            }
        }
        String resInfo = "此次共上传:" + total + "条数据,其中成功 :" + success + "条,上传失败 : " + error + "条。格式错误:"+dataError+"条。";
        saveUpLog(upid,"14",DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"),success,error,dataError,resInfo);
        return resInfo;
    }
    // 基于医生所在科室,转换成国家诊疗科目代码(中山医院专用)
    // 当科室信息在列表中不存在的情况,全部配置为预防保健科
    public static  String[]  depToSubject(String dep){
        String[] res = new String[2];
        res[0] = "10";
        res[1] = "眼科";
        if(StringUtils.isNotBlank(dep)){
            if("1010".equals(dep)){
                res[0] = "3";
                res[1] = "内科";
            }else if("1154".equals(dep)){
                res[0] = "3";
                res[1] = "内科";
            }
        }
        return  res;
    }
    //2.5 预约,是否到诊字典转换
    public static String fgConvent(String status){
        String res ="";
        switch (status) {
            case "-1":
                res = "0";
                break;
            case "0":
                res = "1";
                break;
            case "1":
                res = "1";
                break;
            case "2":
                res = "1";
                break;
            default:
                res = "";
        }
        return res;
    }
    // 将上传失败的数据存储到LOG 中,便于后续补传
    public void saveErrorLog(String upId,String type, String id, String errorInfo,Integer errorType){
        InternetUpErrorLogDO internetUpErrorLogDO = new InternetUpErrorLogDO();
        internetUpErrorLogDO.setUpId(upId);
        internetUpErrorLogDO.setType(type);
        internetUpErrorLogDO.setKeyId(id);
        internetUpErrorLogDO.setErrorInfo(errorInfo);
        internetUpErrorLogDO.setErrorType(errorType);
        internetUpErrorLogService.save(internetUpErrorLogDO);
    }
    public void saveUpLog(String upid,String code,Date startDate,Date endDate,Integer suc,Integer err,Integer dataErr,String remark){
        InternetUpLogDO internetUpLogDO = new InternetUpLogDO();
        internetUpLogDO.setId(upid);
        internetUpLogDO.setCode(code);
        internetUpLogDO.setStartDate(startDate);
        internetUpLogDO.setEndDate(endDate);
        internetUpLogDO.setCreateDate(new Date());
        internetUpLogDO.setSuc(suc);
        internetUpLogDO.setErr(err);
        internetUpLogDO.setDataErr(dataErr);
        internetUpLogDO.setRemark(remark);
        internetUpLogDao.save(internetUpLogDO);
    }
    // 基于中山医院的职务字典,强转为监管平台的字典(该部分过滤掉字典与监管理无法匹配的部分)
    public static  String[]  classToduty(String duty){
        String[] res = new String[2];
        switch (duty) {
            case "1":
                res[0] = "231";
                res[1] = "主任医师";
                break;
            case "2":
                res[0] = "232";
                res[1] = "副主任医师";
                break;
            case "3":
                res[0] = "233";
                res[1] = "主治医师";
                break;
            default:
                res[0] = "234";
                res[1] = "医师";
        }
        return  res;
    }
    /**
     * 网络图片地址
     * @param path
     * @return
     * @throws Exception
     */
    public String getImg(String path)throws Exception{
        try{
            if(path.contains("http")){
                URL url = new URL(path);
                DataInputStream dataInputStream = new DataInputStream(url.openStream());
                return getBase64FromInputStream(dataInputStream);
            }
            URL url = new URL(fastdfs_file_url+path);
            DataInputStream dataInputStream = new DataInputStream(url.openStream());
            return getBase64FromInputStream(dataInputStream);
        }catch (Exception e){
            logger.error("getImg:"+e.toString());
        }
        return "";
    }
    public String getDateString(String date){
        String dates[] = date.split("-");
        if(dates!=null&&dates.length>0){
            if(dates[1].length()<2){
                dates[1] = "0"+dates[1];
            }
            if(dates[2].length()<2){
                dates[2] = "0"+dates[2];
            }
            return dates[0]+"-"+dates[1]+"-"+dates[2];
        }
        return date;
    }
    private String getBase64FromInputStream(InputStream is) throws Exception {
        // 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
        byte[] data = null;
        // 读取图片字节数组
        try {
            ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
            byte[] buff = new byte[100];
            int rc = 0;
            while ((rc = is.read(buff, 0, 100)) > 0) {
                swapStream.write(buff, 0, rc);
            }
            data = swapStream.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    throw new Exception("输入流关闭异常");
                }
            }
        }
        //转化方法1
        BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encodeBuffer(data).trim();
        //转化方法2
//        return new String(Base64.encodeBase64(data));
    }
    public String testImg(String path){
        return ImgUtils.getImageStr(path);
    }
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/internet/service/InternetService.java

@ -219,7 +219,7 @@ public class InternetService extends BaseJpaService<InternetUpErrorLogDO, IntUpE
                "(八)其他\n" +
                "1、本协议构成双方对本协议之约定事项及其他有关事宜的完整协议,除本协议规定的之外,未赋予本协议各方其他权利。 \n" +
                "2、如本协议中的任何条款无论因何种原因完全或部分无效或不具有执行力,本协议的其余条款仍应有效并且有约束力。 \n" +
                "3、本协议中的标题仅为方便而设,在解释本协议时应被忽略\"");
                "3、本协议中的标题仅为方便而设,在解释本协议时应被忽略");
        jb.put("publish_date", "2019-08-24");
        jb.put("protocol_name", "用户使用协议");

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -235,6 +235,8 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
     */
    private Date loginDate;
    private String userId;
    @Column(name = "saas_id")
    public String getSaasId() {
@ -604,4 +606,12 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
        this.loginDate = loginDate;
    }
    @Column(name = "user_id")
    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }
}

+ 251 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseSuperviseDataDict.java

@ -0,0 +1,251 @@
package com.yihu.jw.entity.hospital.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by zdm on 2019/5/28.
 */
@Entity
@Table(name = "base_supervise_data_dict")
public class BaseSuperviseDataDict extends IntegerIdentityEntity {
    private String dictName;//环境名字
    private String corporation;//单位法人姓名
    private String noPraLic;//执业许可登记号
    private String secondOrganName;//机构第二名称
    private String chargePerson;//主要负责人
    private String level;//机构等位分级
    private String economicType;//经济类型
    private String organType;//组织类别
    private String hospitalAddress;//医院具体地址
    private String hospitalPhone;//医院联系电话
    private String secuLevel;//信息系统安全等级保护级别
    private String netService;//开展互联网医疗服务
    private String serviceDept;//开展的临床科室
    private String protocolType;//协议类型
    private String protocolContent;//协议内容
    private String publishDate;//发布时间
    private String protocolName;//协议名称
    private String txtIntroduction;//医生介绍
    private String doctorNetService;//医生开展互联网医疗服务
    private String userProtocolType;//用户使用协议类型
    private String userProtocolContent;//用户使用协议内容
    private String userPublishDate;//用户使用发布时间
    private String userProtocolName;//用户协议名称
    private Integer status;//1生效0失效
    @Column(name = "dict_name")
    public String getDictName() {
        return dictName;
    }
    public void setDictName(String dictName) {
        this.dictName = dictName;
    }
    @Column(name = "corporation")
    public String getCorporation() {
        return corporation;
    }
    public void setCorporation(String corporation) {
        this.corporation = corporation;
    }
    @Column(name = "no_pra_lic")
    public String getNoPraLic() {
        return noPraLic;
    }
    public void setNoPraLic(String noPraLic) {
        this.noPraLic = noPraLic;
    }
    @Column(name = "second_organ_name")
    public String getSecondOrganName() {
        return secondOrganName;
    }
    public void setSecondOrganName(String secondOrganName) {
        this.secondOrganName = secondOrganName;
    }
    @Column(name = "charge_person")
    public String getChargePerson() {
        return chargePerson;
    }
    public void setChargePerson(String chargePerson) {
        this.chargePerson = chargePerson;
    }
    @Column(name = "level")
    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }
    @Column(name = "economic_type")
    public String getEconomicType() {
        return economicType;
    }
    public void setEconomicType(String economicType) {
        this.economicType = economicType;
    }
    @Column(name = "organ_type")
    public String getOrganType() {
        return organType;
    }
    public void setOrganType(String organType) {
        this.organType = organType;
    }
    @Column(name = "hospital_address")
    public String getHospitalAddress() {
        return hospitalAddress;
    }
    public void setHospitalAddress(String hospitalAddress) {
        this.hospitalAddress = hospitalAddress;
    }
    @Column(name = "hospital_phone")
    public String getHospitalPhone() {
        return hospitalPhone;
    }
    public void setHospitalPhone(String hospitalPhone) {
        this.hospitalPhone = hospitalPhone;
    }
    @Column(name = "secu_level")
    public String getSecuLevel() {
        return secuLevel;
    }
    public void setSecuLevel(String secuLevel) {
        this.secuLevel = secuLevel;
    }
    @Column(name = "net_service")
    public String getNetService() {
        return netService;
    }
    public void setNetService(String netService) {
        this.netService = netService;
    }
    @Column(name = "service_dept")
    public String getServiceDept() {
        return serviceDept;
    }
    public void setServiceDept(String serviceDept) {
        this.serviceDept = serviceDept;
    }
    @Column(name = "protocol_type")
    public String getProtocolType() {
        return protocolType;
    }
    public void setProtocolType(String protocolType) {
        this.protocolType = protocolType;
    }
    @Column(name = "protocol_content")
    public String getProtocolContent() {
        return protocolContent;
    }
    public void setProtocolContent(String protocolContent) {
        this.protocolContent = protocolContent;
    }
    @Column(name = "publish_date")
    public String getPublishDate() {
        return publishDate;
    }
    public void setPublishDate(String publishDate) {
        this.publishDate = publishDate;
    }
    @Column(name = "protocol_name")
    public String getProtocolName() {
        return protocolName;
    }
    public void setProtocolName(String protocolName) {
        this.protocolName = protocolName;
    }
    @Column(name = "txt_introduction")
    public String getTxtIntroduction() {
        return txtIntroduction;
    }
    public void setTxtIntroduction(String txtIntroduction) {
        this.txtIntroduction = txtIntroduction;
    }
    @Column(name = "user_protocol_type")
    public String getUserProtocolType() {
        return userProtocolType;
    }
    public void setUserProtocolType(String userProtocolType) {
        this.userProtocolType = userProtocolType;
    }
    @Column(name = "user_protocol_content")
    public String getUserProtocolContent() {
        return userProtocolContent;
    }
    public void setUserProtocolContent(String userProtocolContent) {
        this.userProtocolContent = userProtocolContent;
    }
    @Column(name = "user_publish_date")
    public String getUserPublishDate() {
        return userPublishDate;
    }
    public void setUserPublishDate(String userPublishDate) {
        this.userPublishDate = userPublishDate;
    }
    @Column(name = "user_protocol_name")
    public String getUserProtocolName() {
        return userProtocolName;
    }
    public void setUserProtocolName(String userProtocolName) {
        this.userProtocolName = userProtocolName;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "doctor_net_service")
    public String getDoctorNetService() {
        return doctorNetService;
    }
    public void setDoctorNetService(String doctorNetService) {
        this.doctorNetService = doctorNetService;
    }
}

+ 158 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/dict/BaseSuperviseDict.java

@ -0,0 +1,158 @@
package com.yihu.jw.entity.hospital.dict;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by zdm on 2019/5/28.
 */
@Entity
@Table(name = "base_supervise_dict")
public class BaseSuperviseDict extends IntegerIdentityEntity {
    private String userName ;
    private String psw ;
    private String appId ;
    private String aesEncodeKey ;
    private String urlString;
    private String method;
    private String token;
    private String orgCode;
    private String orgName;
    private String orgArea;
    private String orgSub ;
    private Integer status;
    private String dictName;
    private String imgUrl;//服务器地址
    @Column(name = "url_string")
    public String getUrlString() {
        return urlString;
    }
    public void setUrlString(String urlString) {
        this.urlString = urlString;
    }
    @Column(name = "method")
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    @Column(name = "token")
    public String getToken() {
        return token;
    }
    public void setToken(String token) {
        this.token = token;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
    @Column(name = "org_name")
    public String getOrgName() {
        return orgName;
    }
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    @Column(name = "org_area")
    public String getOrgArea() {
        return orgArea;
    }
    public void setOrgArea(String orgArea) {
        this.orgArea = orgArea;
    }
    @Column(name = "org_sub")
    public String getOrgSub() {
        return orgSub;
    }
    public void setOrgSub(String orgSub) {
        this.orgSub = orgSub;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "dict_name")
    public String getDictName() {
        return dictName;
    }
    public void setDictName(String dictName) {
        this.dictName = dictName;
    }
    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    @Column(name = "psw")
    public String getPsw() {
        return psw;
    }
    public void setPsw(String psw) {
        this.psw = psw;
    }
    @Column(name = "app_id")
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    @Column(name = "aes_encode_key")
    public String getAesEncodeKey() {
        return aesEncodeKey;
    }
    public void setAesEncodeKey(String aesEncodeKey) {
        this.aesEncodeKey = aesEncodeKey;
    }
    @Column(name = "img_url")
    public String getImgUrl() {
        return imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/jgpt/HospitalImgDO.java

@ -2,6 +2,7 @@ package com.yihu.jw.entity.hospital.jgpt;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -14,6 +15,7 @@ public class HospitalImgDO extends UuidIdentityEntity {
    private String name;
    private String img;
    private Integer status;
    public String getName() {
        return name;
@ -30,4 +32,13 @@ public class HospitalImgDO extends UuidIdentityEntity {
    public void setImg(String img) {
        this.img = img;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
}

+ 124 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/service/YkyyService.java

@ -0,0 +1,124 @@
package com.yihu.jw.entrance.service;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.http.HTTPClient;
import com.yihu.jw.util.http.HTTPResponse;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailParseException;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
 *
 * 眼科通接口
 *
 * Created by wangzhinan on 2020/4/11.
 */
@Service
public class YkyyService {
    @Autowired
    private HTTPClient httpClient;
    @Autowired
    private BasePatientDao patientDao;
    private static String yktUrl = "http://www.yanketong.com:133/api/";
    /**
     * 眼科通验证码
     * @param type
     * @param phone
     * @return
     */
    public String getShortMessage(String type,String phone){
        String response="";
        Map<String,String> param = new HashedMap();
        param.put("type",type);
        param.put("telephone",phone);
        String url = yktUrl+"verification_code/short_message";
        HTTPResponse httpResponse = httpClient.get(url,param);
        if (httpResponse.getStatusCode()==200){
            response= httpResponse.getBody();
        }
        return response;
    }
    /**
     * telephone=15578008051&patient_pwd=123456&code=513970&invite_code=a01522&equipment_type=ios&equipment_guid=12312321
     * 眼科通用户注册
     *
     * @param telephone
     * @param patientPwd
     * @param code
     * @return
     */
    public String getRegisterUser(String telephone,String patientPwd,String code,String inviteCode,String equipmentType,String equipmentGuid){
        String response="";
        Map<String,String> param = new HashedMap();
        param.put("telephone",telephone);
        param.put("patient_pwd",patientPwd);
        param.put("code",code);
        param.put("invite_code",inviteCode);
        param.put("equipment_type",equipmentType);
        param.put("equipment_guid",equipmentGuid);
        String url = yktUrl+"user_center/patient_register01";
        HTTPResponse httpResponse = httpClient.get(url,param);
        if (httpResponse.getStatusCode()==200){
            response= httpResponse.getBody();
        }
        return response;
    }
    /**
     * 获取就诊卡数据接口
     * @param userId
     * @return
     */
    public String selectCardList(String userId){
        String response="";
        Map<String,String> param = new HashedMap();
        param.put("user_id",userId);
        String url = yktUrl+"patient/get_patient_card_list";
        HTTPResponse httpResponse = httpClient.get(url,param);
        if (httpResponse.getStatusCode()==200){
            response= httpResponse.getBody();
        }
        return response;
    }
    /**
     * user_id=1a6a0016-a788-3c84-82e0-f1283e891ccc&patient_name=wangzhinan&card=12345678901&hospital_id=7A585AB3-ED33-B40D-C3E3-A8BB0A1195D8&hospital_name=厦门大学附属厦门眼科中心思北院区&type=0&hos_num=1
     *
     * 添加就诊卡接口
     *
     *
     */
    public String addCard(String userId,String patientName,String card,String hospitalId,String hospitalName,String type,String hosNum){
        String response="";
        Map<String,String> param = new HashedMap();
        param.put("user_id",userId);
        param.put("patient_name",patientName);
        param.put("card",card);
        param.put("hospital_id",hospitalId);
        param.put("hospital_name",hospitalName);
        param.put("type",type);
        param.put("hos_num",hosNum);
        String url = yktUrl+"patient/add_card";
        HTTPResponse httpResponse = httpClient.get(url,param);
        if (httpResponse.getStatusCode()==200){
            response= httpResponse.getBody();
        }
        return response;
    }
}

+ 126 - 0
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/job/CommonDataUploadJob.java

@ -0,0 +1,126 @@
package com.yihu.jw.job;
import com.yihu.jw.internet.service.InternetCommonService;
import com.yihu.jw.internet.service.ykyy.YkyyInternetService;
import com.yihu.jw.util.date.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * Created by Trick on 2020/3/11
 */
public class CommonDataUploadJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(DataUploadJob.class);
    @Autowired
    private InternetCommonService internetService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("START========DataUploadJob========");
        try {
            //1、获取 JOB 执行区间  执行时间点的前一天  时间点定在每天的 02:00:00 执行,同步前一天的数据
            String endDate = DateUtil.dateToStr(DateUtil.getNow(),"yyyy-MM-dd")+" 00:00:00";
            String startDate = DateUtil.dateToStr(DateUtil.getPreDays(DateUtil.getNow(),-1),"yyyy-MM-dd")+" 00:00:00";
            String res = "";
            //2、分步执行需要JOB执行的服务
            logger.info("START========2.5 网上预约挂号上传开始========");
            try {
                res = internetService.upAppointmentOnline(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.5 网上预约挂号上传结束========" + res);
//            logger.info("START========2.6 网上医技预约上传开始========");
//            try {
//                res = internetService.upMedicalOnline(startDate,endDate,null);
//            }catch (Exception e){
//                e.printStackTrace();
//                logger.error(e.toString());
//            }
//            logger.info("END==========2.6 网上医技预约上传结束========" + res);
            logger.info("START========2.7 医生评价信息开始========");
            try {
                res = internetService.upNsDoctorScore(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.7 医生评价信息结束========" + res);
            logger.info("START========2.8 网络咨询服务信息开始========");
            try {
                res = internetService.upNsOnlineAsk(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.8 网络咨询服务信息结束========" + res);
            logger.info("START========2.9 网络诊疗服务信息========");
            try {
                res = internetService.upNsOnlineMed(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.9 网络诊疗服务信息========" + res);
            logger.info("START========2.10 电子处方表开始========");
            try {
                res = internetService.upPrescription(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.10 电子处方表结束========" + res);
            logger.info("START========2.11 电子处方_药品明细表开始 ========");
            try {
                res = internetService.upPrescriptionDrug(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.11 电子处方_药品明细表结束 ========" + res);
            logger.info("START========2.12 在线诊疗服务信息-过程图片上传 开始========");
            try {
                res = internetService.upNsOnlineImg(startDate,endDate,null);
            }catch (Exception e){
                e.printStackTrace();
                logger.error(e.toString());
            }
            logger.info("END==========2.12 在线诊疗服务信息-过程图片上传 结束========" + res);
            logger.info("END========DataUploadJob 执行结束========");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("END===ERROE===DataUploadJob,message:"+e.getMessage());
        }
    }
}

+ 83 - 4
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -3,12 +3,10 @@ package com.yihu.jw.web.quota;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.internet.service.DataGeneratorService;
import com.yihu.jw.internet.service.InternetCommonService;
import com.yihu.jw.internet.service.InternetService;
import com.yihu.jw.internet.service.ykyy.YkyyInternetService;
import com.yihu.jw.job.DataUploadJob;
import com.yihu.jw.job.PrescriptionOverdueJob;
import com.yihu.jw.job.PrescriptionStatusUpdateJob;
import com.yihu.jw.job.QuartzHelper;
import com.yihu.jw.job.*;
import com.yihu.jw.job.ykyy.YkyyDataUploadJob;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.service.quota.JobService;
@ -53,6 +51,9 @@ public class JobController extends BaseController {
    @Autowired
    private YkyyInternetService ykyyInternetService;
    @Autowired
    private InternetCommonService internetCommonService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
        this.jobService = jobService;
@ -133,6 +134,17 @@ public class JobController extends BaseController {
                        logger.info("data_ykupload_job  job exist");
                    }
                    break;
                case "data_common_upload_job" :
                    //互联网医院 监管平台上报
                    if (!quartzHelper.isExistJob("data_common_upload_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("data_common_upload_job");
                        quartzHelper.addJob(CommonDataUploadJob.class, trigger, "data_common_upload_job", new HashMap<String, Object>());
                        logger.info("data_common_upload_job  job success");
                    } else {
                        logger.info("data_common_upload_job  job exist");
                    }
                    break;
                default :
            }
@ -466,6 +478,73 @@ public class JobController extends BaseController {
            return error(-1, "执行失败");
        }
    }
    @RequestMapping(value = "/inernetCommonUpload", method = RequestMethod.GET)
    @ApiOperation("监管平台通用业务数据上传")
    public String inernetCommonUpload(String id,String startDate,String endDate,String keyId) {
        try {
            switch(id){
                case "2.2" :
                    internetCommonService.upNsOrganBas();
                    break; //可选
                case "2.3" :
                    //语句
                    internetCommonService.upNsDoctorRecord(keyId);
                    break; //可选
                case "2.5" :
                    //语句
                    internetCommonService.upAppointmentOnline(startDate,endDate,keyId);
                    break; //可选
                case "2.6" :
                    //语句
                    internetCommonService.upMedicalOnline(startDate,endDate,keyId);
                    break; //可选
                case "2.7" :
                    //语句
                    internetCommonService.upNsDoctorScore(startDate,endDate,keyId);
                    break; //可选upNsDoctorScore
                case "2.8" :
                    //语句
                    internetCommonService.upNsOnlineAsk(startDate,endDate,keyId);
                    break; //可选
                case "2.9" :
                    //语句
                    internetCommonService.upNsOnlineMed(startDate,endDate,keyId);
                    break; //可选
                case "2.10" :
                    //语句
                    internetCommonService.upPrescription(startDate,endDate,keyId);
                    break; //可选
                case "2.11" :
                    //语句
                    internetCommonService.upPrescriptionDrug(startDate,endDate,keyId);
                    break; //可选
                case "2.12" :
                    //语句
                    internetCommonService.upNsOnlineImg(startDate,endDate,keyId);
                    break; //可选
                case "2.13" :
                    //语句
                    internetCommonService.upNsOrganProtocol(startDate,endDate,keyId);
                    break; //可选
                case "2.14" :
                    //语句
                    internetCommonService.upNsInvokeTotal(startDate,endDate);
                    break; //可选
                default : //可选
                    //语句
            }
            return write(200, "执行成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "执行失败");
        }
    }
    @RequestMapping(value = "/testImg", method = RequestMethod.GET)
    @ApiOperation("测试图片")
    public String testImg(String path) {

+ 2 - 0
svr/svr-internet-hospital-job/src/main/resources/system.properties

@ -13,3 +13,5 @@ data_upload_job=0 0 2 * * ?
data_ykupload_job=0 0 0 * * ?
#-------------------------眼科医院end-----------------------------#
#-------------------------监管平台通用医院-----------------------------#
data_common_upload_job=0 0 0 * * ?

+ 1 - 1
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java

@ -211,7 +211,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
               taskPatientDetailDO.setUpdateTime(new Date());
               taskPatientDetailDO.setTotal(0L);
               taskPatientDetailDO.setCouponTotal(0L);
               taskPatientDetailDO.setStatus(0);
               taskPatientDetailDO.setStatus(1);
               taskPatientDetailDao.save(taskPatientDetailDO);
           }
       }