|
@ -5,18 +5,20 @@ package com.yihu.wlyy.service.app.health.bank;/**
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
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.dict.SystemDictDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
|
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import com.yihu.wlyy.util.HttpClientUtil;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@ -44,6 +46,8 @@ public class TaskService {
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
@Autowired
|
|
@Autowired
|
|
private PatientDao patientDao;
|
|
private PatientDao patientDao;
|
|
|
|
@Autowired
|
|
|
|
private PatientFamilyMemberDao patientFamilyMemberDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -117,10 +121,14 @@ public class TaskService {
|
|
* @param object 参加任务JSON
|
|
* @param object 参加任务JSON
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject attendTask(JSONObject object){
|
|
|
|
|
|
public JSONObject attendTask(JSONObject object) throws Exception {
|
|
String response = null;
|
|
String response = null;
|
|
Patient patient = patientDao.findByCode(object.getString("patientId"));
|
|
Patient patient = patientDao.findByCode(object.getString("patientId"));
|
|
String unionId = "1";
|
|
String unionId = "1";
|
|
|
|
Patient patient1 = patientDao.findByUnionid(unionId);
|
|
|
|
if (patient1 != null){
|
|
|
|
throw new Exception("该居民已报过名!");
|
|
|
|
}
|
|
patient.setUnionid(unionId);
|
|
patient.setUnionid(unionId);
|
|
patientDao.save(patient);
|
|
patientDao.save(patient);
|
|
object.put("unionId",unionId);
|
|
object.put("unionId",unionId);
|
|
@ -142,26 +150,25 @@ public class TaskService {
|
|
*
|
|
*
|
|
* @param openId 微信id
|
|
* @param openId 微信id
|
|
*
|
|
*
|
|
* @param page 页码
|
|
|
|
*
|
|
|
|
* @param size 分页大小
|
|
|
|
*
|
|
*
|
|
* @return
|
|
* @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();
|
|
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;
|
|
return object;
|
|
}
|
|
}
|
|
}
|
|
}
|