Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

zhanghaoyu 7 years ago
parent
commit
3e887c5cb0
50 changed files with 1457 additions and 139 deletions
  1. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  2. 2 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/datastatic/PayLogController.java
  3. 60 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/specialist/HopsitalServiceItemController.java
  4. 3 3
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/specialist/ServiceItemController.java
  5. 3 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/HospitalDao.java
  6. 4 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/httplog/PayLogService.java
  7. 2 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/DeviceHealthIndexService.java
  8. 2 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyDeviceService.java
  9. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/ServiceItemService.java
  10. 56 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/SpecialistHospitalItemService.java
  11. 3 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/pay_log_list.jsp
  12. 13 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/pay_log_list_js.jsp
  13. 10 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/PatientHealthIndex.java
  14. 5 4
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/AsyncService.java
  15. 1 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  16. 1 1
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/FamilyLianQianService.java
  17. 14 4
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DeviceTypeConvert.java
  18. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  19. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorAdminTeamMemberDao.java
  20. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  21. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/SpecialDiseaseDao.java
  22. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  23. 21 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/disease/PatientDiseaseService.java
  24. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  25. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java
  26. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  27. 234 23
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  28. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  29. 142 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/RehabilitationPlanService.java
  30. 156 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java
  31. 100 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistHospitalItemService.java
  32. 49 13
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
  33. 6 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java
  34. 5 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/kit/JyKitService.java
  35. 122 50
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  36. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java
  37. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java
  38. 26 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java
  39. 62 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/HospitalServiceItemController.java
  40. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java
  41. 10 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java
  42. 88 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/SpecialistEvaluateController.java
  43. 12 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  44. 134 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/specialist/ThirdRehabilitationPlanController.java
  45. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java
  46. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  47. 39 1
      patient-co/patient-co-wlyy/src/main/resources/application-dev.yml
  48. 2 1
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml
  49. 3 2
      patient-co/patient-co-wlyy/src/main/resources/application-prod.yml
  50. 2 1
      patient-co/patient-co-wlyy/src/main/resources/application-test.yml

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java

