소스 검색

[cmd]修改bug

wangzhinan 7 년 전
부모
커밋
5332a432ad

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/CreditLogService.java

@ -311,7 +311,7 @@ public class CreditLogService {
            response = httpClientUtil.httpPost(url,params);
            object1 = JSONObject.parseObject(response);
            JSONArray array = object1.getJSONArray("detailModelList");
            for (int i = 0;i<array.size();i++){
            for (int i = 0;array != null && i<array.size();i++){
                JSONObject object2 = array.getJSONObject(i);
                String patientId = object2.getString("patientId");
                Patient patient = patientDao.findByCode(patientId);

+ 25 - 18
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/TaskService.java

@ -5,18 +5,20 @@ package com.yihu.wlyy.service.app.health.bank;/**
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
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;
@ -44,6 +46,8 @@ public class TaskService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private PatientFamilyMemberDao patientFamilyMemberDao;
    /**
@ -117,10 +121,14 @@ public class TaskService {
     * @param object 参加任务JSON
     * @return
     */
    public JSONObject attendTask(JSONObject object){
    public JSONObject attendTask(JSONObject object) throws Exception {
        String response = null;
        Patient patient = patientDao.findByCode(object.getString("patientId"));
        String unionId = "1";
        Patient patient1 = patientDao.findByUnionid(unionId);
        if (patient1 != null){
            throw new Exception("该居民已报过名!");
        }
        patient.setUnionid(unionId);
        patientDao.save(patient);
        object.put("unionId",unionId);
@ -142,26 +150,25 @@ public class TaskService {
     *
     * @param openId 微信id
     *
     * @param page 页码
     *
     * @param size 分页大小
     *
     * @return
     */
    public JSONObject selectByOpenId(String openId, Integer page,Integer size){
        String sql = "select * from wlyy_patient where openid = '"+ openId +"' LIMIT "+(page-1)*size+","+size;
        List<Patient> patientList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(Patient.class));
        String sqlcount = "select * from wlyy_patient where openid = '"+ openId +"'";
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
        }
    public JSONObject selectByOpenId(String openId){
        Patient patient = patientDao.findByOpenid(openId);
        List<Patient> patientList = new ArrayList<>();
        JSONObject object = new JSONObject();
        object.put("patientList",patientList);
        object.put("total",count);
        object.put("page",page);
        object.put("size",size);
        if (patient != null){
            patientList.add(patient);
            List<PatientFamilyMember> patientFamilyMemberList = patientFamilyMemberDao.findByPatient(patient.getCode());
            for (PatientFamilyMember patientFamilyMember:patientFamilyMemberList){
                Patient patient1 = patientDao.findByCode(patientFamilyMember.getFamilyMember());
                patientList.add(patient1);
            }
            object.put("patientList",patientList);
            object.put("total",patientFamilyMemberList.size());
            object.put("page",1);
            object.put("size",100);
        }
        return object;
    }
}

+ 2 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/bank/TaskController.java

@ -107,20 +107,14 @@ public class TaskController extends BaseController{
    /**
     * 获取用户信息
     *
     * @param page 页码
     *
     * @param size  分页大小
     *
     * @return
     */
    @RequestMapping(value = "/selectByOpenId",method = RequestMethod.POST)
    @ApiOperation("获取用户信息")
    public String selectByOpenId( @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){
    public String selectByOpenId(){
        try {
            return write(200,"添加成功","data",service.selectByOpenId(getOpenid(),page,size));
            return write(200,"添加成功","data",service.selectByOpenId(getOpenid()));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());