Pārlūkot izejas kodu

[cmd]积分处理接口代码

wangzhinan 7 gadi atpakaļ
vecāks
revīzija
cf8c7a6110

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -184,6 +184,7 @@ public class SwaggerConfig {
                        regex("/nofilter/.*"),
                        regex("/idc10/.*"),
                        regex("/iot/.*"),
                        regex("/healthBank/.*"),
                        regex("/im_new/.*"),
                        regex("/dataHandling/.*"),
                        regex("/version/.*"),

+ 170 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/health/bank/CreditLogService.java

@ -0,0 +1,170 @@
package com.yihu.wlyy.service.third.health.bank;/**
 * Created by nature of king on 2018/5/7.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.util.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-05-07 9:24
 * @desc wlyy health bank service
 **/
@Service
@Transactional
public class CreditLogService {
    private Logger logger = LoggerFactory.getLogger(CreditLogService.class);
    @Value("${healthBank.url}")
    private String baseUrl;
    //    private String baseUrl = "http://192.168.131.24:8088/svr-iot/";
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 调用第三方积分排名接口
     *
     * @param doctorId
     * @param page
     * @param size
     * @return
     */
    public JSONObject selectByRanking(String doctorId, Integer page, Integer size){
        String sql = "SELECT * FROM wlyy_sign_family WHERE status = 1 AND doctor = '" +doctorId + "'";
        List<SignFamily> signFamilyList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily.class));
        List<String>  patientIds = new ArrayList<>();
        if (signFamilyList != null && signFamilyList.size() != 0){
            for (SignFamily signFamily:signFamilyList){
                patientIds.add(signFamily.getPatient());
            }
        }
        JSONObject object = new JSONObject();
        object.put("filter",patientIds.toArray());
        object.put("page",page);
        object.put("size",size);
        String url = baseUrl + "selectByRanking";
        String response = null;
        JSONArray data =null;
        JSONObject object1 = null;
        try {
            response = httpClientUtil.iotPostBody(url,object.toString());
            object1 = JSONObject.parseObject(response);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return object1;
    }
    /**
     * 调用添加积分接口
     *
     * @param object
     * @return
     */
    public String insert(JSONObject object){
        String response = null;
        String url =baseUrl + "createCreditsDetail";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return response;
    }
    /**
     * 按条件查询积分
     *
     * @param object
     * @param page
     * @param size
     * @return
     */
    public JSONObject selectByCondition(JSONObject object,Integer page,Integer size){
        String response = null;
        String url =baseUrl + "findCreditsLogInfo";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        params.put("page",page.toString());
        params.put("size",size.toString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 查询账户积分详情
     *
     * @param object
     * @return
     */
    public JSONObject selectAccount(JSONObject object){
        String response = null;
        String url =baseUrl + "selectAccount";
        Map<String,String> params = new HashMap<>();
        params.put("creditsDetail",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 查询任务完成情况
     *
     * @param object
     * @param page
     * @param size
     * @return
     */
    public JSONObject selectByTask(JSONObject object,Integer page,Integer size){
        String response = null;
        String url =baseUrl + "findTask";
        Map<String,String> params = new HashMap<>();
        params.put("task",object.toJSONString());
        params.put("page",page.toString());
        params.put("size",size.toString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
}

+ 141 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/health/bank/CreditsLogController.java

@ -0,0 +1,141 @@
package com.yihu.wlyy.web.third.health.bank.controller;/**
 * Created by nature of king on 2018/5/7.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.third.health.bank.CreditLogService;
import com.yihu.wlyy.web.BaseController;
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.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * @author wangzhinan
 * @create 2018-05-07 8:50
 * @desc credit log controller
 **/
@RestController
@RequestMapping(value = "/healthBank",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "积分处理机制")
public class CreditsLogController extends BaseController {
    @Autowired
    private CreditLogService service;
    /**
     * 查询积分排名
     *
     * @param doctorId
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/findCreditRanking",method = RequestMethod.POST)
    @ApiOperation("查询积分排名")
    public String getById(@ApiParam(name = "doctorId",value = "医生Id")
                              @RequestParam(name = "doctorId")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 write(200,"查询成功","data",service.selectByRanking(doctorId,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * 添加积分
     *
     * @param creditsDetail
     * @return
     */
    @RequestMapping(value = "/insertCredits",method = RequestMethod.POST)
    @ApiOperation("添加积分")
    public String insert(@ApiParam(name = "creditsDetail",value = "居民id集合")
                          @RequestParam(name = "creditsDetail") String creditsDetail){
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            return write(200,"添加成功","data",service.insert(object));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * find credits log details
     *
     * @param creditsLogDo
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/selectDetails",method = RequestMethod.POST)
    @ApiOperation("积分详情")
    public String selectByCondition(@ApiParam(name = "creditsLogDo",value = "积分JSON")
                                    @RequestParam(name = "creditsLogDo") String creditsLogDo,
                                    @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 {
            JSONObject object = JSONObject.parseObject(creditsLogDo);
            return write(200,"查询成功","data",service.selectByCondition(object,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * 账户积分详情
     *
     * @param creditsDetail
     * @return
     */
    @RequestMapping(value = "/selectAccount",method = RequestMethod.POST)
    @ApiOperation("账户积分情况")
    public String selectAccount(@ApiParam(name = "creditsDetail",value = "积分JSON")
                                    @RequestParam(name = "creditsDetail") String creditsDetail){
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            return write(200,"查询成功","data",service.selectAccount(object));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * 查询任务完成情况
     *
     * @param task
     * @param page
     * @param size
     * @return
     */
    @RequestMapping(value = "/selectTasks",method = RequestMethod.POST)
    @ApiOperation("任务完成情况")
    public String selectByTask(@ApiParam(name = "task",value = "任务JSON")
                                    @RequestParam(name = "task") 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 {
            JSONObject object = JSONObject.parseObject(task);
            return write(200,"查询成功","data",service.selectByTask(object,page,size));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}

+ 6 - 0
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -36,6 +36,12 @@ im:
#物联网配置
iot:
  url: http://192.168.131.24:8088/svr-iot/
#健康银行配置
healthBank:
  url: http://localhost:10051/svr-health-bank/
#康复计划配置
rehabilitation:
  url: http://localhost:10055/svr-rehabilitation/
wechat:
  appId: wxd03f859efdf0873d

+ 3 - 0
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -37,6 +37,9 @@ im:
iot:
#  url: http://192.168.131.24:8088/svr-iot/
  url: http://localhost:10050/svr-iot/
#健康银行配置
healthBank:
  url:http://localhost:10051/svr-health-bank/
#康复计划配置
rehabilitation: