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

Merge branch 'dev' of wangzhinan/wlyy2.0 into dev

huangwenjie преди 6 години
родител
ревизия
51241fd905
променени са 47 файла, в които са добавени 3127 реда и са изтрити 1 реда
  1. 127 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/AccountDO.java
  2. 108 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/ActivityDO.java
  3. 48 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/ActivityRuleDO.java
  4. 138 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/CreditsDetailDO.java
  5. 77 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/ExchangeGoodsDO.java
  6. 119 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/GoodsDO.java
  7. 105 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskDO.java
  8. 93 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskDetailDO.java
  9. 49 0
      common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskRuleDO.java
  10. 36 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/health/bank/HealthBankMapping.java
  11. 125 0
      svr/svr-wlyy-health-bank/pom.xml
  12. 1 0
      svr/svr-wlyy-health-bank/readme.MD
  13. 18 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/SvrWlyyHealthBankApplication.java
  14. 50 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/config/SwaggerConfig.java
  15. 29 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/config/jpa/HibernateProperties.java
  16. 58 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/config/jpa/WlyyHealthBankJpa.java
  17. 80 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/AccountController.java
  18. 99 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ActivityController.java
  19. 95 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ActivityDetailController.java
  20. 99 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/CreditsDetailController.java
  21. 81 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ExchangeGoodsController.java
  22. 99 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/GoodsController.java
  23. 115 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/TaskController.java
  24. 95 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/TaskDetailController.java
  25. 15 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/AccountDao.java
  26. 11 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/ActivityDao.java
  27. 11 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/ActivityRuleDao.java
  28. 11 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/CredittsLogDetailDao.java
  29. 15 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/ExchangeGoodsDao.java
  30. 11 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/GoodsDao.java
  31. 15 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/TaskDao.java
  32. 11 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/TaskDetailDao.java
  33. 16 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/dao/TaskRuleDao.java
  34. 32 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/AccountService.java
  35. 109 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityRuleService.java
  36. 83 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActivityService.java
  37. 202 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/CreditsDetailService.java
  38. 99 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ExchangeGoodsService.java
  39. 78 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/GoodsService.java
  40. 112 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskDetailService.java
  41. 84 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/TaskService.java
  42. 33 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/util/DateUtils.java
  43. 92 0
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/util/ISqlUtils.java
  44. 88 0
      svr/svr-wlyy-health-bank/src/main/resources/application.yml
  45. 8 0
      svr/svr-wlyy-health-bank/src/main/resources/banner.txt
  46. 46 0
      svr/svr-wlyy-health-bank/src/main/resources/bootstrap.yml
  47. 1 1
      svr/svr-wlyy-specialist/src/main/resources/application.yml

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

@ -0,0 +1,127 @@
package com.yihu.jw.entity.health.bank;
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;
/**
 * Created by wang zhinan on 2018/4/26.
 */
@Entity
@Table(name = "wlyy_health_bank_account")
public class AccountDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "patient_id")
    private String patientId;
    @Column(name = "account_name")
    private String accountName;
    @Column(name = "total")
    private int total;
    @Column(name = "password")
    private String password;
    @Column(name = "card_number")
    private String cardNumber;
    @Column(name = "hospital_name")
    private String hospitalName;
    @Column(name = "hospital")
    private String hospital;
    @Transient
    private String sum;
    @Transient
    private int usedTotal;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getAccountName() {
        return accountName;
    }
    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }
    public int getTotal() {
        return total;
    }
    public void setTotal(int total) {
        this.total = total;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public int getUsedTotal() {
        return usedTotal;
    }
    public void setUsedTotal(int usedTotal) {
        this.usedTotal = usedTotal;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getCardNumber() {
        return cardNumber;
    }
    public void setCardNumber(String cardNumber) {
        this.cardNumber = cardNumber;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getSum() {
        return sum;
    }
    public void setSum(String sum) {
        this.sum = sum;
    }
}

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

@ -0,0 +1,108 @@
package com.yihu.jw.entity.health.bank;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by wang zhinan on 2018/4/26.
 */
@Entity
@Table(name = "wlyy_health_bank_activity")
public class ActivityDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "activity_title")
    private String activityTitle;
    @Column(name = "activity_content")
    private String activityContent;
    @Column(name = "start_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date startTime;
    @Column(name = "over_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date overTime;
    @Column(name = "status")
    private int status;
    @Column(name = "hospital")
    private String hospital;
    @Column(name = "organizer")
    private String organizer;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getActivityTitle() {
        return activityTitle;
    }
    public void setActivityTitle(String activityTitle) {
        this.activityTitle = activityTitle;
    }
    public String getActivityContent() {
        return activityContent;
    }
    public void setActivityContent(String activityContent) {
        this.activityContent = activityContent;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getOverTime() {
        return overTime;
    }
    public void setOverTime(Date overTime) {
        this.overTime = overTime;
    }
    public String getOrganizer() {
        return organizer;
    }
    public void setOrganizer(String organizer) {
        this.organizer = organizer;
    }
    public int getStatus() {
        return status;
    }
    public void setStatus(int status) {
        this.status = status;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
}

+ 48 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/ActivityRuleDO.java

@ -0,0 +1,48 @@
package com.yihu.jw.entity.health.bank;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by wang zhinan on 2018/4/27.
 */
@Entity
@Table(name = "wlyy_health_bank_activity_rule")
public class ActivityRuleDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "activity_id")
    private String activityId;
    @Column(name = "rule_code")
    private String ruleCode;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getActivityId() {
        return activityId;
    }
    public void setActivityId(String activityId) {
        this.activityId = activityId;
    }
    public String getRuleCode() {
        return ruleCode;
    }
    public void setRuleCode(String ruleCode) {
        this.ruleCode = ruleCode;
    }
}

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

@ -0,0 +1,138 @@
package com.yihu.jw.entity.health.bank;
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;
/**
 * Created by wang zhinan on 2018/4/27.
 */
@Entity
@Table(name = "wlyy_health_bank_credits_detail")
public class CreditsDetailDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "trade_type")
    private String tradeType;
    @Column(name = "transaction_id")
    private String transactionId;
    @Column(name="integrate")
    private int integrate;
    @Column(name = "status")
    private int status;
    @Column(name = "trade_direction")
    private int tradeDirection;
    @Column(name = "account_id")
    private String accountId;
    @Column(name = "patient_id")
    private String patientId;
    @Column(name = "hospital")
    private String hospital;
    @Transient
    private TaskDO taskDO;
    @Transient
    private ActivityDO activityDO;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public int getIntegrate() {
        return integrate;
    }
    public void setIntegrate(int integrate) {
        this.integrate = integrate;
    }
    public int getStatus() {
        return status;
    }
    public void setStatus(int status) {
        this.status = status;
    }
    public String getAccountId() {
        return accountId;
    }
    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public int getTradeDirection() {
        return tradeDirection;
    }
    public void setTradeDirection(int tradeDirection) {
        this.tradeDirection = tradeDirection;
    }
    public String getTransactionId() {
        return transactionId;
    }
    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }
    public String getTradeType() {
        return tradeType;
    }
    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }
    public TaskDO getTaskDO() {
        return taskDO;
    }
    public void setTaskDO(TaskDO taskDO) {
        this.taskDO = taskDO;
    }
    public ActivityDO getActivityDO() {
        return activityDO;
    }
    public void setActivityDO(ActivityDO activityDO) {
        this.activityDO = activityDO;
    }
}

+ 77 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/ExchangeGoodsDO.java

@ -0,0 +1,77 @@
package com.yihu.jw.entity.health.bank;/**
 * Created by nature of king on 2018/5/3.
 */
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;
/**
 * @author wangzhinan
 * @create 2018-05-03 15:17
 * @desc exchange goods
 **/
@Entity
@Table(name = "wlyy_health_bank_exchange_goods")
public class ExchangeGoodsDO extends IdEntityWithOperation implements Serializable {
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "goods_id")
    private String goodsId;
    @Column(name = "integrate")
    private String integrate;
    @Column(name = "patient_id")
    private String patientId;
    @Transient
    private GoodsDO goodsDO;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getGoodsId() {
        return goodsId;
    }
    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }
    public String getIntegrate() {
        return integrate;
    }
    public void setIntegrate(String integrate) {
        this.integrate = integrate;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public GoodsDO getGoodsDO() {
        return goodsDO;
    }
    public void setGoodsDO(GoodsDO goodsDO) {
        this.goodsDO = goodsDO;
    }
}

+ 119 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/GoodsDO.java

@ -0,0 +1,119 @@
package com.yihu.jw.entity.health.bank;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by wang zhinan on 2018/4/27.
 */
