|  | @ -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");
 |