Преглед на файлове

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

humingfen преди 4 години
родител
ревизия
8d23a20bd6
променени са 19 файла, в които са добавени 1816 реда и са изтрити 559 реда
  1. 25 6
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 2 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TnPrescriptionService.java
  3. 282 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java
  4. 44 42
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  5. 0 2
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/AccountDO.java
  6. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskPatientDetailDO.java
  7. 538 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/HlwTnCf01DO.java
  8. 439 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/HlwTnCf02DO.java
  9. 96 0
      svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/TnyyController.java
  10. 1 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  11. 13 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  12. 9 1
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/AccountDao.java
  13. 5 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/TaskPatientDetailDao.java
  14. 12 28
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/AccountService.java
  15. 97 97
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java
  16. 142 299
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java
  17. 7 2
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskPatientDtailService.java
  18. 82 78
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskService.java
  19. 21 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/util/TransforSqlUtl.java

+ 25 - 6
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -2,7 +2,6 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dict.dao.BaseDictJobTitleDao;
import com.yihu.jw.dict.dao.BaseJobCategoryDao;
import com.yihu.jw.dict.dao.DictDeptDescDao;
import com.yihu.jw.dict.dao.DictHospitalDeptDao;
@ -18,7 +17,6 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientBusinessDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.wx.*;
@ -55,6 +53,7 @@ import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
import com.yihu.jw.hospital.message.service.SystemMessageService;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
import com.yihu.jw.hospital.prescription.service.useragent.BaseUserAgent;
@ -92,7 +91,6 @@ import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.jw.yx.dao.YxTokenMappingDao;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.pinyin.PinyinUtil;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
import com.ylzinfo.ehc.common.utils.DateUtils;
@ -128,8 +126,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import static javafx.scene.input.KeyCode.L;
/**
 * Created by Trick on 2019/5/17.
 */
@ -279,6 +275,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private PayInfoNoticeService payInfoNoticeService;
    @Autowired
    private BaseJobCategoryDao jobCategoryDao;
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
@ -2589,7 +2587,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            //保存挂号费用
            prescription.setRegFee(getChargeFee(outpatientDO.getDoctor()));
            prescription.setRegFee(outpatientDO.getFee());
            prescription.setPrescribeTime(new Date());
            //保存费用
            prescriptionDao.save(prescription);