@Entity
@Table(name = "wlyy_health_bank_goods")
public class GoodsDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "name")
    private String name;
    @Column(name = "img_url")
    private String imgUrl;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "start_time")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "over_time")
    private Date overTime;
    @Column(name = "status")
    private String status;
    @Column(name = "require_integrate")
    private String requireIntegrate;
    @Column(name = "content")
    private String content;
    @Column(name = "community")
    private String community;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getImgUrl() {
        return imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getOverTime() {
        return overTime;
    }
    public void setOverTime(Date overTime) {
        this.overTime = overTime;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getRequireIntegrate() {
        return requireIntegrate;
    }
    public void setRequireIntegrate(String requireIntegrate) {
        this.requireIntegrate = requireIntegrate;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getCommunity() {
        return community;
    }
    public void setCommunity(String community) {
        this.community = community;
    }
}

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

@ -0,0 +1,105 @@
package com.yihu.jw.entity.health.bank;
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;
/**
 * Created by wamg zhinan 2018/4/27.
 */
@Entity
@Table(name = "wlyy_health_bank_task")
public class TaskDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "task_title")
    private String taskTitle;
    @Column(name = "task_content")
    private String taskContent;
    @Column(name = "trade_type")
    private String tradeType;
    @Column(name = "transaction_id")
    private String transactionId;
    @Column(name = "period")
    private int period;
    @Column(name = "patient_id")
    private String patientId;
    @Transient
    private int status;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getTaskTitle() {
        return taskTitle;
    }
    public void setTaskTitle(String taskTitle) {
        this.taskTitle = taskTitle;
    }
    public String getTaskContent() {
        return taskContent;
    }
    public void setTaskContent(String taskContent) {
        this.taskContent = taskContent;
    }
    public String getTradeType() {
        return tradeType;
    }
    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }
    public String getTransactionId() {
        return transactionId;
    }
    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }
    public int getPeriod() {
        return period;
    }
    public void setPeriod(int period) {
        this.period = period;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public int getStatus() {
        return status;
    }
    public void setStatus(int status) {
        this.status = status;
    }
}

+ 93 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskDetailDO.java

@ -0,0 +1,93 @@
package com.yihu.jw.entity.health.bank;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by wamg zhinan 2018/4/27.
 */
@Entity
@Table(name = "wlyy_health_bank_task_detail")
public class TaskDetailDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "status")
    private String status;
    @Column(name = "patient_id")
    private String patientId;
    @Column(name = "doctor_id")
    private String doctorId;
    @Column(name = "integrate")
    private int integrate;
    @Column(name = "trade_direction")
    private int tradeDirection;
    @Column(name = "task_id")
    private String taskId;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public String getPatientId() {
        return patientId;
    }
    public void setPatientId(String patientId) {
        this.patientId = patientId;
    }
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
    public int getIntegrate() {
        return integrate;
    }
    public void setIntegrate(int integrate) {
        this.integrate = integrate;
    }
    public int getTradeDirection() {
        return tradeDirection;
    }
    public void setTradeDirection(int tradeDirection) {
        this.tradeDirection = tradeDirection;
    }
    public String getTaskId() {
        return taskId;
    }
    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }
}

+ 49 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/health/bank/TaskRuleDO.java

@ -0,0 +1,49 @@
package com.yihu.jw.entity.health.bank;
import com.yihu.jw.IdEntityWithOperation;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
/**
 * Created by wamg zhinan 2018/4/27.
 */
@Entity
@Table(name = "wlyy_health_bank_task_rule")
public class TaskRuleDO extends IdEntityWithOperation implements Serializable{
    @Column(name = "saas_id")
    private String saasId;
    @Column(name = "task_id")
    private String taskId;
    @Column(name = "rule_code")
    private String ruleCode;
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getTaskId() {
        return taskId;
    }
    public void setTaskId(String taskId) {
        this.taskId = taskId;
    }
    public String getRuleCode() {
        return ruleCode;
    }
    public void setRuleCode(String ruleCode) {
        this.ruleCode = ruleCode;
    }
}

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

@ -0,0 +1,36 @@
package com.yihu.jw.rm.health.bank;
/**
 * Created by Trick on 2018/2/7.
 */
public class HealthBankMapping {
    public static final String api_health_bank_common = "svr-health-bank";
    public static final Integer api_health_bank_fail = -1;
    public static final String api_success ="success";
    public static class healthBank{
        public static final String createAccount = "/createAccount";
        public static final String selectAccount = "/selectAccount";
        public static final String createTask = "/createTask";
        public static final String deleteTask ="/deleteTask";
        public static final String findTask = "/findTask";
        public static final String updateTask ="/updateTask";
        public static final String createTaskDetail = "/createTaskDetail";
        public static final String createActivity="/createActivity";
        public static final String findActivity="/findActivity";
        public static final String updateActivity="/updateActivity";
        public static final String createActivityInfo ="/createActivityInfo";
        public static final String findActivityInfo = "/findActivityInfo";
        public static final String updateActivityInfo ="/updateActivityInfo";
        public static final String createGoods = "/createGoods";
        public static final String findGoods ="/findGoods";
        public static final String updateGoods ="/updateGoods";
        public static final String createCreditsDetail = "/createCreditsDetail";
        public static final String findCreditsLogInfo ="/findCreditsLogInfo";
        public static final String selectByRanking = "/selectByRanking";
        public static final String updateCreditsLogInfo ="/updateCreditsLogInfo";
        public static final String exchangeGoods = "/exchangeGoods";
        public static final String findExchangeGoods="/findExchangeGoods";
    }
}

+ 125 - 0
svr/svr-wlyy-health-bank/pom.xml

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.yihu.jw</groupId>
        <artifactId>svr-lib-parent-pom</artifactId>
        <version>1.0.0</version>
        <relativePath>../../svr-lib-parent-pom/pom.xml</relativePath>
    </parent>
    <groupId>com.yihu.health.bank</groupId>
    <artifactId>svr-wlyy-health-bank</artifactId>
    <version>1.0.0</version>
    <dependencies>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-entity</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-request-mapping</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-exception</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-swagger</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-rest-model</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>
            <artifactId>common-util</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-data-mysql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.yihu.base</groupId>
            <artifactId>common-log</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>
        <!--zipkin支持分布式追踪系统-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons</artifactId>
        </dependency>
    </dependencies>
</project>

+ 1 - 0
svr/svr-wlyy-health-bank/readme.MD

@ -0,0 +1 @@
svr-wlyy-health-bank i健康公共业务后台-健康银行

+ 18 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/SvrWlyyHealthBankApplication.java

@ -0,0 +1,18 @@
package com.yihu.jw;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@SpringBootApplication(exclude = OAuth2AutoConfiguration.class)
@ComponentScan(basePackages = {"com"})
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
public class SvrWlyyHealthBankApplication {
    public static void main(String[] args) {
        SpringApplication.run(SvrWlyyHealthBankApplication.class, args);
    }
}

+ 50 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/config/SwaggerConfig.java

@ -0,0 +1,50 @@
package com.yihu.jw.config;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableSwagger2
@ComponentScan("com.yihu.jw.**")
public class SwaggerConfig {
    public static final String archives_API = "healthBank";
    @Bean
    public Docket wlyyAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName(archives_API)
                .useDefaultResponseMessages(false)
                .forCodeGeneration(false)
                .pathMapping("/")
                .select()
                .paths(or(
                        regex("/" + HealthBankMapping.api_health_bank_common + "/.*")
                ))
                .build()
                .apiInfo(wlyyApiInfo());
    }
    private ApiInfo wlyyApiInfo() {
        ApiInfo wlyyInfo = new ApiInfo("基卫2.0API",
                "基卫2.0API,提供健康银行相关服务。",
                "1.0",
                "No terms of service",
                "wangzhinan@jkzl.com",
                "The Apache License, Version 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0.html"
        );
        return wlyyInfo;
    }
}

+ 29 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/config/jpa/HibernateProperties.java

@ -0,0 +1,29 @@
package com.yihu.jw.config.jpa;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Component
@RefreshScope
public class HibernateProperties {
    @Value("${hibernate.dialect}")
    private String dialect;
    @Value("${hibernate.show_sql}")
    private String show_sql;
    @Value("${hibernate.ejb.naming_strategy}")
    private String naming_strategy;
    public  Properties hibProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect",dialect);
        properties.put("hibernate.show_sql", show_sql);
        properties.put("hibernate.ejb.naming_strategy", naming_strategy);
        return properties;
    }
}

+ 58 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/config/jpa/WlyyHealthBankJpa.java

@ -0,0 +1,58 @@
package com.yihu.jw.config.jpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Properties;
/**
 * Created by chenweida on 2017/4/6.
 */
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
        entityManagerFactoryRef = "wlyyHealthBankEntityManagerFactory",
        transactionManagerRef = "wlyyHealthBankTransactionManager",
        basePackages = {"com.yihu.jw.dao"})   //设置Repository所在位置
