Browse Source

Merge branch 'dev' of linzhuo/patient-co-management into dev

linzhuo 8 years ago
parent
commit
3ee32023ff
23 changed files with 638 additions and 159 deletions
  1. 27 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientDevice.java
  2. 74 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/FoodComp.java
  3. 24 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/FoodCompDao.java
  4. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  5. 7 7
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDeviceDao.java
  6. 10 12
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  7. 80 20
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  8. 35 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  9. 48 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/FoodCompService.java
  10. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  11. 0 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  12. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  13. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  14. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java
  15. 7 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  16. 119 95
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  17. 45 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/messages/ImMessageController.java
  18. 4 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java
  19. 56 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java
  20. 8 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  21. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  22. 78 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/FoodCompController.java
  23. 1 1
      patient-co-wlyy/src/main/resources/system.properties

+ 27 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/device/PatientDevice.java

@ -31,6 +31,33 @@ public class PatientDevice extends IdEntity {
	private String doctor;
	// 操作时间
	private Date czrq;
	/**
	 * 是否有效
	 * 1-已删除绑定
	 * 0-正常绑定
	 */
	private int del;
	/**
	 * 删除人CODE
	 */
	private String delUser;
	@Column(name="del_user")
	public String getDelUser() {
		return delUser;
	}
	public void setDelUser(String delUser) {
		this.delUser = delUser;
	}
	public int getDel() {
		return del;
	}
	public void setDel(int del) {
		this.del = del;
	}
	@Column(name="device_id")
	public Long getDeviceId() {

+ 74 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/education/FoodComp.java

@ -0,0 +1,74 @@
package com.yihu.wlyy.entity.education;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 健康教育
 * @author George
 *
 */
@Entity
@Table(name = "wlyy_food_comp")
public class FoodComp extends IdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 412341231112321L ;
	// 父id
	private Long pid;
	// 名称
	private String name;
	// 热量
	private Long hot;
	// 成分
	private String component;
	//重量
	private int weight;
	public Long getPid() {
		return pid;
	}
	public void setPid(Long pid) {
		this.pid = pid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Long getHot() {
		return hot;
	}
	public void setHot(Long hot) {
		this.hot = hot;
	}
	public String getComponent() {
		return component;
	}
	public void setComponent(String component) {
		this.component = component;
	}
	public int getWeight() {
		return weight;
	}
	public void setWeight(int weight) {
		this.weight = weight;
	}
}

+ 24 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/education/FoodCompDao.java

@ -0,0 +1,24 @@
package com.yihu.wlyy.repository.education;
import com.yihu.wlyy.entity.education.FoodComp;
import com.yihu.wlyy.entity.education.HealthEduArticle;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface FoodCompDao extends PagingAndSortingRepository<FoodComp, Long>, JpaSpecificationExecutor<FoodComp> {
	List<FoodComp> findByPid(Long pid);
	@Query("select a from FoodComp a where a.name like ?1")
	List<FoodComp> findByName(String name);
	FoodComp findById(Long id);
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -35,7 +35,7 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
	// 根據手机号查詢患者信息
	@Query("select p from Patient p where p.mobile=?1 and p.status=1")
	Patient findByMobile(String mobile);
	List<Patient> findByMobile(String mobile);
	// 根據病情等级获取患者信息
	@Query("select p from Patient p where p.diseaseCondition=?1 and p.status=1")

+ 7 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDeviceDao.java

@ -10,16 +10,16 @@ import com.yihu.wlyy.entity.device.PatientDevice;;import java.util.List;
public interface PatientDeviceDao extends PagingAndSortingRepository<PatientDevice, Long>, JpaSpecificationExecutor<PatientDevice> {
    @Query("select a from PatientDevice a where a.user = ?1")
	Iterable<PatientDevice> findByUser(String user);
    @Query("select a from PatientDevice a where a.user = ?1 and a.del =?2")
	Iterable<PatientDevice> findByUser(String user,int del);
	List<PatientDevice> findByUser(String user,Pageable pageRequest);
	List<PatientDevice> findByUserAndDel(String user,int del,Pageable pageRequest);
	List<PatientDevice> findByUserAndDoctor(String user,String doctor, Pageable pageRequest);
	List<PatientDevice> findByUserAndDoctorAndDel(String user,String doctor,int del, Pageable pageRequest);
	List<PatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
	List<PatientDevice> findByDeviceSnAndCategoryCodeAndDel(String deviceSn, String categoryCode,int del);
	PatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode,String userType);
	PatientDevice findByDeviceSnAndCategoryCodeAndUserTypeAndDel(String deviceSn, String categoryCode,String userType,int del);
	PatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn,String userType);
	PatientDevice findByDeviceIdAndDeviceSnAndUserTypeAndDel(Long deviceId, String deviceSn,String userType,int del);
}

+ 10 - 12
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -41,6 +41,7 @@ import com.yihu.wlyy.util.EncodesUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -99,19 +100,17 @@ public class PatientInfoService extends BaseService {
            return -1;
        }
        Patient pMobile = patientDao.findByMobile(mobile);
        if (pMobile != null && !pMobile.getCode().equals(patient)) {
            return -2;
        }
        List<Patient> pMobile = patientDao.findByMobile(mobile);
        //更新的时候不校验手机是否存在
        //if (pMobile != null && !pMobile.getCode().equals(patient)) {
        //    return -2;
        //}
        // 验证码验证
        int smsCheck = smsService.check(mobile, type == 1 ? 8 : 9, captcha);
        // 验证失败,不允许变更
        if (smsCheck != 1) {
            return -3;
        }
        p.setMobile(mobile);
        signFamilyDao.updatePatientMobile(p.getCode(), mobile);
@ -125,9 +124,8 @@ public class PatientInfoService extends BaseService {
     * @return
     */
    public int isMobileRegister(String mobile) {
        Patient p = patientDao.findByMobile(mobile);
        if (p != null) {
        List<Patient> p = patientDao.findByMobile(mobile);
        if (p != null&& p.size()>0) {
            return 1;
        } else {
            return 0;
@ -285,8 +283,8 @@ public class PatientInfoService extends BaseService {
    }
    public void checkMobile(String mobile) throws Exception {
        Patient p = patientDao.findByMobile(mobile);
        if (p != null) {
        List<Patient> p = patientDao.findByMobile(mobile);
        if (p != null&&p.size()>0) {
            throw new Exception("手机号已经被注册");
        }
    }

+ 80 - 20
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.device;
import com.yihu.wlyy.entity.device.Device;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.deviece.DeviceDao;
@ -11,9 +12,11 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -51,6 +54,9 @@ public class PatientDeviceService extends BaseService {
	@Autowired
	private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
	@Autowired
	private AdminTeamService adminTeamService;
	private String url = SystemConf.getInstance().getYihuOpenPlatformUrl();
	private String appid = SystemConf.getInstance().getYihuOpenPlatformAppId();
	private String secret = SystemConf.getInstance().getYihuOpenPlatformSecret();
@ -92,7 +98,7 @@ public class PatientDeviceService extends BaseService {
		//校验sn码是否被使用
		if(needVerify) {
			PatientDevice device = patientDeviceDao.findByDeviceIdAndDeviceSnAndUserType(deviceId, sn, userType);
			PatientDevice device = patientDeviceDao.findByDeviceIdAndDeviceSnAndUserTypeAndDel(deviceId, sn, userType,0);
			if (device != null && !device.getId().equals(patientDevice.getId())) {
				throw new Exception("sn码" + sn + "已被使用!");
			}
@ -168,11 +174,37 @@ public class PatientDeviceService extends BaseService {
		return response;
	}
	public void deleteDevices(String deviceSn,String type,String uuid){
		List<PatientDevice> patientDevices = 	patientDeviceDao.findByDeviceSnAndCategoryCodeAndDel(deviceSn,type,0);
		if(patientDevices==null||patientDevices.size()==0){
			throw  new RuntimeException("设备未被绑定!");
		}
		for(PatientDevice patientDevice: patientDevices){
			patientDevice.setDelUser(uuid);
			patientDeviceDao.save(patientDevice);
		}
	}
	/**
	 * 删除患者设备
	 */
	public void deleteDevice(String id) {
		patientDeviceDao.delete(Long.valueOf(id));
	public List<JSONObject> deleteDevice(String id,String uuid) {
		PatientDevice device = patientDeviceDao.findOne(Long.valueOf(id));
		device.setDelUser(uuid);
		patientDeviceDao.save(device);
		List<PatientDevice> patientDevices = patientDeviceDao.findByDeviceSnAndCategoryCodeAndDel(device.getDeviceSn(),device.getCategoryCode(),0);
		List<JSONObject> objects = new ArrayList<>();
		for(PatientDevice patientDevice:patientDevices){
			JSONObject object = new JSONObject(patientDevice);
			Patient patient = patientDao.findByCode(patientDevice.getUser());
			if(patient!=null){
				object.put("userName",patient.getName());
			}
			objects.add(object);
		}
		return objects;
	}
	/**
@ -214,25 +246,25 @@ public class PatientDeviceService extends BaseService {
			pagesize = 10;
		}
		boolean bo = false;
		//判断该医生是否属于患者的签约行政团队
		List<AdminTeamMember> adminTeamMembers = doctorAdminTeamMemberDao.findByAdminTeam(patientCode,doctorCode);
		if(adminTeamMembers!=null && adminTeamMembers.size()>0)
		{
			bo = true;
		}
		//boolean bo = false;
		////判断该医生是否属于患者的签约行政团队
		//List<AdminTeamMember> adminTeamMembers = doctorAdminTeamMemberDao.findByAdminTeam(patientCode,doctorCode);
		//if(adminTeamMembers!=null && adminTeamMembers.size()>0)
		//{
		//	bo = true;
		//}
		PageRequest pageRequest = new PageRequest(page-1, pagesize);
		List<PatientDevice> list = new ArrayList<>();
		if(bo) //签约医生查看所有设备
		{
			list = patientDeviceDao.findByUser(patientCode,pageRequest);
		}
		else{
			list = patientDeviceDao.findByUserAndDoctor(patientCode, doctorCode,pageRequest);
		}
		//if(bo) //签约医生查看所有设备
		//{
		//	list = patientDeviceDao.findByUser(patientCode,pageRequest);
		//}
		//else{
		//	list = patientDeviceDao.findByUserAndDoctor(patientCode, doctorCode,pageRequest);
		//}
		list = patientDeviceDao.findByUserAndDel(patientCode,0,pageRequest);
		if(list!=null)
		{
			//获取设备路径,医生姓名
@ -241,6 +273,20 @@ public class PatientDeviceService extends BaseService {
			for(PatientDevice item :list)
			{
				Map<String,Object>  map = new HashMap<>();
				if(StringUtils.isNotBlank(item.getDoctor())){
					if(StringUtils.equals(item.getDoctor(),doctorCode)){
						map.put("role",1);//可解绑自己绑定的
					}else{
						List<AdminTeam> adminTeams = adminTeamService.findDoctorsTeams(item.getDoctor(),doctorCode);
						if(adminTeams!=null&&adminTeams.size()>0){
							map.put("role",1);//同行政团队可解绑
						}else{
							map.put("role",0);//不同行政团队不可解绑
						}
					}
				}else{
					map.put("role",0);//患者自己绑定无法解绑
				}
				map.put("id",item.getId()) ;
				map.put("deviceId",item.getDeviceId());
				map.put("deviceSn",item.getDeviceSn());
@ -312,7 +358,7 @@ public class PatientDeviceService extends BaseService {
	 * @return
	 */
	public Iterator<PatientDevice> findPatientHave(String patient) {
		return patientDeviceDao.findByUser(patient).iterator();
		return patientDeviceDao.findByUser(patient,0).iterator();
	}
	/**
@ -329,7 +375,7 @@ public class PatientDeviceService extends BaseService {
	 **/
	public List<Map<String,String>> getDeviceUser(String user,String deviceSn,String type) throws Exception {
		List<Map<String,String>> re = new ArrayList<>();
		List<PatientDevice> list =patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn,type);
		List<PatientDevice> list =patientDeviceDao.findByDeviceSnAndCategoryCodeAndDel(deviceSn,type,0);
		if(list!=null)
		{
			for(PatientDevice item:list)
@ -361,4 +407,18 @@ public class PatientDeviceService extends BaseService {
		return re;
	}
	public List<JSONObject> getDeviceByDeviceSn(String deviceSn,String type){
		List<PatientDevice> list =patientDeviceDao.findByDeviceSnAndCategoryCodeAndDel(deviceSn,type,0);
		List<JSONObject> objects = new ArrayList<>();
		for(PatientDevice patientDevice:list){
			JSONObject object = new JSONObject(patientDevice);
			Patient patient = patientDao.findByCode(patientDevice.getUser());
			if(patient!=null){
				object.put("userName",patient.getName());
			}
			objects.add(object);
		}
		return objects;
	}
}

+ 35 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -139,6 +139,41 @@ public class FamilyMemberService extends BaseService {
        return 1;
    }
    public int addMember(Patient p, String member) throws Exception{
        if (p.getCode().equals(member)) {
            return 0;
        }
        // 添加自己与对方的关系
        PatientFamilyMember fm = memberDao.findByPatientAndFamilyMember(p.getCode(), member);
        // 家庭关系已存在时,不重复添加
        if (fm != null) {
            return -4;
        } else {
            fm = new PatientFamilyMember();
            fm.setPatient(p.getCode());
            fm.setFamilyMember(member);
        }
        fm.setFamilyRelation(6);
        fm.setCzrq(new Date());
        // 添加对方与自己的关系
        PatientFamilyMember fmt = memberDao.findByPatientAndFamilyMember(member, p.getCode());
        // 不存在则创建
        if (fmt == null) {
            fmt = new PatientFamilyMember();
            fmt.setPatient(member);
            fmt.setFamilyMember(p.getCode());
        }
        // 对方与自己的关系转换
        int relationTrans = familyRelationTrans(p, 6);
        fmt.setFamilyRelation(relationTrans);
        fmt.setCzrq(new Date());
        memberDao.save(fm);
        memberDao.save(fmt);
        return 1;
    }
    /**
     * 修改家庭成员关系

+ 48 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/FoodCompService.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.service.app.health;
import com.yihu.wlyy.entity.education.FoodComp;
import com.yihu.wlyy.entity.education.HealthNews;
import com.yihu.wlyy.repository.education.FoodCompDao;
import com.yihu.wlyy.repository.education.HealthNewsDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.persistence.SearchFilter.Operator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 食物健康热量服务类
 * @author George
 *
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class FoodCompService extends BaseService {
	@Autowired
	private FoodCompDao foodCompDao;
	public List<FoodComp> getByPid(Long pid){
		return foodCompDao.findByPid(pid);
	}
	public FoodComp getById(Long id){
		return foodCompDao.findById(id);
	}
	public List<FoodComp> getByName(String name){
		return foodCompDao.findByName("%"+name+"%");
	}
}

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

@ -457,7 +457,7 @@ public class PatientHealthIndexService extends BaseService {
                userType = map.get("user");
            }
            //根据设备获取患者(不同厂家sn码一样的问题未解决!!)
            PatientDevice device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn, type, userType);
            PatientDevice device = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserTypeAndDel(deviceSn, type, userType,0);
            if (device != null) {
                patientCode = device.getUser();
                patient = patientDao.findByCode(patientCode);

+ 0 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -89,7 +89,6 @@ public class MessageService extends BaseService {
     * 查询医生未读消息和最后消息
     */
    public JSONObject findDoctorAllMessage(String doctor) throws Exception {
        // 签约未读消息总数
        int sign = messageDao.amountUnreadByReceiver(doctor);
        JSONObject signJson = new JSONObject();

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -367,4 +367,14 @@ public class AdminTeamService extends BaseService {
    public List<AdminTeam> findHospitalTeams(String hospital){
        return teamDao.findByOrgCode(hospital);
    }
    /**
     *判断该医生是否属于患者的签约行政团队
     * @param patient 患者
     * @param doctorCode 医生
     * @return
     */
    public List<AdminTeamMember> findByAdminTeam(String patient,String doctorCode){
        return memberDao.findByAdminTeam(patient,doctorCode);
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -73,7 +73,7 @@ public class PatientService extends TokenService {
        return patientDao.findBySsc(ssc);
    }
    public Patient findByMobile(String mobile) {
    public List<Patient> findByMobile(String mobile) {
        return patientDao.findByMobile(mobile);
    }

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/HttpUtil.java

@ -136,7 +136,7 @@ public class HttpUtil {
			JSONObject participants = new JSONObject();
			participants.put("system",0);
			participants.put(receiver,0);
			JSONObject sessionObj  = ImUtill.createSession(participants,"2","系统消息","");
			JSONObject sessionObj  = ImUtill.createSession(participants,"0","系统消息","");
			if(sessionObj.getInt("status")==-1){
				throw  new RuntimeException(sessionObj.getString("message"));
			}

+ 7 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -285,6 +285,7 @@ public class LoginController extends BaseController {
                            String mobile,
                            @RequestParam(required = false) String captchaToken,
                            @RequestParam(required = false)String captcha,
                            @RequestParam(required = false)String patient,
                            String newpwd) {
        try {
            //String ct = request.getSession().getAttribute("captchaToken").toString();
@ -325,15 +326,16 @@ public class LoginController extends BaseController {
                }
            } else {
                // 患者端
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                List<Patient> patients = patientService.findByMobile(mobile);
                if (patients == null||patients.size()==0||StringUtils.isBlank(patient)) {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    Patient p  = patientService.findByCode(patient);
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=StringUtils.reverse(password);
                    password=MD5.GetMD5Code(password+patient.getSalt());
                    patient.setPassword(password);
                    patientService.updatePatientPwd(patient);
                    password=MD5.GetMD5Code(password+p.getSalt());
                    p.setPassword(password);
                    patientService.updatePatientPwd(p);
                    return success("操作成功!");
                }
            }

+ 119 - 95
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -2,16 +2,15 @@ package com.yihu.wlyy.web.common.account;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import com.yihu.wlyy.entity.login.LoginLog;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyMemberService;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.HttpUtil;
@ -59,6 +58,8 @@ public class WechatController extends WeixinBaseController {
    private FamilyService familyService;
    @Autowired
    private LoginLogService loginLogService;
    @Autowired
    private FamilyMemberService familyMemberService;
    /**
     * 患者注册-验证手机号
@ -70,14 +71,11 @@ public class WechatController extends WeixinBaseController {
    @ResponseBody
    public String checkmobile(String phone) {
        try {
            Patient temp = patientService.findByMobile(phone);
            if (temp != null) {
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", temp.getCode());
            /**modify by linz 2017年2月28日10:11:49 校验手机号码的时候返回使用此号码的所有人员**/
            List<Patient> temp = patientService.findByMobile(phone);
            if (temp != null&&temp.size()>0) {
                // 设置身份证号
                json.put("idcard", temp.getIdcard());
                return write(200, "患者信息查询成功!", "data", json);
                return write(200, "患者信息查询成功!", "data", temp);
            }
            return error(1, "该手机号未被注册");
        } catch (Exception e) {
@ -112,16 +110,16 @@ public class WechatController extends WeixinBaseController {
                json.put("idcard", temp.getIdcard());
                return write(1, "患者信息查询成功!", "data", json);
            } else {
                Patient temp1 = patientService.findByMobile(mobile);
                if (temp1 != null) {
                    JSONObject json = new JSONObject();
                List<Patient> temp1 = patientService.findByMobile(mobile);
                if (temp1 != null&&temp1.size()>0) {
                    //JSONObject json = new JSONObject();
                    // 设置患者标识
                    json.put("code", temp1.getCode());
                    // 设置手机号码
                    json.put("mobile", temp1.getMobile());
                    // 设置身份证号
                    json.put("idcard", temp1.getIdcard());
                    return write(2, "患者信息查询成功!", "data", json);
                    //json.put("code", temp1.getCode());
                    //// 设置手机号码
                    //json.put("mobile", temp1.getMobile());
                    //// 设置身份证号
                    //json.put("idcard", temp1.getIdcard());
                    return write(2, "患者信息查询成功!", "data", temp1);
                }
            }
            return success("该身份证和手机号未被注册");
@ -156,9 +154,9 @@ public class WechatController extends WeixinBaseController {
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "手机号不允许为空");
            }
            if (patientService.findByMobile(mobile) != null) {
                return error(-1, "该手机号已被注册");
            }
            //if (patientService.findByMobile(mobile) != null) {
            //    return error(-1, "该手机号已被注册");
            //}
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
@ -193,11 +191,11 @@ public class WechatController extends WeixinBaseController {
            if (patient != null) {
                if (!StringUtils.isEmpty(patient.getMobile())) {
                    return error(-1, "该身份证已被注册");
                    return error(-2, "该身份证已被注册");
                }
            }
            return write(200, "验证成功");
            List<Patient> patients = patientService.findByMobile(mobile);
            return write(200, "验证成功","data",patients);
        } catch (Exception e) {
            return error(-1, "验证失败");
        }
@ -213,13 +211,14 @@ public class WechatController extends WeixinBaseController {
     */
    @RequestMapping(value = "regist")
    @ResponseBody
    public String regist(String name,
                         String idcard,
                         String ssc,
                         String mobile,
                         String captcha,
                         String openid,
                         String password) {
    public String regist(@RequestParam(value="name",required = true) String name,
                         @RequestParam(value="idcard",required = true) String idcard,
                         @RequestParam(value="ssc",required = true) String ssc,
                         @RequestParam(value="mobile",required = true) String mobile,
                         @RequestParam(value="captcha",required = true) String captcha,
                         @RequestParam(value="openid",required = true) String openid,
                         @RequestParam(value="password",required = true) String password,
                         @RequestParam(value="home",required = true) String home) {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "姓名不允许为空!");
@ -233,9 +232,9 @@ public class WechatController extends WeixinBaseController {
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "手机号不允许为空!");
            }
            if (patientService.findByMobile(mobile) != null) {
                return error(-1, "该手机号已被注册!");
            }
            //if (patientService.findByMobile(mobile) != null) {
            //    return error(-1, "该手机号已被注册!");
            //}
            // 对验证码进行校验
            int res = smsService.check(mobile, 1, captcha);
            switch (res) {
@ -290,7 +289,7 @@ public class WechatController extends WeixinBaseController {
                patient = new Patient();
            } else {
                if (!StringUtils.isEmpty(patient.getMobile())) {
                    return error(-1, "该身份证已被注册!");
                    return error(-2, "该身份证已被注册!");
                }
            }
            patient.setName(name);
@ -313,6 +312,12 @@ public class WechatController extends WeixinBaseController {
                try {
                    Patient p = patientDao.findByIdcard(idcard);
                    BusinessLogs.info(BusinessLogs.BusinessType.register, p.getCode(), p.getCode(), new JSONObject(p));
                    if("1".equals(home)){
                        List<Patient> patients = patientService.findByMobile(mobile);
                        for(Patient patient1 :patients){
                            familyMemberService.addMember(p,patient1.getCode());
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
@ -342,6 +347,7 @@ public class WechatController extends WeixinBaseController {
            @RequestParam(required = false) String mobile,
            @RequestParam(required = false) String captcha,
            @RequestParam(required = false) String password,
            @RequestParam(required = false) String patient,
            String openid) {
        System.out.println("login openid : " + openid);
        String errorMessage;
@ -353,12 +359,21 @@ public class WechatController extends WeixinBaseController {
        try {
            //账号登录 mobile可能是电话号也可能是身份证
            if (StringUtils.isNoneEmpty(mobile) && StringUtils.isNoneEmpty(password) && !org.springframework.util.StringUtils.isEmpty(mobile)) {
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                    patient = patientService.findByIdcard(mobile);
                List<Patient> patients = patientService.findByMobile(mobile);
                Patient p =null;
                if (patients == null||patients.size()==0) {
                    p = patientService.findByIdcard(mobile);
                }else if(patients.size()==1){
                    p = patients.get(0);//只存在一个用户
                }else if(patients.size()>1&&StringUtils.isBlank(patient)){
                    //多个用户返回用户让患者选择
                    return write(1, "存在多个用户", "data", patients);
                }else if(patients.size()>1&&StringUtils.isNotBlank(patient)){
                    //传入登入者,一般只有多用户才有此操作
                    p = patientService.findByCode(patient);
                }
                loginLog.setLoginType("2");
                if (patient == null) {
                if (p == null) {
                    if (mobile.length() == 11) {
                        errorMessage = "该手机号暂未注册账号,请确认后重新输入!";
                    } else {
@ -367,7 +382,7 @@ public class WechatController extends WeixinBaseController {
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (patient.getStatus() == 0) {
                } else if (p.getStatus() == 0) {
                    if (mobile.length() == 11) {
                        errorMessage = "该手机号已被禁止使用!";
                    } else {
@ -376,7 +391,7 @@ public class WechatController extends WeixinBaseController {
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (patient.getStatus() == 2) {
                } else if (p.getStatus() == 2) {
                    errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
@ -387,31 +402,31 @@ public class WechatController extends WeixinBaseController {
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
                loginLog.setUserCode(patient.getCode());
                loginLog.setUserCode(p.getCode());
                //解密
                password = RSAUtils.getInstance(patientService).decryptString(password);
                password = StringUtils.reverse(password);
                //生成MD5
                String loginPassword = MD5.GetMD5Code(password + patient.getSalt());
                String loginPassword = MD5.GetMD5Code(password + p.getSalt());
                //判断d登录密码是否正确
                if (loginPassword.equals(patient.getPassword())) {
                if (loginPassword.equals(p.getPassword())) {
                    // 绑定用户手机号和openid
                    if (!StringUtils.equals(patient.getOpenid(), openid)) {
                    if (!StringUtils.equals(p.getOpenid(), openid)) {
                        //patient.setOpenid(openid);
                        patientService.updatePatient(patient, openid);
                        patientService.updatePatient(p, openid);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newTxToken(patient.getCode(), openid);
                    Token token = tokenService.newTxToken(p.getCode(), openid);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", patient.getId());
                    map.put("uid", patient.getCode());
                    map.put("name", patient.getName());
                    map.put("id", p.getId());
                    map.put("uid", p.getCode());
                    map.put("name", p.getName());
                    map.put("token", token.getToken());
                    map.put("photo", patient.getPhoto());
                    map.put("photo", p.getPhoto());
                    if (StringUtils.isNoneEmpty(openid)) {
                        //发送微信模板
                        familyService.sendWXMessage(patient);
                        familyService.sendWXMessage(p);
                    }
                    loginLog.setLoginType("1");
@ -448,9 +463,9 @@ public class WechatController extends WeixinBaseController {
                        return error(-1, errorMessage);
                    }
                }
                Patient patient = patientService.findByMobile(mobile);
                List<Patient> patients = patientService.findByMobile(mobile);
                loginLog.setLoginType("1");
                if (patient == null) {
                if (patients == null||patients.size()==0) {
                    if (mobile.length() == 11) {
                        errorMessage = "该手机号暂未注册账号,请确认后重新输入!";
                    } else {
@ -459,48 +474,57 @@ public class WechatController extends WeixinBaseController {
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (patient.getStatus() == 0) {
                    if (mobile.length() == 11) {
                        errorMessage = "该手机号已被禁止使用!";
                    } else {
                        errorMessage = "该身份证号已被禁止使用!";
                }else if(patients.size()>1&&StringUtils.isBlank(patient)) {
                    return write(1, "存在多个用户", "data", patients);
                }else if(patients.size()>1&&StringUtils.isNotBlank(patient)){
                    Patient p = null;
                    if(patients.size()==1){
                        p  = patients.get(0);
                    }else if(StringUtils.isNotBlank(patient)){
                        p = patientService.findByCode(patient);
                    }
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (patient.getStatus() == 2) {
                    errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
                    loginLog.setErrorMessage(errorMessage);
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                } else if (StringUtils.isEmpty(openid)) {
                    errorMessage = "无效的OpenID!";
                    loginLog.setErrorMessage(errorMessage);
                    if (p.getStatus() == 0) {
                        if (mobile.length() == 11) {
                            errorMessage = "该手机号已被禁止使用!";
                        } else {
                            errorMessage = "该身份证号已被禁止使用!";
                        }
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    } else if (p.getStatus() == 2) {
                        errorMessage = "该账号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    } else if (StringUtils.isEmpty(openid)) {
                        errorMessage = "无效的OpenID!";
                        loginLog.setErrorMessage(errorMessage);
                        loginLogService.saveLog(loginLog);
                        return error(-1, errorMessage);
                    }
                    loginLog.setUserCode(p.getCode());
                    // 绑定用户手机号和openid
                    if (!StringUtils.equals(p.getOpenid(), openid)) {
                        //patient.setOpenid(openid);
                        patientService.updatePatient(p, openid);
                    }
                    // 用户校验通过,生成token
                    Token token = tokenService.newTxToken(p.getCode(), openid);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", p.getId());
                    map.put("uid", p.getCode());
                    map.put("name", p.getName());
                    map.put("token", token.getToken());
                    map.put("photo", p.getPhoto());
                    if (StringUtils.isNoneEmpty(openid)) {
                        //发送微信模板
                        familyService.sendWXMessage(p);
                    }
                    loginLog.setType("1");
                    loginLogService.saveLog(loginLog);
                    return error(-1, errorMessage);
                }
                loginLog.setUserCode(patient.getCode());
                // 绑定用户手机号和openid
                if (!StringUtils.equals(patient.getOpenid(), openid)) {
                    //patient.setOpenid(openid);
                    patientService.updatePatient(patient, openid);
                }
                // 用户校验通过,生成token
                Token token = tokenService.newTxToken(patient.getCode(), openid);
                Map<Object, Object> map = new HashMap<Object, Object>();
                map.put("id", patient.getId());
                map.put("uid", patient.getCode());
                map.put("name", patient.getName());
                map.put("token", token.getToken());
                map.put("photo", patient.getPhoto());
                if (StringUtils.isNoneEmpty(openid)) {
                    //发送微信模板
                    familyService.sendWXMessage(patient);
                    return write(200, "登录成功", "data", map);
                }
                loginLog.setType("1");
                loginLogService.saveLog(loginLog);
                return write(200, "登录成功", "data", map);
            }
            return error(-1, "登录失败");
        } catch (Exception e) {

+ 45 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/messages/ImMessageController.java

@ -0,0 +1,45 @@
package com.yihu.wlyy.web.common.messages;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(value = "/imcommon/message", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-消息")
public class ImMessageController extends BaseController {
    @Autowired
    private MessageService messageService;
    @RequestMapping(value = "messages")
    @ResponseBody
    @ApiOperation("查询医生未读消息和最后消息")
    public String messages() {
        try {
            JSONObject json = messageService.findDoctorAllMessage(getUID());
            return write(200, "获取消息总数成功!", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/sms/SMSController.java

@ -17,6 +17,8 @@ import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.web.BaseController;
import java.util.List;
@Controller
@RequestMapping(value = "/common")
@Api(description = "短信")
@ -48,8 +50,8 @@ public class SMSController extends BaseController {
			}
			if (type == 4) {
				// 登录时校验用户是否存在
				Patient patient = patientDao.findByMobile(mobile);
				if (patient == null) {
				List<Patient> patients = patientDao.findByMobile(mobile);
				if (patients == null||patients.size()==0) {
					return error(-1, "该手机号未注册!");
				}
			} else if (type == 5) {

+ 56 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -2,12 +2,16 @@ package com.yihu.wlyy.web.doctor.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.device.PatientDevice;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@ -32,6 +36,9 @@ public class DoctorDeviceController extends BaseController {
	@Autowired
	private PatientDeviceService patientDeviceService;
	@Autowired
	private AdminTeamService adminTeamService;
	private ObjectMapper  objectMapper=new ObjectMapper();
	@ApiOperation("设备保存接口--医生端")
@ -84,12 +91,26 @@ public class DoctorDeviceController extends BaseController {
			PatientDevice pd = patientDeviceService.findById(id);
			if(pd!=null)
			{
				if (!StringUtils.equals(pd.getDoctor(), getUID())) {
					return error(-1, "只允许删除自己绑定设备!");
				if(StringUtils.isNotBlank(pd.getDoctor())){
					List<AdminTeam> adminTeamMembers = adminTeamService.findDoctorsTeams(pd.getUser(),getUID());
					boolean bo = false;
					if(adminTeamMembers!=null && adminTeamMembers.size()>0)
					{
						bo = true;
					}
					if(bo){//同行政团队
						List<JSONObject> objects = patientDeviceService.deleteDevice(id,getUID());
						return write(200,"","data",objects);
					}else{
						return error(-1, "只允许删除自己及自己行政团队绑定的设备!");
					}
				}else if(StringUtils.isNotBlank(pd.getDoctor())&&StringUtils.equals(pd.getDoctor(), getUID())){
					List<JSONObject> objects = patientDeviceService.deleteDevice(id,getUID());
					return write(200,"","data",objects);
				}else{
					return error(-1, "只允许删除自己及自己行政团队绑定的设备!");
				}
				// 删除设备
				patientDeviceService.deleteDevice(id);
				return success("设备已删除!");
			}
			else{
				return error(-1, "不存在该设备!");
@ -98,6 +119,26 @@ public class DoctorDeviceController extends BaseController {
			return invalidUserException(ex, -1,ex.getMessage());
		}
	}
	/**
	 * 设备删除
	 */
	@ApiOperation("设备删除--管理端")
	@RequestMapping(value = "unbindDevice")
	@ResponseBody
	public String deleteByAdmin(@ApiParam(name="deviceSn",value="设备SN")
						 @RequestParam(value="deviceSn",required = true) String deviceSn,
						@ApiParam(name="type",value="设备类型")
						@RequestParam(value="type",required = true) String type) {
		try{
			patientDeviceService.deleteDevices(deviceSn,type,getUID());
			return write(200,"解绑成功!");
		}catch (Exception e){
			return write(-1,e.getMessage());
		}
	}
	@ApiOperation("获取患者设备信息")
	@RequestMapping(value = "PatientDeviceInfo",method = RequestMethod.GET)
	@ResponseBody
@ -163,4 +204,14 @@ public class DoctorDeviceController extends BaseController {
			return invalidUserException(ex, -1, ex.getMessage());
		}
	}
	@ApiOperation("通过sn码获取设备绑定情况(管理端)")
	@RequestMapping(value = "getListByDeviceSn",method = RequestMethod.GET)
	@ResponseBody
	public String getDeviceBindUser(@ApiParam(name="type",value="设备类型",defaultValue = "1")
									@RequestParam(value="type",required = true) String type,
									@ApiParam(name="deviceSn",value="设备SN码",defaultValue = "15L000002")
									@RequestParam(value="deviceSn",required = true) String deviceSn){
			List<JSONObject> objects = patientDeviceService.getDeviceByDeviceSn(deviceSn,type);
			return write(200, "获取设备成功!", "data",objects);
	}
}

+ 8 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -302,12 +302,14 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            if (StringUtils.isNotEmpty(images)) {
                images = CommonUtil.copyTempImage(images);
            }
            if (!org.springframework.util.StringUtils.isEmpty(mobile)) {
                Patient patient = patientService.findByMobile(mobile);
                if (patient != null && !StringUtils.equals(patient.getIdcard(), idcard)) {
                    return error(-1, "该手机号已绑定其他身份证号!");
                }
            }
            /**modify by linz 2017年2月28日10:11:49**/
            //if (!org.springframework.util.StringUtils.isEmpty(mobile)) {
            //    Patient patient = patientService.findByMobile(mobile);
            //    if (patient != null && !StringUtils.equals(patient.getIdcard(), idcard)) {
            //        return error(-1, "该手机号已绑定其他身份证号!");
            //    }
            //}
            /**end**/
            Doctor cDoctor = doctorService.findDoctorByCode(getUID());
            SignFamily sf = familyContractService.agent(getAccessToken(), name, doctor, doctorName,
                    healthDoctor, healthDoctorName, cDoctor.getHospital(), cDoctor.getHospitalName(),

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -125,7 +125,7 @@ public class PatientDeviceController extends BaseController {
					return error(-1, "只允许删除自己的设备!");
				}
				// 删除设备
				patientDeviceService.deleteDevice(id);
				patientDeviceService.deleteDevice(id,getUID());
				return success("设备已删除!");
			}
			else{

+ 78 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/FoodCompController.java

@ -0,0 +1,78 @@
package com.yihu.wlyy.web.patient.health;
import com.yihu.wlyy.entity.education.FoodComp;
import com.yihu.wlyy.service.app.health.FoodCompService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
 * 患者端:食物热量查询
 * @author George
 *
 */
@Controller
@RequestMapping(value = "/patient/health/food", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-食物热量查询")
public class FoodCompController extends BaseController {
	@Autowired
	private FoodCompService foodCompService;
	/**
	 * 查询食物热量列表
	 * @param pid 父id
	 * @return 列表
	 */
	@RequestMapping(value = "list")
	@ResponseBody
	public String list(@RequestParam("pid")long pid) {
		try {
			List<FoodComp> foodComps = foodCompService.getByPid(pid);
			return write(200, "查询成功", "list", foodComps);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询食物热量查询
	 * @param name 查询名称
	 * @return 列表
	 */
	@RequestMapping(value = "search")
	@ResponseBody
	public String list(@RequestParam("name")String name) {
		try {
			List<FoodComp> foodComps = foodCompService.getByName(name);
			return write(200, "查询成功", "list", foodComps);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
	/**
	 * 查询食物热量详情
	 * @param id 查询名称
	 * @return 列表
	 */
	@RequestMapping(value = "detail")
	@ResponseBody
	public String list(@RequestParam("id")Long id) {
		try {
			FoodComp foodComp = foodCompService.getById(id);
			return write(200, "查询成功", "list", foodComp);
		} catch (Exception ex) {
			error(ex);
			return invalidUserException(ex, -1, "查询失败!");
		}
	}
}

+ 1 - 1
patient-co-wlyy/src/main/resources/system.properties

@ -65,7 +65,7 @@ chat_server=http://weixin.xmtyw.cn/res/chat/
sign_check_upload=http://172.19.103.87:8011/wlyy_service
# IM配置
im_list_get=http://172.19.103.29:3008/
im_list_get=http://192.168.131.102:3008/
im_group_server=http://172.19.103.29:3000/api/v1/chats/gm
msg_push_server=http://172.19.103.29:3000/api/v1/chats/sm