@ -2616,6 +2614,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                }
                result.put("code", 1);
                result.put("mes", "诊断完成");
                result.put("prescriptionId",prescription.getId());
                return result;
            }else if (wechatId.equalsIgnoreCase("sd_tnzyy_wx")) {
                outpatientDO.setStatus("2");
                outpatientDao.save(outpatientDO);
                //先下单
                businessOrderService.savePrescriptionOrder(prescription.getId());
                if(!demoFlag){
                    //同步his
                    tnyyEntranceService.findByRealOrder(prescription.getId(),demoFlag);
                    List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findById(prescription.getId());
                    if (prescriptionDOList != null && prescriptionDOList.size() != 0) {
                        WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDOList.get(0);
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                        logger.info("cfsb", wlyyPrescriptionDO.getRealOrder());
                    }
                }
                result.put("code", 1);
                result.put("mes", "诊断完成");
                result.put("prescriptionId",prescription.getId());

+ 2 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TnPrescriptionService.java

@ -539,7 +539,8 @@ public class TnPrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pr
/*            object.put("ybfl",map.get("ybfl"));//医保分类*/
            object.put("retprice",map.get("retprice"));//零售价格
            object.put("stock_amount",map.get("stock_amount"));//库存
            object.put("ypcd",map.get("manu_name"));//产地
            object.put("ypcd",map.get("manu_code"));//产地
            object.put("manu_name",map.get("manu_code"));
           /* object.put("zfpb",map.get("ZFPB"));//作废判别*/
            object.put("jbywbz",map.get("jbyw"));//基本药物标志
            object.put("pack_retprice",map.get("pack_retprice"));

+ 282 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java

@ -14,13 +14,17 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.dict.YkDictIcd10Dao;
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
@ -48,7 +52,12 @@ import static com.yihu.jw.util.common.PwdUtil.randomString;
public class TnyyEntranceService {
    private static Logger logger = LoggerFactory.getLogger(TnyyEntranceService.class);
    private final static String url="http://10.9.1.247:10023/ykyy/createSQLQuery";
    private final static String url="http://10.9.1.247:10023//tnyy/queryBySql";
    private final static String saveUrl="http://10.9.1.247:10023//tnyy/save";
    private final static String updateUrl="http://10.9.1.247:10023//tnyy/updateBySql";
    private final static String updateEntityUrl="http://10.9.1.247:10023/tnyy/update";
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
@ -67,6 +76,10 @@ public class TnyyEntranceService {
    private final static String orgCode ="350211A1002";
    @Autowired
    private PatientMappingDao patientMappingDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private PrescriptionDao prescriptionDao;
@ -897,4 +910,272 @@ public class TnyyEntranceService {
    }
    public void save(Object object){
        hibenateUtils.save(object);
    }
    public void updateBySql(String sql){
        hibenateUtils.updateBySql(sql);
    }
    public void update(Object object){
        hibenateUtils.update(object);
    }
    public String findByRealOrder(String code,boolean demoFlag) throws Exception {
        List<WlyyPrescriptionDO>  wlyyPrescriptionDOs = prescriptionDao.findById(code);
        if (wlyyPrescriptionDOs!=null&&wlyyPrescriptionDOs.size()!=0){
            WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOs.get(0);
            JSONObject objectString = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
            WlyyPrescriptionVO prescriptionVO =  JSONObject.toJavaObject(objectString,WlyyPrescriptionVO.class);
            List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
            List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
            for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                logger.info("11111参数入参"+object.toJSONString());
                WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(object,WlyyPrescriptionInfoVO.class);
                wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
            }
          /*  //诊断
            synPrescriptionDiagnosis(prescriptionVO,code,demoFlag);*/
            prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
         /*   List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(code,1);*/
            synPrecriptionTnHis(prescriptionVO,code);
            /*//同步检查检验
            if(null!=inspectionDOS&&inspectionDOS.size()>0){
                synInspect(inspectionDOS);
            }*/
        }
        return wlyyPrescriptionDOs.toString();
    }
    public WlyyPrescriptionVO synPrecriptionTnHis(WlyyPrescriptionVO wlyyPrescriptionVO,String code) throws Exception {
        HlwTnCf01DO hlwCf01DO = new HlwTnCf01DO();
        logger.info("开始===================");
        if (wlyyPrescriptionVO!=null){
            try {
                hlwCf01DO.setYFSB(3);
                hlwCf01DO.setCFLX(wlyyPrescriptionVO.getType());
                hlwCf01DO.setKFRQ(DateUtil.strToDate(DateUtil.dateToStr(wlyyPrescriptionVO.getCreateTime(),"yyyy-MM-dd HH:mm:ss")));
                hlwCf01DO.setZFPB(0);
                hlwCf01DO.setFYBZ(0);
                hlwCf01DO.setPYBZ(0);
                hlwCf01DO.setCFTS(1);
                hlwCf01DO.setYXPB(1);
                hlwCf01DO.setDYBZ(0);
                hlwCf01DO.setTSCF(0);
                hlwCf01DO.setTYBZ(0);
                hlwCf01DO.setTSLX(6);
                hlwCf01DO.setCFBZ(0);
                hlwCf01DO.setJZXH(0);
                hlwCf01DO.setYXPB(0);
                hlwCf01DO.setPjbz(0);
                hlwCf01DO.setFypj(0);
                String patient = wlyyPrescriptionVO.getPatientCode();
                PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
                hlwCf01DO.setBRID(Integer.parseInt(patientMappingDO.getMappingCode()));
                hlwCf01DO.setBRXM(wlyyPrescriptionVO.getPatientName());
                hlwCf01DO.setKSDM(Integer.parseInt(wlyyPrescriptionVO.getDept()));
                String doctor = wlyyPrescriptionVO.getDoctor();
                DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
                hlwCf01DO.setYSDM(doctorMappingDO.getMappingCode());
                hlwCf01DO.setJZKH(wlyyPrescriptionVO.getSsc());
                if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
                    hlwCf01DO.setJZXH(Integer.parseInt(wlyyPrescriptionVO.getAdmNo()));
                }
               /* hibenateUtils.save(hlwCf01DO);*/
                if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getRealOrder())){
                    hlwCf01DO.setCFSB(Integer.parseInt(wlyyPrescriptionVO.getRealOrder()));
                }
                if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getOriginRealOrder())){
                    hlwCf01DO.setCFHM(wlyyPrescriptionVO.getOriginRealOrder());
                }
                String jsonString = JSONObject.toJSONString(hlwCf01DO);
                Map<String,Object> params = new HashedMap();
                params.put("json",jsonString);
                params.put("table","HLW_CF01");
                logger.info("HLW_CF01:"+jsonString);
                /**
                 {"message":null,"status":200,"obj":{"cfhm":1898356,"cfsb":5390518}}
                 */
                String cfsb = null;
                String cfhm = null;
                if (!StringUtils.isNoneBlank(wlyyPrescriptionVO.getRealOrder())){
                    HttpResponse response = HttpUtils.doGet(saveUrl,params);
                    if (response.getStatus()==200){
                        logger.info("content"+response.getContent());
                        String content = response.getContent();
                        JSONObject jsonObject = JSONObject.parseObject(content);
                        JSONObject object = jsonObject.getJSONObject("obj");
                        if (object!=null){
                            cfsb = object.getString("cfsb");
                            cfhm = object.getString("cfhm");
                            logger.info("kaishi=========="+cfsb);
                            List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findById(code);
                            if (wlyyPrescriptionDOS!=null&&wlyyPrescriptionDOS.size()!=0){
                                WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
                                wlyyPrescriptionDO.setRealOrder(cfsb);
                                wlyyPrescriptionDO.setOriginRealOrder(cfhm);
                                prescriptionDao.save(wlyyPrescriptionDO);
                            }
                        }
                        logger.info("表HLW_CF01同步成功!");
                    }else {
                        logger.info("表HLW_CF01同步失败!"+response.getErrorMsg());
                    }
                }else {
                    cfsb = wlyyPrescriptionVO.getRealOrder();
                    String sql = "update v_ms_dd01 t set t.ZFPB=1,t.ZFSJ=to_date('"+DateUtil.getStringDate()+"','yyyy-mm-dd hh24:mi:ss')  where  t.CFSB ='"+cfsb+"' ";
                    Map<String,Object> params1 = new HashedMap();
                    params1.put("sql",sql);
                    HttpResponse response = HttpUtils.doGet(updateUrl,params1);
                    if (response.getStatus()==200){
                        logger.info("表v_ms_dd01作废成功!");
                        HttpResponse response1 = HttpUtils.doGet(saveUrl,params);
                        if (response1.getStatus()==200){
                            logger.info("content"+response1.getContent());
                            String content = response1.getContent();
                            JSONObject jsonObject = JSONObject.parseObject(content);
                            JSONObject object = jsonObject.getJSONObject("obj");
                            if (object!=null){
                                cfsb = object.getString("cfsb");
                                cfhm = object.getString("cfhm");
                                logger.info("kaishi=========="+cfsb);
                                List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findById(code);
                                if (wlyyPrescriptionDOS!=null&&wlyyPrescriptionDOS.size()!=0){
                                    WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
                                    wlyyPrescriptionDO.setRealOrder(cfsb);
                                    wlyyPrescriptionDO.setOriginRealOrder(cfhm);
                                    prescriptionDao.save(wlyyPrescriptionDO);
                                }
                            }
                            logger.info("表HLW_CF01同步成功!");
                        }else {
                            logger.info("表HLW_CF01同步失败!"+response.getErrorMsg());
                        }
                    }
                   /* hlwCf01DO.setZFPB(1);
                    hlwCf01DO.setZFSJ(new Date());
                    HttpResponse response = HttpUtils.doGet(updateEntityUrl,params);
                    if (response.getStatus()==200){
                        logger.info("content"+response.getContent());
                        logger.info("表HLW_CF01更新成功!");
                    }else {
                        logger.info("表HLW_CF01更新失败!"+response.getErrorMsg());
                    }*/
                }
                logger.info("处方:"+cfsb);
                if (StringUtils.isEmpty(cfsb)){
                    throw new Exception("添加失败");
                }
               /* if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getRealOrder())){
                    String deleteSql = "delete from v_ms_dd02 where cfsb = '"+wlyyPrescriptionVO.getRealOrder()+"'";
                    Map<String,Object> params1 = new HashedMap();
                    params1.put("sql",deleteSql);
                    HttpResponse response = HttpUtils.doGet(updateUrl,params1);
                    if (response.getStatus()==200){
                        logger.info("表v_ms_dd02删除成功!");
                    }
                }*/
                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS =wlyyPrescriptionVO.getInfoVOs();
                for (WlyyPrescriptionInfoVO wlyyPrescriptionInfoVO:wlyyPrescriptionInfoVOS){
                    try {
                        logger.info("chufang1============");
                        HlwTnCf02DO hlwCf02DO = new HlwTnCf02DO();
                        hlwCf02DO.setCFSB(Integer.parseInt(cfsb));
                        hlwCf02DO.setYPXH(Integer.parseInt(wlyyPrescriptionInfoVO.getDrugNo()));
                        logger.info("drugNo"+hlwCf02DO.getYPXH());
                        if (wlyyPrescriptionInfoVO.getDrugPlace()!=null){
                            hlwCf02DO.setYPCD(Integer.parseInt(wlyyPrescriptionInfoVO.getDrugPlace()));
                        }
                        hlwCf02DO.setXMLX(1);
                        hlwCf02DO.setCFTS(1);
                        hlwCf02DO.setYPSL(Double.parseDouble(wlyyPrescriptionInfoVO.getQuantity()));
                        hlwCf02DO.setYPDJ(wlyyPrescriptionInfoVO.getPackRetprice());
                        hlwCf02DO.setHJJE(Integer.parseInt(wlyyPrescriptionInfoVO.getQuantity())*wlyyPrescriptionInfoVO.getPackRetprice());//划价价额
                        hlwCf02DO.setYPZS(1);//药品组数  待确定
                        hlwCf02DO.setYCSL("0");
                        hlwCf02DO.setFYGB(1);//费用归并
                        hlwCf02DO.setZFBL(1.0);//自负比例
                        hlwCf02DO.setYFDW(wlyyPrescriptionInfoVO.getPackUnitName());
                        hlwCf02DO.setMRCS(StringUtils.isNoneBlank(wlyyPrescriptionInfoVO.getGroupNo())?Integer.parseInt(wlyyPrescriptionInfoVO.getGroupNo()):0);//每日次数
                        hlwCf02DO.setYFBZ(3);
                        hlwCf02DO.setYPYF(wlyyPrescriptionInfoVO.getUsageCode());
                        hlwCf02DO.setGYTJ(wlyyPrescriptionInfoVO.getYpyf());
                        hlwCf02DO.setSL(Integer.parseInt(wlyyPrescriptionInfoVO.getQuantity()));
                        hlwCf02DO.setPSPB(0);
                        hlwCf02DO.setYYTS(1);
                        hlwCf02DO.setJhjg(0);
                        hlwCf02DO.setJhje(0);
                        hlwCf02DO.setJhjg1(0);
                        hlwCf02DO.setDzdr(0);
                        hlwCf02DO.setYCJL(wlyyPrescriptionInfoVO.getDosage()!=null?Double.parseDouble(wlyyPrescriptionInfoVO.getDosage()):0);
                        if (wlyyPrescriptionInfoVO.getHisCode()!=null){
                            hlwCf02DO.setSBXH(wlyyPrescriptionInfoVO.getHisCode());
                        }
                    /*hlwCf02DO.setYPZH(Integer.parseInt(wlyyPrescriptionInfoVO.getFrequency()));*/
                        hlwCf02DO.setYFGG(wlyyPrescriptionInfoVO.getSpecification());
                  /*  hibenateUtils.save(hlwCf02DO);*/
                        String jsonString1 = JSONObject.toJSONString(hlwCf02DO);
                        logger.info("chufang2============");
                        Map<String,Object> params1 = new HashedMap();
                        params1.put("json",jsonString1);
                        params1.put("table","HLW_CF02");
                        logger.info("HLW_CF02:"+jsonString1);
                        if (wlyyPrescriptionInfoVO.getHisCode()==null){
                            HttpResponse response1 = HttpUtils.doGet(saveUrl,params1);
                            Integer sbxh = null;
                            if (response1.getStatus()==200){
                                logger.info("content"+response1.getContent());
                                String content = response1.getContent();
                                JSONObject jsonObject = JSONObject.parseObject(content);
                                JSONObject object = jsonObject.getJSONObject("obj");
                                if (object!=null){
                                    sbxh = object.getInteger("sbxh");
                                    logger.info("kaishi=========="+cfsb);
                                    WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO = prescriptionInfoDao.findOne(wlyyPrescriptionInfoVO.getId());
                                    if (wlyyPrescriptionInfoDO!=null){
                                        wlyyPrescriptionInfoDO.setHisCode(sbxh);
                                        prescriptionInfoDao.save(wlyyPrescriptionInfoDO);
                                    }
                                }
                                logger.info("表HLW_CF02同步成功!");
                            }else {
                                logger.info("表HLW_CF02同步失败!"+response1.getErrorMsg());
                            }
                        }else {
                            HttpResponse response1 = HttpUtils.doGet(updateEntityUrl,params1);
                            if (response1.getStatus()==200){
                                logger.info("content"+response1.getContent());
                                logger.info("表HLW_CF02更新成功!");
                            }else {
                                logger.info("表HLW_CF02更新失败!"+response1.getErrorMsg());
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                        e.getMessage();
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return null;
    }
}

+ 44 - 42
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -181,53 +181,55 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                wlyyPrescriptionDO = prescriptionDao.save(wlyyPrescriptionDO);
                JSONArray array = new JSONArray();
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(code, 1);
                WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
                for (WlyyPrescriptionInfoDO prescriptionInfoDO : wlyyPrescriptionInfoDOS) {
                    JSONObject object = new JSONObject();
                    //{"commodityName":"","commodityPrice":"","DrugUnit":"","MedicineDoctor":""}
                    object.put("commodityName", prescriptionInfoDO.getDrugName());
                    object.put("commodityPrice", prescriptionInfoDO.getPackRetprice());
                    object.put("DrugUnit", prescriptionInfoDO.getPackUnitName());
                    DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
                    String yktDoctor = "";
                    if (doctorMappingDO != null && StringUtils.isNoneBlank(doctorMappingDO.getMappingCode())) {
                        System.out.println("----------------"+hospitalSysDictDO.getDictValue());
                        if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                        } else {
                            String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
                            JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
                            if (jsonObject.getInteger("code") == 200) {
                                JSONArray array1 = jsonObject.getJSONArray("data");
                                if (array1 != null && array1.size() != 0) {
                                    yktDoctor = array1.getJSONObject(0).getString("DOCTORUSERID");
                if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                    WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("YKTCONTROL");
                    for (WlyyPrescriptionInfoDO prescriptionInfoDO : wlyyPrescriptionInfoDOS) {
                        JSONObject object = new JSONObject();
                        //{"commodityName":"","commodityPrice":"","DrugUnit":"","MedicineDoctor":""}
                        object.put("commodityName", prescriptionInfoDO.getDrugName());
                        object.put("commodityPrice", prescriptionInfoDO.getPackRetprice());
                        object.put("DrugUnit", prescriptionInfoDO.getPackUnitName());
                        DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(businessOrderDO.getDoctor());
                        String yktDoctor = "";
                        if (doctorMappingDO != null && StringUtils.isNoneBlank(doctorMappingDO.getMappingCode())) {
                            System.out.println("----------------"+hospitalSysDictDO.getDictValue());
                            if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                            } else {
                                String doctorResponse = ykyyService.getYktDoctor(doctorMappingDO.getMappingCode());
                                JSONObject jsonObject = JSONObject.parseObject(doctorResponse);
                                if (jsonObject.getInteger("code") == 200) {
                                    JSONArray array1 = jsonObject.getJSONArray("data");
                                    if (array1 != null && array1.size() != 0) {
                                        yktDoctor = array1.getJSONObject(0).getString("DOCTORUSERID");
                                    }
                                }
                            }
                        } else {
                            throw new Exception("医生映射表不存在!");
                        }
                    } else {
                        throw new Exception("医生映射表不存在!");
                        object.put("MedicineDoctor", yktDoctor);
                        array.add(object);
                    }
                    object.put("MedicineDoctor", yktDoctor);
                    array.add(object);
                }
                BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
                String userId = null;
                if (patientDO != null) {
                    userId = patientDO.getUserId();
                }
                if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                    BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
                    String userId = null;
                    if (patientDO != null) {
                        userId = patientDO.getUserId();
                    }
                    if (null != hospitalSysDictDO && "0".equalsIgnoreCase(hospitalSysDictDO.getDictValue())) {
                } else {
                    String response = ykyyService.addOrder4Jkzl("1", wlyyPrescriptionDO.getOrderId(), businessOrderDO.getOrderNo(), userId, array);
                    if (StringUtils.isNoneBlank(response)) {
                        JSONObject jsonObject = JSONObject.parseObject(response);
                        if (jsonObject.getString("code").equalsIgnoreCase("10000")) {
                            String orderId = jsonObject.getString("orderId");
                            String orderNo = jsonObject.getString("orderNo");
                            businessOrderDO.setYkOrderId(orderId);
                            businessOrderDO.setYkOrderNo(orderNo);
                            businessOrderDO.setUploadStatus(1);
                            businessOrderDao.save(businessOrderDO);
                    } else {
                        String response = ykyyService.addOrder4Jkzl("1", wlyyPrescriptionDO.getOrderId(), businessOrderDO.getOrderNo(), userId, array);
                        if (StringUtils.isNoneBlank(response)) {
                            JSONObject jsonObject = JSONObject.parseObject(response);
                            if (jsonObject.getString("code").equalsIgnoreCase("10000")) {
                                String orderId = jsonObject.getString("orderId");
                                String orderNo = jsonObject.getString("orderNo");
                                businessOrderDO.setYkOrderId(orderId);
                                businessOrderDO.setYkOrderNo(orderNo);
                                businessOrderDO.setUploadStatus(1);
                                businessOrderDao.save(businessOrderDO);
                            }
                        }
                    }
                }

+ 0 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/AccountDO.java

@ -123,7 +123,6 @@ public class AccountDO extends UuidIdentityEntityWithOperator implements Seriali
        this.usedTotal = usedTotal;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getPassword() {
        return password;
    }
@ -132,7 +131,6 @@ public class AccountDO extends UuidIdentityEntityWithOperator implements Seriali
        this.password = password;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getCardNumber() {
        return cardNumber;
    }

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskPatientDetailDO.java

@ -111,6 +111,7 @@ public class TaskPatientDetailDO extends UuidIdentityEntityWithOperator implemen
        this.patientId = patientId;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getPatientIdcard() {
        return patientIdcard;
    }
@ -119,7 +120,6 @@ public class TaskPatientDetailDO extends UuidIdentityEntityWithOperator implemen
        this.patientIdcard = patientIdcard;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getPatientOpenid() {
        return patientOpenid;
    }

+ 538 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/HlwTnCf01DO.java

@ -0,0 +1,538 @@
package com.yihu.jw.entity.hospital.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
 * 眼科处方表1数据
 *
 * */
//@ApiModel(value = "HlwTnCf01DO", description = "眼科处方表1数据")
@Entity
@Table(name = "MS_CF01")
public class HlwTnCf01DO {
    private Integer cFSB;//	NUMBER(18)	N			处方识别 每次写一次就变化一次不能重复
    private String cFHM;//	VARCHAR2(10)	Y			处方号码
    private String fPHM;//	VARCHAR2(12)	Y			发票号码
    private Integer mZXH;//	NUMBER(18)	Y			门诊序号
    private Integer cFLX;//	NUMBER(1)	N			处方类型
    private Integer bRID;//	NUMBER(18)	Y			病人ID号
    private String bRXM;//	VARCHAR2(40)	Y			病人姓名
    private Date kFRQ;//	DATE	        N			开方日期
    private Integer cFTS;//	NUMBER(2)	N			处方贴数
    private Integer kSDM;//	NUMBER(4)	Y			科室代码
    private String ySDM;//	VARCHAR2(10)	Y			医生代码
    private Date fYRQ;//	DATE	        Y			发药日期
    private Integer fYCK;//	NUMBER(2)	Y			发药窗口
    private String hJGH;//	VARCHAR2(10)	Y			划价工号
    private String pYGH;//	VARCHAR2(10)	Y			配药工号
    private String fYGH;//	VARCHAR2(10)	Y			发药工号
    private Integer pYBZ;//	NUMBER(1)	N			配药标志
    private Integer fYBZ;//	NUMBER(1)	N			发药标志
    private Integer cFGL;//	NUMBER(18)	Y			处方关联
    private Integer zFPB;//	NUMBER(1)	N			作废判别
    private Integer dYBZ;//	NUMBER(1)	Y			打印标志
    private Integer yFSB;//	NUMBER(3)	N			药房识别
    private Integer tSCF;//	NUMBER(2)	Y			特殊处方
    private Integer tSLX;//	INTEGER	Y			特殊类型
    private Integer tYBZ;//	NUMBER(1)	Y			退药标志
    private Integer cFBZ;//	NUMBER(1)	Y			处方标志(CFBZ = 2 处方锁定)
    private Integer jZXH;//	NUMBER(18)	Y			门诊就诊
    private Integer yXPB;//	NUMBER(1)	N			优先处方
    private String jZKH;//	VARCHAR2(20)	Y			就诊卡号
    private Integer dMSB;//numeric(5, 0)
    private String sqr;//sqr varchar(8)
    private Integer zyzd;//numeric(18, 0)
    private Integer tmhd;//numeric(1, 0)
    private String voice;//	varchar(1)
    private String sereen;//	varchar(1)
    private Date voiceDate;//	datetime
    private Integer sJTS;//	numeric(4, 0)
    private Integer mRJJ;//	numeric(2, 0)
    private Integer pjbz;//	numeric(1, 0)
    private Integer fypj;//	numeric(1, 0)
    private Integer cFSCBZ;//	int
    private Integer sbjbh;//	int
    private String sbjbh1;//	varchar(20)
    private String grbh;//	varchar(50)
    private String dbjbbm;//	varchar(50)
    private String mzlsh;//	varchar(50)
    private Integer dJBZ;//	numeric(2, 0)
    private Integer djbzGx;//	int
    @Id
    @Column(name = "CFSB")
    public Integer getCFSB() {
        return cFSB;
    }
    public void setCFSB(Integer cFSB) {
        this.cFSB = cFSB;
    }
    @Column(name = "CFHM")
    public String getCFHM() {
        return cFHM;
    }
    public void setCFHM(String cFHM) {
        this.cFHM = cFHM;
    }
    @Column(name = "FPHM")
    public String getFPHM() {
        return fPHM;
    }
    public void setFPHM(String fPHM) {
        this.fPHM = fPHM;
    }
    @Column(name = "MZXH")
    public Integer getMZXH() {
        return mZXH;
    }
    public void setMZXH(Integer mZXH) {
        this.mZXH = mZXH;
    }
    @Column(name = "CFLX")
    public Integer getCFLX() {
        return cFLX;
    }
    public void setCFLX(Integer cFLX) {
        this.cFLX = cFLX;
    }
    @Column(name = "BRID")
    public Integer getBRID() {
        return bRID;
    }
    public void setBRID(Integer bRID) {
        this.bRID = bRID;
    }
    @Column(name = "BRXM")
    public String getBRXM() {
        return bRXM;
    }
    public void setBRXM(String bRXM) {
        this.bRXM = bRXM;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "KFRQ")
    public Date getKFRQ() {
        return kFRQ;
    }
    public void setKFRQ(Date kFRQ) {
        this.kFRQ = kFRQ;
    }
    @Column(name = "CFTS")
    public Integer getCFTS() {
        return cFTS;
    }
    public void setCFTS(Integer cFTS) {
        this.cFTS = cFTS;
    }
    @Column(name = "KSDM")
    public Integer getKSDM() {
        return kSDM;
    }
    public void setKSDM(Integer kSDM) {
        this.kSDM = kSDM;
    }
    @Column(name = "YSDM")
    public String getYSDM() {
        return ySDM;
    }
    public void setYSDM(String ySDM) {
        this.ySDM = ySDM;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "FYRQ")
    public Date getFYRQ() {
        return fYRQ;
    }
    public void setFYRQ(Date fYRQ) {
        this.fYRQ = fYRQ;
    }
    @Column(name = "FYCK")
    public Integer getFYCK() {
        return fYCK;
    }
    public void setFYCK(Integer fYCK) {
        this.fYCK = fYCK;
    }
    @Column(name = "HJGH")
    public String getHJGH() {
        return hJGH;
    }
    public void setHJGH(String hJGH) {
        this.hJGH = hJGH;
    }
    @Column(name = "PYGH")
    public String getPYGH() {
        return pYGH;
    }
    public void setPYGH(String pYGH) {
        this.pYGH = pYGH;
    }
    @Column(name = "FYGH")
    public String getFYGH() {
        return fYGH;
    }
    public void setFYGH(String fYGH) {
        this.fYGH = fYGH;
    }
    @Column(name = "PYBZ")
    public Integer getPYBZ() {
        return pYBZ;
    }
    public void setPYBZ(Integer pYBZ) {
        this.pYBZ = pYBZ;
    }
    @Column(name = "FYBZ")
    public Integer getFYBZ() {
        return fYBZ;
    }
    public void setFYBZ(Integer fYBZ) {
        this.fYBZ = fYBZ;
    }
    @Column(name = "CFGL")
    public Integer getCFGL() {
        return cFGL;
    }
    public void setCFGL(Integer cFGL) {
        this.cFGL = cFGL;
    }
    @Column(name = "ZFPB")
    public Integer getZFPB() {
        return zFPB;
    }
    public void setZFPB(Integer zFPB) {
        this.zFPB = zFPB;
    }
    @Column(name = "DYBZ")
    public Integer getDYBZ() {
        return dYBZ;
    }
    public void setDYBZ(Integer dYBZ) {
        this.dYBZ = dYBZ;
    }
    @Column(name = "YFSB")
    public Integer getYFSB() {
        return yFSB;
    }
    public void setYFSB(Integer yFSB) {
        this.yFSB = yFSB;
    }
    @Column(name = "TSCF")
    public Integer getTSCF() {
        return tSCF;
    }
    public void setTSCF(Integer tSCF) {
        this.tSCF = tSCF;
    }
    @Column(name = "TSLX")
    public Integer getTSLX() {
        return tSLX;
    }
    public void setTSLX(Integer tSLX) {
        this.tSLX = tSLX;
    }
    @Column(name = "TYBZ")
    public Integer getTYBZ() {
        return tYBZ;
    }
    public void setTYBZ(Integer tYBZ) {
        this.tYBZ = tYBZ;
    }
    @Column(name = "CFBZ")
    public Integer getCFBZ() {
        return cFBZ;
    }
    public void setCFBZ(Integer cFBZ) {
        this.cFBZ = cFBZ;
    }
    @Column(name = "JZXH")
    public Integer getJZXH() {
        return jZXH;
    }
    public void setJZXH(Integer jZXH) {
        this.jZXH = jZXH;
    }
    @Column(name = "YXPB")
    public Integer getYXPB() {
        return yXPB;
    }
    public void setYXPB(Integer yXPB) {
        this.yXPB = yXPB;
    }
    @Column(name = "JZKH")
    public String getJZKH() {
        return jZKH;
    }
    public void setJZKH(String jZKH) {
        this.jZKH = jZKH;
    }
    @Column(name = "DMSB")
    public Integer getdMSB() {
        return dMSB;
    }
    public void setdMSB(Integer dMSB) {
        this.dMSB = dMSB;
    }
    @Column(name = "sqr")
    public String getSqr() {
        return sqr;
    }
    public void setSqr(String sqr) {
        this.sqr = sqr;
    }
    @Column(name = "zyzd")
    public Integer getZyzd() {
        return zyzd;
    }
    public void setZyzd(Integer zyzd) {
        this.zyzd = zyzd;
    }
    @Column(name = "tmhd")
    public Integer getTmhd() {
        return tmhd;
    }
    public void setTmhd(Integer tmhd) {
        this.tmhd = tmhd;
    }
    @Column(name = "voice")
    public String getVoice() {
        return voice;
    }
    public void setVoice(String voice) {
        this.voice = voice;
    }
    @Column(name = "sereen")
    public String getSereen() {
        return sereen;
    }
    public void setSereen(String sereen) {
        this.sereen = sereen;
    }
    @Column(name = "voice_date")
    public Date getVoiceDate() {
        return voiceDate;
    }
    public void setVoiceDate(Date voiceDate) {
        this.voiceDate = voiceDate;
    }
    @Column(name = "SJTS")
    public Integer getSJTS() {
        return sJTS;
    }
    public void setSJTS(Integer sJTS) {
        this.sJTS = sJTS;
    }
    @Column(name = "MRJJ")
    public Integer getMRJJ() {
        return mRJJ;
    }
    public void setMRJJ(Integer mRJJ) {
        this.mRJJ = mRJJ;
    }
    @Column(name = "pjbz")
    public Integer getPjbz() {
        return pjbz;
    }
    public void setPjbz(Integer pjbz) {
        this.pjbz = pjbz;
    }
    @Column(name = "fypj")
    public Integer getFypj() {
        return fypj;
    }
    public void setFypj(Integer fypj) {
        this.fypj = fypj;
    }
    @Column(name = "CFSCBZ")
    public Integer getCFSCBZ() {
        return cFSCBZ;
    }
    public void setCFSCBZ(Integer cFSCBZ) {
        this.cFSCBZ = cFSCBZ;
    }
    @Column(name = "sbjbh")
    public Integer getSbjbh() {
        return sbjbh;
    }
    public void setSbjbh(Integer sbjbh) {
        this.sbjbh = sbjbh;
    }
    @Column(name = "sbjbh1")
    public String getSbjbh1() {
        return sbjbh1;
    }
    public void setSbjbh1(String sbjbh1) {
        this.sbjbh1 = sbjbh1;
    }
    @Column(name = "grbh")
    public String getGrbh() {
        return grbh;
    }
    public void setGrbh(String grbh) {
        this.grbh = grbh;
    }
    @Column(name = "dbjbbm")
    public String getDbjbbm() {
        return dbjbbm;
    }
    public void setDbjbbm(String dbjbbm) {
        this.dbjbbm = dbjbbm;
    }
    @Column(name = "mzlsh")
    public String getMzlsh() {
        return mzlsh;
    }
    public void setMzlsh(String mzlsh) {
        this.mzlsh = mzlsh;
    }
    @Column(name = "DJBZ")
    public Integer getDJBZ() {
        return dJBZ;
    }
    public void setDJBZ(Integer dJBZ) {
        this.dJBZ = dJBZ;
    }
    @Column(name = "djbz_gx")
    public Integer getDjbzGx() {
        return djbzGx;
    }
    public void setDjbzGx(Integer djbzGx) {
        this.djbzGx = djbzGx;
    }
}

+ 439 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/HlwTnCf02DO.java

@ -0,0 +1,439 @@
package com.yihu.jw.entity.hospital.prescription;
import javax.persistence.*;
/**
 * 眼科处方表1数据
 *
 * */
@Entity
@Table(name = "MS_CF02")
public class HlwTnCf02DO {
    private Integer sBXH;//NUMBER(18)   N注释
    private Integer cFSB;//NUMBER(18)   N识别序号
    private Integer yPXH;//NUMBER(6)    N处方识别
    private Integer yPCD;//NUMBER(6)    N药品序号
    private Integer xMLX;//NUMBER(2)    N药品产地
    private Integer cFTS;//NUMBER(2)    N项目类型
    private Double yPSL;//NUMBER(10,2) N处方贴数
    private Double yPDJ;//NUMBER(12,4) N药品数量
    private Double hJJE;//NUMBER(12,2) N药品单价
    private Integer yPZS;//INTEGER      N划价金额
    private String yCSL;//VARCHAR2(20)  N药品组数
    private Integer fYGB;//NUMBER(4)    N一次数量
    private Double zFBL;//NUMBER(5,3)  N费用归并
    private Integer gYTJ;//NUMBER(4)    Y自负比例
    private String yPYF;//VARCHAR2(20)  Y给药途径
    private Integer yPZH;//NUMBER(18)   Y药品用法
    private String yFGG;//VARCHAR2(20)  Y药品组号
    private String yFDW;//VARCHAR2(4)   Y药房规格
    private Integer yFBZ;//NUMBER(4)    N药房单位
    private String sJYL;//VARCHAR2(20)  Y药房包装
    private Integer pSPB;//NUMBER(1)    Y实际用量
    private Integer yYTS;//INTEGER      Y皮试判别
    private Double yCSL2;//NUMBER(10,4)Y用药天数
    private Double xSSL;//NUMBER(10,4) Y一次用量
    private Integer mRCS;//NUMBER(2)    N显示数量
    private String cFBZ;//VARCHAR2(40)  Y每日次数
    private Double yCJL;//NUMBER(10,2) Y处方标志
    private Integer pSJG;//NUMBER(1)    Y一次剂量
    private Integer pLXH;//NUMBER(4)    Y皮试结果
    private Integer sL;//numeric(18, 0)总数量
    private Integer yPSL1;//	numeric(10, 2)	Checked
    private Integer tgbz;//	int	Checked
    private Integer brjsh;//	numeric(18, 0)	Checked
    private Integer cSBZ;//	numeric(1, 0)	Checked
    private Integer jhjg;//	numeric(12, 4)	Unchecked
    private Integer jhje;//	numeric(12, 4)	Unchecked
    private String brjsh1;//	varchar(40)	Checked
    private String posLsh;//	varchar(6)	Checked
    private String jyje	;//varchar(12)	Checked
    private Integer jhjg1;//	numeric(12, 4)	Unchecked
    private Integer dzdr;//	numeric(1, 0)	Unchecked
    private Integer ypid;//	numeric(18, 0)	Checked
    @Id
    @Column(name = "SBXH")
    public Integer getSBXH() {
        return sBXH;
    }
    public void setSBXH(Integer sBXH) {
        this.sBXH = sBXH;
    }
    @Column(name = "CFSB")
    public Integer getCFSB() {
        return cFSB;
    }
    public void setCFSB(Integer cFSB) {
        this.cFSB = cFSB;
    }
    @Column(name = "YPXH")
    public Integer getYPXH() {
        return yPXH;
    }
    public void setYPXH(Integer yPXH) {
        this.yPXH = yPXH;
    }
    @Column(name = "YPCD")
    public Integer getYPCD() {
        return yPCD;
    }
    public void setYPCD(Integer yPCD) {
        this.yPCD = yPCD;
    }
    @Column(name = "XMLX")
    public Integer getXMLX() {
        return xMLX;
    }
    public void setXMLX(Integer xMLX) {
        this.xMLX = xMLX;
    }
    @Basic
    @Column(name = "CFTS")
    public Integer getCFTS() {
        return cFTS;
    }
    public void setCFTS(Integer cFTS) {
        this.cFTS = cFTS;
    }
    @Column(name = "YPSL")
    public Double getYPSL() {
        return yPSL;
    }
    public void setYPSL(Double yPSL) {
        this.yPSL = yPSL;
    }
    @Column(name = "YPDJ")
    public Double getYPDJ() {
        return yPDJ;
    }
    public void setYPDJ(Double yPDJ) {
        this.yPDJ = yPDJ;
    }
    @Column(name = "HJJE")
    public Double getHJJE() {
        return hJJE;
    }
    public void setHJJE(Double hJJE) {
        this.hJJE = hJJE;
    }
    @Column(name = "YPZS")
    public Integer getYPZS() {
        return yPZS;
    }
    public void setYPZS(Integer yPZS) {
        this.yPZS = yPZS;
    }
    @Column(name = "YCSL")
    public String getYCSL() {
        return yCSL;
    }
    public void setYCSL(String yCSL) {
        this.yCSL = yCSL;
    }
    @Column(name = "FYGB")
    public Integer getFYGB() {
        return fYGB;
    }
    public void setFYGB(Integer fYGB) {
        this.fYGB = fYGB;
    }
    @Column(name = "ZFBL")
    public Double getZFBL() {
        return zFBL;
    }
    public void setZFBL(Double zFBL) {
        this.zFBL = zFBL;
    }
    @Column(name = "GYTJ")
    public Integer getGYTJ() {
        return gYTJ;
    }
    public void setGYTJ(Integer gYTJ) {
        this.gYTJ = gYTJ;
    }
    @Column(name = "YPYF")
    public String getYPYF() {
        return yPYF;
    }
    public void setYPYF(String yPYF) {
        this.yPYF = yPYF;
    }
    @Column(name = "YPZH")
    public Integer getYPZH() {
        return yPZH;
    }
    public void setYPZH(Integer yPZH) {
        this.yPZH = yPZH;
    }
    @Column(name = "YFGG")
    public String getYFGG() {
        return yFGG;
    }
    public void setYFGG(String yFGG) {
        this.yFGG = yFGG;
    }
    @Column(name = "YFDW")
    public String getYFDW() {
        return yFDW;
    }
    public void setYFDW(String yFDW) {
        this.yFDW = yFDW;
    }
    @Column(name = "YFBZ")
    public Integer getYFBZ() {
        return yFBZ;
    }
    public void setYFBZ(Integer yFBZ) {
        this.yFBZ = yFBZ;
    }
    @Column(name = "SJYL")
    public String getSJYL() {
        return sJYL;
    }
    public void setSJYL(String sJYL) {
        this.sJYL = sJYL;
    }
    @Column(name = "PSPB")
    public Integer getPSPB() {
        return pSPB;
    }
    public void setPSPB(Integer pSPB) {
        this.pSPB = pSPB;
    }
    @Column(name = "YYTS")
    public Integer getYYTS() {
        return yYTS;
    }
    public void setYYTS(Integer yYTS) {
        this.yYTS = yYTS;
    }
    @Column(name = "YCSL2")
    public Double getYCSL2() {
        return yCSL2;
    }
    public void setYCSL2(Double yCSL2) {
        this.yCSL2 = yCSL2;
    }
    @Column(name = "XSSL")
    public Double getXSSL() {
        return xSSL;
    }
    public void setXSSL(Double xSSL) {
        this.xSSL = xSSL;
    }
    @Column(name = "MRCS")
    public Integer getMRCS() {
        return mRCS;
    }
    public void setMRCS(Integer mRCS) {
        this.mRCS = mRCS;
    }
    @Column(name = "CFBZ")
    public String getCFBZ() {
        return cFBZ;
    }
    public void setCFBZ(String cFBZ) {
        this.cFBZ = cFBZ;
    }
    @Column(name = "YCJL")
    public Double getYCJL() {
        return yCJL;
    }
    public void setYCJL(Double yCJL) {
        this.yCJL = yCJL;
    }
    @Column(name = "PSJG")
    public Integer getPSJG() {
        return pSJG;
    }
    public void setPSJG(Integer pSJG) {
        this.pSJG = pSJG;
    }
    @Column(name = "PLXH")
    public Integer getPLXH() {
        return pLXH;
    }
    public void setPLXH(Integer pLXH) {
        this.pLXH = pLXH;
    }
    @Column(name = "SL")
    public Integer getSL() {
        return sL;
    }
    public void setSL(Integer sL) {
        this.sL = sL;
    }
    @Column(name = "YPSL1")
    public Integer getYPSL1() {
        return yPSL1;
    }
    public void setYPSL1(Integer yPSL1) {
        this.yPSL1 = yPSL1;
    }
    @Column(name = "tgbz")
    public Integer getTgbz() {
        return tgbz;
    }
    public void setTgbz(Integer tgbz) {
        this.tgbz = tgbz;
    }
    @Column(name = "brjsh")
    public Integer getBrjsh() {
        return brjsh;
    }
    public void setBrjsh(Integer brjsh) {
        this.brjsh = brjsh;
    }
    @Column(name = "CSBZ")
    public Integer getCSBZ() {
        return cSBZ;
    }
    public void setCSBZ(Integer cSBZ) {
        this.cSBZ = cSBZ;
    }
    @Column(name = "jhjg")
    public Integer getJhjg() {
        return jhjg;
    }
    public void setJhjg(Integer jhjg) {
        this.jhjg = jhjg;
    }
    @Column(name = "jhje")
    public Integer getJhje() {
        return jhje;
    }
    public void setJhje(Integer jhje) {
        this.jhje = jhje;
    }
    @Column(name = "brjsh1")
    public String getBrjsh1() {
        return brjsh1;
    }
    public void setBrjsh1(String brjsh1) {
        this.brjsh1 = brjsh1;
    }
    @Column(name = "pos_lsh")
    public String getPosLsh() {
        return posLsh;
    }
    public void setPosLsh(String posLsh) {
        this.posLsh = posLsh;
    }
    @Column(name = "jyje")
    public String getJyje() {
        return jyje;
    }
    public void setJyje(String jyje) {
        this.jyje = jyje;
    }
    @Column(name = "jhjg1")
    public Integer getJhjg1() {
        return jhjg1;
    }
    public void setJhjg1(Integer jhjg1) {
        this.jhjg1 = jhjg1;
    }
    @Column(name = "dzdr")
    public Integer getDzdr() {
        return dzdr;
    }
    public void setDzdr(Integer dzdr) {
        this.dzdr = dzdr;
    }
    @Column(name = "ypid")
    public Integer getYpid() {
        return ypid;
    }
    public void setYpid(Integer ypid) {
        this.ypid = ypid;
    }
}

+ 96 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/TnyyController.java

@ -1,9 +1,14 @@
package com.yihu.jw.entrance.controller;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -13,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2020/1/19.
 */
@ -23,6 +31,8 @@ public class TnyyController extends EnvelopRestEndpoint {
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
    @Autowired
    private HibenateUtils hibenateUtils;
    @GetMapping(value = "/queryBySql")
    @ApiOperation(value = "视图统一查询")
@ -31,6 +41,92 @@ public class TnyyController extends EnvelopRestEndpoint {
        return success(tnyyEntranceService.queryBySql(sql));
    }
    @GetMapping(value = "/update")
    @ApiOperation(value = "更新实体类")
    public ObjEnvelop udapte(@ApiParam(name = "json", value = "json", required = true)
                             @RequestParam(value = "json",required = true)String json,
                             @ApiParam(name = "table", value = "table", required = true)
                             @RequestParam(value = "table",required = true)String table){
        ObjEnvelop envelop = new ObjEnvelop();
        JSONObject object = JSONObject.parseObject(json);
        if (table.equalsIgnoreCase("HLW_CF01")){
            HlwTnCf01DO hlwCf01VO =  JSONObject.toJavaObject(object,HlwTnCf01DO.class);
            tnyyEntranceService.update(hlwCf01VO);
            envelop.setObj(hlwCf01VO);
        } else if (table.equalsIgnoreCase("HLW_CF02")) {
            HlwTnCf02DO hlwCf02VO =  JSONObject.toJavaObject(object,HlwTnCf02DO.class);
            tnyyEntranceService.update(hlwCf02VO);
            envelop.setObj(hlwCf02VO);
        }
        return success(envelop);
    }
    @GetMapping(value = "/updateBySql")
    @ApiOperation(value = "更新支付")
    public ObjEnvelop updateBySql(@ApiParam(name = "sql", value = "sql语句", required = true)
                                  @RequestParam(value = "sql",required = true)String sql){
        ObjEnvelop envelop = new ObjEnvelop();
        tnyyEntranceService.updateBySql(sql);
        return success(envelop);
    }
    @GetMapping(value = "/save")
    @ApiOperation(value = "保存01表")
    public Envelop save(@ApiParam(name = "json", value = "json", required = true)
                                 @RequestParam(value = "json",required = true)String json,
                             @ApiParam(name = "table", value = "table", required = true)
                                 @RequestParam(value = "table",required = true)String table){
        ObjEnvelop envelop = new ObjEnvelop();
        JSONObject object = JSONObject.parseObject(json);
        if (table.equalsIgnoreCase("HLW_CF01")){
            HlwTnCf01DO hlwTnCf01DO =  JSONObject.toJavaObject(object,HlwTnCf01DO.class);
            String cfsbSql =" select DQZ + 1 as \"total\"  from GY_IDENTITY_MS where BMC = 'MS_CF01'";
            String cfhmSql="select DQZ + 1 as \"total\"  from GY_IDENTITY_MS where BMC = 'MS_CF01_CFHM'";
            List<Map<String,Object>> cfsbList = hibenateUtils.createSQLQuery(cfsbSql);
            List<Map<String,Object>> cfhmList = hibenateUtils.createSQLQuery(cfhmSql);
            Long cfsb = 0L;
            Long cfhm = 0L;
            if (cfsbList!=null&&cfsbList.size()!=0){
                cfsb = Long.parseLong(cfsbList.get(0).get("total").toString());
                System.out.println("cfsb:"+cfsb);
                String updateCfsb = "update GY_IDENTITY_MS set DQZ=DQZ+1 where BMC = 'MS_CF01'";
                hibenateUtils.updateBySql(updateCfsb);
            }
            if (cfhmList!=null&&cfhmList.size()!=0){
                cfhm = Long.parseLong(cfhmList.get(0).get("total").toString());
                System.out.println("cfhm:"+cfhm);
                String updateCfhm = "update GY_IDENTITY_MS set DQZ=DQZ+1 where BMC = 'MS_CF01_CFHM'";
                hibenateUtils.updateBySql(updateCfhm);
            }
            hlwTnCf01DO.setCFSB(cfsb.intValue());
            hlwTnCf01DO.setCFHM(cfhm+"");
            JSONObject object1 = new JSONObject();
            object1.put("cfsb",cfsb);
            object1.put("cfhm",cfhm);
            tnyyEntranceService.save(hlwTnCf01DO);
            envelop.setObj(object1);
        }else if (table.equalsIgnoreCase("HLW_CF02")){
            HlwTnCf02DO hlwCf02DO =  JSONObject.toJavaObject(object,HlwTnCf02DO.class);
            String sbxhSql =" select DQZ + 1 as \"total\"  from GY_IDENTITY_MS where BMC = 'MS_CF02'";
            List<Map<String,Object>> sbxhList = hibenateUtils.createSQLQuery(sbxhSql);
            Long sbxh = 0L;
            if (sbxhList!=null&&sbxhList.size()!=0){
                sbxh = Long.parseLong(sbxhList.get(0).get("total").toString());
                String updateSbxh = "update GY_IDENTITY_MS set DQZ=DQZ+1 where BMC = 'MS_CF02'";
                hibenateUtils.updateBySql(updateSbxh);
            }
            JSONObject object1 = new JSONObject();
            object1.put("sbxh",sbxh);
            envelop.setObj(object1);
            hlwCf02DO.setSBXH(sbxh.intValue());
            tnyyEntranceService.save(hlwCf02DO);
        }
        return envelop;
    }
    
}

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -232,7 +232,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		
			JSONObject result = new JSONObject();
			synchronized (outpatientCode.intern()){
				if(!"xm_ykyy_wx".equals(wxId)){//中山医院-心脏中心需要挂号
				if(!"xm_ykyy_wx".equals(wxId)&&!"sd_tnzyy_wx".equals(wxId)){//中山医院-心脏中心需要挂号
					//1.调用挂号接口
					logger.info("调用挂号接口====START");
					String rsCode = "";

+ 13 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -2672,4 +2672,17 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping("/syncPrescription")
    @ApiOperation(value = "同步泰安处方")
    public Envelop syncPrescription( @ApiParam(name = "code", value = "code")
                                @RequestParam(value = "code",required = false)String code) throws Exception {
        try {
            return success(tnyyEntranceService.findByRealOrder(code,demoFlag));
        } catch (Exception e) {
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 9 - 1
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/AccountDao.java

@ -3,11 +3,13 @@ package com.yihu.jw.dao;/**
 */
import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.entity.health.bank.ActivityRuleDO;
import com.yihu.jw.entity.health.bank.ActivityDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author wangzhinan
 * @create 2018-05-10 11:15
@ -16,4 +18,10 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface AccountDao extends PagingAndSortingRepository<AccountDO,String>,JpaSpecificationExecutor<AccountDO> {
    @Query("select t from AccountDO t where t.patientId=?1 and t.status=1")
    AccountDO selectByPatientId(String patientId);
    @Query("select t from AccountDO t where t.patientId=?1 and t.status=1")
    List<AccountDO> selectsByPatientId(String patientId);
    @Query("select t from AccountDO t where t.patientId=?1")
    List<AccountDO> findByPatientId(String patientId);
}

+ 5 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/TaskPatientDetailDao.java

@ -17,9 +17,14 @@ public interface TaskPatientDetailDao extends PagingAndSortingRepository<TaskPat
    @Query("select t from TaskPatientDetailDO t where taskId = ?1")
    List<TaskPatientDetailDO> selectByTaskId(String taskId);
    @Query("select t from TaskPatientDetailDO t where taskId = ?1 and patientOpenid = ?2")
    List<TaskPatientDetailDO> selectByTaskIdAndOpenid(String taskId,String openId);
    @Query("select t from TaskPatientDetailDO t where taskId = ?1 and patientId =?2")
    TaskPatientDetailDO selectByTaskIdAndPatientId(String taskId,String patientId);
    @Query("select t from TaskPatientDetailDO t where taskId = ?1 and patientId =?2")
    List<TaskPatientDetailDO> selectByTaskIdAndPatientId2(String taskId,String patientId);
    @Query("select t from TaskPatientDetailDO t where activityId = ?1 and patientId =?2")
    TaskPatientDetailDO selectByActivityIdAndPatientId(String activityId,String patientId);

+ 12 - 28
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/AccountService.java

@ -9,11 +9,11 @@ import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.entity.health.bank.TaskDO;
import com.yihu.jw.entity.health.bank.TaskPatientDetailDO;
import com.yihu.jw.entity.health.bank.TaskRuleDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -131,6 +131,7 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                buffer.deleteCharAt(buffer.length()-1);
                buffer.append(") ");
                String accountSql = "select * from wlyy_health_bank_account where patient_id in "+buffer;
                accountSql = TransforSqlUtl.wlyyHealthBankAccountAll(accountSql);
                List<AccountDO> accountDOSList = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper<>(AccountDO.class));
                if (accountDOSList != null && accountDOSList.size() !=0){
                    String sql2 = " SELECT " +
@ -171,19 +172,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                            " ( " +
                            " SELECT " +
                            " ba.id AS id, " +
                            " ba.total /*+ COALESCE (bacd1.sum, 0)*/ AS sum " +
                            " ba.total AS sum " +
                            " FROM " +
                            " wlyy_health_bank_account ba " +
                            /*" LEFT JOIN ( " +
                            " SELECT " +
                            " COALESCE (SUM(bacd.integrate), 0) AS sum, " +
                            " bacd.account_id " +
                            "  FROM " +
                            " wlyy_health_bank_credits_detail bacd " +
                            " WHERE " +
                            " bacd.trade_direction = - 1 " +
                            " GROUP BY " +
                            " bacd.account_id ) bacd1 ON ba.id = bacd1.account_id "+*/
                            " WHERE " +
                            " ba.id IN " +buffer1+
                            " )ba1 WHERE ba1.sum > "+accountDO1.getSum();
@ -204,19 +195,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                            " ( " +
                            " SELECT " +
                            " ba.id AS id, " +
                            " ba.total /*+ COALESCE (bacd1.sum, 0)*/ AS sum " +
                            " ba.total AS sum " +
                            " FROM " +
                            " wlyy_health_bank_account ba " +
                            /*" LEFT JOIN ( " +
                            " SELECT " +
                            " COALESCE (SUM(bacd.integrate), 0) AS sum, " +
                            " bacd.account_id " +
                            "  FROM " +
                            " wlyy_health_bank_credits_detail bacd " +
                            " WHERE " +
                            " bacd.trade_direction = - 1 " +
                            " GROUP BY " +
                            " bacd.account_id ) bacd1 ON ba.id = bacd1.account_id " +*/
                            " )ba1 WHERE ba1.sum > "+accountDO1.getSum();
                    List<Map<String,Object>> rstotal5 = jdbcTemplate.queryForList(sql4);
                    Integer Count2 = 0;
@ -251,8 +232,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
    public MixEnvelop<AccountDO, AccountDO> findByCondition1(JSONArray patients, String ruleId, Integer page, Integer size){
        for (int i=0;i<patients.size();i++){
            String patientId = patients.getJSONObject(i).getString("code");
            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(patientId);
            if (accountDOS == null || accountDOS.size() == 0) {
                AccountDO accountDO1 = new AccountDO();
                accountDO1.setPatientId(patientId);
@ -318,7 +300,7 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
        String sql =
                "SELECT ba1.patient_id AS patient_id," +
                        "AES_DECRYPT(from_base64(ba1.account_name,"+ AesEncryptUtils.KEY+") AS account_name," +
                        "ba1.account_name AS account_name," +
                        "ba1.hospital AS hospital," +
                        "ba1.total AS total," +
                        "ba1.create_time AS create_time," +
@ -349,6 +331,7 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
                        "LIMIT "+(page-1)*size+","+size +")ba1" +
                        " ORDER BY " +
                        " ba1.sum DESC";
        sql = TransforSqlUtl.accountName(sql);
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        String sqlCount = "SELECT count(1) AS total"+
                " FROM " +
@ -384,8 +367,9 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
     */
    public MixEnvelop<AccountDO, AccountDO> selectByPatient(String patient,String name,String hospital,String hospitalName,String idcard){
        MixEnvelop<AccountDO,AccountDO> envelop = new MixEnvelop<>();
        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patient+"'";
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patient+"'";
//        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        List<AccountDO> accountDOS = accountDao.selectsByPatientId(patient);
        if (accountDOS == null || accountDOS.size()==0){
            AccountDO accountDO = new AccountDO();
            accountDO.setTotal(0);

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

@ -12,6 +12,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
@ -170,75 +171,75 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            accountDO = accountDao.save(accountDO);
        }
        ActivityDO activityDO = activityDao.selectByTemplateIdAndType(planCode,"健康计划");
       if (activityDO==null){
           activityDO = new ActivityDO();
           activityDO.setStatus(1);
           activityDO.setSaasId("dev");
           activityDO.setCreateTime(new Date());
           activityDO.setUpdateTime(new Date());
           activityDO.setOrganizer("SYSTEM");
           activityDO.setTitle(templateName);
           activityDO.setType("健康计划");
           activityDO.setDescription(templateName);
           activityDO.setGlobelTemplate(planCode);
           activityDO.setIntroduction(templateName);
           activityDO.setIsFlag(-1);
           activityDO.setDelFlag(1);
           activityDO =  activityDao.save(activityDO);
           TaskDO taskDO = new TaskDO();
           taskDO.setSaasId("dev");
           taskDO.setCreateTime(new Date());
           taskDO.setUpdateTime(new Date());
           taskDO.setTitle(templateName);
           taskDO.setType("ACTIVITY_TASK");
           taskDO.setTaskCode("ACTIVITY_PLAN");
           taskDO.setTransactionId(activityDO.getId());
           taskDO.setContent(templateName);
           taskDO.setStatus(1);
           taskDO = taskDao.save(taskDO);
           TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
           if (taskPatientDetailDO==null){
               taskPatientDetailDO = new TaskPatientDetailDO();
               taskPatientDetailDO.setSaasId("dev");
               taskPatientDetailDO.setTaskId(taskDO.getId());
               taskPatientDetailDO.setActivityId(activityDO.getId());
               taskPatientDetailDO.setPatientIdcard(idcard);
               taskPatientDetailDO.setPatientId(patient);
               taskPatientDetailDO.setHospital(hospital);
               taskPatientDetailDO.setHospitalName(hospitalName);
               taskPatientDetailDO.setCreateTime(new Date());
               taskPatientDetailDO.setUpdateTime(new Date());
               taskPatientDetailDO.setTotal(0L);
               taskPatientDetailDO.setCouponTotal(0L);
               taskPatientDetailDO.setStatus(1);
               taskPatientDetailDao.save(taskPatientDetailDO);
           }
       }else {
           List<TaskDO> taskDOS = taskDao.selectByActivityId(activityDO.getId());
           if (taskDOS!=null&&taskDOS.size()!=0){
               TaskDO taskDO = taskDOS.get(0);
               TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
               if (taskPatientDetailDO==null){
                   taskPatientDetailDO = new TaskPatientDetailDO();
                   taskPatientDetailDO.setSaasId("dev");
                   taskPatientDetailDO.setTaskId(taskDO.getId());
                   taskPatientDetailDO.setActivityId(activityDO.getId());
                   taskPatientDetailDO.setPatientIdcard(idcard);
                   taskPatientDetailDO.setPatientId(patient);
                   taskPatientDetailDO.setHospital(hospital);
                   taskPatientDetailDO.setHospitalName(hospitalName);
                   taskPatientDetailDO.setCreateTime(new Date());
                   taskPatientDetailDO.setUpdateTime(new Date());
                   taskPatientDetailDO.setTotal(0L);
                   taskPatientDetailDO.setCouponTotal(0L);
                   taskPatientDetailDO.setStatus(1);
                   taskPatientDetailDao.save(taskPatientDetailDO);
               }
           }
        if (activityDO==null){
            activityDO = new ActivityDO();
            activityDO.setStatus(1);
            activityDO.setSaasId("dev");
            activityDO.setCreateTime(new Date());
            activityDO.setUpdateTime(new Date());
            activityDO.setOrganizer("SYSTEM");
            activityDO.setTitle(templateName);
            activityDO.setType("健康计划");
            activityDO.setDescription(templateName);
            activityDO.setGlobelTemplate(planCode);
            activityDO.setIntroduction(templateName);
            activityDO.setIsFlag(-1);
            activityDO.setDelFlag(1);
            activityDO =  activityDao.save(activityDO);
            TaskDO taskDO = new TaskDO();
            taskDO.setSaasId("dev");
            taskDO.setCreateTime(new Date());
            taskDO.setUpdateTime(new Date());
            taskDO.setTitle(templateName);
            taskDO.setType("ACTIVITY_TASK");
            taskDO.setTaskCode("ACTIVITY_PLAN");
            taskDO.setTransactionId(activityDO.getId());
            taskDO.setContent(templateName);
            taskDO.setStatus(1);
            taskDO = taskDao.save(taskDO);
            TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
            if (taskPatientDetailDO==null){
                taskPatientDetailDO = new TaskPatientDetailDO();
                taskPatientDetailDO.setSaasId("dev");
                taskPatientDetailDO.setTaskId(taskDO.getId());
                taskPatientDetailDO.setActivityId(activityDO.getId());
                taskPatientDetailDO.setPatientIdcard(idcard);
                taskPatientDetailDO.setPatientId(patient);
                taskPatientDetailDO.setHospital(hospital);
                taskPatientDetailDO.setHospitalName(hospitalName);
                taskPatientDetailDO.setCreateTime(new Date());
                taskPatientDetailDO.setUpdateTime(new Date());
                taskPatientDetailDO.setTotal(0L);
                taskPatientDetailDO.setCouponTotal(0L);
                taskPatientDetailDO.setStatus(1);
                taskPatientDetailDao.save(taskPatientDetailDO);
            }
        }else {
            List<TaskDO> taskDOS = taskDao.selectByActivityId(activityDO.getId());
            if (taskDOS!=null&&taskDOS.size()!=0){
                TaskDO taskDO = taskDOS.get(0);
                TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patient);
                if (taskPatientDetailDO==null){
                    taskPatientDetailDO = new TaskPatientDetailDO();
                    taskPatientDetailDO.setSaasId("dev");
                    taskPatientDetailDO.setTaskId(taskDO.getId());
                    taskPatientDetailDO.setActivityId(activityDO.getId());
                    taskPatientDetailDO.setPatientIdcard(idcard);
                    taskPatientDetailDO.setPatientId(patient);
                    taskPatientDetailDO.setHospital(hospital);
                    taskPatientDetailDO.setHospitalName(hospitalName);
                    taskPatientDetailDO.setCreateTime(new Date());
                    taskPatientDetailDO.setUpdateTime(new Date());
                    taskPatientDetailDO.setTotal(0L);
                    taskPatientDetailDO.setCouponTotal(0L);
                    taskPatientDetailDO.setStatus(1);
                    taskPatientDetailDao.save(taskPatientDetailDO);
                }
            }
       }
       envelop.setObj(activityDO);
       return envelop;
        }
        envelop.setObj(activityDO);
        return envelop;
    }
@ -274,10 +275,9 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
            activityDO1.setTotal(count);
            String taskSql1 = "select * from wlyy_health_bank_task_patient_detail btpd where activity_id = '"+activityDO1.getId()
                    +"' and (patient_idcard = '"+ AesEncryptUtils.encrypt(activityDO.getPatientIdcard())+"' OR union_id = '"+activityDO.getUnionId()+"')";
            taskSql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(taskSql1);
            List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
            for (TaskPatientDetailDO taskPatientDetailDO : taskPatientDetailDOS){
                taskPatientDetailDO.setPatientIdcard(AesEncryptUtils.decrypt(taskPatientDetailDO.getPatientIdcard()));
            }
            activityDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
            String tasksql = "select * from wlyy_health_bank_task where transaction_id = '"+activityDO1.getId()+"'";
            List<TaskDO> taskDOList = jdbcTemplate.query(tasksql,new BeanPropertyRowMapper(TaskDO.class));
@ -534,31 +534,31 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
     */
    public MixEnvelop<Boolean, Boolean> daleteActivity(String id){
        MixEnvelop<Boolean, Boolean> envelop = new MixEnvelop<>();
            List<TaskDO> taskDOList = taskDao.selectByActivityId(id);
            for (TaskDO taskDO:taskDOList){
                taskDO.setStatus(0);
                taskDO.setCreateTime(new Date());
                taskDO.setUpdateTime(new Date());
                taskDao.save(taskDO);
            }
            List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByActivityId(id);
            for(TaskPatientDetailDO taskPatientDetailDO:taskPatientDetailDOS){
                taskPatientDetailDO.setStatus(-1);
                taskPatientDetailDO.setCreateTime(new Date());
                taskPatientDetailDO.setUpdateTime(new Date());
                taskPatientDetailDao.save(taskPatientDetailDO);
            }
            ActivityRuleDO ruleDO = activityRuleDao.selectByActivityId(id);
            if(null!=ruleDO){
                ruleDO.setDelFlag(0);
                activityRuleDao.save(ruleDO);
            }
            ActivityDO activityDO = activityDao.findOne(id);
            activityDO.setStatus(-1);
            activityDO.setCreateTime(new Date());
            activityDO.setUpdateTime(new Date());
            activityDO.setDelFlag(0);
            activityDao.save(activityDO);
        List<TaskDO> taskDOList = taskDao.selectByActivityId(id);
        for (TaskDO taskDO:taskDOList){
            taskDO.setStatus(0);
            taskDO.setCreateTime(new Date());
            taskDO.setUpdateTime(new Date());
            taskDao.save(taskDO);
        }
        List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByActivityId(id);
        for(TaskPatientDetailDO taskPatientDetailDO:taskPatientDetailDOS){
            taskPatientDetailDO.setStatus(-1);
            taskPatientDetailDO.setCreateTime(new Date());
            taskPatientDetailDO.setUpdateTime(new Date());
            taskPatientDetailDao.save(taskPatientDetailDO);
        }
        ActivityRuleDO ruleDO = activityRuleDao.selectByActivityId(id);
        if(null!=ruleDO){
            ruleDO.setDelFlag(0);
            activityRuleDao.save(ruleDO);
        }
        ActivityDO activityDO = activityDao.findOne(id);
        activityDO.setStatus(-1);
        activityDO.setCreateTime(new Date());
        activityDO.setUpdateTime(new Date());
        activityDO.setDelFlag(0);
        activityDao.save(activityDO);
        return envelop;
    }
@ -795,7 +795,7 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
                " wlyy_health_bank_task_patient_detail btpd WHERE btpd.activity_id ='"+activityId+"' AND btpd.patient_id !='"+patient+
                "' GROUP BY patient_id )btpd1 " +
                "WHERE " +
                 " btpd1.sum >= (SELECT SUM(s.total) as total " +
                " btpd1.sum >= (SELECT SUM(s.total) as total " +
                "FROM  wlyy_health_bank_task_patient_detail s WHERE s.patient_id ='"+patient+"' AND  s.activity_id='"+activityId+"')" +
                " ORDER BY btpd1.sum desc "+
                " limit "+countTotal1+",1" ;

+ 142 - 299
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java

@ -11,6 +11,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.slf4j.Logger;
@ -70,13 +71,13 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    @Value("${account.initPassword}")
    private String initPassword;
   /**
    /**
     *  find creditsLogInfo
     *
     * @return
     * @throws ParseException
     */
   public MixEnvelop<CreditsDetailDO, CreditsDetailDO> findByCondition(CreditsDetailDO creditsDetailDO, Integer page, Integer size) throws ParseException {
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> findByCondition(CreditsDetailDO creditsDetailDO, Integer page, Integer size) throws ParseException {
        String sql = new ISqlUtils().getSql(creditsDetailDO,page,size,"*");
        List<CreditsDetailDO> creditsDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(CreditsDetailDO.class));
        for (CreditsDetailDO creditsDetailDO1 : creditsDetailDOS){
@ -248,20 +249,6 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        return MixEnvelop.getSuccess(HealthBankMapping.api_success,accountDO);
    }
    /*
    public Envelop<Boolean> exchangeGoods(GoodsDO goodsDO){
        CreditsDetailDO creditsLogDetailDO = new CreditsDetailDO();
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
*/
    public MixEnvelop<AccountDO, AccountDO> selectByRanking(List<String> patientIds, Integer page, Integer size){
        StringBuffer buffer = new StringBuffer();
        buffer.append(" ba.patient_id in(");
@ -276,7 +263,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        buffer.append(") ");
        String sql =
                "SELECT ba1.patient_id AS patient_id," +
                        "AES_DECRYPT(from_base64(ba1.account_name,"+ AesEncryptUtils.KEY+") AS account_name," +
                        "ba1.account_name AS account_name," +
                        "ba1.hospital AS hospital," +
                        "ba1.total AS total," +
                        "ba1.create_time AS create_time," +
@ -307,6 +294,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        " ORDER BY " +
                        " ba1.total DESC"+
                        " LIMIT "+(page-1)*size+","+size ;
        sql = TransforSqlUtl.accountName(sql);
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        String sqlCount = "SELECT count(1) AS total"+
                " FROM " +
@ -344,8 +332,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> insert(CreditsDetailDO creditsDetailDO){
        try {
            synchronized (creditsDetailDO.getPatientId()){
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0){
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }else {
@ -366,7 +355,8 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                    accountDO1.setCreateTime(new Date());
                    accountDO1.setUpdateTime(new Date());
                    accountDao.save(accountDO1);
                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    List<AccountDO> accountDOS = accountDao.findByPatientId(creditsDetailDO.getPatientId());
//                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    creditsDetailDO.setAccountId(accountDOS.get(0).getId());
                }
                TaskDO taskDO = new TaskDO();
@ -381,8 +371,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                TaskRuleDO taskRuleDO = taskRuleDOS.get(0);
                creditsDetailDO.setIntegrate(taskRuleDO.getIntegrate());
                creditsDetailDO.setTradeDirection(taskRuleDO.getTradeDirection());
                String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDOList.get(0).getId()+"' and patient_id = '" + creditsDetailDO.getPatientId() +"'";
                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
//                String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDOList.get(0).getId()+"' and patient_id = '" + creditsDetailDO.getPatientId() +"'";
//                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndPatientId2(taskDOList.get(0).getId(),creditsDetailDO.getPatientId());
                if (taskPatientDetailDOS == null || taskPatientDetailDOS.size() ==0){
                    TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
                    taskPatientDetailDO.setTaskId(creditsDetailDO.getTransactionId());
@ -400,6 +391,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                }else if (taskPatientDetailDOS != null && taskDOList.get(0).getPeriod() == 0){
                    String taskSql1 = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDOList.get(0).getId()+
                            "' and patient_id = '"+creditsDetailDO.getPatientId()+"' and create_time > '" + DateUtils.getDayBegin() +"' and create_time < '"+ DateUtils.getDayEnd() +"'";
                    taskSql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(taskSql1);
                    List<TaskPatientDetailDO> taskPatientDetailDOS1 = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                    if (taskPatientDetailDOS1 == null || taskPatientDetailDOS1.size() == 0){
                        TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
@ -508,8 +500,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                " ORDER BY btpd1.total DESC "+" LIMIT " + (page-1)*size+","+size;
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        for (TaskPatientDetailDO taskPatientDetailDO : taskPatientDetailDOS){
            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
//            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(taskPatientDetailDO.getPatientId());
            taskPatientDetailDO.setAccountDO(accountDOS.get(0));
        }
        String sqlCount =  "SELECT " +
@ -632,28 +625,10 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        logger.info(taskPatientDetailDOS.toString()+""+taskPatientDetailDOS.size());
        for (int i = 0;taskPatientDetailDOS != null&&taskPatientDetailDOS.size()!=0 && i<taskPatientDetailDOS.size();i++){
            TaskPatientDetailDO taskPatientDetailDO = taskPatientDetailDOS.get(i);
            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
//            String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(taskPatientDetailDO.getPatientId());
            if (taskPatientDetailDOS.get(i).getPatientId().equalsIgnoreCase(patientId)){
                /*String taskSql = "select count(1)+1 as total from (" +
                        "select *  from (SELECT " +
                        " SUM(ptpd.total) AS total, " +
                        " ptpd.patient_openid AS patient_openid, " +
                        " ptpd.task_id AS task_id, " +
                        " ptpd.activity_id AS activity_id, " +
                        " ptpd.create_time as create_time, " +
                        " ptpd.patient_id AS patient_id " +
                        " FROM " +
                        " wlyy_health_bank_task_patient_detail ptpd " +
                        " WHERE " +
                        " activity_id = '" + activityId + "')ptpd1 where" +
                        " ptpd1.patient_id = '"+patientId+"' AND ptpd1.total > "+taskPatientDetailDOS.get(i).getTotal()+") ptpd2";
                List<Map<String,Object>> rstotal1 = jdbcTemplate.queryForList(taskSql);
                Long count = 0L;
                if(rstotal1!=null&&rstotal1.size()>0){
                    count = (Long) rstotal1.get(0).get("total");
                }
                accountDOS.get(0).setActivityRanking(count);*/
                taskPatientDetailDO.setIsFlag(1);
            }else {
                taskPatientDetailDO.setIsFlag(0);
@ -730,25 +705,28 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                taskDO1 = taskDOList.get(0);
            }
            if (taskRuleDO.getPeriod() == 1){
                    String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"'";
                    List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                    if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                        throw new Exception("已奖励过");
                    }
//                    String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"'";
//                    List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndPatientId2(taskDO1.getId(),patientId);
                if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                    throw new Exception("已奖励过");
                }
            }else if (taskRuleDO.getPeriod() == 0){
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                    Date date = new Date();
                    String date1 = dateFormat.format(date);
                    String begin = DateUtils.getMinMonthDate(date1);
                    String end = DateUtils.getMaxMonthDate(date1);
                    String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"' AND create_time > '"+begin+"' AND create_time < '"+end+"'";
                    List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                    if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                        throw new Exception("已奖励过");
                    }
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                Date date = new Date();
                String date1 = dateFormat.format(date);
                String begin = DateUtils.getMinMonthDate(date1);
                String end = DateUtils.getMaxMonthDate(date1);
                String sql = "select * from wlyy_health_bank_task_patient_detail where patient_id = '"+patientId+"'AND task_id ='"+taskDO1.getId()+"' AND create_time > '"+begin+"' AND create_time < '"+end+"'";
                sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                if (taskPatientDetailDOS != null && taskPatientDetailDOS.size() != 0){
                    throw new Exception("已奖励过");
                }
            }
            String sql1 = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+"' " +
                    "AND patient_idcard = '"+AesEncryptUtils.encrypt(idCard)+"' AND patient_openid = '"+openId+"' AND union_id = '"+unionId+"'";
                    "AND patient_idcard = '"+ AesEncryptUtils.decrypt(idCard) +"' AND patient_openid = '"+openId+"' AND union_id = '"+unionId+"'";
            sql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql1);
            List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
            TaskPatientDetailDO taskPatientDetailDO1 = new TaskPatientDetailDO();
            if (taskPatientDetailDOS.isEmpty() && taskPatientDetailDOS.size() == 0){
@ -767,8 +745,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
            }else {
                taskPatientDetailDO1 = taskPatientDetailDOS.get(0);
            }
            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//            String sql = "select * from wlyy_health_bank_account where patient_id = '"+patientId+"'";
//            List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOS = accountDao.findByPatientId(patientId);
            if (taskRuleDO.getTradeDirection() == -1 && taskRuleDO.getIntegrate() == 0){
                String integrateSql = "select * from wlyy_health_bank_credits_detail where patient_id = '"+patientId+"' " +
                        "AND transaction_id IN (SELECT id FROM wlyy_health_bank_task WHERE task_code IN ('BP_BIND','GLU_BIND','BP_MEASURE','GLU_MEASURE','RULE'))";
@ -849,46 +828,12 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        return envelop;
    }
    /**
     * 固定数据
     *
     * @param
     * @return
     *//*
    public List<TaskDO> getTasks(String patientId){
        List<TaskDO> taskDOList = new ArrayList<>();
        TaskDO taskDO = new TaskDO();
        *//*taskDO.setPatientId(patientId);*//*
        taskDO.setTaskCode("BIND");
        taskDO.setPeriod(1);
        taskDO.setTaskTitle("首次绑定");
        taskDO.setTaskContent("(绑定社区登记发放的设备,可获得各类型设备的首绑奖励。)");
        taskDO.setTradeType("activity");
        taskDO.setTransactionId("402885e96324a409016324c0a45a0006");
        taskDO.setCreateTime(new Date());
        taskDO.setUpdateTime(new Date());
        taskDOList.add(taskDO);
        TaskDO taskDO1 = new TaskDO();
        *//*taskDO1.setPatientId(patientId);*//*
        taskDO1.setTaskCode("MEASURE");
        taskDO1.setPeriod(0);
        taskDO1.setTaskTitle("每日测量");
        taskDO1.setTaskContent("(使用社区发放的已关联您身份信息的设备,绑定后每天完成测量)");
        taskDO1.setTradeType("activity");
        taskDO1.setTransactionId("402885e96324a409016324c0a45a0006");
        taskDO1.setCreateTime(new Date());
        taskDO1.setUpdateTime(new Date());
        taskDOList.add(taskDO1);
        return taskDOList;
    }
*/
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> stepAddIntegrate(CreditsDetailDO creditsDetailDO){
        try {
            synchronized (creditsDetailDO.getPatientId()){
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '"+creditsDetailDO.getPatientId() +"'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0){
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }else {
@ -910,11 +855,13 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                    accountDO1.setCreateTime(new Date());
                    accountDO1.setUpdateTime(new Date());
                    accountDao.save(accountDO1);
                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    List<AccountDO> accountDOS = accountDao.findByPatientId(creditsDetailDO.getPatientId());
//                    List<AccountDO> accountDOS = jdbcTemplate.query(sqlAccount,new BeanPropertyRowMapper(AccountDO.class));
                    creditsDetailDO.setAccountId(accountDOS.get(0).getId());
                }
                String sql1 = "select *  from wlyy_health_bank_task_patient_detail where "+
                        " patient_idcard = '"+AesEncryptUtils.encrypt(creditsDetailDO.getIdCard())+"' AND union_id = '"+creditsDetailDO.getUnionId()+"' AND task_id = '"+creditsDetailDO.getTransactionId()+"'";
                        " patient_idcard = '"+ AesEncryptUtils.encrypt(creditsDetailDO.getIdCard()) +"' AND union_id = '"+creditsDetailDO.getUnionId()+"' AND task_id = '"+creditsDetailDO.getTransactionId()+"'";
                sql1 = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql1);
                List<TaskPatientDetailDO> taskPatientDetailDOList = jdbcTemplate.query(sql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                if(taskPatientDetailDOList == null || taskPatientDetailDOList.size()==0){
                    throw new Exception("该居民参与活动查不到!");
@ -988,100 +935,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        }
                    }
                }
          /*  for (int i = 0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                if (creditsDetailDOS != null && creditsDetailDOS.size() != 0){
                    CreditsDetailDO creditsDetailDO1 = creditsDetailDOS.get(0);
                    TaskRuleDO taskRuleDO = taskRuleDao.findOne(taskDO.getRuleCode());
                    if (creditsDetailDO.getStepNumber() < step1 && creditsDetailDO.getStepNumber() >0){
                        creditsDetailDO1.setIntegrate(0);
                        creditsDetailDO1.setTradeDirection(1);
                        CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                        AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                        accountDO.setTotal(accountDO.getTotal()+creditsDetailDO2.getIntegrate());
                        AccountDO accountDO1 = accountDao.save(accountDO);
                        creditsDetailDO2.setTotal(accountDO1.getTotal());
                        taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+creditsDetailDO2.getIntegrate());
                        taskPatientDetailDao.save(taskPatientDetailDO);
                        creditsDetailDOS.clear();
                        creditsDetailDOS.add(creditsDetailDO2);
                    }else if (creditsDetailDO.getStepNumber() >= step1 && creditsDetailDO.getStepNumber() < step2){
                        creditsDetailDO1.setIntegrate(creditsDetailDO1.getIntegrate()+1);
                        creditsDetailDO1.setTradeDirection(1);
                        CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                        AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                        accountDO.setTotal(accountDO.getTotal()+(creditsDetailDO2.getIntegrate()));
                        AccountDO accountDO1 = accountDao.save(accountDO);
                        creditsDetailDO2.setTotal(accountDO1.getTotal());
                        taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+(creditsDetailDO2.getIntegrate()));
                        taskPatientDetailDao.save(taskPatientDetailDO);
                        creditsDetailDOS.clear();
                        creditsDetailDOS.add(creditsDetailDO2);
                    }else if (creditsDetailDO.getStepNumber() >= step2){
                        if (creditsDetailDO1.getIntegrate() == 1){
                            creditsDetailDO1.setIntegrate(2);
                            creditsDetailDO1.setTradeDirection(1);
                            CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                            AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                            accountDO.setTotal(accountDO.getTotal()+(creditsDetailDO2.getIntegrate()-1));
                            AccountDO accountDO1 = accountDao.save(accountDO);
                            creditsDetailDO2.setTotal(accountDO1.getTotal());
                            taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+(creditsDetailDO2.getIntegrate()-1));
                            taskPatientDetailDao.save(taskPatientDetailDO);
                            creditsDetailDOS.clear();
                            creditsDetailDOS.add(creditsDetailDO2);
                        }*//*else if(creditsDetailDO1.getIntegrate() == 3){
                            creditsDetailDO1.setIntegrate(creditsDetailDO1.getIntegrate()+5);
                            creditsDetailDO1.setTradeDirection(1);
                            CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                            AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                            accountDO.setTotal(accountDO.getTotal()+(creditsDetailDO2.getIntegrate()-3));
                            AccountDO accountDO1 = accountDao.save(accountDO);
                            creditsDetailDO2.setTotal(accountDO1.getTotal());
                            taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+(creditsDetailDO2.getIntegrate()-3));
                            taskPatientDetailDao.save(taskPatientDetailDO);
                            creditsDetailDOS.clear();
                            creditsDetailDOS.add(creditsDetailDO2);
                        }*//*
                    }
                }else{
                    CreditsDetailDO creditsDetailDO1 = new CreditsDetailDO();
                    if (creditsDetailDO.getStepNumber() < step1 && creditsDetailDO.getStepNumber() >0){
                        creditsDetailDO1.setIntegrate(0);
                        creditsDetailDO1.setTradeDirection(1);
                    }else if (creditsDetailDO.getStepNumber() >= step1 && creditsDetailDO.getStepNumber() < step2){
                        creditsDetailDO1.setIntegrate(1);
                        creditsDetailDO1.setTradeDirection(1);
                    }else if (creditsDetailDO.getStepNumber() >=step2){
                        creditsDetailDO1.setIntegrate(2);
                        creditsDetailDO1.setTradeDirection(1);
                    }
                    creditsDetailDO1.setSaasId("dev");
                    creditsDetailDO1.setTradeType("ACTIVITY_TASK");
                    creditsDetailDO1.setPatientId(creditsDetailDO.getPatientId());
                    creditsDetailDO1.setHospital(creditsDetailDO.getHospital());
                    creditsDetailDO1.setHospitalName(creditsDetailDO.getHospitalName());
                    creditsDetailDO1.setAccountId(creditsDetailDO.getAccountId());
                    creditsDetailDO1.setStatus(1);
                    creditsDetailDO1.setCreateTime(new Date());
                    creditsDetailDO1.setUpdateTime(new Date());
                    creditsDetailDO1.setTransactionId(taskPatientDetailDO.getTaskId());
                    CreditsDetailDO creditsDetailDO2 = credittsLogDetailDao.save(creditsDetailDO1);
                    AccountDO accountDO = accountDao.findOne(creditsDetailDO2.getAccountId());
                    accountDO.setTotal(accountDO.getTotal()+creditsDetailDO2.getIntegrate());
                    taskPatientDetailDO.setTotal(taskPatientDetailDO.getTotal()+creditsDetailDO2.getIntegrate());
                    taskPatientDetailDao.save(taskPatientDetailDO);
                    creditsDetailDO2.setTotal(accountDO.getTotal());
                    creditsDetailDOS.add(creditsDetailDO2);
                }*/
              /*  String step = redisTemplate.opsForValue().get(STEP);
                if (StringUtils.isEmpty(step)){
                    throw new Exception("获取步数失败!");
                }
                JSONObject object = JSONObject.parseObject(step);
                int step1 = object.getInteger("step1");
                int step2 = object.getInteger("step2");
*/
                try{
                    activeRecordService.insert("dev",creditsDetailDOS.get(0).getTransactionId(),null,null,null,creditsDetailDOS.get(0).getPatientId());
                }catch (Exception e){
@ -1103,8 +957,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        MixEnvelop envelop = new MixEnvelop<>();
        envelop.setObj(true);
        TaskDO taskDO =  taskDao.selectByTaskRuleId(ruleId);
        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patientId+"'";
        List<AccountDO> accountDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
//        String sql = "select * from wlyy_health_bank_account where status = 1 and patient_id = '"+patientId+"'";
//        List<AccountDO> accountDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        List<AccountDO> accountDOs = accountDao.findByPatientId(patientId);
        AccountDO accountDO = null;
        if("add".equals(type)&&(accountDOs==null||accountDOs.size()==0)){
            //新建账户
@ -1130,106 +985,91 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
            accountDO = accountDOs.get(0);
        }
       if (taskDO == null){
           TaskRuleDO taskRuleDO =  taskRuleDao.findByCode(ruleId);
           TaskDO  taskDO1 = new TaskDO();
           taskDO1.setTitle(taskRuleDO.getName());
           taskDO1.setContent(taskRuleDO.getDescription());
           taskDO1.setSaasId("dev");
           taskDO1.setTaskCode("RULE");
           taskDO1.setType("RULE_TASK");
           taskDO1.setTransactionId(ruleId);
           taskDO1.setCreateTime(new Date());
           taskDO1.setUpdateTime(new Date());
           taskDO1.setRuleCode(taskRuleDO.getId());
           taskDO1.setStatus(1);
           taskDO = taskDao.save(taskDO1);
       }
       TaskPatientDetailDO patientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patientId);
       if (patientDetailDO == null){
           TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
           taskPatientDetailDO.setSaasId("dev");
           taskPatientDetailDO.setTaskId(taskDO.getId());
           taskPatientDetailDO.setPatientId(patientId);
           taskPatientDetailDO.setDoctorId(doctorId);
           taskPatientDetailDO.setPatientIdcard(accountDO.getIdCard());
           taskPatientDetailDO.setCreateTime(new Date());
           taskPatientDetailDO.setUpdateTime(new Date());
           taskPatientDetailDO.setStatus(1);
           taskPatientDetailDao.save(taskPatientDetailDO);
       }
        if (taskDO == null){
            TaskRuleDO taskRuleDO =  taskRuleDao.findByCode(ruleId);
            TaskDO  taskDO1 = new TaskDO();
            taskDO1.setTitle(taskRuleDO.getName());
            taskDO1.setContent(taskRuleDO.getDescription());
            taskDO1.setSaasId("dev");
            taskDO1.setTaskCode("RULE");
            taskDO1.setType("RULE_TASK");
            taskDO1.setTransactionId(ruleId);
            taskDO1.setCreateTime(new Date());
            taskDO1.setUpdateTime(new Date());
            taskDO1.setRuleCode(taskRuleDO.getId());
            taskDO1.setStatus(1);
            taskDO = taskDao.save(taskDO1);
        }
        TaskPatientDetailDO patientDetailDO = taskPatientDetailDao.selectByTaskIdAndPatientId(taskDO.getId(),patientId);
        if (patientDetailDO == null){
            TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
            taskPatientDetailDO.setSaasId("dev");
            taskPatientDetailDO.setTaskId(taskDO.getId());
            taskPatientDetailDO.setPatientId(patientId);
            taskPatientDetailDO.setDoctorId(doctorId);
            taskPatientDetailDO.setPatientIdcard(accountDO.getIdCard());
            taskPatientDetailDO.setCreateTime(new Date());
            taskPatientDetailDO.setUpdateTime(new Date());
            taskPatientDetailDO.setStatus(1);
            taskPatientDetailDao.save(taskPatientDetailDO);
        }
       if("add".equals(type)){
           CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
           creditsDetailDO.setAccountId(accountDO.getId());
           creditsDetailDO.setIdCard(accountDO.getIdCard());
           creditsDetailDO.setSaasId("dev");
           creditsDetailDO.setTradeType("ACTIVITY_TASK");
           creditsDetailDO.setTradeDirection(1);
           creditsDetailDO.setIntegrate(integrate);
           creditsDetailDO.setDescription(reason);
           creditsDetailDO.setStatus(1);
           creditsDetailDO.setHospital(hospital);
           creditsDetailDO.setHospitalName(hospitalName);
           creditsDetailDO.setCreateTime(new Date());
           creditsDetailDO.setUpdateTime(new Date());
           creditsDetailDO.setTransactionId(taskDO.getId());
           creditsDetailDO.setPatientId(patientId);
           creditsDetailDO.setHospitalName(hospitalName);
           credittsLogDetailDao.save(creditsDetailDO);
           accountDO.setTotal(accountDO.getTotal()+integrate);
           accountDao.save(accountDO);
       }else{
           if (accountDO.getTotal().compareTo(integrate)>=0){
               CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
               creditsDetailDO.setAccountId(accountDO.getId());
               creditsDetailDO.setIdCard(accountDO.getIdCard());
               creditsDetailDO.setSaasId("dev");
               creditsDetailDO.setTradeType("ACTIVITY_TASK");
               creditsDetailDO.setTradeDirection(-1);
               creditsDetailDO.setIntegrate(integrate);
               creditsDetailDO.setDescription(reason);
               creditsDetailDO.setStatus(1);
               creditsDetailDO.setHospital(hospital);
               creditsDetailDO.setHospitalName(hospitalName);
               creditsDetailDO.setCreateTime(new Date());
               creditsDetailDO.setUpdateTime(new Date());
               creditsDetailDO.setTransactionId(taskDO.getId());
               creditsDetailDO.setPatientId(patientId);
               creditsDetailDO.setHospitalName(hospitalName);
               credittsLogDetailDao.save(creditsDetailDO);
               accountDO.setTotal(accountDO.getTotal()-integrate);
               accountDao.save(accountDO);
           }else {
               envelop.setMessage("积分不足!");
               throw new Exception("积分不足!");
           }
       }
       return envelop;
    }
    /*public JSONObject getStepNumber(){
        String step = redisTemplate.·().get(STEP);
        logger.info("redis数据:"+step);
        String sql = ""
        String step1 = systemDictDao.
        logger.info("数据库的数据:"+step1);
        if (step != null && step.equalsIgnoreCase(step1)){
            JSONObject jsonObject = JSONObject.parseObject(step);
            logger.info("数据不一致:"+jsonObject.toString());
            return jsonObject;
        }else {
            JSONObject jsonObject = JSONObject.parseObject(step);
            redisTemplate.opsForValue().set(STEP,step1);
            logger.info("数据一致:"+jsonObject.toString());
            return jsonObject;
        if("add".equals(type)){
            CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
            creditsDetailDO.setAccountId(accountDO.getId());
            creditsDetailDO.setIdCard(accountDO.getIdCard());
            creditsDetailDO.setSaasId("dev");
            creditsDetailDO.setTradeType("ACTIVITY_TASK");
            creditsDetailDO.setTradeDirection(1);
            creditsDetailDO.setIntegrate(integrate);
            creditsDetailDO.setDescription(reason);
            creditsDetailDO.setStatus(1);
            creditsDetailDO.setHospital(hospital);
            creditsDetailDO.setHospitalName(hospitalName);
            creditsDetailDO.setCreateTime(new Date());
            creditsDetailDO.setUpdateTime(new Date());
            creditsDetailDO.setTransactionId(taskDO.getId());
            creditsDetailDO.setPatientId(patientId);
            creditsDetailDO.setHospitalName(hospitalName);
            credittsLogDetailDao.save(creditsDetailDO);
            accountDO.setTotal(accountDO.getTotal()+integrate);
            accountDao.save(accountDO);
        }else{
            if (accountDO.getTotal().compareTo(integrate)>=0){
                CreditsDetailDO creditsDetailDO = new CreditsDetailDO();
                creditsDetailDO.setAccountId(accountDO.getId());
                creditsDetailDO.setIdCard(accountDO.getIdCard());
                creditsDetailDO.setSaasId("dev");
                creditsDetailDO.setTradeType("ACTIVITY_TASK");
                creditsDetailDO.setTradeDirection(-1);
                creditsDetailDO.setIntegrate(integrate);
                creditsDetailDO.setDescription(reason);
                creditsDetailDO.setStatus(1);
                creditsDetailDO.setHospital(hospital);
                creditsDetailDO.setHospitalName(hospitalName);
                creditsDetailDO.setCreateTime(new Date());
                creditsDetailDO.setUpdateTime(new Date());
                creditsDetailDO.setTransactionId(taskDO.getId());
                creditsDetailDO.setPatientId(patientId);
                creditsDetailDO.setHospitalName(hospitalName);
                credittsLogDetailDao.save(creditsDetailDO);
                accountDO.setTotal(accountDO.getTotal()-integrate);
                accountDao.save(accountDO);
            }else {
                envelop.setMessage("积分不足!");
                throw new Exception("积分不足!");
            }
        }
    }*/
        return envelop;
    }
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> weekReward(CreditsDetailDO creditsDetailDO) {
        try {
            synchronized (creditsDetailDO.getPatientId()) {
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0) {
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }
@ -1460,8 +1300,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> shareIntegrate(CreditsDetailDO creditsDetailDO) {
        try {
            synchronized (creditsDetailDO.getPatientId()) {
                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//                String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//                List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
                List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                if (accountDOList != null && accountDOList.size() != 0) {
                    creditsDetailDO.setAccountId(accountDOList.get(0).getId());
                }
@ -1530,8 +1371,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                Boolean isShare = jsonObject.getBoolean("isshare");
                if (isShare){
                    JSONObject object = jsonObject.getJSONObject("shareData");
                    String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
                    List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//                    String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//                    List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
                    List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
                    CreditsDetailDO creditsDetailDO1 = new CreditsDetailDO();
                    if (accountDOList != null && accountDOList.size() != 0) {
                        creditsDetailDO1.setAccountId(accountDOList.get(0).getId());
@ -1667,8 +1509,9 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
    public MixEnvelop<CreditsDetailDO, CreditsDetailDO> weekRewardAndIntegrate(CreditsDetailDO creditsDetailDO,Integer flag) {
        synchronized (creditsDetailDO.getPatientId()) {
            MixEnvelop<CreditsDetailDO, CreditsDetailDO> envelop = new MixEnvelop<>();
            String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
            List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
//            String sqlAccount = "select * from wlyy_health_bank_account ba where ba.patient_id = '" + creditsDetailDO.getPatientId() + "'";
//            List<AccountDO> accountDOList = jdbcTemplate.query(sqlAccount, new BeanPropertyRowMapper(AccountDO.class));
            List<AccountDO> accountDOList = accountDao.findByPatientId(creditsDetailDO.getPatientId());
            if (accountDOList != null && accountDOList.size() != 0) {
                creditsDetailDO.setAccountId(accountDOList.get(0).getId());
            }
@ -1804,7 +1647,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql1);
                String idcard = null;
                if (maps!=null&&maps.size()!=0){
                    idcard = AesEncryptUtils.decrypt(maps.get(0).get("idcard").toString());
                    idcard = maps.get(0).get("idcard").toString();
                    accountDO.setIdCard(idcard);
                }
                TaskDO taskDO = taskDao.selectById("5e5d857d684d77f201684d7f58b3000a132");

+ 7 - 2
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskPatientDtailService.java

@ -11,6 +11,7 @@ import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.mysql.query.BaseJpaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -77,8 +78,9 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
        taskPatientDetailDO.setCreateTime(new Date());
        taskPatientDetailDO.setUpdateTime(new Date());
        taskPatientDetailDO.setStatus(Integer.parseInt("0"));
        String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
        List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
//        String accountSql = "select * from wlyy_health_bank_account where patient_id = '"+taskPatientDetailDO.getPatientId()+"'";
//        List<AccountDO> accountDOS = jdbcTemplate.query(accountSql,new BeanPropertyRowMapper(AccountDO.class));
        List<AccountDO> accountDOS = accountDao.findByPatientId(taskPatientDetailDO.getPatientId());
        if (accountDOS == null || accountDOS.size() ==0){
            AccountDO accountDO = new AccountDO();
            accountDO.setSaasId("dev");
@ -153,6 +155,7 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
        String sql ="select * from wlyy_health_bank_task_patient_detail where " +
                " (patient_idcard = '"+ AesEncryptUtils.encrypt(idCard)+"' OR union_id ='"+unionId+"') AND task_id IN " +
                "(select id from wlyy_health_bank_task where task_code = '"+taskCode+"' )";
        sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        logger.info("参与信息:"+taskPatientDetailDOS);
        if (taskPatientDetailDOS!=null&&taskPatientDetailDOS.size()!=0){
@ -168,6 +171,7 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
        String sql ="select * from wlyy_health_bank_task_patient_detail where " +
                " (patient_idcard = '"+AesEncryptUtils.encrypt(idCard)+"' OR union_id ='"+unionId+"') AND task_id = '"+taskId+"'" ;
        sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        logger.info("参与信息:"+taskPatientDetailDOS);
        return taskPatientDetailDOS.get(0);
@ -184,6 +188,7 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
    public List<TaskPatientDetailDO> select(Integer page,Integer size){
        String sql ="SELECT * FROM `wlyy_health_bank_task_patient_detail` btpd " +
                "GROUP BY btpd.activity_id, btpd.patient_id ORDER BY btpd.create_time limit "+(page-1)*size+","+size;
        sql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(sql);
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(TaskPatientDetailDO.class));
        for (TaskPatientDetailDO taskPatientDetailDO : taskPatientDetailDOS){
            ActivityDO activityDO = activityDao.selectById(taskPatientDetailDO.getActivityId());

+ 82 - 78
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskService.java

@ -13,6 +13,7 @@ import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import com.yihu.jw.util.TransforSqlUtl;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -96,41 +97,42 @@ public class TaskService extends BaseJpaService<TaskDO,TaskDao> {
     * @param size 分页大小
     * @return
     */
   public MixEnvelop<TaskDO, TaskDO> selectByCondition(TaskDO taskDO, Integer page, Integer size){
       TaskDO taskDO2 = new TaskDO();
       String sql = new ISqlUtils().getSql(taskDO,page,size,"*");
       List<TaskDO> taskDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
       for (TaskDO taskDO1:taskDOS){
           if (taskDO1.getType()!= null && taskDO1.getType().equalsIgnoreCase("ACTIVITY_TASK")){
               ActivityDO activityDO = activityDao.findOne(taskDO1.getTransactionId());
               taskDO1.setActivityDO(activityDO);
           }
           TaskRuleDO taskRuleDO = taskRuleDao.findOne(taskDO1.getRuleCode());
           taskDO1.setRuleName(taskRuleDO.getName());
           //参与活动的详情
           String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+
                   "' and patient_openid = '"+taskDO.getOpenId()+"'";
           List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
           taskDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
           //参与人数
           String taskSql1 = "select count(1) as total from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+"'";
           List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(taskSql1);
           Long count = 0L;
           if(rstotal!=null&&rstotal.size()>0){
               count = (Long) rstotal.get(0).get("total");
           }
           taskDO1.setTotal(count);
           taskDO1.setPatientId(taskDO.getPatientId());
    public MixEnvelop<TaskDO, TaskDO> selectByCondition(TaskDO taskDO, Integer page, Integer size){
        TaskDO taskDO2 = new TaskDO();
        String sql = new ISqlUtils().getSql(taskDO,page,size,"*");
        List<TaskDO> taskDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
        for (TaskDO taskDO1:taskDOS){
            if (taskDO1.getType()!= null && taskDO1.getType().equalsIgnoreCase("ACTIVITY_TASK")){
                ActivityDO activityDO = activityDao.findOne(taskDO1.getTransactionId());
                taskDO1.setActivityDO(activityDO);
            }
            TaskRuleDO taskRuleDO = taskRuleDao.findOne(taskDO1.getRuleCode());
            taskDO1.setRuleName(taskRuleDO.getName());
            //参与活动的详情
//           String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+
//                   "' and patient_openid = '"+taskDO.getOpenId()+"'";
//           List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
            List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndOpenid(taskDO1.getId(),taskDO.getOpenId());
            taskDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
            //参与人数
            String taskSql1 = "select count(1) as total from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO1.getId()+"'";
            List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(taskSql1);
            Long count = 0L;
            if(rstotal!=null&&rstotal.size()>0){
                count = (Long) rstotal.get(0).get("total");
            }
            taskDO1.setTotal(count);
            taskDO1.setPatientId(taskDO.getPatientId());
       }
       String sqlcount = new ISqlUtils().getSql(taskDO,0,0,"count");
       List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
       Long count = 0L;
       if(rstotal!=null&&rstotal.size()>0){
           count = (Long) rstotal.get(0).get("total");
       }
       return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOS,page,size,count);
   }
        }
        String sqlcount = new ISqlUtils().getSql(taskDO,0,0,"count");
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOS,page,size,count);
    }
    /**
     * 查看当前的任务
@ -140,50 +142,52 @@ public class TaskService extends BaseJpaService<TaskDO,TaskDao> {
     * @param size 分页大小
     * @return
     */
   public MixEnvelop<TaskDO, TaskDO> selectByTask(JSONArray array, String patientId, Integer page, Integer size){
       StringBuffer buffer = new StringBuffer();
       List<String> taskCodes = new ArrayList<>();
       for (int i=0;i<array.size();i++){
           taskCodes.add(array.getString(i));
       }
       buffer.append(" bt.task_code in(");
       if (taskCodes == null || taskCodes.size() == 0){
           buffer.append("''");
       }else {
           for (int i=0;i<taskCodes.size();i++){
               buffer.append("'"+taskCodes.get(i)+"'").append(",");
           }
           buffer.deleteCharAt(buffer.length()-1);
       }
       buffer.append(") ");
       String sql = "select * from wlyy_health_bank_task bt where "+buffer +" ORDER BY update_time DESC LIMIT "+(page-1)*size+","+size;
       List<TaskDO> taskDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
       for (TaskDO taskDO:taskDOList){
           if (taskDO.getType().equalsIgnoreCase("ACTIVITY_TASK")){
               ActivityDO activityDO = activityDao.findOne(taskDO.getTransactionId());
               taskDO.setActivityDO(activityDO);
           }
           if (taskDO.getPeriod() == 1){
               String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
                       "' and patient_id = '"+patientId+"'";
               List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
               taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
           }else if (taskDO.getPeriod() == 0){
               String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
                       "' and patient_id = '"+patientId+"' and create_time > '" + DateUtils.getDayBegin() +"' and create_time < '"+ DateUtils.getDayEnd() +"'";
               List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
               taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
           }
           taskDO.setPatientId(patientId);
       }
       String sqlcount = "select COUNT(1) AS  total from wlyy_health_bank_task bt where "+buffer ;
       List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
       Long count = 0L;
       if(rstotal!=null&&rstotal.size()>0){
           count = (Long) rstotal.get(0).get("total");
       }
       return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOList,page,size,count);
   }
    public MixEnvelop<TaskDO, TaskDO> selectByTask(JSONArray array, String patientId, Integer page, Integer size){
        StringBuffer buffer = new StringBuffer();
        List<String> taskCodes = new ArrayList<>();
        for (int i=0;i<array.size();i++){
            taskCodes.add(array.getString(i));
        }
        buffer.append(" bt.task_code in(");
        if (taskCodes == null || taskCodes.size() == 0){
            buffer.append("''");
        }else {
            for (int i=0;i<taskCodes.size();i++){
                buffer.append("'"+taskCodes.get(i)+"'").append(",");
            }
            buffer.deleteCharAt(buffer.length()-1);
        }
        buffer.append(") ");
        String sql = "select * from wlyy_health_bank_task bt where "+buffer +" ORDER BY update_time DESC LIMIT "+(page-1)*size+","+size;
        List<TaskDO> taskDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
        for (TaskDO taskDO:taskDOList){
            if (taskDO.getType().equalsIgnoreCase("ACTIVITY_TASK")){
                ActivityDO activityDO = activityDao.findOne(taskDO.getTransactionId());
                taskDO.setActivityDO(activityDO);
            }
            if (taskDO.getPeriod() == 1){
//               String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
//                       "' and patient_id = '"+patientId+"'";
//               List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                List<TaskPatientDetailDO> taskPatientDetailDOS = taskPatientDetailDao.selectByTaskIdAndPatientId2(taskDO.getId(),patientId);
                taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
            }else if (taskDO.getPeriod() == 0){
                String taskSql = "select * from wlyy_health_bank_task_patient_detail where task_id = '"+taskDO.getId()+
                        "' and patient_id = '"+patientId+"' and create_time > '" + DateUtils.getDayBegin() +"' and create_time < '"+ DateUtils.getDayEnd() +"'";
                taskSql = TransforSqlUtl.wlyyHealthBankTaskPatientDetailAll(taskSql);
                List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                taskDO.setTaskPatientDetailDOS(taskPatientDetailDOS);
            }
            taskDO.setPatientId(patientId);
        }
        String sqlcount = "select COUNT(1) AS  total from wlyy_health_bank_task bt where "+buffer ;
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
        return MixEnvelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOList,page,size,count);
    }
   /* public List<TaskDO> getTasks(String patientId){
       List<TaskDO> taskDOList = new ArrayList<>();
       TaskDO taskDO = new TaskDO();

+ 21 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/util/TransforSqlUtl.java

@ -0,0 +1,21 @@
package com.yihu.jw.util;
/**
 * Created by yeshijie on 2021/2/4.
 */
public class TransforSqlUtl {
    public static String accountName(String sql){
        return sql.replaceAll("ba1.account_name","CAST(AES_DECRYPT(from_base64(ba1.account_name),'jkzl2021ZJXL*#%a')AS char)");
    }
    public static String wlyyHealthBankAccountAll(String sql){
        String str = "*,CAST(AES_DECRYPT(from_base64(account_name),'jkzl2021ZJXL*#%a') AS CHAR ) AS account_name ";
        return sql.replace("*",str);
    }
    public static String wlyyHealthBankTaskPatientDetailAll(String sql){
        String str = "*,CAST(AES_DECRYPT(from_base64(patient_idcard),'jkzl2021ZJXL*#%a') AS CHAR ) AS patient_idcard ";
        return sql.replace("*",str);
    }
}