public class WlyyHealthBankJpa {
    @Autowired
    private HibernateProperties hibernateProperties;
    @Bean(name = "wlyyHealthBankEntityManagerFactory")
    @Primary
    public LocalContainerEntityManagerFactoryBean entityManagerFactoryPrimary(DataSource dataSource) {
        LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean();
        emfb.setDataSource(dataSource);
        emfb.setPackagesToScan("com.yihu.jw.entity.health");
        emfb.setPersistenceUnitName("bank");
        JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
        emfb.setJpaVendorAdapter(vendorAdapter);
        Properties properties = hibernateProperties.hibProperties();
        properties.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.ImprovedNamingStrategy");
        emfb.setJpaProperties(hibernateProperties.hibProperties());
        return emfb;
    }
    @Bean(name = "wlyyHealthBankTransactionManager")
    @Primary
    JpaTransactionManager transactionManagerSecondary(
            @Qualifier("wlyyHealthBankEntityManagerFactory") EntityManagerFactory builder) {
        return new JpaTransactionManager(builder);
    }
}

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

@ -0,0 +1,80 @@
package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/5/10.
 */
import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.entity.health.bank.CreditsDetailDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.AccountService;
import com.yihu.jw.service.CreditsDetailService;
import io.swagger.annotations.Api;
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;
/**
 * @author wangzhinan
 * @create 2018-05-10 11:44
 * @desc account Controller
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "银行账户相关操作",description = "银行账户相关操作")
public class AccountController extends EnvelopRestController {
    @Autowired
    private AccountService service;
    @Autowired
    private CreditsDetailService creditsDetailService;
    @Autowired
    private Tracer tracer;
    /**
     * 添加账户
     * @param account
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.createAccount)
    @ApiOperation(value = "添加账户")
    public Envelop<Boolean> insert(@ApiParam(name = "account",value = "账户JSON")
                                   @RequestParam(value = "account",required = true)String account){
        try {
            AccountDO accountDO = toEntity(account,AccountDO.class);
            return service.insert(accountDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    /**
     * 获取账户
     *
     * @param creditsDetail
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.selectAccount)
    @ApiOperation(value = "获取账户信息")
    public Envelop<AccountDO> selectByAccount(@ApiParam(name = "creditsDetail",value = "积分JSON")
                                   @RequestParam(value = "creditsDetail",required = false)String creditsDetail){
        try {
            CreditsDetailDO creditsDetailDO = toEntity(creditsDetail,CreditsDetailDO.class);
            return creditsDetailService.findByTradeDirection(creditsDetailDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 99 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ActivityController.java

@ -0,0 +1,99 @@
package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.jw.entity.health.bank.ActivityDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.ActivityService;
import io.swagger.annotations.Api;
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.*;
/**
 * @author wangzhinan
 * @create 2018-04-27 14:14
 * @desc 健康活动
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "健康活动相关操作",description = "健康活动相关操作")
public class ActivityController extends EnvelopRestController{
    @Autowired
    private ActivityService service;
    @Autowired
    private Tracer tracer;
    /**
     *  publish activity
     *
     * @param activity
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.createActivity)
    @ApiOperation(value = "发布活动")
    public Envelop<Boolean> publishActivity(@ApiParam(name = "activity",value = "健康活动JSON")
                                          @RequestParam(value = "activity",required = true)String activity){
        try {
            ActivityDO activityDO = toEntity(activity,ActivityDO.class);
            return service.insert(activityDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    /**
     * find health activity
     *
     * @param activity
     * @param page
     * @param size
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.findActivity)
    @ApiOperation(value = "查看健康活动")
    public Envelop<ActivityDO> getActivity(@ApiParam(name = "activity",value = "健康活动JSON")
                                                    @RequestParam(value = "activity",required = false)String activity,
                                                @ApiParam(name = "page", value = "第几页,从1开始")
                                                @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                                @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                                @RequestParam(value = "size", required = false)Integer size){
        try{
            ActivityDO activityDO = toEntity(activity,ActivityDO.class);
            return service.findByCondition(activityDO,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    /**
     * out activity
     *
     * @param activity
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.updateActivity)
    @ApiOperation(value = "下架活动")
    public Envelop<Boolean> outActivity(@ApiParam(name = "activity",value = "健康活动JSON")
                                            @RequestParam(value = "activity",required = true)String activity){
        try {
            ActivityDO activityDO = toEntity(activity,ActivityDO.class);
            return service.update(activityDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 95 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ActivityDetailController.java

@ -0,0 +1,95 @@
package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.ActivityRuleService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author wangzhinan
 * @create 2018-04-27 15:24
 * @desc health activity info controller
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "健康活动参与情况相关操作",description = "健康活动参与情况相关操作")
public class ActivityDetailController extends EnvelopRestController {
    @Autowired
    private ActivityRuleService service;
    @Autowired
    private Tracer tracer;
/*
    *//**
     * patient attend activity
     *
     * @param activityInfo
     * @return
     *//*
    @PostMapping(value = HealthBankMapping.healthBank.createActivityInfo)
    @ApiOperation(value = "参与活动")
    public Envelop<Boolean> attendActivity(@ApiParam(name = "activityInfo",value = "健康活动详情JSON")
                                            @RequestParam(value = "activityInfo",required = true)String activityInfo){
        try {
            ActivityRuleDO activityRuleDO = toEntity(activityInfo,ActivityRuleDO.class);
            return service.insert(activityRuleDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    *//**
     * find health activity
     *
     * @param activityInfo
     * @param page
     * @param size
     * @return
     *//*
    @PostMapping(value = HealthBankMapping.healthBank.findActivityInfo)
    @ApiOperation(value = "查看健康活动")
    public Envelop<ActivityRuleDO> getActivityInfo(@ApiParam(name = "activityInfo",value = "健康活动JSON")
                                                @RequestParam(value = "activityInfo",required = false)String activityInfo,
                                                   @ApiParam(name = "page", value = "第几页,从1开始")
                                                @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                                   @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                                @RequestParam(value = "size", required = false)Integer size){
        try{
            ActivityRuleDO activityRuleDO = toEntity(activityInfo,ActivityRuleDO.class);
            return service.findByCondition(activityRuleDO,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    *//**
     * patient update activity status
     *
     * @param activityInfo
     * @return
     *//*
    @PostMapping(value = HealthBankMapping.healthBank.updateActivityInfo)
    @ApiOperation(value = "更新活动状态")
    public Envelop<Boolean> updateActivity(@ApiParam(name = "activityInfo",value = "健康活动JSON")
                                        @RequestParam(value = "activityInfo",required = true)String activityInfo){
        try {
            ActivityRuleDO activityRuleDO = toEntity(activityInfo,ActivityRuleDO.class);
            return service.update(activityRuleDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }*/
}

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

@ -0,0 +1,99 @@
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.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.CreditsDetailService;
import io.swagger.annotations.Api;
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.*;
import java.util.ArrayList;
import java.util.List;
/**
 * @author wangzhinan
 * @create 2018-04-27 16:51
 * @desc credits log info
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "健康积分相关操作",description = "健康积分相关操作")
public class CreditsDetailController extends EnvelopRestController {
    @Autowired
    private Tracer tracer;
    @Autowired
    private CreditsDetailService service;
    @PostMapping(value = HealthBankMapping.healthBank.findCreditsLogInfo)
    @ApiOperation(value = "查看积分记录")
    public Envelop<CreditsDetailDO> selectCreditsLogInfo(@ApiParam(name = "creditsDetail",value = "积分记录JSON")
                                                          @RequestParam(value = "creditsDetail",required = false)String creditsDetail,
                                                            @ApiParam(name = "page", value = "第几页,从1开始")
                                                          @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                                            @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                                          @RequestParam(value = "size", required = false)Integer size){
        try{
            CreditsDetailDO creditsDetailDO = toEntity(creditsDetail,CreditsDetailDO.class);
            return service.findByCondition(creditsDetailDO,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    /**
     * 添加积分
     *
     * @param creditsDetail
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.createCreditsDetail)
    @ApiOperation(value = "添加积分记录")
    public Envelop<Boolean> insert(@ApiParam(name = "creditsDetail",value = "积分记录JSON")
                                   @RequestParam(value = "creditsDetail",required = true)String creditsDetail){
        try {
            CreditsDetailDO creditsDetailDO = toEntity(creditsDetail,CreditsDetailDO.class);
            return service.insert(creditsDetailDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = HealthBankMapping.healthBank.selectByRanking)
    @ApiOperation(value = "查询积分排名")
    public Envelop<AccountDO> selectByRanking(@RequestBody JSONObject object){
        try{
            JSONArray array = object.getJSONArray("filter");
            Integer page = object.getInteger("page");
            Integer size = object.getInteger("size");
            List<String> patientIds = new ArrayList<>();
            for (int i=0;array != null && array.size()!=0&& i<array.size();i++){
                patientIds.add(array.getString(i));
            }
            return service.selectByRanking(patientIds,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 81 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/ExchangeGoodsController.java

@ -0,0 +1,81 @@
package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/5/3.
 */
