Przeglądaj źródła

[CMD]健康银行代码

wpq 6 lat temu
rodzic
commit
a078a23827

+ 34 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/ActivityDO.java

@ -9,6 +9,7 @@ import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
 * Created by wang zhinan on 2018/4/26.
@ -58,12 +59,21 @@ public class ActivityDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "remark")
    private String remark;//活动备注
    @Column(name = "type")
    private String type;//活动类型
    @Transient
    private String patientId;//居民id
    @Transient
    private String openId;//微信编码
    @Transient
    private Long total;//参加总数
    @Transient
    private List<TaskPatientDetailDO> taskPatientDetailDOS;//参与活动详情
    public String getSaasId() {
        return saasId;
    }
@ -186,4 +196,28 @@ public class ActivityDO extends IdEntityWithOperation implements Serializable {
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public Long getTotal() {
        return total;
    }
    public void setTotal(Long total) {
        this.total = total;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public List<TaskPatientDetailDO> getTaskPatientDetailDOS() {
        return taskPatientDetailDOS;
    }
    public void setTaskPatientDetailDOS(List<TaskPatientDetailDO> taskPatientDetailDOS) {
        this.taskPatientDetailDOS = taskPatientDetailDOS;
    }
}

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

@ -63,6 +63,7 @@ public class CreditsDetailDO extends IdEntityWithOperation implements Serializab
    @Transient
    private String openId;//微信编号
    public String getSaasId() {
        return saasId;
    }

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

@ -191,4 +191,5 @@ public class TaskDO extends IdEntityWithOperation implements Serializable{
    public void setOpenId(String openId) {
        this.openId = openId;
    }
}

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

@ -5,6 +5,7 @@ import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
/**
@ -35,6 +36,14 @@ public class TaskPatientDetailDO extends IdEntityWithOperation implements Serial
    @Column(name = "task_id")
    private String taskId;//任务id
    @Column(name = "activity_id")
    private String activityId;//活动id
    @Column(name = "total")
    private Long total;//活动中获取的积分
    @Transient
    private AccountDO accountDO;//账户信息
    public String getSaasId() {
        return saasId;
@ -92,4 +101,27 @@ public class TaskPatientDetailDO extends IdEntityWithOperation implements Serial
        this.taskId = taskId;
    }
    public String getActivityId() {
        return activityId;
    }
    public void setActivityId(String activityId) {
        this.activityId = activityId;
    }
    public Long getTotal() {
        return total;
    }
    public void setTotal(Long total) {
        this.total = total;
    }
    public AccountDO getAccountDO() {
        return accountDO;
    }
    public void setAccountDO(AccountDO accountDO) {
        this.accountDO = accountDO;
    }
}

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/bank/HealthBankMapping.java

@ -13,6 +13,7 @@ public class HealthBankMapping {
        public static final String createAccount = "/createAccount";
        public static final String selectAccount = "/selectAccount";
        public static final String findAccount = "/findAccount";
        public static final String findAccounByCondition ="/findAccounByCondition";
        public static final String createTask = "/createTask";
        public static final String deleteTask ="/deleteTask";
        public static final String findTask = "/findTask";
@ -46,6 +47,7 @@ public class HealthBankMapping {
        public static final String findCreditsLogInfo ="/findCreditsLogInfo";
        public static final String selectByActivity = "/selectByActivity";
        public static final String selectByRanking = "/selectByRanking";
        public static final String selectByActivityRanking = "/selectByActivityRanking";
        public static final String updateCreditsLogInfo ="/updateCreditsLogInfo";
        public static final String exchangeGoods = "/exchangeGoods";
        public static final String findExchangeGoods="/findExchangeGoods";

+ 37 - 4
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/AccountController.java

@ -2,6 +2,8 @@ package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/5/10.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.entity.health.bank.CreditsDetailDO;
import com.yihu.jw.restmodel.common.Envelop;
@ -14,10 +16,10 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
 * @author wangzhinan
@ -132,4 +134,35 @@ public class AccountController extends EnvelopRestController {
        }
    }*/
    /**
     * 筛选用户
     * @param object
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.findAccounByCondition)
    @ApiOperation(value = "按条件获取用户信息")
    public Envelop<AccountDO> select(@RequestBody JSONObject object){
        try{
            JSONArray patientIds = object.getJSONArray("patientIds");
            JSONArray deviceTypes = object.getJSONArray("deviceTypes");
            int bindStatus = object.getInteger("bindStatus");
            Integer page = object.getInteger("page");
            Integer size = object.getInteger("size");
            List<String> patientIds1 = new ArrayList<>();
            for (int i=0;patientIds != null && patientIds.size()!=0&& i<patientIds.size();i++){
                patientIds1.add(patientIds.getString(i));
            }
            List<String> deviceTypes1 = new ArrayList<>();
            for (int i=0;deviceTypes != null && deviceTypes.size()!=0&& i<deviceTypes.size();i++){
                deviceTypes1.add(deviceTypes.getString(i));
            }
            return service.findByCondition1(patientIds1,bindStatus,deviceTypes1,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 34 - 6
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/CreditsDetailController.java

@ -2,7 +2,11 @@ package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/4/27.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.entity.health.bank.CreditsDetailDO;
import com.yihu.jw.entity.health.bank.TaskPatientDetailDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
@ -12,10 +16,10 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
 * @author wangzhinan
@ -119,7 +123,7 @@ public class CreditsDetailController extends EnvelopRestController {
     * @param object {"filter":[""],"page":"","size":""}
     * @return
     */
  /*  @PostMapping(value = HealthBankMapping.healthBank.selectByRanking)
    @PostMapping(value = HealthBankMapping.healthBank.selectByRanking)
    @ApiOperation(value = "查询积分排名")
    public Envelop<AccountDO> selectByRanking(@RequestBody JSONObject object){
        try{
@ -136,7 +140,31 @@ public class CreditsDetailController extends EnvelopRestController {
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }*/
    }
    /**
     * 活动排名
     * @param object
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.selectByActivityRanking)
    @ApiOperation(value = "活动排名")
    public Envelop<TaskPatientDetailDO> selectByActivityRanking(@RequestBody JSONObject object){
        try{
            JSONArray array = object.getJSONArray("filter");
            String activityId = object.getString("activityId");
            Integer page = object.getInteger("page");
            Integer size = object.getInteger("size");
            List<String> ids = new ArrayList<>();
            for (int i=0;array != null && array.size()!=0&& i<array.size();i++){
                ids.add(array.getString(i));
            }
            return service.selectByActivityRanking(activityId,ids,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

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

@ -67,4 +67,100 @@ public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
        }
        return Envelop.getSuccessListWithPage(HealthBankMapping.api_success,accountDOS,page,size,count);
    }
    public Envelop<AccountDO> findByCondition1(List<String> patientIds ,int bindStatus,List<String> deviceTypes,Integer page,Integer size){
        StringBuffer buffer = new StringBuffer();
        buffer.append(" btpd.patient_id in(");
        if (patientIds == null || patientIds.size() == 0){
            buffer.append("''");
        }else {
            for (int i=0;i<patientIds.size();i++){
                buffer.append("'"+patientIds.get(i)+"'").append(",");
            }
            buffer.deleteCharAt(buffer.length()-1);
        }
        buffer.append(") ");
        StringBuffer buffer1 = new StringBuffer();
        buffer1.append("(");
        if (deviceTypes == null || deviceTypes.size() == 0){
            buffer1.append("''");
        }else {
            for (int i=0;i<deviceTypes.size();i++){
                buffer1.append("'"+deviceTypes.get(i)+"'").append(",");
            }
            buffer1.deleteCharAt(buffer1.length()-1);
        }
        buffer1.append(")");
        String sql1 = null ;
        if (bindStatus == -1){
            sql1 = "( SELECT btpd.patient_id AS patient_id FROM " +
                    "  wlyy_health_bank_task_patient_detail btpd " +
                    " LEFT JOIN wlyy_health_bank_task bt ON bt.id = btpd.task_id WHERE " +
                    " bt.task_code NOT IN "+buffer1+" and "+buffer+")";
        }else if (bindStatus == 1){
            sql1 = "( SELECT btpd.patient_id AS patient_id FROM " +
                    "  wlyy_health_bank_task_patient_detail btpd " +
                    " LEFT JOIN wlyy_health_bank_task bt ON bt.id = btpd.task_id WHERE " +
                    " bt.task_code IN "+buffer1 +" and "+buffer+")";
        }
        String sql =
                "SELECT ba1.patient_id AS patient_id," +
                        "ba1.account_name AS account_name," +
                        "ba1.hospital AS hospital," +
                        "ba1.total AS total," +
                        "ba1.create_time AS create_time," +
                        "ba1.sum AS sum" +
                        " FROM" +
                        "( SELECT " +
                        "ba.patient_id AS patient_id," +
                        "ba.account_name AS account_name," +
                        "ba.hospital AS hospital," +
                        "ba.total AS total," +
                        "ba.create_time AS create_time," +
                        "(ba.total +COALESCE((cd1.total),0)) AS sum" +
                        " FROM" +
                        " wlyy_health_bank_account ba" +
                        " LEFT JOIN ( " +
                        "SELECT" +
                        " SUM(cd.integrate) AS total," +
                        " cd.patient_id AS patient_id" +
                        " FROM" +
                        " wlyy_health_bank_credits_detail cd" +
                        " WHERE " +
                        "cd.trade_direction = - 1" +
                        " GROUP BY " +
                        " cd.patient_id ) cd1 ON cd1.patient_id = ba.patient_id " +
                        " WHERE ba.patient_id IN " + sql1 +
                        " ORDER BY" +
                        " ba.create_time DESC " +
                        "LIMIT "+(page-1)*size+","+size +")ba1" +
                        " ORDER BY " +
                        " ba1.sum DESC";
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        String sqlCount = "SELECT count(1) AS total"+
                " FROM " +
                " wlyy_health_bank_account ba LEFT JOIN " +
                " ( " +
                " SELECT " +
                " SUM(cd.integrate) AS total, " +
                " cd.patient_id AS patient_id " +
                " FROM " +
                " wlyy_health_bank_credits_detail cd " +
                " WHERE " +
                " cd.trade_direction = - 1 " +
                " GROUP BY " +
                " cd.patient_id " +
                " ) cd1 ON cd1.patient_id = ba.patient_id " +
                "WHERE ba.patient_id IN " + sql1 +
                " ORDER BY " +
                " ba.create_time, " +
                " (ba.total + COALESCE(cd1.total,0)) DESC ";
        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 Envelop.getSuccessListWithPage(HealthBankMapping.api_success, accountDOS,page,size,count);
    }
}

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

@ -5,6 +5,7 @@ package com.yihu.jw.service;/**
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.ActivityDao;
import com.yihu.jw.entity.health.bank.ActivityDO;
import com.yihu.jw.entity.health.bank.TaskPatientDetailDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
@ -61,7 +62,29 @@ public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
    public Envelop<ActivityDO> findByCondition(ActivityDO activityDO,Integer page, Integer size) throws ParseException {
        String sql = new ISqlUtils().getSql(activityDO,page,size,"*");
        List<ActivityDO> activityDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityDO.class));
        for (ActivityDO activityDO1:activityDOS){
            String taskSql = "SELECT" +
                    " COUNT(1) AS total1 " +
                    "FROM " +
                    " ( " +
                    " SELECT DISTINCT " +
                    "  (btpd.patient_openid) " +
                    "  FROM " +
                    "  wlyy_health_bank_task_patient_detail btpd " +
                    "  WHERE " +
                    "  activity_id = '" +activityDO1.getId()+
                    "' ) btpd1";
            List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(taskSql);
            Long count = 0L;
            if(rstotal!=null&&rstotal.size()>0){
                count = (Long) rstotal.get(0).get("total1");
            }
            activityDO1.setTotal(count);
            String taskSql1 = "select * from wlyy_health_bank_task_patient_detail btpd where activity_id = '"+activityDO1.getId()
                    +"' and patient_openid = '"+activityDO.getOpenId()+"'";
            List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
            activityDO1.setTaskPatientDetailDOS(taskPatientDetailDOS);
        }
        String sqlcount = new ISqlUtils().getSql(activityDO,0,0,"count");
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;

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

@ -147,7 +147,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        "ba.hospital AS hospital," +
                        "ba.total AS total," +
                        "ba.create_time AS create_time," +
                        "(ba.total +(cd1.total)) AS sum" +
                        "(ba.total +COALESCE((cd1.total),0)) AS sum" +
                        " FROM" +
                        " wlyy_health_bank_account ba" +
                        " LEFT JOIN ( " +
@ -159,7 +159,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        " WHERE " +
                        "cd.trade_direction = - 1" +
                        " GROUP BY " +
                        " cd.patient_id ) cd1 ON cd1.patient_id = ba.patient_id\n" +
                        " cd.patient_id ) cd1 ON cd1.patient_id = ba.patient_id " +
                        " WHERE " + buffer +
                        " ORDER BY" +
                        " ba.create_time DESC " +
@ -184,7 +184,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                "WHERE " + buffer +
                " ORDER BY " +
                " ba.create_time, " +
                " (ba.total + cd1.total) DESC ";
                " (ba.total + COALESCE(cd1.total,0)) DESC ";
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlCount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
@ -244,6 +244,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                    taskPatientDetailDO.setStatus(Integer.parseInt("0"));
                    taskPatientDetailDO.setCreateTime(new Date());
                    taskPatientDetailDO.setUpdateTime(new Date());
                    taskPatientDetailDO.setTotal(Long.parseLong("0"));
                    taskPatientDetailDao.save(taskPatientDetailDO);
                }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()+
@ -259,6 +260,7 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                        taskPatientDetailDO.setStatus(Integer.parseInt("0"));
                        taskPatientDetailDO.setCreateTime(new Date());
                        taskPatientDetailDO.setUpdateTime(new Date());
                        taskPatientDetailDO.setTotal(Long.parseLong("0"));
                        taskPatientDetailDao.save(taskPatientDetailDO);
                    }
                }
@ -268,6 +270,18 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                creditsDetailDO1.setFlag(creditsDetailDO.getFlag());
                List<CreditsDetailDO> creditsDetailDOList = new ArrayList<>();
                creditsDetailDOList.add(creditsDetailDO1);
                TaskPatientDetailDO taskPatientDetailDO = new TaskPatientDetailDO();
                taskPatientDetailDO.setPatientId(creditsDetailDO1.getPatientId());
                taskPatientDetailDO.setTaskId(creditsDetailDO1.getTransactionId());
                String taskSql1 = ISqlUtils.getAllSql(taskPatientDetailDO);
                List<TaskPatientDetailDO> taskPatientDetailDOS1 = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
                TaskPatientDetailDO taskPatientDetailDO1 = taskPatientDetailDOS1.get(0);
                if (creditsDetailDO1.getTradeDirection() == 1){
                    taskPatientDetailDO1.setTotal(taskPatientDetailDO1.getTotal()+creditsDetailDO1.getIntegrate());
                }else if (creditsDetailDO.getTradeDirection() == -1){
                    taskPatientDetailDO1.setTotal(taskPatientDetailDO1.getTotal()-creditsDetailDO1.getIntegrate());
                }
                taskPatientDetailDao.save(taskPatientDetailDO1);
                AccountDO accountDO = accountDao.findOne(creditsDetailDO1.getAccountId());
                if (creditsDetailDO1.getTradeDirection() == 1){
                    accountDO.setTotal(accountDO.getTotal()+creditsDetailDO1.getIntegrate());
@ -291,6 +305,88 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
        }
    }
    /**
     * 活动排名
     *
     * @param activityId 活动id
     * @param ids 微信编码
     *
     * @param page 页码
     *
     * @param size 分页大小
     * @return
     */
    public Envelop<TaskPatientDetailDO> selectByActivityRanking(String activityId,List<String> ids,Integer page,Integer size){
        StringBuffer buffer = new StringBuffer();
        buffer.append("(");
        if (ids == null || ids.size() == 0){
            buffer.append("''");
        }else {
            for (int i=0;i<ids.size();i++){
                buffer.append("'"+ids.get(i)+"'").append(",");
            }
            buffer.deleteCharAt(buffer.length()-1);
        }
        buffer.append(") ");
        String sql = "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 +
                "' GROUP BY " +
                " patient_openid " +
                " ORDER BY ptpd.create_time DESC " +
                " )btpd1 " +
                " WHERE  patient_openid IN "+buffer+
                " 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));
            taskPatientDetailDO.setAccountDO(accountDOS.get(0));
        }
        String sqlCount =  "SELECT " +
                " count(1) AS total " +
                "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+
                "' GROUP BY " +
                " patient_openid " +
                " ORDER BY ptpd.create_time DESC " +
                " )btpd1 " +
                "WHERE  patient_openid IN "+buffer+
                " ORDER BY btpd1.total DESC ";
        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 Envelop.getSuccessListWithPage(HealthBankMapping.api_success, taskPatientDetailDOS,page,size,count);
    }
    /**
     * 根据活动查询积分
     *
@ -319,6 +415,10 @@ public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,Creditt
                " and patient_id = '" +patientId+
                "' LIMIT "+(page-1)*size +","+size;
        List<CreditsDetailDO> creditsDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(CreditsDetailDO.class));
        for (CreditsDetailDO creditsDetailDO : creditsDetailDOS){
            TaskDO taskDO = taskDao.findOne(creditsDetailDO.getTransactionId());
            creditsDetailDO.setTaskDO(taskDO);
        }
        String sqlcount = "SELECT count(1) AS" +
                " total FROM " +
                " wlyy_health_bank_credits_detail " +

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

@ -6,7 +6,6 @@ import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.ActivityDao;
import com.yihu.jw.dao.TaskDao;
import com.yihu.jw.dao.TaskPatientDetailDao;
import com.yihu.jw.entity.health.bank.ActivityDO;
import com.yihu.jw.entity.health.bank.TaskDO;
import com.yihu.jw.entity.health.bank.TaskPatientDetailDO;
import com.yihu.jw.entity.health.bank.TaskRangDO;
@ -73,12 +72,25 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
        taskPatientDetailDO.setCreateTime(new Date());
        taskPatientDetailDO.setUpdateTime(new Date());
        taskPatientDetailDO.setStatus(Integer.parseInt("0"));
        String sql = "select * from wlyy_health_bank_task_patient_detail where patient_openid = '"+taskPatientDetailDO.getPatientOpenid()+"'";
        String activitySql = "select * from wlyy_health_bank_task where transaction_id = '" + taskPatientDetailDO.getActivityId() +"'";
        List<TaskDO> taskDOList = jdbcTemplate.query(activitySql,new BeanPropertyRowMapper(TaskDO.class));
        StringBuffer buffer = new StringBuffer();
        buffer.append(" and task_id in (");
        for (TaskDO taskDO : taskDOList){
            buffer.append("'"+taskDO.getId()+"'").append(",");
        }
        buffer.deleteCharAt(buffer.length()-1);
        buffer.append(")");
        String sql = "select * from wlyy_health_bank_task_patient_detail where patient_openid = '"+taskPatientDetailDO.getPatientOpenid()+"'"+buffer;
        List<TaskPatientDetailDO> taskPatientDetailDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        if (taskPatientDetailDOList != null && taskPatientDetailDOList.size() !=0){
            throw new Exception("该微信账号已报名过!");
        }
        taskPatientDetailDao.save(taskPatientDetailDO);
        for (TaskDO taskDO : taskDOList){
            taskPatientDetailDO.setTotal(Long.parseLong("0"));
            taskPatientDetailDO.setTaskId(taskDO.getId());
            taskPatientDetailDao.save(taskPatientDetailDO);
        }
        envelop.setObj(true);
        return envelop;
    }
@ -99,29 +111,4 @@ public class TaskPatientDtailService extends BaseJpaService<TaskPatientDetailDO,
    }
    /**
     * 我参与的活动
     *
     * @param taskPatientDetailDO 参与信息对象
     * @param page 页码
     * @param size 分页大小
     * @return
     */
    public Envelop<TaskPatientDetailDO> selectByPatient(TaskPatientDetailDO taskPatientDetailDO,Integer page,Integer size){
        String sql = new ISqlUtils().getSql(taskPatientDetailDO,page,size,"*");
        List<TaskPatientDetailDO> taskPatientDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskPatientDetailDO.class));
        for (TaskPatientDetailDO taskPatientDetailDO1:taskPatientDetailDOS){
            TaskDO taskDO = taskDao.findOne(taskPatientDetailDO1.getTaskId());
            ActivityDO activityDO = activityDao.findOne(taskDO.getTransactionId());
            taskDO.setActivityDO(activityDO);
            taskPatientDetailDO1.setTaskDO(taskDO);
        }
        String sqlcount = new ISqlUtils().getSql(taskPatientDetailDO,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 Envelop.getSuccessListWithPage(HealthBankMapping.api_success, taskPatientDetailDOS,page,size,count);
    }
}

+ 5 - 1
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/util/ISqlUtils.java

@ -25,6 +25,10 @@ public class ISqlUtils {
        }else if(isFlag.equalsIgnoreCase("*")){
            sb.append("select * from ").append(tableName).append(" where 1=1 ");
        }
        JSONObject object1  = (JSONObject) JSONObject.toJSON(object);
        if (object1.getString("id") !=null){
            sb.append(" and id = '" + object1.getString("id")+"' ");
        }
        Field[] fArray= c.getDeclaredFields();
        for(Field f:fArray){
                //拿到字段后与实体类中的属性匹配,并得到其get方法,用来获取他的属性值
@ -52,7 +56,7 @@ public class ISqlUtils {
                }
        }
        if(isFlag.equalsIgnoreCase("*")){
            sb.append("ORDER BY update_time DESC ").append("LIMIT ").append((page-1)*size+",").append(size);
            sb.append(" ORDER BY update_time DESC ").append("LIMIT ").append((page-1)*size+",").append(size);
        }
        return sb.toString();
    }