@ -30,7 +30,7 @@ public class Message extends IdEntity {
	/** type
	 *  消息类型(1.是家庭签约信息  2.体征消息  3分配健管师 4.随访提醒 5.咨询回复提醒,6.续方咨询待审核提醒,7.续方消息待取药
	 *  8.续方支付成功后团队长分配健管师,9线下调整完成,10意见反馈 11账号申诉,12.协同服务 13.孕检提醒 14.文章提交审核消息  15、健康文章审核结果
	 *  16.专科医生申请签约消息,17、家庭医生转诊预约消息
	 *  16.专科医生申请签约消息,17、家庭医生转诊预约消息,18、专科医生共管通知,19、
	 *  101患者申请取消签约、102患者同意取消签约、103患者拒绝取消签约、104患者填写了血糖记录、105患者填写了血压记录、106患者填写了体重记录、
	 *  107患者填写了腰围记录、108患者填写了运动记录、109患者填写了用药记录、110患者填写了饮食记录、111患者提交了问卷随访、112请求添加好友消息、
	 *  113入群消息、114群解散消息、115踢出群消息、116新的网络咨询、117网络咨询追问、

+ 2 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/datastatic/PayLogController.java

@ -38,10 +38,11 @@ public class PayLogController extends BaseController {
            @RequestParam(value = "params",required = false) String params,
            @RequestParam(value = "startDate",required = false) String startDate,
            @RequestParam(value = "endDate",required = false) String endDate,
            @RequestParam(value = "status",required = false) String status,
            @RequestParam(value = "page",required = false) Integer page,
            @RequestParam(value = "rows",required = false) Integer pageSize){
        try{
            Page<PayLog> payLogs = payLogService.searchList(params,startDate, endDate, page, pageSize);
            Page<PayLog> payLogs = payLogService.searchList(params,startDate, endDate, status, page, pageSize);
            return write(200,"操作成功",page,pageSize,payLogs);
        }catch (Exception ex){
            error(ex);

+ 60 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/specialist/HopsitalServiceItemController.java

@ -0,0 +1,60 @@
package com.yihu.wlyy.controller.manager.specialist;/**
 * Created by nature of king on 2018/8/29.
 */
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.service.manager.specialist.SpecialistHospitalItemService;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
 * @author wangzhinan
 * @create 2018-08-29 1:48
 * @desc 机构服务项目
 **/
@Controller
@RequestMapping(value="admin/specialist/hospitalServiceItem")
public class HopsitalServiceItemController extends BaseController {
    @Autowired
    private SpecialistHospitalItemService specialistHospitalItemService;
    @RequestMapping(value = "initial")
    public String listInit() {
        return "desizenMan/new-institutional-projects";
    }
    /**
     * 添加机构服务项目
     *
     * @param hospitalServiceItem
     * @return
     */
    @RequestMapping(value = "createHospitalServiceItem", method = RequestMethod.POST)
    @ResponseBody
    public String insert(@RequestParam(name = "hospitalServiceItem") String hospitalServiceItem){
        try {
            return write(200, "操作成功", "data",specialistHospitalItemService.insert(hospitalServiceItem));
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 获取机构
     * @return
     */
    public String selectHospitals(){
        try {
            return write(200, "查询成功", "data",specialistHospitalItemService.selectHospital());
        } catch (Exception ex) {
            error(ex);
            return error(-1, "查询失败");
        }
    }
}

+ 3 - 3
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/specialist/ServiceItemController.java

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 * @desc 服务项目
 **/
@Controller
@RequestMapping(value="admin/specialist/")
@RequestMapping(value="admin/specialist/serviceItem")
public class ServiceItemController  extends BaseController {
    @Autowired
    private ServiceItemService serviceItemService;
@ -72,9 +72,9 @@ public class ServiceItemController  extends BaseController {
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "updateServiceItem", method = RequestMethod.POST)
    @RequestMapping(value = "selectServiceItem", method = RequestMethod.POST)
    @ResponseBody
    public String updateServiceItem(@RequestParam(name = "serviceItem") String serviceItem,
    public String selectServiceItem(@RequestParam(name = "serviceItem") String serviceItem,
                                    @RequestParam(name = "page",defaultValue = "1")Integer page,
                                    @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize){
        try {

+ 3 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/HospitalDao.java

@ -47,4 +47,7 @@ public interface HospitalDao extends PagingAndSortingRepository<Hospital, Long>,
    @Query("select p from Hospital p where p.code like ?1 order by p.code desc ")
    List<Hospital> findByCodePrefix(String codePrefix);
    @Query("select p from Hospital p where p.del = 1 and p.level in (1,2) ")
    List<Hospital> findAllHospital();
}

+ 4 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/httplog/PayLogService.java

@ -27,7 +27,7 @@ public class PayLogService extends BaseJpaService<PayLog,PayLogDao> {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public Page<PayLog> searchList(String params, String startDate, String endDate, Integer page, Integer pageSize) throws Exception{
    public Page<PayLog> searchList(String params, String startDate, String endDate, String status, Integer page, Integer pageSize) throws Exception{
        List<PayLog> payLogList = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if(page == null){
@ -49,7 +49,9 @@ public class PayLogService extends BaseJpaService<PayLog,PayLogDao> {
        if(!StringUtils.isEmpty(endDate)){
            filters.append("and create_time < '"+endDate+"' ");
        }
        if(!StringUtils.isEmpty(status)){
            filters.append("and status = '"+status+"' ");
        }
        payLogList = jdbcTemplate.query(sql+filters.toString()+" order by p.create_time desc"+" limit "+(page-1)*pageSize+","+pageSize, new BeanPropertyRowMapper<>(PayLog.class));
        if(payLogList.size()<=0){
            return new PageImpl<PayLog>(new ArrayList<>(), pageRequest, 0);

+ 2 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/DeviceHealthIndexService.java

@ -69,8 +69,8 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
        StringBuilder filter = new StringBuilder();
        String sql =" SELECT i.* ,s.name userName FROM device.wlyy_patient_health_index i , wlyy.wlyy_sign_family s WHERE s. STATUS > 0  and i.user=s.patient ";
        String countSql =" SELECT count(1) as num FROM device.wlyy_patient_health_index i, wlyy.wlyy_sign_family s WHERE s. STATUS > 0  and i.user=s.patient ";
        String sql =" SELECT i.* ,s.name userName FROM device.wlyy_patient_health_index i , wlyy.wlyy_patient s WHERE  i.user=s.code ";
        String countSql =" SELECT count(1) as num FROM device.wlyy_patient_health_index i, wlyy.wlyy_patient s WHERE  i.user=s.code ";
        //1、管理员  2、医生 0、其他
        if(loginUser.getType()==2){
            Doctor doctor = doctorDao.findByCode(loginUser.getCode());

+ 2 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyDeviceService.java

@ -176,14 +176,14 @@ public class WlyyDeviceService {
            //判断设备厂商是否存在,不存在则存入
            if(StringUtils.isNotBlank(device.getManufacturerId())) {
                DeviceManufacturer manufacturer = deviceManufacturerDao.findByCode(device.getManufacturerId());
                if (manufacturer == null) {
                if (manufacturer == null && StringUtils.isNotBlank(device.getManufacturerCode()) && StringUtils.isNotBlank(device.getManufacturer())) {
                    manufacturer = new DeviceManufacturer();
                    manufacturer.setCode(device.getManufacturerId());
                    manufacturer.setManufacturerCode(device.getManufacturerCode());
                    manufacturer.setManufacturerName(device.getManufacturer());
                    manufacturer.setCzrq(new Date());
                    deviceManufacturerDao.save(manufacturer);
                }else {
                }else if(manufacturer != null){
                    device.setManufacturerCode(manufacturer.getManufacturerCode());
                    device.setManufacturer(manufacturer.getManufacturerName());
                }

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/ServiceItemService.java

@ -59,7 +59,7 @@ public class ServiceItemService extends BaseService {
     */
    public JSONObject createServiceItem(String serviceItem) throws Exception {
        String response = null;
        String url =getBaseUrl() + "createActiveRecord";
        String url =getBaseUrl() + "createServiceItem";
        Map<String,String> params = new HashMap<>();
        params.put("serviceItem",serviceItem);
        try {

+ 56 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/specialist/SpecialistHospitalItemService.java

@ -0,0 +1,56 @@
package com.yihu.wlyy.service.manager.specialist;/**
 * Created by nature of king on 2018/8/28.
 */
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.Hospital;
import com.yihu.wlyy.repository.HospitalDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-08-28 20:40
 * @desc 机构服务项目
 **/
@Service
@Transactional
public class SpecialistHospitalItemService extends BaseService {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistHospitalItemService.class);
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${specialist.url}")
    private String specialistUrl;
    public List<Hospital> selectHospital(){
        List<Hospital> hospitals = hospitalDao.findAllHospital();
        return hospitals;
    }
    public JSONObject insert(String hospitalServiceItem){
        String response = null;
        String url =specialistUrl + "svr-specialist/createHospitalServiceItem";
        Map<String,String> params = new HashMap<>();
        params.put("hospitalServiceItem",hospitalServiceItem);
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
}

+ 3 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/pay_log_list.jsp

@ -26,6 +26,9 @@
            <div class="m-form-control f-ml15">
                <input type="text" id="inp_endDate" placeholder="请输入查询结束日期" class="f-ml10" data-attr-scan="endDate"/>
            </div>
            <div class="m-form-control f-ml15">
                <input type="text" id="inp_status" placeholder="请输入状态" class="f-ml10" data-attr-scan="status"/>
            </div>
            <sec:authorize url="/admin/paylog/list">
                <div id="btn_search" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
                    <span>查询</span>

+ 13 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/static/pay_log_list_js.jsp

@ -40,6 +40,7 @@
                $params: $("#inp_params"),//参数
                $startDate: $("#inp_startDate"),
                $endDate: $("#inp_endDate"),
                $status: $("#inp_status"),
                init: function () {
                    this.$element.show();
                    this.$element.attrScan();
@ -59,6 +60,17 @@
                        labelAlign: 'center',
                        cancelable: true
                    });
                    this.statusBox = this.$status.ligerComboBox({
                        width: 150,
                        data: [
                            {text: '失败', statusId: '0'},
                            {text: '成功', statusId: '1'},
                            {text: '已重试', statusId: '2'}
                        ],
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                    $("#inp_startDate").val(date);
                    this.bindEvents();
                },
@ -144,6 +156,7 @@
                reloadGrid: function (msg) {
                    retrieve.$element.attrScan();
                    var values = retrieve.$element.Fields.getValues();
                    values.status = retrieve.statusBox.getValue();
                    reloadGrid.call(this, values);
                },
            };

+ 10 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/model/PatientHealthIndex.java

@ -48,6 +48,8 @@ public class PatientHealthIndex extends IdEntity {
	//设备编号
	private String deviceSn;
	private String button;//按键号
	private Integer status;//状态:0为标准,1为异常
	private Integer manageResult;//异常数据处理 0未干预 1异常有效干预 2异常无效干预
@ -203,4 +205,12 @@ public class PatientHealthIndex extends IdEntity {
	public void setManageResult(Integer manageResult) {
		this.manageResult = manageResult;
	}
	public String getButton() {
		return button;
	}
	public void setButton(String button) {
		this.button = button;
	}
}

+ 5 - 4
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/AsyncService.java

@ -584,7 +584,7 @@ public class AsyncService extends BaseService{
     * @param deviceType
     */
    @Async
    public void addIntegral(String deviceSn,String type,String userType,String patientCode,Integer deviceType){
    public void addIntegral(String deviceSn,String type,String userType,String patientCode,Integer deviceType,String uploadTime){
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String hospital = "";
@ -601,7 +601,8 @@ public class AsyncService extends BaseService{
            PatientDevice patientDevice = patientDeviceDao.findByDeviceSnAndCategoryCodeAndUserType(deviceSn,type,userType);
            boolean dataUoloadCount = true;
            if (patientDevice!=null){
                String today = DateUtil.getStringDateShort();
                //String today = DateUtil.getStringDateShort();
                uploadTime = uploadTime.substring(0,10);
                /*String startTime = today+" 00:00:00";
                String endTime = today+" 23:59:59";
                int dateType =1;
@ -616,10 +617,10 @@ public class AsyncService extends BaseService{
                //判断今天是否加过体征积分
                String urlSearch = wlyyService + "healthBank/selectByDate";
                List<NameValuePair> paramsSearch1 = new ArrayList<>();
                paramsSearch1.add(new BasicNameValuePair("objectStr", "{\"taskCode\":\"BP_MEASURE\",\"startTime\":\""+today+"\",\"endTime\":\""+today+"\",\"patientId\":\""+patientCode+"\"}"));
                paramsSearch1.add(new BasicNameValuePair("objectStr", "{\"taskCode\":\"BP_MEASURE\",\"startTime\":\""+uploadTime+"\",\"endTime\":\""+uploadTime+"\",\"patientId\":\""+patientCode+"\"}"));
                String responseSearch1 = HttpClientUtil.post(urlSearch, paramsSearch1, "UTF-8");
                List<NameValuePair> paramsSearch2 = new ArrayList<>();
                paramsSearch2.add(new BasicNameValuePair("objectStr", "{\"taskCode\":\"GLU_MEASURE\",\"startTime\":\""+today+"\",\"endTime\":\""+today+"\",\"patientId\":\""+patientCode+"\"}"));
                paramsSearch2.add(new BasicNameValuePair("objectStr", "{\"taskCode\":\"GLU_MEASURE\",\"startTime\":\""+uploadTime+"\",\"endTime\":\""+uploadTime+"\",\"patientId\":\""+patientCode+"\"}"));
                String responseSearch2 = HttpClientUtil.post(urlSearch, paramsSearch2, "UTF-8");
                com.alibaba.fastjson.JSONObject object1 = com.alibaba.fastjson.JSONObject.parseObject(responseSearch1);
                com.alibaba.fastjson.JSONObject object2 = com.alibaba.fastjson.JSONObject.parseObject(responseSearch2);

+ 1 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -506,6 +506,7 @@ public class DeviceService extends BaseService{
            String user = device.getUser();
            obj.setUser(user);
            obj.setButton(userType);
            obj.setIdcard(device.getUserIdcard());
            obj.setStatus(0);
            //  1血糖 2血压 3体重 4腰围

+ 1 - 1
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/FamilyLianQianService.java

@ -59,7 +59,7 @@ public class FamilyLianQianService {
                if (demographicInfo != null) {
                    logger.info("personId"+demographicInfo.getPersonid().toString());
                    List<ResidenceInfo> residenceInfo = residenceInfoDao.findByPersonIdAndState(demographicInfo.getPersonid());
                    if (residenceInfo == null){
                    if (residenceInfo == null || residenceInfo.size() == 0){
                        continue;
                    }
                    List<ResidenceInfo> residenceInfoList = residenceInfoDao.findByFamilyIdAndLeave(residenceInfo.get(0).getFamilystateid());

+ 14 - 4
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DeviceTypeConvert.java

@ -37,12 +37,22 @@ public class DeviceTypeConvert implements Convert {
        return oneList;
    }
    //1、血糖,2、血压
    public String getKey(DataModel dataModel,List<Map<String,Object>> dict){
        for (Map<String,Object> one : dict){
            String result = one.get("name")+"";
            if(dataModel.getServerType().equals(result)||dataModel.getServerType().indexOf(result)>0){
                return one.get("code")+"";
        if("1".equals(dataModel.getServerType())){
             for (Map<String,Object> one : dict){
                String result = one.get("name")+"";
                if(result.equals("血糖")){
                    return one.get("code")+"";
                }
            }
        }else if("2".equals(dataModel.getServerType())){
            for (Map<String,Object> one : dict){
                String result = one.get("name")+"";
                if(result.equals("血压")){
                    return one.get("code")+"";
                }
            }
        }
        return "";

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -125,7 +125,7 @@ public class DoctorInterceptor extends BaseInterceptor {
            }
            Token token = null;
            Map<String, Token> tempMap = null;
            //Map<String, Token> tempMap = null;
            //1.50 登录缓存存储为redis
            if (platform == 2) {

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

@ -36,7 +36,7 @@ public interface DoctorAdminTeamMemberDao extends
            "AND m.doctorCode = d.code AND t.available = true AND m.available = true ORDER BY d.level")
    List<Doctor> findAllMembers(@Param(value = "teamId") long teamId);
    @Query("SELECT d,m.available as available FROM AdminTeamMember m, AdminTeam t, Doctor d WHERE t.id = :teamId AND t.id = m.teamId " +
    @Query("SELECT distinct m.doctorCode,d,m.available as available FROM AdminTeamMember m, AdminTeam t, Doctor d WHERE t.id = :teamId AND t.id = m.teamId " +
            "AND m.doctorCode = d.code AND t.available = true ORDER BY d.level")
    List<Object[]> findMembers(@Param(value = "teamId") long teamId);

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -437,4 +437,8 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    //查看团队内医生签约人数
    @Query("select count(1) from SignFamily a where a.status > 0 and a.adminTeamId = ?1 and (a.doctor = ?2 or a.doctorHealth = ?2)")
    int countByAdminTeamId(Long adminTeamId, String doctor);
    //根据居民和医生找出居民签约团队
    @Query("select f from SignFamily f where f.status > 0 and f.patient = ?1 and ( f.doctor = ?2 or doctorHealth = ?2  )")
    SignFamily findSignFamilyByPatientAndDoctor(String patient, String doctor);
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/specialist/SpecialDiseaseDao.java

@ -12,6 +12,7 @@ import java.util.List;
 */
public interface SpecialDiseaseDao extends PagingAndSortingRepository<SpecialDisease, Long>, JpaSpecificationExecutor<SpecialDisease> {
    @Query("from SpecialDisease where code=?1 and del=1")
    SpecialDisease findByCode(String code);
    List<SpecialDisease> findByDel(String del);

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -2828,5 +2828,21 @@ public class ConsultTeamService extends ConsultService {
        re.put("list",ja);
        return re.toString();
    }
    
    //判断居民家庭医生专科是否有共管关系
    public int getSpecialDoctorFamilyDoctorPatientCount(String patient,String special_doctor,String family_doctor){
        String sql = "SELECT " +
                "count(a.id) FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                "JOIN wlyy.wlyy_sign_family b " +
                "ON a.patient=b.patient " +
                "AND b.`status`=1 " +
                "WHERE a.sign_status> 0 " +
                "AND a.`status`>=0 " +
                "AND a.doctor='"+special_doctor+"' " +
                "AND (b.doctor='"+family_doctor+"' or b.doctor_health='"+family_doctor+"')" +
                "AND a.patient='"+patient+"'";
        int count = jdbcTemplate.queryForObject(sql,Integer.class);
        return  count;
    }
}

+ 21 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/disease/PatientDiseaseService.java

@ -497,4 +497,25 @@ public class PatientDiseaseService extends BaseService {
            }
        }
    }
    
    public List<Map<String,Object>> getPatientDiseaseCount(String doctor, Long teamCode) {
        String sql ="SELECT " +
                "count(b.id) AS count," +
                "b.disease_name AS labelName," +
                "b.disease AS label " +
                "FROM wlyy_specialist.wlyy_specialist_patient_relation a " +
                "JOIN wlyy.wlyy_patient_disease_server b ON a.patient=b.patient and b.del=1 " +
                "WHERE a.sign_status> 0 AND a.`status`>=0 " +
                "AND a.doctor='"+doctor+"' " +
                "GROUP BY b.disease";
    
        List<Map<String,Object>> result =  jdbcTemplate.queryForList(sql);
        if(!result.isEmpty()){
            for (int i = 0; i < result.size(); i++) {
                result.get(i).put("labelType","7");
            }
        }
        
        return result;
    }
}

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

@ -804,6 +804,8 @@ public class FamilyMemberService extends BaseService {
        switch (relation) {
            case 1:
                relationTrans = 1;
                break;
            case 2:
                if (patient.getSex() == 1) {
                    relationTrans = 5;

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

@ -450,4 +450,8 @@ public class FamilyService {
        String salt= "c89233bd15994b68ab3708ce79d5c2c4";
        System.out.println(MD5.GetMD5Code(password+salt));
    }
    public SignFamily findByPatientAndDoctor(String patient, String doctor) {
        return signFamilyDao.findSignFamilyByPatientAndDoctor(patient, doctor);
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -395,7 +395,7 @@ public class SignWebService extends BaseService {
                    "  (doctor = '"+doctor+"' or doctor_health = '"+doctor+"') " +
                    " AND STATUS > 0 " +
                    " AND type = 2 " +
                    " AND expenses_status = '0'  " +
                    " AND (expenses_status = '0' or expenses_status = '3')  " +
                    " ) AS waitPayCount, " +
                    "( " +
                    " SELECT " +

+ 234 - 23
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -20,6 +20,7 @@ import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.web.quota.vo.SaveModel;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.type.StringClobType;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -5573,15 +5574,15 @@ public class StatisticsESService {
                    int map1value = 0;
                    int map2value = 0;
                    if(sortType==1){
                        map1value = (int) o1.get("allNum");
                        map2value = (int) o2.get("allNum");
                        map1value = Integer.valueOf(o1.get("allNum").toString());
                        map2value = Integer.valueOf(o2.get("allNum").toString());
                    }else if(sortType==2){
                        map1value = (int) o1.get("bindingNum");
                        map2value = (int) o2.get("bindingNum");
                        map1value = Integer.valueOf(o1.get("bindingNum").toString());
                        map2value = Integer.valueOf(o2.get("bindingNum").toString());
                    }else {
                        map1value = (int) o1.get("rateNum");
                        map2value = (int) o2.get("rateNum");
                        map1value = Integer.valueOf(o1.get("rateNum").toString());
                        map2value = Integer.valueOf(o2.get("rateNum").toString());
                    }
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
@ -5616,14 +5617,16 @@ public class StatisticsESService {
            }
            if (hospitals != null && hospitals.size() > 0) {
                int amount = 0;
                int allNum = 0;
                for (Hospital hos : hospitals) {
                    if (hos.getCode().length() > 10) {
                        continue;
                    }
//                    String sql = " select count(DISTINCT p.doctor,p.device_sn) AS amount,p.doctor as doctorCode,r.name as doctorName from wlyy.wlyy_patient_device p JOIN wlyy.wlyy_doctor r on p.doctor is not null and  p.doctor =r.code  LEFT JOIN device.wlyy_devices d on p.device_sn=d.device_code where p.del=0 and p.doctor is not null and d.grant_org_code ='" + hos.getCode() + "'  group by p.doctor,r.name";
                    String sql = " select count(*) as amount,if(a.doctor is null,'other',a.doctor) as doctorCode,if(a.NAME is null,'其他',a.NAME) as doctorName " +
                            " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p left join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                            "where p.del=0 and d.is_binding in (1,2) and d.grant_org_code ='" + hos.getCode() + "') a " +
                            " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p RIGHT join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                            "where p.del=0 and d.is_binding in (1,2) and p.category_code in('1','2') and d.grant_org_code ='" + hos.getCode() + "') a " +
                            " GROUP BY a.doctor,a.name";
                    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                    for (Map<String, Object> one : list) {
@ -5632,9 +5635,23 @@ public class StatisticsESService {
                        obj.put("name", one.get("doctorName"));
                        obj.put("amount", one.get("amount"));
                        obj = deviceRateList(obj,hos);
                        if("other".equals(one.get("doctorCode")+"")){
                            amount += Integer.valueOf(obj.get("amount")+"");
                            allNum += Integer.valueOf(obj.get("allNum")+"");
                            continue;
                        }
                        resultList.add(obj);
                    }
                }
                Map<String, Object> otherObj = new HashMap<>();
                otherObj.put("code", "other");
                otherObj.put("name", "其他");
                otherObj.put("amount", amount);
                otherObj.put("allNum", allNum);
                otherObj.put("bindingNum", amount);
                otherObj.put("rate", getRange(amount, allNum, 2));//续签率是 续签量/去年的签约数
                otherObj.put("rateNum", getRangeNum(amount, allNum, 2));//续签率是 续签量/去年的签约数
                resultList.add(otherObj);
            }
//        }
        return resultList;
@ -5754,7 +5771,7 @@ public class StatisticsESService {
        String temp = "other".equals(reMap.get("code"))? " and p.doctor is null ":" and p.doctor='"+reMap.get("code")+"' ";
        String sql = " select count(1) as amount " +
                " from (select  DISTINCT p.doctor,r.name,p.device_sn FROM wlyy.wlyy_patient_device p left join device.wlyy_devices d on p.device_sn=d.device_code left JOIN wlyy.wlyy_doctor r ON  p.doctor = r. CODE " +
                " where d.is_binding in (1,2) and  d.grant_org_code ='" + hos.getCode() + "' "+temp+") a " +
                " where d.is_binding in (1,2) and p.category_code in('1','2') and d.grant_org_code ='" + hos.getCode() + "' "+temp+") a " +
                " GROUP BY a.doctor,a.name";
//        Map<String, Object> map = jdbcTemplate.queryForMap(sql);
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
@ -6159,14 +6176,6 @@ public class StatisticsESService {
//    }
    /**
     * 查询签约
     *
     * @param type      0 按周,1 按月
     * @param startDate
     * @param endDate
     * @return
     */
    /*public JSONArray getDeviceLine(String doctor, String type, String startDate, String endDate) throws Exception {
        AdminTeam admin = adminTeamDao.findByLeaderCode(doctor);
@ -6194,7 +6203,7 @@ public class StatisticsESService {
        return rsJs;
    }*/
    public JSONArray getDeviceLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
    /*public JSONArray getDeviceLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        List<Map<String, Object>> resultList = new ArrayList<>();
@ -6204,7 +6213,8 @@ public class StatisticsESService {
        List<SaveModel> esModelList = new ArrayList<>();
        if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
            String time = DateUtil.getStringDateShort();
            //String time = DateUtil.getStringDateShort();
            String time= elasticsearchUtil.getQuotaTime();
            String sql ="SELECT" +
                    " pd.doctor team," +
                    " pd.doctor_name teamName," +
@ -6217,8 +6227,8 @@ public class StatisticsESService {
                    " AND pd.del = 0" +
                    " AND pd.category_code IN (1, 2)" +
                    " AND pd.czrq>='2018-06-30 17:00:00'"+
                    " AND pd.czrq < '"+time+" 17:00:00'" +
                    " AND LEFT(pd.czrq,4)= '"+year+"'";
                    " AND pd.czrq <= '"+time+"'" +
                    " AND LEFT(pd.czrq,4)= '"+year+"' AND grant_admin_team NOT IN(SELECT id FROM wlyy_admin_team WHERE LENGTH(org_code)!=10)";
            if(level==3){
                sql +=" AND LEFT(dw.grant_org_code,6)= '"+area+"'";
            }else if (level==4){
@ -6227,7 +6237,7 @@ public class StatisticsESService {
            sql +=" GROUP BY team";
            esModelList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SaveModel.class));
        }else {
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(date, area, level, index, SaveModel.timeLevel_DDL, low_level);
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0("2018-07-01",date, area, level, index, SaveModel.timeLevel_ZL, low_level);
        }
        if (esModelList != null && esModelList.size() > 0) {
@ -6259,10 +6269,135 @@ public class StatisticsESService {
        }
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
        *//*if (resultList == null || resultList.size() < 1) {
            resultList = getLowLevelMapKey(level, low_level, area);
        }*//*
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                if (!low_level.equals("5")) {
                    PopulationBase peopleNum = getPopulationBase(area, year);
                    if (peopleNum != null) {
                        map.put("rate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getNum() * 100));
                        map.put("taskRate", df.format(((long) map.get("amount") * 1.0000) / peopleNum.getTaskNum() * 100));
                        map.put("targetRate", df.format(peopleNum.getTaskNum() * 1.0000 / peopleNum.getNum() * 100));
                        map.put("rateString", map.get("amount") + "/" + peopleNum.getNum());
                        map.put("taskRateString", map.get("amount") + "/" + peopleNum.getTaskNum());
                        map.put("targetRateString", peopleNum.getTaskNum() + "/" + peopleNum.getNum());
                        map.put("num", peopleNum.getNum());
                        map.put("task", peopleNum.getTaskNum());
                    }
                }
            }
            *//*if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
                translateTeamLeaderName(resultList);
            }*//*
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    long map1value = (long) o1.get("amount");
                    long map2value = (long) o2.get("amount");
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                        return sort == 1 ? 1 : -1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }*/
    public JSONArray getDeviceLowLevelTotal(String date, String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String low_level = String.valueOf(org.springframework.util.StringUtils.isEmpty(lowLevel) ? (level + 1) : lowLevel);
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (date.compareTo(dateFormat.format(new Date())) >= 0) {
            date = elasticsearchUtil.getQuotaTime();
        }
        List<SaveModel> esModelList = new ArrayList<>();
        List<Map<String,Object>> sqlList = new ArrayList<>();
        if ((level == 2 && "5".equals(lowLevel)) || (level == 4) || (level == 3 && "5".equals(lowLevel))) {
            //String time = DateUtil.getStringDateShort();
            String time=  redisTemplate.opsForValue().get("quota:date");
            String sql ="SELECT" +
                    " d.device_code," +
                    " pd.doctor," +
                    " pd.doctor_name," +
                    " pd.user_type" +
                    " FROM" +
                    " device.wlyy_devices d" +
                    " LEFT JOIN wlyy.wlyy_patient_device pd ON d.device_code = pd.device_sn" +
                    " WHERE" +
                    " d.is_binding IN (1, 2)" +
                    " AND pd.category_code IN ('1', '2')" +
                    " AND d.grant_time <= '"+time+"'" +
                    " AND d.grant_admin_team NOT IN(SELECT id FROM wlyy_admin_team WHERE LENGTH(org_code)!=10)"+
                    " ";
            if(level==3){
                sql +=" AND d.grant_admin_team IN(SELECT id FROM wlyy_admin_team WHERE LEFT(org_code,6) = '"+area+"'AND available = 1) AND LEFT(d.grant_org_code,6)= '"+area+"'";
            }else if (level==4){
                sql +=" AND d.grant_admin_team IN(SELECT id FROM wlyy_admin_team WHERE org_code = '"+area+"'AND available = 1) AND d.grant_org_code = '"+area+"'";
            }else if (level==2){
                sql +=" AND d.grant_admin_team IN(SELECT id FROM wlyy_admin_team WHERE available = 1)";
            }
            sqlList = jdbcTemplate.queryForList(sql);
        }else {
            esModelList = (List<SaveModel>) elasticsearchUtil.findListDateQuotaLevel0(year+"-07-01",date, area, level, index, SaveModel.timeLevel_ZL, low_level);
        }
        esModelList = getDeviceBindToTeam(sqlList);
        //到绑定人的封装数据
        if (esModelList != null && esModelList.size() > 0) {
            for (SaveModel one : esModelList) {
                Map<String, Object> maps = new HashMap<String, Object>();
                maps.put("amount", one.getResult1().intValue());
                if (low_level.equals("3")) {
                    maps.put("code", one.getTown());
                    maps.put("name", one.getTownName());
                } else if (low_level.equals("4")) {
                    maps.put("code", one.getHospital());
                    maps.put("name", one.getHospitalName());
                } else if (low_level.equals("5")) {
                    if (StringUtils.isNotEmpty(one.getTeam())){
                        maps.put("code", one.getTeam());
                        if (StringUtils.isEmpty(one.getTeamName())){
                            Doctor doctor = doctorDao.findByCode(one.getTeam());
                            if (doctor!=null){
                                maps.put("name", doctor.getName());
                            }
                        }else {
                            maps.put("name", one.getTeamName());
                        }
                    }
                    if (StringUtils.isEmpty(one.getTeam())){
                        maps.put("code","0");
                        maps.put("name", "其他");
                    }
                }
                resultList.add(maps);
            }
        }
        // 结果为空时,自建结果集
        /*if (resultList == null || resultList.size() < 1) {
            resultList = getLowLevelMapKey(level, low_level, area);
        }*/
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.0000");
            for (Map<String, Object> map : resultList) {
@ -6307,4 +6442,80 @@ public class StatisticsESService {
            return new JSONArray();
        }
    }
    public List<SaveModel> getDeviceBindToTeam(List<Map<String,Object>> dataList) throws Exception{
        if (dataList==null && dataList.size()==0){
            return  null;
        }
        Map<String,Object> resultMap = new HashedMap();
        List<SaveModel> resultList = new ArrayList<>();
        //如果有两个键,则取a键
        for (Map<String,Object> map : dataList){
            String deviceSn = String.valueOf(map.get("device_code"));
            List<Map<String,Object>> deviceList =  null;
            if (resultMap.containsKey(deviceSn)){
                deviceList = (List<Map<String,Object>>)resultMap.get(deviceSn);
                String userType = String.valueOf(deviceList.get(0).get("user_type"));
                if (Integer.parseInt(String.valueOf(map.get("user_type")))<Integer.parseInt(userType)){
                    deviceList.clear();
                    deviceList.add(map);
                }
            }else {
                deviceList = new ArrayList<>();
                deviceList.add(map);
            }
            resultMap.put(deviceSn,deviceList);
        }
        //遍历map
        List<Map<String,Object>> mapList = new ArrayList<>();
        resultMap.forEach((key, value) -> {
            mapList.addAll((List<Map<String,Object>>)value);
        });
        //根据医生code聚合返回页面所需要结果
         Map<String,Object> doctorMap = new HashedMap();
         for (Map<String,Object> map2 : mapList){
             String key = "";
             String doctor = "";
             String doctorName = "";
             if (map2.get("doctor")!= null){
                 doctor = String.valueOf(map2.get("doctor"));
             }
             if (map2.get("doctor_name")!=null){
                 doctorName = String.valueOf(map2.get("doctor_name"));
             }
             if (StringUtils.isEmpty(doctor)){
                 key ="qita,";
             }else if (StringUtils.isNotBlank(doctor)){
                 key =doctor+","+doctorName;
             }
             int count = 0;
             if (doctorMap.containsKey(key)){
                 count = Integer.valueOf(String.valueOf(doctorMap.get(key)));
             }
             count++;
             doctorMap.put(key,count);
         }
         //遍历map
        for (Map.Entry<String,Object> entry : doctorMap.entrySet()){
             SaveModel saveModel = new SaveModel();
             String key = entry.getKey();
             String[] keyStr = key.split(",");
             if(keyStr[0].equals("qita")){
                 saveModel.setTeam("");
             }else {
                 saveModel.setTeam(keyStr[0]);
             }
             if (keyStr.length>1){
                 saveModel.setTeamName(keyStr[1]);
             }
             saveModel.setResult1(Double.valueOf(String.valueOf(entry.getValue())));
             resultList.add(saveModel);
        }
        return  resultList;
    }
}

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

@ -442,9 +442,9 @@ public class AdminTeamService extends BaseService {
        int count = 0;
        members = memberDao.findMembers(teamId);
        for(Object[] member : members){
            Object[] obj = new Object[member.length + 1];
            System.arraycopy(member, 0, obj, 0, member.length);
            Doctor d = (Doctor) member[0];
            Object[] obj = new Object[member.length ];
            System.arraycopy(member, 1, obj, 0, member.length-1);
            Doctor d = (Doctor) member[1];
            count = signFamilyDao.countByAdminTeamId(teamId, d.getCode());
            obj[obj.length - 1] = count;
            list.add(obj);

+ 142 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/RehabilitationPlanService.java

@ -0,0 +1,142 @@
package com.yihu.wlyy.service.specialist;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2018/8/22.
 */
@Service
@Transactional
public class RehabilitationPlanService extends BaseService {
    @Value("${specialist.url}")
    private String specialistUrl;
    public JSONObject findTemplateInfo(Long teamId) {
        Map<String, Object> param = new HashedMap();
        param.put("adminTeamCode", teamId);
        HttpResponse response = null;
        try {
            response = HttpUtils.doGet(specialistUrl + "svr-specialist/findRehabilitationPlanTemplate", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public JSONObject findTemplateDetailInfo(String templateId) {
        Map<String, Object> param = new HashedMap();
        param.put("templateId", templateId);
        HttpResponse response = null;
        try {
            response = HttpUtils.doGet(specialistUrl + "svr-specialist/findTemplateDetailByTemplateId", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public String createTemplate(String title, Doctor doctor, Long teamId) {
        JSONObject json = new JSONObject();
        json.put("title", title);
        json.put("adminTeamCode", teamId);
        json.put("hospital", doctor.getHospital());
        json.put("hospitalName", doctor.getHospitalName());
        json.put("createUser", doctor.getCode());
        json.put("createUserName", doctor.getName());
        Map<String, Object> param = new HashedMap();
        param.put("rehabilitationTemplate", json.toString());
        HttpResponse response = null;
        try {
            response = HttpUtils.doPost(specialistUrl + "svr-specialist/createRehabilitationPlanTemplate", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        if ("success".equals(rs.getString("message"))) {
            return rs.getString("obj");
        }
        return rs.getString("message");
    }
    public String createTemplateDetail(String json, String type, Doctor doctor) {
        JSONObject object = new JSONObject(json);
        JSONArray details = new JSONArray();
        String templateId = object.get("templateId").toString();
        String serviceItemIds = object.get("hospitalServiceItemIds").toString();
        if(serviceItemIds.contains(",")) {
            String [] itemIds = serviceItemIds.split(",");
            int len = itemIds.length;
            while (len > 0){
                len --;
                JSONObject j = new JSONObject();
                j.put("templateId", templateId);
                j.put("hospitalServiceItemId", itemIds[len]);
                j.put("createUser", doctor.getCode());
                j.put("createUserName", doctor.getName());
                details.put(len, j);
            }
        }
        Map<String, Object> param = new HashedMap();
        param.put("rehabilitationTemplateDetail", details.toString());
        HttpResponse response = null;
        try {
            if(type.equals("create")) {
                response = HttpUtils.doPost(specialistUrl + "svr-specialist/createRehabilitationTemplateDetail", param);
            }else if(type.equals("edit")) {
                response = HttpUtils.doPost(specialistUrl + "svr-specialist/updateRehabilitationTemplateDetail", param);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs.getString("message");
    }
    public JSONObject findServiceItemsByHospital(SignFamily signFamily, Doctor doctor) {
        List<String> hospitals = null;
        hospitals.add(doctor.getHospital());
        hospitals.add(signFamily.getHospital());
        Map<String, Object> param = new HashedMap();
        param.put("hospitals", hospitals);
        HttpResponse response = null;
        try {
            response = HttpUtils.doPost(specialistUrl + "svr-specialist/", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs;
    }
    public String createRehabilitationPlan(String json, Doctor doctor) {
        JSONObject object = new JSONObject(json);
        object.put("createUser", doctor.getCode());
        object.put("createUserName", doctor.getName());
        Map<String, Object> param = new HashedMap();
        param.put("rehabilitationPlan", json.toString());
        HttpResponse response = null;
        try {
            response = HttpUtils.doPost(specialistUrl + "svr-specialist/createPatientRehabilitationPlan", param);
        } catch (Exception e) {
            e.printStackTrace();
        }
        JSONObject rs = new JSONObject(response.getContent());
        return rs.getString("message");
    }
}

+ 156 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistEvaluateSevice.java

@ -0,0 +1,156 @@
package com.yihu.wlyy.service.specialist;/**
 * Created by nature of king on 2018/8/28.
 */
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-08-28 9:09
 * @desc 服务项目评论
 **/
@Service
@Transactional
public class SpecialistEvaluateSevice extends BaseService {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistEvaluateSevice.class);
    @Autowired
    private MessageDao messageDao;
    @Value("${specialist.url}")
    private String specialistUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private DoctorDao doctorDao;
    /**
     * 添加评论
     *
     * @param object
     * @return
     */
    public JSONObject insert(JSONObject object){
        String response = null;
        String url =specialistUrl + "svr-specialist/createEvaluate";
        Map<String,String> params = new HashMap<>();
        params.put("evaluate",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 更新评论
     *
     * @param object
     * @return
     */
    public JSONObject update(JSONObject object){
        String response = null;
        String url =specialistUrl + "svr-specialist/updateEvaluate";
        Map<String,String> params = new HashMap<>();
        params.put("evaluate",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 获取评论
     *
     * @param object
     * @return
     */
    public JSONObject select(JSONObject object){
        String response = null;
        String url =specialistUrl + "svr-specialist/getEvaluate";
        Map<String,String> params = new HashMap<>();
        params.put("evaluate",object.toJSONString());
        try {
            response = httpClientUtil.httpPost(url,params);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    }
    /**
     * 发送消息 type:19 受理提醒,20 待办工作提醒 21 服务进展提醒-已完成 22 服务进展提醒-未完成
     */
    public JSONObject sendMessage(Message message,String hospital,String patient){
        JSONObject object = new JSONObject();
        try {
            Patient patient1 = patientDao.findByCode(patient);
            Hospital hospital1 = hospitalDao.findByCode(hospital);
            Doctor doctor = doctorDao.findByCode(message.getSender());
            if (message.getType() == 19 && StringUtils.isNoneBlank(hospital)){
                message.setType(19);
                message.setTitle("康复计划-受理提醒");
                message.setContent("您的"+patient1.getName()+"签约居民,刚刚出院,"+hospital1.getName()+"已完成康复计划的制定,请查看");
            }else if (message.getType() == 20){
                message.setType(20);
                message.setTitle("康复计划-待办工作提醒");
                message.setContent("您的"+patient1.getName()+"签约居民10天后计划到"+hospital1.getName()+"复诊,请查看");
            }else if (message.getType() == 21){
                message.setType(21);
                message.setTitle("康复计划-服务进展提醒");
                message.setContent("您的"+patient1.getName()+"签约居民已完成康复计划今日项目,请查看");
            }else if (message.getType() == 22){
                message.setType(22);
                message.setTitle("康复计划-服务进展提醒");
                message.setContent("您的"+patient1.getName()+"签约居民未完成康复计划今天项目,请尽快处理");
            }
            message.setSenderName(doctor.getName());
            message.setCode(getCode());
            message.setSenderPhoto(doctor.getPhoto());
            message.setReadonly(1);//是否只读消息
            message.setSex(doctor.getSex());
            message.setOver("1");//未处理
            message.setDel("1");
            message.setState(1);
            message.setCzrq(new Date());
            messageDao.save(message);
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return object;
    }
}

+ 100 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistHospitalItemService.java

@ -0,0 +1,100 @@
package com.yihu.wlyy.service.specialist;/**
 * Created by nature of king on 2018/8/28.
 */
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.HttpClientUtil;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-08-28 20:40
 * @desc 机构服务项目
 **/
@Service
@Transactional
public class SpecialistHospitalItemService extends BaseService {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(SpecialistHospitalItemService.class);
    @Autowired
    private HospitalDao hospitalDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Value("${specialist.url}")
    private String specialistUrl;
    public List<Hospital> selectHospital(){
        List<Hospital> hospitals = hospitalDao.findAllHospital();
        return hospitals;
    }
    /**
     * 获取服务项目
     * @param hospitals
     * @return
     */
    public JSONObject selectByHospital(String hospitals){
        String response = null;
        JSONObject object = new JSONObject();
        String url =specialistUrl + "svr-specialist/selectByHospital";
        Map<String,String> params = new HashMap<>();
        params.put("hospitals",hospitals);
        try {
            response = httpClientUtil.httpPost(url,params);
            object = JSONObject.parseObject(response);
            JSONArray array = object.getJSONArray("detailModelList");
            for (int i = 0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                String hospital = jsonObject.getString("hospital");
                Hospital hospital1 = hospitalDao.findByCode(hospital);
                jsonObject.put("hospitalDo",hospital1);
            }
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return object;
    }
    /**
     * 根据服务项目ids获取数据
     *
     * @param ids
     * @return
     */
    public JSONObject selectByIds(String ids){
        String response = null;
        JSONObject object = new JSONObject();
        String url =specialistUrl + "svr-specialist/selectById";
        Map<String,String> params = new HashMap<>();
        params.put("ids",ids);
        try {
            response = httpClientUtil.httpPost(url,params);
            object = JSONObject.parseObject(response);
            JSONArray array = object.getJSONArray("detailModelList");
            for (int i = 0;i<array.size();i++){
                JSONObject jsonObject = array.getJSONObject(i);
                String hospital = jsonObject.getString("hospital");
                Hospital hospital1 = hospitalDao.findByCode(hospital);
                jsonObject.put("hospitalDo",hospital1);
            }
        }catch (Exception e){
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return object;
    }
}

+ 49 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -23,6 +23,8 @@ import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.label.SignPatientLabelService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.task.PushMsgTask;
@ -72,6 +74,8 @@ public class SpecialistService extends BaseService {
    @Autowired
    private PatientDiseaseServerDao patientDiseaseServerDao;
    @Autowired
    private PatientDiseaseService patientDiseaseService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SpecialDiseaseDao specialDiseaseDao;
@ -182,7 +186,10 @@ public class SpecialistService extends BaseService {
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatusAndTeamCode(type, 1, teamCode);
            return setPatientCount(list, doctor);
        } else {
        } else if("7".equals(type)){
            return patientDiseaseService.getPatientDiseaseCount(doctor,teamCode);
        }
        else {
            //非自定义标签
            List<SignPatientLabel> list = signPatientLabelDao.findByLabelTypeAndStatus(type, 1);
@ -465,17 +472,19 @@ public class SpecialistService extends BaseService {
                String[] str = disease.split(",");
                for (String ds : str) {
                    SpecialDisease dis = specialDiseaseDao.findByCode(ds);
                    // 保存居民病种
                    PatientDiseaseServer server = new PatientDiseaseServer();
                    server.setCode(getCode());
                    server.setDel("1");
                    server.setSpecialistRelationCode(rs.getString("obj"));
                    server.setPatient(patient);
                    server.setPatientName(p.getName());
                    server.setDisease(dis.getCode());
                    server.setDiseaseName(dis.getName());
                    server.setCreateTime(new Date());
                    patientDiseaseServerDao.save(server);
                    if(dis!=null){
                        // 保存居民病种
                        PatientDiseaseServer server = new PatientDiseaseServer();
                        server.setCode(getCode());
                        server.setDel("1");
                        server.setSpecialistRelationCode(rs.getString("obj"));
                        server.setPatient(patient);
                        server.setPatientName(p.getName());
                        server.setDisease(dis.getCode());
                        server.setDiseaseName(dis.getName());
                        server.setCreateTime(new Date());
                        patientDiseaseServerDao.save(server);
                    }
                }
                // 添加签约申请消息
                Message message = new Message();
@ -540,11 +549,18 @@ public class SpecialistService extends BaseService {
        return mes;
    }
    public String agreeSpecialistTeam(String token, String state, String relationCode, String remark, Long mesId) throws Exception {
    public String agreeSpecialistTeam(String token, String state, String relationCode, String remark, Long mesId, String labelcode, String doctorcode) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("state", state);
        param.put("relationCode", relationCode);
        param.put("remark", remark);
        
        if(StringUtils.isNotBlank(doctorcode)){
            Doctor doctor = doctorDao.findByCode(doctorcode);
            param.put("health_assistant", doctorcode);//计管医生
            param.put("health_assistant_name", doctor.getName());//计管医生名称
        }
        HttpResponse response = HttpUtils.doPost(specialistUrl + "svr-specialist/agreeSpecialistTeam", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
@ -571,6 +587,26 @@ public class SpecialistService extends BaseService {
                //推送给居民模板消息
                pushWeiTemp(token, "0", remark, p, d);
            } else {
    
                //保存居民健康情况标签
                if(StringUtils.isNotBlank(labelcode)){
                    SignPatientLabel signPatientLabel = labelService.getLabelByCodeAndType(labelcode,"8");
                    //先删除已有健康情况标签
                    signPatientLabelInfoDao.deleteByPatientAndLabelTypeAndStatus(p.getCode(),"8",1);
                    SignPatientLabelInfo signPatientLabelInfo = new SignPatientLabelInfo();
                    signPatientLabelInfo.setLabel(signPatientLabel.getLabelCode());
                    signPatientLabelInfo.setLabelType(signPatientLabel.getLabelType());
                    signPatientLabelInfo.setLabelName(signPatientLabel.getLabelName());
                    signPatientLabelInfo.setCzrq(new Date());
                    signPatientLabelInfo.setPatient(p.getCode());
                    signPatientLabelInfo.setPname(p.getName());
                    signPatientLabelInfo.setStatus(1);
                    //添加新的健康情况标签
                    signPatientLabelInfoDao.save(signPatientLabelInfo);
                    
                }
                
                
                //推送给居民模板消息
                pushWeiTemp(token, "1", "", p, d);

+ 6 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/guahao/GuahaoXMService.java

@ -1255,6 +1255,12 @@ public class GuahaoXMService extends BaseService implements IGuahaoService {
        if (p == null) {
            throw new Exception("患者信息不存在!");
        }
        
        //判断居民是否有签约
        List<SignFamily> sign = signFamilyDao.findSSandJTByIdcard(p.getIdcard());
        if(sign == null || sign.size()==0){
            throw new Exception("未签约患者不能预约10天号源!");
        }
        Map<String, String> map = objectMapper.readValue(arrangeDate, Map.class);
        if (map.containsKey("sectionType") && map.containsKey("startTime")) {

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/kit/JyKitService.java

@ -31,6 +31,8 @@ public class JyKitService {
    @Value("${juye.companyCode}")
    private String companyCode;
    @Value("${juye.companySecret}")
    private String companySecret;
    @Value("${juye.url}")
    private String jyUrl;
    @Autowired
@ -41,7 +43,7 @@ public class JyKitService {
    private String timeTermRedisKey = "juye:getToken:time_term";
    private String tokenRedisKey = "juye:getToken:token";
    /****************************************接口路径 start**************************************************/
    /****************************************接口路径 start****************************************************/
    private String kitBinding = "companyBindDevice";//药盒绑定接口
    private String getKitSetInfo = "getInfoByDeviceSn";//获取药盒设置信息接口
    private String getKitToken = "getToken";//获取巨烨token
@ -186,6 +188,7 @@ public class JyKitService {
     */
    public String getRequestPost(List<NameValuePair> params,String url) throws Exception{
        params.add(new BasicNameValuePair("company_code", companyCode));
        params.add(new BasicNameValuePair("company_secret", companySecret));
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
@ -198,7 +201,7 @@ public class JyKitService {
     * @throws Exception
     */
    public String getRequestGet(List<NameValuePair> params,String url) throws Exception{
        String paramStr="?company_code="+companyCode;
        String paramStr="?company_code="+companyCode+"&company_secret="+companySecret;
        for(NameValuePair one : params){
            paramStr += "&"+one.getName()+"="+one.getValue();
        }

+ 122 - 50
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -10,18 +10,21 @@ import com.yihu.wlyy.entity.device.PatientDeviceLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.manage.User;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.health.repository.DeviceDetailDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.manage.UserDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.PatientDeviceLogDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.device.DeviceDetailService;
import com.yihu.wlyy.service.app.device.PatientDeviceService;
import com.yihu.wlyy.service.app.health.bank.CreditLogService;
import com.yihu.wlyy.util.*;
import net.sf.json.JSONArray;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringEscapeUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -67,6 +70,8 @@ public class DataHandingService {
    private CreditLogService creditLogService;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Transactional
    public String producePatientAndDoctorPassword() {
@ -298,28 +303,33 @@ public class DataHandingService {
    public boolean updateDeviceDefalut(){
        boolean flag = true;
        try{
            String deviceSql = "SELECT wd.*,dd.category_code,dd.is_multi_user FROM device.wlyy_devices wd LEFT JOIN wlyy.dm_device dd ON wd.device_model = dd.model";
            //String deviceSql = "SELECT wd.*,dd.category_code,dd.is_multi_user FROM device.wlyy_devices wd LEFT JOIN wlyy.dm_device dd ON wd.device_model = dd.model";
            String deviceSql ="SELECT wd.*,dd.category_code,dd.is_multi_user FROM device.wlyy_devices wd LEFT JOIN wlyy.dm_device dd ON wd.device_model = dd.model where dd.category_code IN(1,2) AND (wd.binding_count IS NULL OR wd.binding_count='' OR wd.binding_count='null')";
            List<Map<String,Object>> deviceDetailList = jdbcTemplate.queryForList(deviceSql);
            //把wlyy_devices库里bindCount先补充默认值
            List<String> deviceSqlList = new ArrayList<>();
            for (Map<String,Object> deviceMap : deviceDetailList){
                String bindingCount="";
                if (StringUtils.isEmpty(String.valueOf(deviceMap.get("binding_count"))) || StringUtils.pathEquals("null",String.valueOf(deviceMap.get("binding_count")))){
                    if (org.apache.commons.lang3.StringUtils.isNotEmpty(String.valueOf(deviceMap.get("is_multi_user"))) && StringUtils.pathEquals("0",String.valueOf(deviceMap.get("is_multi_user")))){
               /* if (StringUtils.isEmpty(String.valueOf(deviceMap.get("binding_count"))) || StringUtils.pathEquals("null",String.valueOf(deviceMap.get("binding_count")))){
                    }*/
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(String.valueOf(deviceMap.get("is_multi_user"))) && StringUtils.pathEquals("0",String.valueOf(deviceMap.get("is_multi_user")))){
                    bindingCount="{\"1\":\"0\"}";
                }else if (org.apache.commons.lang3.StringUtils.isNotEmpty(String.valueOf(deviceMap.get("is_multi_user"))) && StringUtils.pathEquals("1",String.valueOf(deviceMap.get("is_multi_user")))){
                    bindingCount="{\"1\":\"0\",\"2\":\"0\"}";
                }else if (StringUtils.isEmpty(String.valueOf(deviceMap.get("is_multi_user"))) || StringUtils.pathEquals("null",String.valueOf(deviceMap.get("is_multi_user")))){
                    if (String.valueOf(deviceMap.get("device_name")).contains("血糖")){
                        bindingCount="{\"1\":\"0\"}";
                    }else if (org.apache.commons.lang3.StringUtils.isNotEmpty(String.valueOf(deviceMap.get("is_multi_user"))) && StringUtils.pathEquals("1",String.valueOf(deviceMap.get("is_multi_user")))){
                    }
                    if (String.valueOf(deviceMap.get("device_name")).contains("血压")){
                        bindingCount="{\"1\":\"0\",\"2\":\"0\"}";
                    }
                    if (StringUtils.isEmpty(String.valueOf(deviceMap.get("device_name")))){
                        bindingCount="{\"1\":\"0\",\"2\":\"0\"}";
                    }else if (StringUtils.isEmpty(String.valueOf(deviceMap.get("is_multi_user"))) || StringUtils.pathEquals("null",String.valueOf(deviceMap.get("is_multi_user")))){
                        if (String.valueOf(deviceMap.get("device_name")).contains("血糖")){
                            bindingCount="{\"1\":\"0\"}";
                        }
                        if (String.valueOf(deviceMap.get("device_name")).contains("血压")){
                            bindingCount="{\"1\":\"0\",\"2\":\"0\"}";
                        }
                    }
                    //String updateDeviceSql = ;
                    deviceSqlList.add("UPDATE device.wlyy_devices SET binding_count='"+bindingCount +"' where device_code='"+String.valueOf(deviceMap.get("device_code"))+"'");
                }
                //String updateDeviceSql = ;
                deviceSqlList.add("UPDATE device.wlyy_devices SET binding_count='"+bindingCount +"' where device_code='"+String.valueOf(deviceMap.get("device_code"))+"'");
            }
            if (deviceSqlList.size()>0){
                String deviceStr[] = new String[deviceSqlList.size()];
@ -329,24 +339,28 @@ public class DataHandingService {
            //更新grant_org_code字段
            List<String> deviceNoCodeSqlList = new ArrayList<>();
            String orgCodeSql = "SELECT * FROM device.wlyy_devices WHERE grant_org_code IS NULL OR grant_org_code =''";
            String orgCodeSql = "SELECT * FROM device.wlyy_devices WHERE grant_org_code IS NULL OR grant_org_code ='' OR grant_org_code='null'";
            List<DeviceDetail> noOrgList = jdbcTemplate.query(orgCodeSql,new BeanPropertyRowMapper<>(DeviceDetail.class));
            if (noOrgList!=null && noOrgList.size()>0){
                for (DeviceDetail deviceDetail:noOrgList){
                    String orgCode = "";
                    if (deviceDetail.getOrgName().contains("嵩屿")){
                        orgCode = "3502050100";
                    }
                    if (deviceDetail.getOrgName().contains("石塘")){
                        orgCode = "3502050200";
                    }
                    if (deviceDetail.getOrgName().contains("东孚")){
                        orgCode = "3502050300";
                    }
                    if (deviceDetail.getOrgName().contains("新阳")){
                        orgCode = "3502050400";
                    if (!StringUtils.isEmpty(deviceDetail.getOrgName())){
                        if (deviceDetail.getOrgName().contains("嵩屿")){
                            orgCode = "3502050100";
                        }
                        if (deviceDetail.getOrgName().contains("石塘")){
                            orgCode = "3502050200";
                        }
                        if (deviceDetail.getOrgName().contains("东孚")){
                            orgCode = "3502050300";
                        }
                        if (deviceDetail.getOrgName().contains("新阳")){
                            orgCode = "3502050400";
                        }
                        if (org.apache.commons.lang3.StringUtils.isNotBlank(orgCode)){
                            deviceNoCodeSqlList.add("UPDATE device.wlyy_devices SET grant_org_code='"+orgCode+"' where id='"+deviceDetail.getId()+"'");
                        }
                    }
                    deviceNoCodeSqlList.add("UPDATE device.wlyy_devices SET grant_org_code='"+orgCode+"' where id='"+deviceDetail.getId()+"'");
                }
                if (deviceNoCodeSqlList.size()>0){
                    String deviceNoCodeStr[] = new String[deviceNoCodeSqlList.size()];
@ -364,7 +378,7 @@ public class DataHandingService {
    @Transactional(rollbackFor = Exception.class)
    public void updateDevice()throws Exception{
        //String patientDeviceSql = "SELECT pd.*,sf.admin_team_code,sf.hospital FROM wlyy_patient_device pd LEFT JOIN wlyy_sign_family sf ON pd.`user` = sf.patient where sf.`status`>0 GROUP BY pd.id";
        String patientDeviceSql = "SELECT pd.id,pd.device_id AS deviceId,pd.category_code categoryCode,pd.device_name deviceName,pd.device_sn deviceSn,pd.`user`,pd.user_type userType,pd.czrq,sf.admin_team_code,sf.hospital,sf.hospital_name orgName FROM wlyy_patient_device pd LEFT JOIN wlyy_sign_family sf ON pd.`user` = sf.patient where sf.`status`>0 GROUP BY pd.id";
        String patientDeviceSql = "SELECT pd.id,pd.device_id AS deviceId,pd.category_code categoryCode,pd.device_name deviceName,pd.device_sn deviceSn,pd.`user`,pd.user_type userType,pd.czrq FROM wlyy_patient_device pd where pd.category_code in(1,2) GROUP BY pd.id";
        List<Map<String,Object>> patientDeviceList = jdbcTemplate.queryForList(patientDeviceSql);
        String deviceSql = "SELECT * FROM device.wlyy_devices";
        List<DeviceDetail> deviceDetailList = jdbcTemplate.query(deviceSql,new BeanPropertyRowMapper<>(DeviceDetail.class));
@ -405,36 +419,64 @@ public class DataHandingService {
                if (deviceDetail.getDeviceCode().equals(deviceSn)){
                    i++;
                }
            }
            //判断wlyy_device里的bindCount是否正确 正确无需更新
            DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSn);
            int count = 0;
            if (deviceDetail!=null && org.apache.commons.lang3.StringUtils.isNotBlank(deviceDetail.getBindingCount())){
                JSONObject jsonObject = new JSONObject(deviceDetail.getBindingCount());
                Iterator iterator = jsonObject.keys();
                while(iterator.hasNext()) {
                    count += jsonObject.getInt((String) iterator.next());
                }
            }
            PatientDevice patientDevice = MapListUtils.convertMap2Bean(patientDeviceMap,PatientDevice.class);
            if (i==1){
                List<String> userTypeList = map.get(patientDevice.getDeviceSn());
                String bindCount = "";
                int size = userTypeList.size();
                if (size==1){
                    if (Integer.valueOf(patientDevice.getUserType())>0 && Integer.valueOf(patientDevice.getUserType())==1){
                        bindCount = "{\"1\":\"1\",\"2\":\"0\"}";
                    }else if (Integer.valueOf(patientDevice.getUserType())>0 && Integer.valueOf(patientDevice.getUserType())==2){
                        bindCount = "{\"1\":\"0\",\"2\":\"1\"}";
                    }else if (Integer.valueOf(patientDevice.getUserType())<0){
                        bindCount = "{\"1\":\"1\"}";
                    }
                }else if (size>1){
                    if (Integer.valueOf(patientDevice.getUserType())>0){
                        bindCount = "{\"1\":\"1\",\"2\":\"1\"}";
                    }else if (Integer.valueOf(patientDevice.getUserType())<0){
                        bindCount = "{\"1\":\"2\"}";
            if (count!=i){
                if (i==1){
                    List<String> userTypeList = map.get(patientDevice.getDeviceSn());
                    String bindCount = "";
                    int size = userTypeList.size();
                    if (size==1){
                        if (Integer.valueOf(patientDevice.getUserType())>0 && Integer.valueOf(patientDevice.getUserType())==1){
                            bindCount = "{\"1\":\"1\",\"2\":\"0\"}";
                        }else if (Integer.valueOf(patientDevice.getUserType())>0 && Integer.valueOf(patientDevice.getUserType())==2){
                            bindCount = "{\"1\":\"0\",\"2\":\"1\"}";
                        }else if (Integer.valueOf(patientDevice.getUserType())<0){
                            bindCount = "{\"1\":\"1\"}";
                        }
                    }else if (size>1){
                        if (Integer.valueOf(patientDevice.getUserType())>0){
                            bindCount = "{\"1\":\"1\",\"2\":\"1\"}";
                        }else if (Integer.valueOf(patientDevice.getUserType())<0){
                            bindCount = "{\"1\":\"2\"}";
                        }
                    }
                   /* String sql = "UPDATE device.wlyy_devices SET is_grant=1,grant_admin_team='"+String.valueOf(patientDeviceMap.get
                            ("admin_team_code"))+"',grant_org_code='"+String.valueOf(patientDeviceMap.get("hospital"))+"',is_binding="+size+",binding_count='"+bindCount
                            +"',grant_time='"+DateUtil.dateToStr(patientDevice.getCzrq(),"yyyy-MM-dd HH:mm:ss")+"',org_name='"+String.valueOf(patientDeviceMap.get("orgName"))+"' where device_code='"+patientDevice.getDeviceSn()+"'";
                    sqlList.add(sql);*/
                    String sql = "UPDATE device.wlyy_devices SET is_grant=1,is_binding="+size+",binding_count='"+bindCount
                            +"',grant_time='"+DateUtil.dateToStr(patientDevice.getCzrq(),"yyyy-MM-dd HH:mm:ss")+"' where device_code='"+patientDevice.getDeviceSn()+"'";
                    sqlList.add(sql);
                }
                String sql = "UPDATE device.wlyy_devices SET is_grant=1,grant_admin_team='"+String.valueOf(patientDeviceMap.get
                        ("admin_team_code"))+"',grant_org_code='"+String.valueOf(patientDeviceMap.get("hospital"))+"',is_binding="+size+",binding_count='"+bindCount
                        +"',grant_time='"+DateUtil.dateToStr(patientDevice.getCzrq(),"yyyy-MM-dd HH:mm:ss")+"',org_name='"+String.valueOf(patientDeviceMap.get("orgName"))+"' where device_code='"+patientDevice.getDeviceSn()+"'";
                sqlList.add(sql);
            }
            //如果wlyy_devices表里没有对应的数据 则增加一条。
            if (i==0){
                String bindCount = "";
                String user= String.valueOf(patientDeviceMap.get("user"));
                SignFamily signFamily = signFamilyDao.findByPatient(user);
                if (signFamily==null && signFamilyDao.findLastJySignByPatient(user,2)!=null){
                    signFamily = signFamilyDao.findLastJySignByPatient(user,2).get(0);
                }
                String adminTeam="";
                String orgName ="";
                String orCode ="";
                if (signFamily!=null){
                    adminTeam=String.valueOf(signFamily.getAdminTeamId());
                    orgName = signFamily.getHospitalName();
                    orCode = signFamily.getHospital();
                }
                if (Integer.valueOf(patientDevice.getUserType())>0 && Integer.valueOf(patientDevice.getUserType())==1){
                    bindCount = "{\"1\":\"1\",\"2\":\"0\"}";
                }else if (Integer.valueOf(patientDevice.getUserType())>0 && Integer.valueOf(patientDevice.getUserType())==2){
@ -442,12 +484,42 @@ public class DataHandingService {
                }else if (Integer.valueOf(patientDevice.getUserType())<0){
                    bindCount = "{\"1\":\"1\"}";
                }
                deviceDetailService.insertDevice(patientDevice,String.valueOf(patientDeviceMap.get("admin_team_code")),String.valueOf(patientDeviceMap.get("hospital_name")),String.valueOf(patientDeviceMap.get("hospital")),bindCount,1);
                deviceDetailService.insertDevice(patientDevice,adminTeam,orgName,orCode,bindCount,1);
            }
        }
        String[] sqlStr = new String[sqlList.size()];
        sqlStr = sqlList.toArray(sqlStr);
        jdbcTemplate.batchUpdate(sqlStr);
        //更新wlyy_device里的org_name grant_org_code grant_admin_team
        List<String> uSqlList = new ArrayList<>();
        //String noBindSql ="SELECT * FROM device.`wlyy_devices` WHERE (grant_admin_team IS NULL OR grant_admin_team ='' OR grant_admin_team='null' OR grant_org_code IS NULL OR grant_org_code='' OR grant_org_code='null' OR grant_org_code='' OR org_name IS NULL OR org_name= '' OR org_name='null')  AND is_binding>0";
        String noBindSql ="SELECT * FROM device.`wlyy_devices` WHERE (grant_admin_team IS NULL OR grant_admin_team ='' OR grant_admin_team='null' OR grant_org_code IS NULL OR grant_org_code='' OR grant_org_code='null' OR grant_org_code='')  AND is_binding>0";
        List<DeviceDetail> noBindDeviceList = jdbcTemplate.query(noBindSql,new BeanPropertyRowMapper<>(DeviceDetail.class));
        for (DeviceDetail deviceDetail: noBindDeviceList){
            for (Map<String,Object> map1:patientDeviceList){
                String deviceSn = String.valueOf(map1.get("deviceSn"));
                if (deviceDetail.getDeviceCode().equals(deviceSn)){
                    SignFamily signFamily = signFamilyDao.findByPatient(String.valueOf(map1.get("user")));
                    if (signFamily==null){
                        List<SignFamily> signFamilyList = signFamilyDao.findLastJySignByPatient(String.valueOf(map1.get("user")),2);
                        if (signFamilyList!=null && signFamilyList.size()>0){
                            signFamily = signFamilyDao.findLastJySignByPatient(String.valueOf(map1.get("user")),2).get(0);
                        }
                    }
                    if (signFamily!=null){
                        String sql = "UPDATE device.wlyy_devices SET is_grant=1,grant_admin_team='"+signFamily.getAdminTeamId()+"',grant_org_code='"+signFamily.getHospital()+"',is_binding=1 ,org_name='"+signFamily.getHospitalName()+"' where device_code='"+deviceSn+"'";
                        uSqlList.add(sql);
                    }
                }
            }
        }
        String[] uSqlStr = new String[uSqlList.size()];
        uSqlStr = uSqlList.toArray(uSqlStr);
        jdbcTemplate.batchUpdate(uSqlStr);
    }
    public void addPointOldDeviceBind()throws Exception{

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -302,9 +302,9 @@ public class DataHandlingController extends BaseController {
    public String updateDevice(){
        try {
            boolean flag = dataHandingService.updateDeviceDefalut();
            /*if (flag){
            if (flag){
                dataHandingService.updateDevice();
            }*/
            }
            return write(200,"清洗数据成功!");
        }catch (Exception e){
            e.printStackTrace();

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -1227,13 +1227,14 @@ public class DoctorConsultController extends WeixinBaseController {
        try {
            String doctorCode = getUID();
            Doctor doctor = doctorService.findDoctorByCode(doctorCode);
            Patient p = patientService.findByCode(patient);
            com.alibaba.fastjson.JSONObject content = new com.alibaba.fastjson.JSONObject();
            content.put("name",p.getName());
            content.put("patient",patient);
            content.put("photo",p.getPhoto());
            content.put("age",IdCardUtil.getAgeForIdcard(p.getIdcard()));
            content.put("sex",IdCardUtil.getSexForIdcard(p.getIdcard()));
            content.put("sex",IdCardUtil.getSexForIdcard_new(p.getIdcard()));
            SignFamily signFamily = signFamilyDao.findByPatient(patient);
            if(signFamily!=null){
                content.put("hospitalName",signFamily.getHospitalName());

+ 26 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/message/DoctorMessageController.java

@ -8,6 +8,7 @@ import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.specialist.SpecialistEvaluateSevice;
import com.yihu.wlyy.service.third.jkEduArticle.ThirdJkEduArticleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
@ -43,6 +44,8 @@ public class DoctorMessageController extends BaseController {
    private MessageDao messageDao;
    @Autowired
    private ThirdJkEduArticleService thirdJkEduArticleService;
    @Autowired
    private SpecialistEvaluateSevice specialistEvaluateSevice;
    @RequestMapping(value = "messages")
    @ResponseBody
@ -585,4 +588,27 @@ public class DoctorMessageController extends BaseController {
        }
    }
    @RequestMapping(value = "sendMessage", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("发送消息")
    public String sendMessage(@ApiParam(name = "message",value = "消息对象")
                              @RequestParam(value = "message")String message,
                              @ApiParam(name = "hospital",value = "医院code")
                              @RequestParam(value = "hospital")String hospital,
                              @ApiParam(name = "patient",value = "居民code")
                              @RequestParam(value = "patient")String patient) {
        try {
            com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(message);
            Message message1 = new Message();
            message1.setSender(object.getString("sender"));
            message1.setType(object.getInteger("type"));
            message1.setReceiver(object.getString("receiver"));
            return write(200, "获取消息成功!","data",specialistEvaluateSevice.sendMessage(message1,hospital,patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取消息失败!");
        }
    }
}

+ 62 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/HospitalServiceItemController.java

@ -0,0 +1,62 @@
package com.yihu.wlyy.web.doctor.specialist;/**
 * Created by nature of king on 2018/8/29.
 */
import com.yihu.wlyy.service.specialist.SpecialistHospitalItemService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author wangzhinan
 * @create 2018-08-29 1:58
 * @desc 机构服务项目
 **/
@RestController
@RequestMapping(value = "/doctor/specialist/hospitalServiceItem", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "专科医生-机构服务项目管理")
public class HospitalServiceItemController extends BaseController {
    @Autowired
    private SpecialistHospitalItemService specialistHospitalItemService;
    /**
     *根据医院code获取服务项目
     *
     * @param hospitals
     * @return
     */
    @RequestMapping(value = "/selectByHospital",method = RequestMethod.GET)
    @ApiOperation(value = "根据医院code获取服务项目")
    public String selectByHospital(@ApiParam(name = "hospitals", value = "医院code")@RequestParam(value = "hospitals")String hospitals){
        try {
            return write(200,"获取成功!","data",specialistHospitalItemService.selectByHospital(hospitals));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    /**
     * 根据机构id获取服务项目
     * @param ids
     * @return
     */
    @RequestMapping(value = "/selectByIds",method = RequestMethod.GET)
    @ApiOperation(value = "根据机构id获取服务项目")
    public String selectByIds(@ApiParam(name = "ids", value = "机构服务项目id")@RequestParam(value = "hospitals")String ids){
        try {
            return write(200,"获取成功!","data",specialistHospitalItemService.selectByIds(ids));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -226,7 +226,7 @@ public class SpecialistController extends WeixinBaseController {
                                      @ApiParam(name = "doctorcode", value = "协管医生") @RequestParam(required = false) String doctorcode
                                      ) throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId));
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId,labelcode,doctorcode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");

+ 10 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java

@ -72,16 +72,16 @@ public class PatientSpecialistController extends WeixinBaseController{
        }
    }
    @RequestMapping(value = "/agreeSpecialistTeam", method = RequestMethod.GET)
    @ApiOperation(value = "医生审核")
    public String agreeSpecialistTeam(String state,String relationCode,String remark,Long mesId)throws Exception {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
//    @RequestMapping(value = "/agreeSpecialistTeam", method = RequestMethod.GET)
//    @ApiOperation(value = "医生审核")
//    public String agreeSpecialistTeam(String state,String relationCode,String remark,Long mesId)throws Exception {
//        try {
//            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId, labelcode, doctorcode));
//        } catch (Exception e) {
//            error(e);
//            return error(-1, "请求失败");
//        }
//    }
    @RequestMapping(value = "/findPatientTeamList", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民所有专科医生签约信息")

+ 88 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/SpecialistEvaluateController.java

@ -0,0 +1,88 @@
package com.yihu.wlyy.web.patient.specialist;/**
 * Created by nature of king on 2018/8/28.
 */
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.specialist.SpecialistEvaluateSevice;
import com.yihu.wlyy.web.WeixinBaseController;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * @author wangzhinan
 * @create 2018-08-28 9:34
 * @desc 评价
 **/
@RestController
@RequestMapping(value = "/patient/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-评价管理")
public class SpecialistEvaluateController extends WeixinBaseController {
    @Autowired
    private SpecialistEvaluateSevice specialistEvaluateSevice;
    /**
     * 服务项目评价添加
     * @param evaluates
     * @return
     */
    @RequestMapping(value = "/createEvaluate",method = RequestMethod.POST)
    @ApiOperation("服务项目评价添加")
    public String insert(@ApiParam(name = "evaluates",value = "服务项目评价")
                             @RequestParam(name = "evaluates")String evaluates){
        try {
            JSONObject object = JSONObject.parseObject(evaluates);
            object.put("patient",getUID());
            return write(200,"提交成功","data",specialistEvaluateSevice.insert(object));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     * 更新服务项目评价
     * @param evaluates
     * @return
     */
    @RequestMapping(value = "/updateEvaluate",method = RequestMethod.POST)
    @ApiOperation("更新服务项目评价")
    public String update(@ApiParam(name = "evaluates",value = "服务项目评价")
                             @RequestParam(name = "evaluates")String evaluates){
        try {
            JSONObject object = JSONObject.parseObject(evaluates);
            object.put("patient",getUID());
            return write(200,"提交成功","data",specialistEvaluateSevice.update(object));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
    /**
     *  获取服务项目评价
     * @param evaluate
     * @return
     */
    @RequestMapping(value = "/selectEvaluate",method = RequestMethod.POST)
    @ApiOperation("获取服务项目评价")
    public String select(@ApiParam(name = "evaluate",value = "服务项目评价")
                         @RequestParam(name = "evaluate")String evaluate){
        try {
            JSONObject object = JSONObject.parseObject(evaluate);
            object.put("patient",getUID());
            return write(200,"提交成功","data",specialistEvaluateSevice.select(object));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());
        }
    }
}

+ 12 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -517,6 +517,11 @@ public class EsStatisticsController extends BaseController {
                    if ("13".equals(idx)) {
                        idx = "1";
                    }
                    //20指标一个键绑定一条数据 2018年开始所以改用86指标. 2018-08-27 zd
                    String thisYear = Constant.getNowYearByDate(endDate);
                    if ("20".equals(idx) && Integer.valueOf(thisYear)>=2018){
                        idx="86";
                    }
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode, year,SaveModel.timeLevel_DDL);
                    result.put("index_" + idx, json);
                }
@ -531,7 +536,7 @@ public class EsStatisticsController extends BaseController {
    }
    /**
     * 指标截止日期累积量 到达量
     * 指标截止日期累积量 到达量.
     *
     * @param date
     * @param area
@ -592,7 +597,8 @@ public class EsStatisticsController extends BaseController {
                    } else if (idx.equals("72")) {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalOnlineTeamLeader(date, area, level, idx, sort, lowLevel, year, ""));
                    }else if (idx.equals("20") && Integer.valueOf(year)>=2018){
                        result.put("index_" + idx, statisticsESService.getDeviceLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                        //20指标是一个键绑定一条数据 所以2018年开始使用86指标 2018-08-27 zd
                        result.put("index_" + idx, statisticsESService.getDeviceLowLevelTotal(date, area, level, "86", sort, lowLevel, year));
                    }else {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                    }
@ -659,7 +665,10 @@ public class EsStatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                Long total = statisticsESService.getIndexTotal(endDate, area, level, idx, "2");
                if ("20".equals(idx) && Integer.valueOf(year)>=2018){
                    idx = "86";
                }
                Long total=statisticsESService.getIndexTotal(endDate, area, level, idx, "2");
                result.put("index_" + idx, total);
            }

+ 134 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/specialist/ThirdRehabilitationPlanController.java

@ -0,0 +1,134 @@
package com.yihu.wlyy.web.third.specialist;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.specialist.RehabilitationPlanService;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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.RestController;
/**
 * Created by humingfen on 2018/8/22.
 */
@RestController
@RequestMapping(value = "/third/rehabilitaionPlan",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "康复服务套餐管理")
public class ThirdRehabilitationPlanController extends BaseController {
    @Autowired
    private RehabilitationPlanService rehabilitationPlanService;
    @Autowired
    private AdminTeamService teamService;
    @Autowired
    private DoctorService doctorService;
    @Autowired
    private FamilyService familyService;
    @RequestMapping(value = "/findTemplateList", method = RequestMethod.GET)
    @ApiOperation(value = "获取康复服务套餐模板列表")
    public String templateList(@ApiParam(name = "patient", value = "居民标识")
                                   @RequestParam(required = false)String patient){
        try {
            Long adminTeamId = null;
            if(StringUtils.isNotBlank(patient)) {
                SignFamily signFamily = familyService.findByPatientAndDoctor(patient, getUID());
                adminTeamId = signFamily.getAdminTeamId();
            }else {
                AdminTeam team = teamService.findByLeaderCode(getUID());
                adminTeamId = team.getId();
            }
            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateInfo(adminTeamId));
//            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateInfo((long) 646));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findTemplateDetail", method = RequestMethod.GET)
    @ApiOperation(value = "获取康复服务套餐模板明细")
    public String findTemplateDetail(@ApiParam(name = "templateId", value = "模板id")
                                         @RequestParam(required = true)String templateId){
        try {
            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateDetailInfo(templateId));
//            return write(200, "获取成功", "data", rehabilitationPlanService.findTemplateInfo((long) 646));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/createTemplate", method = RequestMethod.POST)
    @ApiOperation(value = "创建康复服务套餐模板")
    public String createTemplate(@ApiParam(name = "title", value = "康复服务模板名称")
                                 @RequestParam(required = true) String title){
        try {
            AdminTeam team = teamService.findByLeaderCode(getUID());
            Doctor doctor = doctorService.findDoctorByCode(getUID());
            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplate(title,doctor,team.getId()));
//            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
//            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplate(title,doctor,(long) 646));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/createTemplateDetail", method = RequestMethod.POST)
    @ApiOperation(value = "创建康复服务套餐模板明细")
    public String createTemplateDetail(@ApiParam(name = "json", value = "康复服务模板明细")
                                 @RequestParam(required = true) String json,
                                       @ApiParam(name = "type", value = "create或者edit")
                                       @RequestParam(required = true) String type){
        try {
//            Doctor doctor = doctorService.findDoctorByCode(getUID());
//            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplate(title,doctor,team.getId()));
            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
            return write(200, "获取成功", "data", rehabilitationPlanService.createTemplateDetail(json,type,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findServiceItemsByHospital", method = RequestMethod.GET)
    @ApiOperation(value = "根据机构查找服务项目列表")
    public String findServiceItemsByHospital(@ApiParam(name = "patient", value = "居民标识")
                                                 @RequestParam(required = true)String patient){
        try {
//            Doctor doctor = doctorService.findDoctorByCode(getUID());
            SignFamily signFamily = familyService.findByPatientAndDoctor(patient, getUID());
            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
            return write(200, "获取成功", "data", rehabilitationPlanService.findServiceItemsByHospital(signFamily,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/createRehabilitationPlan", method = RequestMethod.POST)
    @ApiOperation(value = "创建居民康复计划")
    public String createRehabilitationPlan(@ApiParam(name = "json", value = "康复计划json")
                                 @RequestParam(required = true) String json){
        try {
//            Doctor doctor = doctorService.findDoctorByCode(getUID());
            Doctor doctor = doctorService.findDoctorByCode("0272469a6dcf11e69f7c005056850d66");
            return write(200, "获取成功", "data", rehabilitationPlanService.createRehabilitationPlan(json,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java

@ -1,10 +1,12 @@
package com.yihu.wlyy.web.third.zysoft;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.SMS;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientReservation;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.SMSDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
@ -80,6 +82,9 @@ public class BookingController extends WeixinBaseController {
    
    @Autowired
    private StringRedisTemplate redisTemplate;
    
    @Autowired
    private DoctorDao doctorDao;
    /**
@ -608,6 +613,24 @@ public class BookingController extends WeixinBaseController {
                                      @ApiParam(name="surveyCode",value = "筛选code",defaultValue = "a")
                                      @RequestParam(value = "surveyCode",required = false)String surveyCode) {
        try {
            
            String currentdoctorid = getUID();
            //获取当前登录的医生CODE,判断接口传递的代预约医生CODE是否一致
            if(StringUtils.isBlank(currentdoctorid) || !currentdoctorid.equals(dcode)){
                return error(-1, "创建挂号单失败10001:当前登录医生和代预约医生不一致!");
            }
    
            //判断接口传入的代预约医生CODE是否为空
            if(StringUtils.isBlank(dcode)){
                return error(-1, "创建挂号单失败10002:代预约医生不能为空!");
            }
    
            //判断接口传入的代预约医生CODE查询代预约医生是否存在
            Doctor doctor = doctorDao.findByCode(dcode);
            if(doctor == null || StringUtils.isBlank(doctor.getCode())){
                return error(-1, "创建挂号单失败:代预约的医生不存在!");
            }
            
            String orderCode = guahaoXM.CreateOrderByDoctor(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode,surveyCode);
            //获取预约信息查询是否挂号成功
            PatientReservation obj = patientReservationService.findByCode(orderCode);

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -883,8 +883,8 @@ public class WeiXinEventProcess {
        Map<String, String> articleConsult = new HashMap<>();
        articleConsult.put("Url", url);
        articleConsult.put("Title", "您有一个开通专科服务的邀请,点击查看");
        articleConsult.put("Description", "家庭医生协助专科医生团队为您提供专项服务");
        articleConsult.put("Title", "您正在申请开通专科服务,点击查看");
        articleConsult.put("Description", "共同为您提供健康管理保障");
        articleConsult.put("PicUrl", imgWebapp.getSpecialist_sign_url());
        articles.add(articleConsult);

+ 39 - 1
patient-co/patient-co-wlyy/src/main/resources/application-dev.yml

@ -97,6 +97,43 @@ wechat:
   template_patient_bind_device: 1GWPw6LFcSuz2LFTo6LhE-YY8abtmcKRvor1fUzfxBE
    #积分到账通知
   template_healthbank_credit: A2L6WBm1p6bDPYGkGnUmoMvpWlRruP2lapYwHfLV7Rg
  imgUrl:
    #居民wifi图片地址
    patient_wifi_pic_url: group1/M00/00/B0/Cl8WjVtgHqaAcNKWAABYgyiykZs906.png
    #居民抽奖图片地址
    patient_draw_pic_url: group1/M00/00/B0/Cl8WjVtgGbWAYqumAADhRnoXe38057.png
    #专科医生签约图片地址
    specialist_sign_url: group1/M00/00/AE/Cl8WjFtgHZqAHpknAAH7mgUpbH0162.png
    #健康金图片地址
    doctor_activity_url: group1/M00/00/B0/Cl8WjVtgGbWAUJixAAAde0sVAJk652.png
    #通用活动图片地址
    currency_url: group1/M00/00/B0/Cl8WjVtgGbWAfZI4AAD7PWeBzLo954.png
    #就诊记录
    patient_visit_pic: group1/M00/00/AE/Cl8WjFtgIK-AAhmHAAEML2dpBxA906.png
    #检查检验
    patient_inspect_pic: group1/M00/00/B0/Cl8WjVtgGy6AAs61AAAxJl28nU8047.png
    #社区体检
    patient_examination_pic: group1/M00/00/B0/Cl8WjVtgGbWAVj77AAAg8pVTY9s660.png
    #处方记录
    patient_prescription_pic: group1/M00/00/AE/Cl8WjFtgHZqAXPgzAAAyHL8RzEU114.png
    #居民取药码
    patient_QRCode_pic: group1/M00/00/B0/Cl8WjVtgG4WAC7JDAAAV7lNAUpY772.png
    #居民产检计划
    patient_prenata_pic: group1/M00/00/AE/Cl8WjFtgHZqAVhwaAACK6PRmuEE754.png
    #居民免疫计划
    patient_immune_pic: group1/M00/00/B0/Cl8WjVtgG4WANg5iAAAckaOvfLQ582.png
    #医生咨询操作指南
    patient_operatinginstrutions_pic_url: group1/M00/00/B0/Cl8WjVtgG4WALvB0AAFkoQR6sbI214.png
    #预约挂号
    patient_booking_pic_url: group1/M00/00/AE/Cl8WjFtgG8qAc0LRAAAh07_OGxo533.png
    #设备绑定
    patient_device_pic_url: group1/M00/00/AE/Cl8WjFtgG8qANy56AAArKMof5DE911.png
    #我的家庭
    patient_family_pic_url: group1/M00/00/AE/Cl8WjFtgHZmAb043AAA5I5LejjI793.png
    #续签
    patient_sign_again_pic_url: group1/M00/00/B0/Cl8WjVtgG4WAV-8SAAAc2gFIWBc275.png
    #家庭医生签约1+1+N
    doctor_qrcode_pic_url: group1/M00/00/AE/Cl8WjFtgJGaAZ1VyAAD3GkV403w850.png
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
@ -184,4 +221,5 @@ ylz:
juye:
  url: http://api.zayata.com/index.php?s=/Company/Device/
  token: YTgzYjc2YWIzZjdjOTA1MTE0ODY2YjcyOGNkYWFmZWR6YXlhdGFjb21wYW55
  companyCode: 86350206000000001
  companyCode: 86350206000000001
  companySecret: ODZhZjg1OWM4YTQyMDNkMWU5MDkxNjE0YmRhODI5YmU=

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -226,4 +226,5 @@ ylz:
#药盒请求巨烨的域名以及巨烨给予的公司编号
juye:
  url: http://zayata.oicp.net:30080/index.php?s=/Company/Device/
  companyCode: 86350206000000001
  companyCode: 86350206000000001
  companySecret: ODZhZjg1OWM4YTQyMDNkMWU5MDkxNjE0YmRhODI5YmU=

+ 3 - 2
patient-co/patient-co-wlyy/src/main/resources/application-prod.yml

@ -225,7 +225,8 @@ ylz:
  gateway:
    url: http://120.42.37.94:1301/ehc-empi-web/gateway
#药盒请求巨烨的域名以及巨烨给予的公司编号
# 药盒请求巨烨的域名以及巨烨给予的公司编号
juye:
  url: http://api.zayata.com/index.php?s=/Company/Device/
  companyCode: 86350206000000001
  companyCode: 86350206000000001
  companySecret: ODZhZjg1OWM4YTQyMDNkMWU5MDkxNjE0YmRhODI5YmU=

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-test.yml

@ -211,4 +211,5 @@ ylz:
    url: http://www.mstpay.com:1300/huangsb
juye:
  url: http://zayata.oicp.net:30080/index.php?s=/Company/Device/
  companyCode: 86350206000000001
  companyCode: 86350206000000001
  companySecret: ODZhZjg1OWM4YTQyMDNkMWU5MDkxNjE0YmRhODI5YmU=