import com.yihu.jw.entity.health.bank.ExchangeGoodsDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.ExchangeGoodsService;
import io.swagger.annotations.Api;
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;
/**
 * @author wangzhinan
 * @create 2018-05-03 16:17
 * @desc exchange goods Controller
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "商品兑换相关操作",description = "商品兑换相关操作")
public class ExchangeGoodsController extends EnvelopRestController {
    @Autowired
    private ExchangeGoodsService service;
    @Autowired
    private Tracer tracer;
    /**
     * find exchange goods
     *
     * @param exchangeGoods
     * @param page
     * @param size
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.findExchangeGoods)
    @ApiOperation(value = "查看兑换商品信息")
    public Envelop<ExchangeGoodsDO> getExchangeGoods(@ApiParam(name = "exchangeGoods",value = "兑换商品JSON")
                                           @RequestParam(value = "exchangeGoods",required = false)String exchangeGoods,
                                           @ApiParam(name = "page", value = "第几页,从1开始")
                                           @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                           @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                           @RequestParam(value = "size", required = false)Integer size){
        try{
            ExchangeGoodsDO exchangeGoodsDO = toEntity(exchangeGoods,ExchangeGoodsDO.class);
            return service.findByCondition(exchangeGoodsDO,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
   /* *//**
     * exchange goods
     *
     * @param exchangeGoods
     * @return
     *//*
    @PostMapping(value = HealthBankMapping.healthBank.exchangeGoods)
    @ApiOperation(value = "兑换商品")
    public Envelop<Boolean> exchangeGoods(@ApiParam(name = "exchangeGoods",value = "兑换商品JSON")
                                          @RequestParam(value = "exchangeGoods")String exchangeGoods){
        try {
            ExchangeGoodsDO exchangeGoodsDO =toEntity(exchangeGoods,ExchangeGoodsDO.class);
            return service.insert(exchangeGoodsDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }*/
}

+ 99 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/GoodsController.java

@ -0,0 +1,99 @@
package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.jw.entity.health.bank.GoodsDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.GoodsService;
import io.swagger.annotations.Api;
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;
/**
 * @author wangzhinan
 * @create 2018-04-27 16:42
 * @desc goods service
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "健康服务商品相关操作",description = "健康服务商品相关操作")
public class GoodsController extends EnvelopRestController {
    @Autowired
    private GoodsService service;
    @Autowired
    private Tracer tracer;
    /**
     * patient publish  gooods
     *
     * @param goods
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.createGoods)
    @ApiOperation(value = "上架服务商品")
    public Envelop<Boolean> publishGoods(@ApiParam(name = "goods",value = "健康服务商品JSON")
                                           @RequestParam(value = "goods",required = true)String goods){
        try {
            GoodsDO goodsDO = toEntity(goods,GoodsDO.class);
            service.insert(goodsDO);
            return service.insert(goodsDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    /**
     * find health goods
     *
     * @param goods
     * @param page
     * @param size
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.findGoods)
    @ApiOperation(value = "查看健康服务商品")
    public Envelop<GoodsDO> getActivityInfo(@ApiParam(name = "goods",value = "健康服务商品JSON")
                                                   @RequestParam(value = "goods",required = false)String goods,
                                                   @ApiParam(name = "page", value = "第几页,从1开始")
                                                   @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                                   @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                                   @RequestParam(value = "size", required = false)Integer size){
        try{
            GoodsDO goodsDO = toEntity(goods,GoodsDO.class);
            return service.findByCondition(goodsDO,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    /**
     * patient update goods status
     *
     * @param goods
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.updateGoods)
    @ApiOperation(value = "更新健康服务商品")
    public Envelop<Boolean> updateActivity(@ApiParam(name = "goods",value = "健康服务商品JSON")
                                           @RequestParam(value = "goods",required = true)String goods){
        try {
            GoodsDO goodsDO = toEntity(goods,GoodsDO.class);
            return service.update(goodsDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
}

+ 115 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/TaskController.java

@ -0,0 +1,115 @@
package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.jw.entity.health.bank.TaskDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.TaskService;
import io.swagger.annotations.Api;
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;
/**
 * @author wangzhinan
 * @create 2018-04-27 9:29
 * @desc health blank Controller
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "健康任务相关操作",description = "健康银行相关操作")
public class TaskController extends EnvelopRestController {
    @Autowired
    private TaskService service;
    @Autowired
    private Tracer tracer;
    /**
     * doctor assigning task patient
     *
     * @param task
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.createTask)
    @ApiOperation(value = "添加任务")
    public Envelop<Boolean> assigningTask(@ApiParam(name = "task",value = "健康任务JSON")
                                          @RequestParam(value = "task",required = true)String task){
        try {
            TaskDO taskDO = toEntity(task,TaskDO.class);
            return service.insert(taskDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = HealthBankMapping.healthBank.findTask)
    @ApiOperation(value = "查询任务")
    public Envelop<TaskDO> assigningTask(@ApiParam(name = "task",value = "健康任务JSON")
                                          @RequestParam(value = "task",required = true)String task,
                                          @ApiParam(name = "page", value = "第几页,从1开始")
                                          @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                          @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                              @RequestParam(value = "size", required = false)Integer size){
        try {
            TaskDO taskDO = toEntity(task,TaskDO.class);
            return service.selectByCondition(taskDO,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    /**//**
     * patient find health task
     *
     * @param patientId
     * @param page
     * @param size
     * @return
     *//*
    @GetMapping(value = HealthBankMapping.healthBank.findTask)
    @ApiOperation(value = "查看健康任务")
    public Envelop<TaskDetailDO> getTaskByPatient(@ApiParam(name = "patientId",value = "居民Id")
                                                @RequestParam(value = "patientId",required = false)String patientId,
                                                  @ApiParam(name = "doctorId",value = "家庭医生Id")
                                                @RequestParam(value = "doctorId",required = false)String doctorId,
                                                  @ApiParam(name = "page", value = "第几页,从1开始")
                                                @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                                  @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                                @RequestParam(value = "size", required = false)Integer size){
        try{
            return service.findTaskByPatient(patientId,doctorId,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = HealthBankMapping.healthBank.updateTask)
    @ApiOperation(value = "居民执行健康任务")
    public Envelop<Boolean> updateTask(@ApiParam(name = "taskInfo",value = "健康任务JSON")
                                                @RequestParam(value = "taskInfo",required = true)String taskInfo){
        try{
            TaskDetailDO taskDetailDO = toEntity(taskInfo,TaskDetailDO.class);
            return service.update(taskDetailDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }*/
}

+ 95 - 0
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/controller/TaskDetailController.java

@ -0,0 +1,95 @@
package com.yihu.jw.controller;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.jw.entity.health.bank.TaskDetailDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.restmodel.common.EnvelopRestController;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.service.TaskDetailService;
import io.swagger.annotations.Api;
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.*;
/**
 * @author wangzhinan
 * @create 2018-04-27 9:29
 * @desc health blank Controller
 **/
@RestController
@RequestMapping(HealthBankMapping.api_health_bank_common)
@Api(tags = "健康任务相关操作",description = "健康银行相关操作")
public class TaskDetailController extends EnvelopRestController {
    @Autowired
    private TaskDetailService service;
    @Autowired
    private Tracer tracer;
    /**
     * doctor assigning task patient
     *
     * @param taskDetail
     * @return
     */
    @PostMapping(value = HealthBankMapping.healthBank.createTaskDetail)
    @ApiOperation(value = "居民参与活动")
    public Envelop<Boolean> assigningTask(@ApiParam(name = "taskDetail",value = "健康任务JSON")
                                          @RequestParam(value = "taskDetail",required = true)String taskDetail){
        try {
            TaskDetailDO taskDetailDO = toEntity(taskDetail,TaskDetailDO.class);
            return service.insert(taskDetailDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
/*
    *//**
     * patient find health task
     *
     * @param patientId
     * @param page
     * @param size
     * @return
     *//*
    @GetMapping(value = HealthBankMapping.healthBank.findTask)
    @ApiOperation(value = "查看健康任务")
    public Envelop<TaskDetailDO> getTaskByPatient(@ApiParam(name = "patientId",value = "居民Id")
                                                @RequestParam(value = "patientId",required = false)String patientId,
                                                  @ApiParam(name = "doctorId",value = "家庭医生Id")
                                                @RequestParam(value = "doctorId",required = false)String doctorId,
                                                  @ApiParam(name = "page", value = "第几页,从1开始")
                                                @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                                  @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                                @RequestParam(value = "size", required = false)Integer size){
        try{
            return service.findTaskByPatient(patientId,doctorId,page,size);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = HealthBankMapping.healthBank.updateTask)
    @ApiOperation(value = "居民执行健康任务")
    public Envelop<Boolean> updateTask(@ApiParam(name = "taskInfo",value = "健康任务JSON")
                                                @RequestParam(value = "taskInfo",required = true)String taskInfo){
        try{
            TaskDetailDO taskDetailDO = toEntity(taskInfo,TaskDetailDO.class);
            return service.update(taskDetailDO);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }*/
}

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

@ -0,0 +1,15 @@
package com.yihu.jw.dao;/**
 * Created by nature of king on 2018/5/10.
 */
import com.yihu.jw.entity.health.bank.AccountDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author wangzhinan
 * @create 2018-05-10 11:15
 * @desc health bank account dao
 **/
public interface AccountDao extends PagingAndSortingRepository<AccountDO,String>,JpaSpecificationExecutor<AccountDO> {
}

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

@ -0,0 +1,11 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.health.bank.ActivityDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wang zhinan on 2018/4/27.
 */
public interface ActivityDao extends PagingAndSortingRepository<ActivityDO,String>,JpaSpecificationExecutor<ActivityDO> {
}

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

@ -0,0 +1,11 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.health.bank.ActivityRuleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wang zhinan on 2018/4/27.
 */
public interface ActivityRuleDao extends PagingAndSortingRepository<ActivityRuleDO,String>,JpaSpecificationExecutor<ActivityRuleDO>{
}

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

@ -0,0 +1,11 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.health.bank.CreditsDetailDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wang zhinan on 2018/4/27.
 */
public interface CredittsLogDetailDao extends PagingAndSortingRepository<CreditsDetailDO,String>,JpaSpecificationExecutor<CreditsDetailDO>{
}

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

@ -0,0 +1,15 @@
package com.yihu.jw.dao;/**
 * Created by nature of king on 2018/5/3.
 */
import com.yihu.jw.entity.health.bank.ExchangeGoodsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author wangzhinan
 * @create 2018-05-03 15:28
 * @desc exchange goods dao
 **/
public interface ExchangeGoodsDao extends PagingAndSortingRepository<ExchangeGoodsDO,String>,JpaSpecificationExecutor<ExchangeGoodsDO> {
}

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

@ -0,0 +1,11 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.health.bank.GoodsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wang zhinan  on 2018/4/27.
 */
public interface GoodsDao extends PagingAndSortingRepository<GoodsDO,String>,JpaSpecificationExecutor<GoodsDO> {
}

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

@ -0,0 +1,15 @@
package com.yihu.jw.dao;/**
 * Created by nature of king on 2018/5/10.
 */
import com.yihu.jw.entity.health.bank.TaskDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author wangzhinan
 * @create 2018-05-10 11:17
 * @desc health bank task dao
 **/
public interface TaskDao extends PagingAndSortingRepository<TaskDO,String>,JpaSpecificationExecutor<TaskDO> {
}

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

@ -0,0 +1,11 @@
package com.yihu.jw.dao;
import com.yihu.jw.entity.health.bank.TaskDetailDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wang zhinan on 2018/4/27.
 */
public interface TaskDetailDao extends PagingAndSortingRepository<TaskDetailDO,String>,JpaSpecificationExecutor<TaskDetailDO> {
}

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

@ -0,0 +1,16 @@
/**
 * Created by nature of king on 2018/5/10.
 */
package com.yihu.jw.dao;
import com.yihu.jw.entity.health.bank.TaskRuleDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author wangzhinan
 * @create 2018-05-10 11:17
 * @desc health bank task dao
 **/
public interface TaskRuleDao extends PagingAndSortingRepository<TaskRuleDO,String>,JpaSpecificationExecutor<TaskRuleDO> {
}

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

@ -0,0 +1,32 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/5/10.
 */
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.AccountDao;
import com.yihu.jw.entity.health.bank.AccountDO;
import com.yihu.jw.restmodel.common.Envelop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
/**
 * @author wangzhinan
 * @create 2018-05-10 11:26
 * @desc account service
 **/
@Service
@Transactional
public class AccountService extends BaseJpaService<AccountDO,AccountDao> {
    @Autowired
    private AccountDao accountDao;
    public Envelop<Boolean> insert(AccountDO accountDO){
        accountDao.save(accountDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
}

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

@ -0,0 +1,109 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.ActivityDao;
import com.yihu.jw.dao.ActivityRuleDao;
import com.yihu.jw.dao.CredittsLogDetailDao;
import com.yihu.jw.entity.health.bank.ActivityRuleDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.ParseException;
/**
 * @author wangzhinan
 * @create 2018-04-27 14:40
 * @desc health activity info Service
 **/
@Service
@Transactional
public class ActivityRuleService extends BaseJpaService<ActivityRuleDO,ActivityRuleDao> {
    @Autowired
    private ActivityRuleDao activityRuleDao;
    @Autowired
    private ActivityDao activityDao;
    @Autowired
    private CredittsLogDetailDao credittsLogDetailDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * insert activityRuleDO
     *
     * @param activityRuleDO
     * @return
    public Envelop<Boolean> insert(ActivityRuleDO activityRuleDO){
        activityRuleDao.save(activityRuleDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
    *//**
     *  find by condition
     *
     * @param activityRuleDO
     * @param page
     * @param size
     * @return
     * @throws ParseException
     *//*
    public Envelop<ActivityRuleDO> findByCondition(ActivityRuleDO activityRuleDO, Integer page, Integer size) throws ParseException {
        String sql = new ISqlUtils().getSql(activityRuleDO,page,size,"*");
        List<ActivityRuleDO> activityRuleDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ActivityRuleDO.class));
        List<ActivityRuleDO> activityRuleDOList = new ArrayList<>();
        for (ActivityRuleDO activityRuleDO1 : activityRuleDOS){
            ActivityDO activityDO = activityDao.findOne(activityRuleDO1.getActivityId());
            activityRuleDO1.setActivityDO(activityDO);
            activityRuleDOList.add(activityRuleDO1);
        }
        String sqlcount = new ISqlUtils().getSql(activityRuleDO,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, activityRuleDOList,page,size,count);
    }
    *//**
     * update activityRuleDO
     *
     * @param activityRuleDO
     * @return
     *//*
    public Envelop<Boolean> update(ActivityRuleDO activityRuleDO){
        ActivityDO activityDO = activityDao.findOne(activityRuleDO.getActivityId());
        ActivityRuleDO activityRuleDO1 = new ActivityRuleDO();
        activityRuleDO1 = activityRuleDao.findOne(activityRuleDO.getId());
        if (activityRuleDO.getStatus().equalsIgnoreCase("finished")){
            activityRuleDO.setIntegrate(activityDO.getIntegrate());
        }
        String sql = "select cl.status as status,cl.total as total from health_bank_credits_log cl order by cl.update_time desc";
        List<CreditsDetailDO> creditsLogDetailDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(CreditsDetailDO.class));
        activityRuleDao.save(activityRuleDO);
        if (activityRuleDO.getStatus().equalsIgnoreCase("finished")&&!activityRuleDO1.getStatus().equalsIgnoreCase("unfinished")){
            CreditsDetailDO creditsLogDetailDO = new CreditsDetailDO();
            if (creditsLogDetailDOList == null || creditsLogDetailDOList.size() ==0){
                creditsLogDetailDO.setTotal(Long.parseLong(activityDO.getIntegrate()));
            }else {
                creditsLogDetailDO.setTotal(Long.parseLong(activityDO.getIntegrate().replace("+",""))+ creditsLogDetailDOList.get(0).getTotal());
            }
            creditsLogDetailDO.setPatientId(activityRuleDO.getPatientId());
            creditsLogDetailDO.setIntegrate("+"+ activityRuleDO.getIntegrate());
            creditsLogDetailDO.setIntegrateType("HEALTH_ACTIVITY");
            creditsLogDetailDO.setIntegrateId(activityRuleDO.getActivityId());
            creditsLogDetailDO.setStatus("unused");
            creditsLogDetailDO.setCommunity(activityDO.getCommunity());
            credittsLogDetailDao.save(creditsLogDetailDO);
        }
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }*/
}

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

@ -0,0 +1,83 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/4/27.
 */
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.restmodel.common.Envelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-04-27 14:38
 * @desc health activity Service
 **/
@Service
@Transactional
public class ActivityService extends BaseJpaService<ActivityDO,ActivityDao> {
    @Autowired
    private ActivityDao activityDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * insert activityDO
     *
     * @param activityDO
     * @return
     */
    public Envelop<Boolean> insert(ActivityDO activityDO){
        activityDao.save(activityDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
    /**
     *  find by condition
     *
     * @param activityDO
     * @param page
     * @param size
     * @return
     * @throws ParseException
     */
    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));
        String sqlcount = new ISqlUtils().getSql(activityDO,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,activityDOS,page,size,count);
    }
    /**
     * update activityDO
     *
     * @param activityDO
     * @return
     */
    public Envelop<Boolean> update(ActivityDO activityDO){
        activityDao.save(activityDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
}

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

@ -0,0 +1,202 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.*;
import com.yihu.jw.entity.health.bank.*;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-04-27 16:53
 * @desc credits log info Service
 **/
@Service
@Transactional
public class CreditsDetailService extends BaseJpaService<CreditsDetailDO,CredittsLogDetailDao> {
    @Autowired
    private CredittsLogDetailDao credittsLogDetailDao;
    @Autowired
    private TaskDao taskDao;
    @Autowired
    private ActivityDao activityDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private AccountDao accountDao;
    @Autowired
    private TaskDetailDao taskDetailDao;
   /**
     *  find creditsLogInfo
     *
     * @return
     * @throws ParseException
     */
    public Envelop<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){
            if (creditsDetailDO1.getTradeType().equalsIgnoreCase("HEALTH_TASK")){
                TaskDO taskDO = taskDao.findOne(creditsDetailDO1.getTransactionId());
                creditsDetailDO1.setTaskDO(taskDO);
            }else if(creditsDetailDO1.getTradeType().equalsIgnoreCase("HEALTH_ACTIVITY")){
                ActivityDO activityDO = activityDao.findOne(creditsDetailDO1.getTransactionId());
                creditsDetailDO1.setActivityDO(activityDO);
            }
        }
        String sqlcount = new ISqlUtils().getSql(creditsDetailDO,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, creditsDetailDOS,page,size,count);
    }
    /**
     * 获取账户信息
     *
     * @param creditsDetailDO
     * @return
     */
    public Envelop<AccountDO> findByTradeDirection(CreditsDetailDO creditsDetailDO){
        AccountDO accountDO = accountDao.findOne(creditsDetailDO.getAccountId());
        String sql = "SELECT SUM(cd.integrate) as total FROM wlyy_health_bank_credits_detail cd where cd.trade_direction = "+creditsDetailDO.getTradeDirection();
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
        if (rstotal!= null && rstotal.size()>0){
            if (rstotal.get(0).get("total") == null){
                accountDO.setUsedTotal(0);
            }else {
                accountDO.setUsedTotal(Integer.parseInt(rstotal.get(0).get("total").toString()));
            }
        }
        return Envelop.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 Envelop<AccountDO> selectByRanking(List<String> patientIds, Integer page, Integer size){
        StringBuffer buffer = new StringBuffer();
        if (patientIds !=null && patientIds.size()!=0){
            buffer.append(" ba.patient_id in(");
            for (int i=0;i<patientIds.size();i++){
                buffer.append("'"+patientIds.get(i)+"'").append(",");
            }
            buffer.append(")");
            buffer.deleteCharAt(buffer.length()-2);
        }
        String sql = "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 +(cd1.total)) AS sum " +
                " FROM " +
                " wlyy_health_bank_account ba, " +
                " ( " +
                " 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 " +
                "WHERE " + buffer +
                "AND cd1.patient_id = ba.patient_id " +
                "ORDER BY " +
                " ba.create_time, " +
                " (ba.total + cd1.total) DESC " +
                "LIMIT "+(page-1)*size+","+size;
        List<AccountDO> accountDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(AccountDO.class));
        String sqlCount = "SELECT count(1) AS total"+
                " FROM " +
                " wlyy_health_bank_account ba, " +
                " ( " +
                " 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 " +
                "WHERE " + buffer +
                "AND cd1.patient_id = ba.patient_id " +
                "ORDER BY " +
                " ba.create_time, " +
                " (ba.total + cd1.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, accountDOS,page,size,count);
    }
    /**
     * 添加积分
     *
     * @param creditsDetailDO
     * @return
     */
    public Envelop<Boolean> insert(CreditsDetailDO creditsDetailDO){
        if (creditsDetailDO.getTradeDirection() == 1){
            if (creditsDetailDO.getTradeType().equals("HEALTH_TASK")){
                TaskDetailDO taskDetailDO = new TaskDetailDO();
                taskDetailDO.setIntegrate(creditsDetailDO.getIntegrate());
                taskDetailDO.setTaskId(creditsDetailDO.getTransactionId());
                taskDetailDO.setSaasId(creditsDetailDO.getSaasId());
                taskDetailDO.setPatientId(creditsDetailDO.getPatientId());
                taskDetailDO.setTradeDirection(creditsDetailDO.getTradeDirection());
                taskDetailDO.setStatus("1");
                taskDetailDao.save(taskDetailDO);
            }
        }
        CreditsDetailDO creditsDetailDO1 =credittsLogDetailDao.save(creditsDetailDO);
        AccountDO accountDO = accountDao.findOne(creditsDetailDO1.getAccountId());
        if (creditsDetailDO1.getTradeDirection() == 1){
            accountDO.setTotal(accountDO.getTotal()+creditsDetailDO1.getIntegrate());
        }else if (creditsDetailDO.getTradeDirection() == -1){
            accountDO.setTotal(accountDO.getTotal()-creditsDetailDO1.getIntegrate());
        }
        accountDao.save(accountDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
}

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

@ -0,0 +1,99 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/5/3.
 */
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.CredittsLogDetailDao;
import com.yihu.jw.dao.ExchangeGoodsDao;
import com.yihu.jw.dao.GoodsDao;
import com.yihu.jw.entity.health.bank.ExchangeGoodsDO;
import com.yihu.jw.entity.health.bank.GoodsDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-05-03 15:34
 * @desc exchange goods Service
 **/
@Service
@Transactional
public class ExchangeGoodsService extends BaseJpaService<ExchangeGoodsDO,ExchangeGoodsDao> {
    @Autowired
    private ExchangeGoodsDao exchangeGoodsDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private CredittsLogDetailDao credittsLogDetailDao;
    @Autowired
    private GoodsDao goodsDao;
  /*  *//**
     * exchange goods
     *
     * @param exchangeGoodsDO
     * @return
     *//*
    public Envelop<Boolean> insert(ExchangeGoodsDO exchangeGoodsDO){
        GoodsDO goodsDO = goodsDao.findOne(exchangeGoodsDO.getGoodsId());
        exchangeGoodsDO.setIntegrate(goodsDO.getRequireIntegrate());
        exchangeGoodsDao.save(exchangeGoodsDO);
        String sql = "select cl.status as status,cl.total as total from health_bank_credits_log cl order by cl.update_time desc";
        List<CreditsDetailDO> creditsLogDetailDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(CreditsDetailDO.class));
        CreditsDetailDO creditsLogDetailDO = new CreditsDetailDO();
        if (creditsLogDetailDOList == null || creditsLogDetailDOList.size() ==0){
            creditsLogDetailDO.setTotal(Long.parseLong(goodsDO.getRequireIntegrate()));
        }else {
            creditsLogDetailDO.setTotal(creditsLogDetailDOList.get(0).getTotal()-Long.parseLong(goodsDO.getRequireIntegrate()));
        }
        creditsLogDetailDO.setPatientId(exchangeGoodsDO.getPatientId());
        creditsLogDetailDO.setIntegrate("-"+exchangeGoodsDO.getIntegrate());
        creditsLogDetailDO.setIntegrateType("EXCHANGE_GOODS");
        creditsLogDetailDO.setIntegrateId(exchangeGoodsDO.getGoodsId());
        creditsLogDetailDO.setStatus("used");
        creditsLogDetailDO.setCommunity(goodsDO.getCommunity());
        credittsLogDetailDao.save(creditsLogDetailDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }*/
    /**
     * find exchange goods info
     *
     * @param exchangeGoodsDO
     * @param page
     * @param size
     * @return
     * @throws ParseException
     */
    public Envelop<ExchangeGoodsDO> findByCondition(ExchangeGoodsDO exchangeGoodsDO, Integer page, Integer size) throws ParseException {
        String sql = new ISqlUtils().getSql(exchangeGoodsDO,page,size,"*");
        List<ExchangeGoodsDO> exchangeGoodsDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ExchangeGoodsDO.class));
        List<ExchangeGoodsDO> exchangeGoodsDOList = new ArrayList<>();
        for (ExchangeGoodsDO exchangeGoodsDO1:exchangeGoodsDOS){
            GoodsDO goodsDO = goodsDao.findOne(exchangeGoodsDO1.getGoodsId());
            exchangeGoodsDO1.setGoodsDO(goodsDO);
            exchangeGoodsDOList.add(exchangeGoodsDO1);
        }
        String sqlcount = new ISqlUtils().getSql(exchangeGoodsDO,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,exchangeGoodsDOList,page,size,count);
    }
}

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

@ -0,0 +1,78 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.GoodsDao;
import com.yihu.jw.entity.health.bank.GoodsDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.ISqlUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-04-27 16:56
 * @desc goods Service
 **/
@Service
@Transactional
public class GoodsService extends BaseJpaService<GoodsDO,GoodsDao> {
    @Autowired
    private GoodsDao goodsDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * insert health task
     *
     * @param goodsDO
     * @return
     */
    public Envelop<Boolean> insert(GoodsDO goodsDO){
        goodsDao.save(goodsDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
    /**
     * find goods
     * @param goodsDO
     * @param page
     * @param size
     * @return
     * @throws ParseException
     */
    public Envelop<GoodsDO> findByCondition(GoodsDO goodsDO, Integer page, Integer size) throws ParseException {
        String sql = new ISqlUtils().getSql(goodsDO,page,size,"*");
        List<GoodsDO> goodsDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(GoodsDO.class));
        String sqlcount = new ISqlUtils().getSql(goodsDO,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,goodsDOS,page,size,count);
    }
    /**
     * update goods
     *
     * @param goodsDO
     * @return
     */
    public Envelop<Boolean> update(GoodsDO goodsDO){
        goodsDao.save(goodsDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
}

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

@ -0,0 +1,112 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/4/27.
 */
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.CredittsLogDetailDao;
import com.yihu.jw.dao.TaskDetailDao;
import com.yihu.jw.entity.health.bank.TaskDetailDO;
import com.yihu.jw.restmodel.common.Envelop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.ParseException;
/**
 * @author wangzhinan
 * @create 2018-04-27 9:35
 * @desc health blank Service
 **/
@Service
@Transactional
public class TaskDetailService extends BaseJpaService<TaskDetailDO,TaskDetailDao> {
    @Autowired
    private TaskDetailDao taskDetailDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private CredittsLogDetailDao credittsLogDetailDao;
    /**
     * 参与任务
     *
     * @param taskDetailDO
     * @return
     */
    public Envelop<Boolean> insert(TaskDetailDO taskDetailDO){
        taskDetailDao.save(taskDetailDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
   /* *//**
     * insert health task
     *
     * @param taskDetailDO
     * @return
     *//*
    public Envelop<Boolean> insert(TaskDetailDO taskDetailDO){
        taskDetailDao.save(taskDetailDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
    *//**
     *  patient or doctor find health task
     *
     * @param patientId
     * @param page
     * @param size
     * @return
     * @throws ParseException
     *//*
    public Envelop<TaskDetailDO> findTaskByPatient(String patientId, String doctorId, Integer page, Integer size) throws ParseException {
        TaskDetailDO taskDetailDO = new TaskDetailDO();
        taskDetailDO.setDoctorId(doctorId);
        taskDetailDO.setPatientId(patientId);
        String sql = new ISqlUtils().getSql(taskDetailDO,page,size,"*");
        List<TaskDetailDO> taskDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDetailDO.class));
        String sqlcount = new ISqlUtils().getSql(taskDetailDO,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, taskDetailDOS,page,size,count);
    }
    *//**
     * 修改健康任务
     *
     * @param taskDetailDO
     * @return
     *//*
    public Envelop<Boolean> update(TaskDetailDO taskDetailDO){
        TaskDetailDO taskDetailDO1 = taskDetailDao.findOne(taskDetailDO.getId());
        String sql = "select cl.status as status,cl.total as total from health_bank_credits_log cl order by cl.update_time desc";
        List<CreditsDetailDO> creditsLogDetailDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(CreditsDetailDO.class));
        taskDetailDao.save(taskDetailDO);
        if (taskDetailDO.getStatus().equalsIgnoreCase("finished")&&!taskDetailDO1.getStatus().equalsIgnoreCase("unfinished")){
            CreditsDetailDO creditsLogDetailDO = new CreditsDetailDO();
            if (creditsLogDetailDOList == null || creditsLogDetailDOList.size() ==0){
                creditsLogDetailDO.setTotal(Long.parseLong(taskDetailDO.getIntegrate()));
            }else {
                creditsLogDetailDO.setTotal(Long.parseLong(taskDetailDO.getIntegrate().replace("+",""))+ creditsLogDetailDOList.get(0).getTotal());
            }
            creditsLogDetailDO.setPatientId(taskDetailDO.getPatientId());
            creditsLogDetailDO.setIntegrate("+"+ taskDetailDO.getIntegrate());
            creditsLogDetailDO.setIntegrateType("HEALTH_TASK");
            creditsLogDetailDO.setIntegrateId(taskDetailDO.getId());
            creditsLogDetailDO.setStatus("unused");
            credittsLogDetailDao.save(creditsLogDetailDO);
        }
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }*/
}

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

@ -0,0 +1,84 @@
package com.yihu.jw.service;/**
 * Created by nature of king on 2018/5/10.
 */
import com.yihu.base.mysql.query.BaseJpaService;
import com.yihu.jw.dao.TaskDao;
import com.yihu.jw.dao.TaskDetailDao;
import com.yihu.jw.entity.health.bank.TaskDO;
import com.yihu.jw.entity.health.bank.TaskDetailDO;
import com.yihu.jw.restmodel.common.Envelop;
import com.yihu.jw.rm.health.bank.HealthBankMapping;
import com.yihu.jw.util.DateUtils;
import com.yihu.jw.util.ISqlUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-05-10 13:45
 * @desc task service
 **/
@Service
@Transactional
public class TaskService extends BaseJpaService<TaskDO,TaskDao>{
    @Autowired
    private TaskDao taskDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private TaskDetailDao taskDetailDao;
    public Envelop<Boolean> insert(TaskDO taskDO){
        taskDao.save(taskDO);
        Envelop<Boolean> envelop = new Envelop<>();
        envelop.setObj(true);
        return envelop;
    }
   /* public Envelop<CreditsDetailDO> findByCondition(TaskDO taskDO, Integer page, Integer size) throws ParseException {
        String sql = new ISqlUtils().getSql(taskDO,page,size,"*");
        List<CreditsDetailDO> creditsDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(CreditsDetailDO.class));
        String sqlcount = new ISqlUtils().getSql(creditsDetailDO,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, creditsDetailDOS,page,size,count);
    }*/
   public Envelop<TaskDO> selectByCondition(TaskDO taskDO,Integer page,Integer size){
       String sql = new ISqlUtils().getSql(taskDO,page,size,"*");
       List<TaskDO> taskDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(TaskDO.class));
       List<TaskDO> taskDOList = new ArrayList<>();
       for (TaskDO taskDO1 : taskDOS){
           if (taskDO1.getPeriod() == 0){
               String taskSql1 = "SELECT * FROM wlyy_health_bank_task_detail td WHERE" +
                       " td.task_id = '" +taskDO1.getId()+
                       "' AND td.create_time > '" + DateUtils.getDayBegin()+
                       "' AND td.create_time < '"+DateUtils.getDayEnd()+"'";
               List<TaskDetailDO> taskDetailList = jdbcTemplate.query(taskSql1,new BeanPropertyRowMapper(TaskDetailDO.class));
               if (taskDetailList != null && taskDetailList.size() != 0){
                   taskDO1.setStatus(1);
               }
               taskDOList.add(taskDO1);
           }
       }
       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 Envelop.getSuccessListWithPage(HealthBankMapping.api_success, taskDOList,page,size,count);
   }
}

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

@ -0,0 +1,33 @@
package com.yihu.jw.util;/**
 * Created by nature of king on 2018/5/11.
 */
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
 * @author wangzhinan
 * @create 2018-05-11 14:02
 * @desc date  component
 **/
public  class DateUtils {
    private final static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    //获取当天的开始时间
      public static String getDayBegin() {
          Calendar cal = new GregorianCalendar();
          cal.set(Calendar.HOUR_OF_DAY, 0);
          cal.set(Calendar.MINUTE, 0);
          cal.set(Calendar.SECOND, 0);
          cal.set(Calendar.MILLISECOND, 0);
          return sdf.format(cal.getTime());
      }
      //获取当天的结束时间
      public static String getDayEnd() {
          Calendar cal = new GregorianCalendar();
          cal.set(Calendar.HOUR_OF_DAY, 23);
          cal.set(Calendar.MINUTE, 59);
          cal.set(Calendar.SECOND, 59);
          return sdf.format(cal.getTime());
      }
}

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

@ -0,0 +1,92 @@
package com.yihu.jw.util;/**
 * Created by nature of king on 2018/4/27.
 */
import javax.persistence.Column;
import javax.persistence.Table;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
 * @author wangzhinan
 * @create 2018-04-27 12:47
 * @desc sql自定义编辑
 **/
public class ISqlUtils {
    public static String getSql(Object object,Integer page,Integer size,String isFlag){
        StringBuffer sb = new StringBuffer();
        Class c =object.getClass();
        Table table = (Table)c.getAnnotation(Table.class);
        String tableName = table.name();
        if (isFlag.equalsIgnoreCase("count")){
            sb.append("select count(1) AS total from ").append(tableName).append(" where 1=1");
        }else if(isFlag.equalsIgnoreCase("*")){
            sb.append("select * from ").append(tableName).append(" where 1=1 ");
        }
        Field[] fArray= c.getDeclaredFields();
        for(Field f:fArray){
                //拿到字段后与实体类中的属性匹配,并得到其get方法,用来获取他的属性值
                String getMethodName ="";
                boolean isCExist =f.isAnnotationPresent(Column.class);
                if(isCExist){
                    Column mc =f.getAnnotation(Column.class);
                    String columeName =mc.name();  //字段对应数据库名字
                    String name =f.getName();       //字段名字
                    Object value=null;              //字段值
                    getMethodName="get"+name.substring(0,1).toUpperCase()+name.substring(1);//拼接属性的get方法
                    try {
                        Method m =c.getMethod(getMethodName);
                        value =(Object)m.invoke(object);     //拿到属性的值
                        if(value == null || "".equals(value) || value.equals(Integer.parseInt("0"))){  //如果属性没值,不拼接sql
                            continue;
                        }
                        else if(value instanceof String){
                            value ="'"+value+"'";
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    sb.append(" and ").append(columeName +"=" ).append(value+"");
                }
        }
        if(isFlag.equalsIgnoreCase("*")){
            sb.append("ORDER BY update_time DESC ").append("LIMIT ").append((page-1)*size+",").append(size);
        }
        return sb.toString();
    }
    public static String getAllSql(Object object){
        StringBuffer sb = new StringBuffer();
        Class c =object.getClass();
        Table table = (Table)c.getAnnotation(Table.class);
        String tableName = table.name();
        sb.append("select * from ").append(tableName).append(" where 1=1 ");
        Field[] fArray= c.getDeclaredFields();
        for(Field f:fArray){
            //拿到字段后与实体类中的属性匹配,并得到其get方法,用来获取他的属性值
            String getMethodName ="";
            boolean isCExist =f.isAnnotationPresent(Column.class);
            if(isCExist){
                Column mc =f.getAnnotation(Column.class);
                String columeName =mc.name();  //字段对应数据库名字
                String name =f.getName();       //字段名字
                Object value=null;              //字段值
                getMethodName="get"+name.substring(0,1).toUpperCase()+name.substring(1);//拼接属性的get方法
                try {
                    Method m =c.getMethod(getMethodName);
                    value =(Object)m.invoke(object);     //拿到属性的值
                    if(value == null || "".equals(value) || value.equals(Integer.parseInt("0"))){  //如果属性没值,不拼接sql
                        continue;
                    }
                    else if(value instanceof String){
                        value ="'"+value+"'";
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                sb.append(" and ").append(columeName +"=" ).append(value+"");
            }
        }
        return sb.toString();
    }
}

+ 88 - 0
svr/svr-wlyy-health-bank/src/main/resources/application.yml

@ -0,0 +1,88 @@
##如果有配置服务的话,远程服务器和本地服务器配置不一致的情况下,优先远程的为主  git上 svr-base ->  git application ->本地 appliction ->本地 bootstarp
server:
  port: 10051
spring:
  application:
    name:  svr-wlyy-health-bank-wzn  #注册到发现服务的id 如果id一样 eurika会自动做负载
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 50
    max-idle: 50 #最大空闲连接
    min-idle: 10 #最小空闲连接
    validation-query-timeout: 20
    log-validation-errors: true
    validation-interval: 60000 #避免过度验证,保证验证不超过这个频率——以毫秒为单位。如果一个连接应该被验证,但上次验证未达到指定间隔,将不再次验证。
    validation-query: SELECT 1 #SQL 查询, 用来验证从连接池取出的连接, 在将连接返回给调用者之前。 如果指定, 则查询必须是一个SQL SELECT 并且必须返回至少一行记录
    test-on-borrow: true #指明是否在从池中取出连接前进行检验, 如果检验失败, 则从池中去除连接并尝试取出另一个。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
    test-on-return: true #指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效validationQuery 参数必须设置为非空字符串
    idle-timeout: 30000
    connection-test-query: SELECT 1
    num-tests-per-eviction-run: 50 #在每次空闲连接回收器线程(如果有)运行时检查的连接数量,最好和maxActive
    test-while-idle: true #指明连接是否被空闲连接回收器(如果有)进行检验,如果检测失败,则连接将被从池中去除
    min-evictable-idle-time-millis: 3600000 #连接池中连接,在时间段内一直空闲,被逐出连接池的时间(1000*60*60),以毫秒为单位
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
  data:
    elasticsearch: #ElasticsearchProperties
      cluster-name: jkzl #默认即为elasticsearch  集群名
      cluster-nodes: 172.19.103.68:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
      local: false #是否本地连接
      properties: # Additional properties used to configure the client.
        enable: true
  # JEST (Elasticsearch HTTP client) (JestProperties)
  elasticsearch:
    jest:
      uris: http://172.19.103.68:9200
#      uris: http://172.19.103.68:9200
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
#      username: # Login user.
#      password: # Login password.
#      proxy.port:  # Proxy port the HTTP client should use.
#      proxy.host:  # Proxy host the HTTP client should use.
#hibernate 配置
hibernate:
  dialect: org.hibernate.dialect.MySQL5Dialect
  show_sql: true
  ejb:
    naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
fast-dfs:
  tracker-server: 172.19.103.54:22122 #服务器地址
  connect-timeout: 2 #链接超时时间
  network-timeout: 30
  charset: ISO8859-1 #编码
  http:
    tracker-http-port: 80
    anti-steal-token: no
    secret-key: FastDFS1234567890
  pool: #连接池大小
    init-size: 5
    max-size: 20
    wait-time: 500
---
spring:
  profiles: jwdev
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/wlyy_health_bank?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: root
    password: 123456
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
---
spring:
  profiles: jwtest
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
---
spring:
  profiles: jwprod
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/

+ 8 - 0
svr/svr-wlyy-health-bank/src/main/resources/banner.txt

@ -0,0 +1,8 @@
${AnsiColor.BRIGHT_YELLOW}
    _                           __   _       _            _                             _
   FJ___      ____      ___ _   LJ  FJ_     FJ___        FJ___      ___ _    _ ___     FJ __
  J  __ `.   F __ J    F __` L  FJ J  _|   J  __ `.     J  __ J    F __` L  J '__ J   J |/ /L
  | |--| |  | _____J  | |--| | J  L| |-'   | |--| |     | |--| |  | |--| |  | |__| |  |    \
  F L  J J  F L___--. F L__J J J  LF |__-. F L  J J     F L__J J  F L__J J  F L  J J  F L:\ J
 J__L  J__LJ\______/FJ\____,__LJ__L\_____/J__L  J__L   J__,____/LJ\____,__LJ__L  J__LJ__L \\_J.
 |__L  J__| J______F  J____,__F|__|J_____F|__L  J__|   J__,____F  J____,__F|__L  J__||__L  \L_|

+ 46 - 0
svr/svr-wlyy-health-bank/src/main/resources/bootstrap.yml

@ -0,0 +1,46 @@
##优先读取 boostarap配置 然后在读取application。yml的配置
spring:
  #从发现服务里面取配置服务的信息
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      username: jw
      password: jkzl
      discovery:
        enabled: true #使用发现服务
        service-id: svr-configurations #配置服务的名字
---
spring:
  profiles: jwdev
##发现服务的地址
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwtest
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@172.19.103.33:8761/eureka/
---
spring:
  profiles: jwprod
eureka:
  client:
    serviceUrl:
      #http://账号:密码@127.0.0.1:8761/eureka/
      defaultZone: http://jw:jkzl@127.0.0.1:8761/eureka/

+ 1 - 1
svr/svr-wlyy-specialist/src/main/resources/application.yml

@ -4,7 +4,7 @@ server:
spring:
  application:
    name:  svr-wlyy-specialist-lyx  #注册到发现服务的id 如果id一样 eurika会自动做负载
    name:  svr-wlyy-specialist-wzn  #注册到发现服务的id 如果id一样 eurika会自动做负载
  datasource:
    driver-class-name: com.mysql.jdbc.Driver