Browse Source

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

liuwenbin 7 years ago
parent
commit
4abfca2c79
33 changed files with 548 additions and 968 deletions
  1. 0 362
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/notification/WeChatController.java
  2. 126 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/notification/WechatTemplateController.java
  3. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/wechat/WeixinTemplate.java
  4. 1 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/wechat/WechatTemplateConfigDao.java
  5. 18 15
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/DeviceHealthIndexService.java
  6. 0 509
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/wechat/WeChatService.java
  7. 92 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/wechat/WechatTemplateService.java
  8. 3 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/main.jsp
  9. 1 1
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_edit.jsp
  10. 1 1
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_list.jsp
  11. 2 1
      patient-co-manage/wlyy-manage/src/main/webapp/static/develop/lib/plugin/validate/jValidate.js
  12. 1 0
      patient-co-manage/wlyy-manage/src/main/webapp/static/js/menu.js
  13. 1 1
      patient-co/patient-co-figure-label/pom.xml
  14. 32 0
      patient-co/patient-co-figure-label/sql/label_es_sql
  15. 2 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java
  16. 2 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java
  17. 2 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java
  18. 2 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java
  19. 43 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.java
  20. 35 5
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  21. 17 1
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/SaveModel.java
  22. 7 7
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java
  23. 12 4
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java
  24. 46 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MD5Util.java
  25. 40 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeModelIDUtil.java
  26. 26 23
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceService.java
  27. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  28. 17 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java
  29. 5 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  30. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  31. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PyhsicExamRemindController.java
  32. 2 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  33. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java

+ 0 - 362
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/notification/WeChatController.java

@ -1,362 +0,0 @@
package com.yihu.wlyy.controller.manager.notification;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.WlyyAuditNotice;
import com.yihu.wlyy.entity.WlyyAuditNoticeScope;
import com.yihu.wlyy.entity.WlyyUserRole;
import com.yihu.wlyy.service.manager.notification.WlyyAuditNoticeScopeService;
import com.yihu.wlyy.service.manager.notification.WlyyAuditNoticeService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
 * Created by yww on 2017/1/22.
 */
@Controller
@RequestMapping("/admin/notification")
public class NotificationController extends BaseController {
    @Autowired
    private WlyyAuditNoticeService wlyyAuditNoticeService;
    @Autowired
    private WlyyAuditNoticeScopeService wlyyAuditNoticeScopeService;
    @Autowired
    private WlyyUserRoleService wlyyUserRoleService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String notificationListInitial(Model model) {
        User currentUser = (User) request.getSession().getAttribute("current_user");
        model.addAttribute("isAuditor", wlyyAuditNoticeService.isAuditor(currentUser));
        return "notification/notification_list";
    }
    //跳转消息通知详情页
    @RequestMapping(value = "view", method = RequestMethod.GET)
    @ApiIgnore
    public String notificationView(Model model, @RequestParam(value = "id", required = true) Long id, String mode) {
        User currentUser = (User) request.getSession().getAttribute("current_user");
        WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
        WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeService.findByNoticeId(id);
        model.addAttribute("notice", notice);
        model.addAttribute("noticeId", notice.getId());
        model.addAttribute("title", notice.getTitle());
        model.addAttribute("status", notice.getStatus());
        model.addAttribute("time", notice.getSendTime());
        model.addAttribute("scope", notice.getConditionDescription());
        model.addAttribute("content", notice.getContent());
        model.addAttribute("totalCount", "总共 " + notice.getTotalCount() + " 人");
        model.addAttribute("isAuditor", wlyyAuditNoticeService.isAuditor(currentUser));
        model.addAttribute("isOwned", false);//页面判断用于显示操作按钮
        if (StringUtils.equals(notice.getApplyUserId(), currentUser.getCode())) {
            model.addAttribute("isOwned", true);
        }
        if (noticeScope != null) {
            if (!StringUtils.isEmpty(noticeScope.getServerTypeContent())) {
                model.addAttribute("serverTypeContent", noticeScope.getServerTypeContent());
            }
            if (!StringUtils.isEmpty(noticeScope.getHealthSituationContent())) {
                model.addAttribute("healthSituationContent", noticeScope.getHealthSituationContent());
            }
            if (!StringUtils.isEmpty(noticeScope.getDiseaseTypeContent())) {
                model.addAttribute("diseaseTypeContent", noticeScope.getDiseaseTypeContent());
            }
        }
        model.addAttribute("mode",mode);
        return "notification/notification_view";
    }
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    public String searchNotificationList(
            @ApiParam(name = "searchNm", value = "标题/提交人名")
            @RequestParam(value = "searchNm", required = false) String searchNm,
            @ApiParam(name = "status", value = "状态")
            @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "page")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int pageSize) {
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            Page<WlyyAuditNotice> notices = wlyyAuditNoticeService.searchList(searchNm, status, currentUser, page, pageSize);
            return write(200, "操作成功", page, pageSize, notices);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    //页面跳转(详情页面)
    @RequestMapping(value ="infoInit/{id}",method = RequestMethod.GET)
    public String infoInit(@PathVariable("id") Long id, String mode){
        if(id==0){
            request.setAttribute("UUID", UUID.randomUUID().toString().replace("-", ""));
        }
        User currentUser = (User) request.getSession().getAttribute("current_user");
        //范围权限
        String city = "350200";
        String cityAuthority = "0";
        String areaAuthority = "0";
        String communityAuthority = "0";
        List<Map<String, String>> roleMap = (List<Map<String, String>>)request.getSession().getAttribute("roleMap");
        if(roleMap.size()>0){//管理员
            for (Map<String, String> map : roleMap){
                String code = map.get("code");
                if(city.equals(code)){
                    cityAuthority = "1";
                    areaAuthority = "1";
                    communityAuthority = "1";
                }else if(code.length()==6){
                    areaAuthority = "1";
                    communityAuthority = "1";
                }else {
                    communityAuthority = "1";
                }
            }
        }else{
            //社区医生
            communityAuthority = "2";
        }
        request.setAttribute("cityAuthority", cityAuthority);
        request.setAttribute("areaAuthority", areaAuthority);
        request.setAttribute("communityAuthority", communityAuthority);
        request.setAttribute("id", id);
        request.setAttribute("mode",mode);
        request.setAttribute("isAuditor", wlyyAuditNoticeService.isAuditor(currentUser));
        return "notification/notification_edit";
    }
    //根据id获取单个
    @RequestMapping(value = "notice")
    @ResponseBody
    public String getNotice(@RequestParam(value = "id") Long id){
        try {
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeService.findByNoticeId(id);
            JSONObject json = new JSONObject();
            json.put("noticeId",notice.getId());
            json.put("title",notice.getTitle());
            json.put("content",notice.getContent());
            json.put("sendTime",notice.getSendTime());
            json.put("sendType",notice.getSendType());
            json.put("scope",noticeScope.getScope());
            json.put("scopeId",noticeScope.getScopeId());
            json.put("condition",noticeScope.getCondition());
            json.put("diseaseTypeId",noticeScope.getDiseaseTypeId());
            json.put("healthSituationId",noticeScope.getHealthSituationId());
            json.put("serverTypeId",noticeScope.getServerTypeId());
            return write(200,"操作成功!","data",json);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 是否有有审核权限
     * @return
     */
    @RequestMapping(value = "isNoticeAuditor")
    @ResponseBody
    public String isNoticeAuditor(){
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            boolean flag = wlyyAuditNoticeService.isNoticeAuditor(currentUser.getCode(),String.valueOf(currentUser.getOrganizationId()));
            if(flag){
                return write(200,"有权限!","authority","1");
            }
            return write(200,"没权限!","authority","0");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //新增
    @RequestMapping(value = "create")
    @ResponseBody
    public String createNotice(String jsonData) {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Map<String,String> map = objectMapper.readValue(jsonData, Map.class);
            User currentUser = (User) request.getSession().getAttribute("current_user");
            wlyyAuditNoticeService.create(map, currentUser);
            return success("新增成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "新增失败!");
        }
    }
    /**
     * 提交
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "submit")
    @ResponseBody
    public String submit(
            @RequestParam(value = "id", required = true) Long id) {
        try {
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //判断是否为审核者(审核者只能看到非本人的待审核通知,看不到待提交通知)
            if (!StringUtils.equals("1", notice.getStatus())) {
                return error(-1, "提交状态的消息通知才能进行提交操作!");
            }
            boolean res = wlyyAuditNoticeService.isAuditor(currentUser);
            if (res) {
                //审核者自己的消息通知,直接通过+发信息+保存发送对象信息
                wlyyAuditNoticeService.approve(id, notice, currentUser);
                return write(200, "操作成功");
            } else {
                notice.setStatus("2");
                wlyyAuditNoticeService.save(notice);
                return write(200, "操作成功");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    /**
     * 撤回
     * @param id
     * @return
     */
    @RequestMapping(value = "revoke")
    @ResponseBody
    public String revoke(
            @RequestParam(value = "id", required = true) Long id){
        try {
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if("2".equals(notice.getStatus())){//待审核
                notice.setStatus("6");//撤回
                wlyyAuditNoticeService.save(notice);
            }else{
                return error(-1, "撤回失败,只有待审核才能撤回!");
            }
            return success("撤回成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "撤回失败!");
        }
    }
    //修改
    @RequestMapping(value = "update")
    @ResponseBody
    public String updateNotice(String jsonData){
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            Map<String,String> map = objectMapper.readValue(jsonData, Map.class);
            User currentUser = (User) request.getSession().getAttribute("current_user");
            wlyyAuditNoticeService.updateNotice(map, currentUser);
            return success("修改成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "修改失败!");
        }
    }
    //删除
    @RequestMapping(value = "delete")
    @ResponseBody
    public String deleteNotification(long id) {
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //是本人的消息通知才能删除
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if (notice == null) {
                return error(-1, "id有误!");
            }
            if (!StringUtils.equals(notice.getApplyUserId(), currentUser.getCode())) {
                return error(-1, "非本人的消息通知,没有权限删除!");
            }
            wlyyAuditNoticeService.deleteNotice(id);
            return write(200, "操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    //审核通过
    @RequestMapping(value = "approve")
    @ResponseBody
    public String approve(long id) {
        try {
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //验证消息通知为待审核
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if (notice == null) {
                return error(-1, "提供的id有误!");
            }
            if (!StringUtils.equals("2", notice.getStatus())) {
                return error(-1, "消息状态不符,待审核状态才能进行审核操作!");
            }
            String auditorCode = currentUser.getCode();
            String noticeHospital = notice.getApplyUserHospital();
            if (StringUtils.isEmpty(noticeHospital)) {
                return error(-1, "消息通知机构信息有误,为空值!");
            }
            //审核权限验证(审核者的下辖机构有此消息通知编辑者所属机构)
            boolean res = wlyyAuditNoticeService.isNoticeAuditor(auditorCode, noticeHospital);
            wlyyAuditNoticeService.approve(id, notice, currentUser);
            return write(200, "操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "refuse")
    @ResponseBody
    public String refuse(
            @RequestParam(value = "id", required = true) Long id) {
        try {
            if (id == null) {
                return error(-1, "id不能为空!");
            }
            User currentUser = (User) request.getSession().getAttribute("current_user");
            //是本人的消息通知才能删除
            WlyyAuditNotice notice = wlyyAuditNoticeService.retrieve(id);
            if (notice == null) {
                return error(-1, "id有误!");
            }
            notice.setStatus("5");
            wlyyAuditNoticeService.save(notice);
            return write(200, "操作成功!");
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

+ 126 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/notification/WechatTemplateController.java

@ -0,0 +1,126 @@
package com.yihu.wlyy.controller.manager.notification;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.entity.User;
import com.yihu.wlyy.entity.WlyyAuditNotice;
import com.yihu.wlyy.entity.WlyyAuditNoticeScope;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.service.manager.notification.WlyyAuditNoticeScopeService;
import com.yihu.wlyy.service.manager.notification.WlyyAuditNoticeService;
import com.yihu.wlyy.service.manager.wechat.WechatTemplateService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
import com.yihu.wlyy.service.wechat.WechatService;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @Description: 微信模板管理
* @Author: WuJunjie
* @Date: Created in 2018/3/20 9:07
*/
@Controller
@RequestMapping("/admin/wechatTemplate")
public class WechatTemplateController extends BaseController {
    @Autowired
    private WechatTemplateService wechatTemplateService;
    @Autowired
    private WlyyAuditNoticeScopeService wlyyAuditNoticeScopeService;
    @Autowired
    private WlyyUserRoleService wlyyUserRoleService;
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String notificationListInitial(Model model) {
        return "wechat/wechat_list";
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息
     * @param templateName
     * @param scene
     * @param page
     * @param pageSize
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "list", method = RequestMethod.POST)
    @ResponseBody
    public String searchNotificationList(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene,
            @ApiParam(name = "page")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int pageSize) {
        try {
            Page<WechatTemplateConfig> templetes = wechatTemplateService.searchList(templateName, scene, page, pageSize);
            return write(200, "操作成功", page, pageSize, templetes);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "getTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String getTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene) {
        try {
            WechatTemplateConfig templete = wechatTemplateService.getTemplate(templateName, scene);
            return write(200, "操作成功", "data",templete);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
    /**
     * 新增或修改模板详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "updateTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String updateTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene) {
        try {
            return write(200, "操作成功", "data","");
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/wechat/WeixinTemplate.java

@ -12,7 +12,7 @@ import javax.persistence.Table;
 */
@Entity
@Table(name = "weixin_template")
public class WeixinTemplate  extends IdEntity {
public class WeixinTemplate extends IdEntity {
    private String accId;//'微信公众号原始ID'
    private String templateName;//'自定义模板名称'

+ 1 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/wechat/WechatTemplateConfigDao.java

@ -1,5 +1,4 @@
package com.yihu.wlyy.repository.wechat;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
@ -14,5 +13,5 @@ public interface WechatTemplateConfigDao extends PagingAndSortingRepository<Wech
    //根据自定义模板名称、场景值查询有效模板内容
    @Query("select t  from WechatTemplateConfig t where t.templateName=?1 and t.scene=?2 and t.status = 1 ")
    WechatTemplateConfig findByScene(String templateName,String scene);
    WechatTemplateConfig findByScene(String templateName, String scene);
}

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

@ -172,14 +172,26 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
        User loginUser = (User) request.getSession().getAttribute("userInfo");
        StringBuilder filter = new StringBuilder();
        String sql = "SELECT a.patient  FROM wlyy.wlyy_sign_family a, wlyy.wlyy_patient b WHERE a.status > 0 AND a.patient = b.code  ";
        //1、管理员  2、医生 0、其他
        if(loginUser.getType()==2){
            Doctor doctor = doctorDao.findByCode(loginUser.getCode());
            String[] codes =signFamilyDao.findByHospital(doctor.getHospital());
            if(codes != null && codes.length >0){
                filter.append("user="+StringUtils.join(codes, ","));
            if(doctor!=null &&StringUtils.isNotEmpty(doctor.getHospital())){
                sql += " AND a.hospital = '"+doctor.getHospital()+"' ";
            }
        }
        //根据患者名称过滤
        if(!StringUtils.isEmpty(userName)){
            sql +=" AND b.NAME LIKE '%"+userName+"%'";
        }
        //根据健管师或医生名称过滤
        if(!StringUtils.isEmpty(doctorName)){
            sql += " and (a.doctor_name like '%"+doctorName+"%' or a.doctor_health_name like '%"+doctorName+"%') ";
        }
        List<String> patientList = jdbcTemplate.queryForList(sql,String.class);
        if(!StringUtils.isEmpty(deviceSn)){
            filter.append("deviceSn="+deviceSn+";");
        }
@ -198,18 +210,9 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
            filter.append("czrq>=" + DateTimeUtil.utcDateTimeFormat(startTimeTemp)+ ";");
            filter.append("czrq<=" + DateTimeUtil.utcDateTimeFormat(endTimeTemp)+ ";");
        }
        if(!StringUtils.isEmpty(userName)){
            List<String> codes = patientDao.findByName(userName);
            if(codes != null && codes.size() >0){
                filter.append("user="+StringUtils.join(codes, ","));
            }
        }
        //根据医生名称过滤居民
        if(!StringUtils.isEmpty(doctorName)){
            String[] codes = signFamilyDao.findByDoctorName("%"+doctorName+"%");
            if(codes != null && codes.length >0){
                filter.append("user="+StringUtils.join(codes, ","));
            }
        if(patientList != null && patientList.size() >0){
            String temp = StringUtils.join(patientList, ",");
            filter.append("user="+temp+";");
        }
        if(!StringUtils.isEmpty(indexType)){

+ 0 - 509
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/wechat/WeChatService.java

@ -1,509 +0,0 @@
package com.yihu.wlyy.service.manager.notification;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.service.SMSService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyRoleService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.SQLQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
 * Created by Administrator on 2017/1/22.
 */
@Service
public class WlyyAuditNoticeService extends BaseJpaService<WlyyAuditNotice, WlyyAuditNoticeDao> {
    @Autowired
    private WlyyRoleDao wlyyRoleDao;
    @Autowired
    private WlyyRoleService roleService;
    @Autowired
    private WlyyUserRoleDao wlyyUserRoleDao;
    @Autowired
    private WlyyUserRoleService wlyyUserRoleService;
    @Autowired
    private WlyyAuditNoticeDao wlyyAuditNoticeDao;
    @Autowired
    private WlyyAuditNoticeScopeDao wlyyAuditNoticeScopeDao;
    @Autowired
    private WlyyAuditNoticeObjectDao wlyyAuditNoticeObjectDao;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SMSService smsService;
    /**
     * 新增消息
     * @param map
     * @param user
     */
    @Transactional
    public void create(Map<String,String> map,User user){
        String communityAuthority = map.get("communityAuthority");
        String scope = map.get("scope");// 0- 全市 1 - 指定区 2 - 指定社区
        String scopeId = map.get("scopeId");//范围明细ID,scope=1时为区ID串,2时为社区id串
        String scopeContent = map.get("scopeContent");//
        String city = map.get("city");
        String town = map.get("town");
        String community = map.get("community");
        String conditionDescription = map.get("conditionDescription");
        String conditionType = map.get("condition_type");//筛选条件:0-全部;1-根据条件
        String condition = map.get("condition");//0 - 全部居民   1 - 设置条件?  设置的条件类别:1:卫计委三大分组(服务类型) 2:健康状况 3:疾病类型
        String conditionId = map.get("conditionId");//0 - 全部居民   1 - 设置条件
        String serverTypeContent = map.get("serverTypeContent");
        String serverTypeId = map.get("serverTypeId");
        String healthSituationContent = map.get("healthSituationContent");
        String healthSituationId = map.get("healthSituationId");
        String diseaseTypeContent = map.get("diseaseTypeContent");
        String diseaseTypeId = map.get("diseaseTypeId");
        String sendType = map.get("sendType");
        String content = map.get("content");
        List<Patient> list = getSendPatients(conditionType, scope, city, town, community, serverTypeId, healthSituationId, diseaseTypeId);
        //需要审核的通知公告主表
        WlyyAuditNotice notice = new WlyyAuditNotice();
        notice.setApplyTime(new Date());
        notice.setApplyUserHospital(user.getOrganizationId()+"");
        notice.setApplyUserId(user.getCode());
        notice.setApplyUserName(user.getName());
        notice.setConditionDescription(conditionDescription);
        notice.setContent(content);
        String status = "";// 0 - 创建(瞬间状态) 1- 待提交  2 - 待审核 3 - 待发送 4 - 已发送  5 - 已拒绝 6 - 撤回(处于待审核时可修改为该状态)
        if("2".equals(communityAuthority)){
            //医生 需要审核
            status = "2";
        }else{
            //管理员 直接发送(设置状态,还未执行)
            status = "4";
            notice.setAuditTime(new Date());
            notice.setAuditUserId(user.getCode());
            notice.setAuditUserName(user.getName());
        }
        notice.setStatus(status);
//        notice.setApplyUserHospital(user.getOrganizationName());
        notice.setSendType(sendType);
        if("1".equals(sendType)){
            notice.setSendTime(DateUtil.strToDateLong(map.get("sendTime")+":00"));
        }
        notice.setTitle(map.get("title"));
        notice.setTotalCount(list.size());
        wlyyAuditNoticeDao.save(notice);
        //消息公告对象范围主表
        WlyyAuditNoticeScope noticeScope = new WlyyAuditNoticeScope();
        noticeScope.setNoticeId(notice.getId());
        noticeScope.setScope(scope);
        noticeScope.setScopeContent(scopeContent);
        noticeScope.setScopeId(scopeId);
//        noticeScope.setCondition(condition);
        noticeScope.setCondition(conditionType);
        noticeScope.setServerTypeId(serverTypeId);
        noticeScope.setServerTypeContent(serverTypeContent);
        noticeScope.setHealthSituationId(healthSituationId);
        noticeScope.setHealthSituationContent(healthSituationContent);
        noticeScope.setDiseaseTypeId(diseaseTypeId);
        noticeScope.setDiseaseTypeContent(diseaseTypeContent);
        noticeScope.setConditionDescription(conditionDescription);
        wlyyAuditNoticeScopeDao.save(noticeScope);
        //审核自身消息通知自己发短信操作(新线程)****************新线程发彩信
        if (isAuditor(user)) {
            sendMsgThread(list, notice);
        }
//        if("3".equals(status)){
//            saveNoticeObject(list,notice);
//        }
    }
    /**
     * 保存消息通知对象
     * @param list
     * @param notice
     */
//    private void saveNoticeObject(List<Patient> list,WlyyAuditNotice notice){
//        //需要审核的通知公告对象
//        WlyyAuditNoticeObject noticeObject = null;
//        List<WlyyAuditNoticeObject> objectList = new ArrayList<>();
//        String mobiles = "";
//        int i = 0;
//        for (Patient p:list){
//            noticeObject = new WlyyAuditNoticeObject();
//            noticeObject.setNoticeId(notice.getId());
//            noticeObject.setToUserId(p.getCode());
//            noticeObject.setToUserTel(p.getMobile());
//            noticeObject.setContent(notice.getContent());
//            //TODO 每次条用发送短信接口,根据返回信息对应更新状态,保存数据(若被中断时?)
//            //smsService.sendMsg(mobiles,content);//判断返回值,设置发送状态--立即发送时
//
//            noticeObject.setStatus(notice.getStatus());//?未发送
//            noticeObject.setSendTime(new Date());
//            noticeObject.setInsertTime(new Date());
//            objectList.add(noticeObject);
//
//            i++;
//            mobiles += p.getMobile()+",";
//            if(i%901==0){//900条发一次
//                mobiles = mobiles.substring(0,mobiles.length()-1);
//                //smsService.sendMsg(mobiles,content);
//                System.out.println("i="+i+"---mobile="+mobiles);
//                mobiles = "";
//            }else if(i==list.size()){
//                mobiles = mobiles.substring(0,mobiles.length()-1);
//                //smsService.sendMsg(mobiles,content);
//                System.out.println("i="+i+"---mobile="+mobiles);
//                mobiles = "";
//            }
//        }
//
//        if(objectList.size()>0){
//            wlyyAuditNoticeObjectDao.save(objectList);
//        }
//    }
    /**
     * 按条件查询居民
     * @param conditionType
     * @param scope
     * @param city
     * @param town
     * @param community
     * @param serverTypeId
     * @param healthSituationId
     * @param diseaseTypeId
     * @return
     */
    public List<Patient> getSendPatients(String conditionType,String scope,String city,String town,String community,String serverTypeId,String healthSituationId,String diseaseTypeId){
        List<Patient> list = null;
        String sql = "";
        //根据发送范围,筛选条件过滤出居民
        if("0".equals(conditionType)){//筛选条件分支:全部居民
            if("0".equals(scope)){
                list = patientDao.findByCity(city);//全市全部居民
            }else if("1".equals(scope)){
                String towns[] = town.split(",");
                list = patientDao.findByCityAndTowns(city,towns);//指定区全部居民
            }else if("2".equals(scope)){
                String communitys[] = community.split(",");
                list = patientDao.findByCityAndHospital(city,communitys);//指定社区全部居民
            }
        }else if ("1".equals(conditionType)){//筛选条件分支:按条件(服务类型、健康状况、疾病类型)
            //筛选条件
            String conditionSql = "";
            if(!StringUtils.isEmpty(serverTypeId)){
                conditionSql += " (s.label_type=1 and s.label in ("+serverTypeId+")) ";
                String[] serverTypeIds = serverTypeId.split(",");
            }
            if(!StringUtils.isEmpty(healthSituationId)){
                if(StringUtils.isEmpty(conditionSql)){
                    conditionSql += " (s.label_type=2 and s.label in ("+healthSituationId+"))";
                }else {
                    conditionSql += " or (s.label_type=2 and s.label in ("+healthSituationId+"))";
                }
                String[] healthSituationIds = healthSituationId.split(",");
            }
            if(!StringUtils.isEmpty(diseaseTypeId)){
                if(StringUtils.isEmpty(conditionSql)){
                    conditionSql += " (s.label_type=3 and s.label in ("+diseaseTypeId+")) ";
                }else {
                    conditionSql += " or (s.label_type=3 and s.label in ("+diseaseTypeId+")) ";
                }
                String[] diseaseTypeIds = diseaseTypeId.split(",");
            }
            //-------------发送范围
            if("0".equals(scope)){
                sql += "SELECT DISTINCT p.* from wlyy_patient p " +
                        " WHERE p.city=350200 and p.mobile is not null and p.mobile!='' and p.code in(select DISTINCT s.patient " +
                        " from wlyy_sign_patient_label_info s " +
                        " where "+conditionSql+")";
                SQLQuery sqlQuery = currentSession().createSQLQuery(sql).addEntity(Patient.class);
                list = sqlQuery.list();
            }else if("1".equals(scope)){
                sql += "SELECT DISTINCT p.* from wlyy_patient p " +
                        " WHERE p.city=350200 and p.town in ("+town+") and p.mobile is not null and p.mobile!='' and p.code in(select DISTINCT s.patient " +
                        " from wlyy_sign_patient_label_info s " +
                        " where "+conditionSql+")";
                SQLQuery sqlQuery = currentSession().createSQLQuery(sql).addEntity(Patient.class);
                list = sqlQuery.list();
            }else if("2".equals(scope)){
                community = "'" + community.replace(",","','") + "'";//字符类型数据库需要添加''
                sql += "SELECT DISTINCT p.* from wlyy_patient p LEFT JOIN wlyy_sign_family f on p.code = f.patient " +
                        " WHERE p.city=350200 and f.hospital in ("+community+") and p.mobile is not null and p.mobile!='' and p.code in(select DISTINCT s.patient " +
                        " from wlyy_sign_patient_label_info s " +
                        " where "+conditionSql+")";
                SQLQuery sqlQuery = currentSession().createSQLQuery(sql).addEntity(Patient.class);
                list = sqlQuery.list();
            }
        }
        return list;
    }
    /**
     * 编辑消息
     * @param map
     * @param user
     */
    @Transactional
    public void updateNotice(Map<String,String> map,User user){
        Long noticeId = Long.parseLong(map.get("id"));
        String communityAuthority = map.get("communityAuthority");
        String scope = map.get("scope");// 0- 全市 1 - 指定区 2 - 指定社区
        String scopeId = map.get("scopeId");//范围明细ID,scope=1时为区ID串,2时为社区id串
        String scopeContent = map.get("scopeContent");//
        String city = map.get("city");
        String town = map.get("town");
        String community = map.get("community");
        String conditionDescription = map.get("conditionDescription");
        String conditionType = map.get("condition_type");//筛选条件:0-全部;1-根据条件
        String serverTypeContent = map.get("serverTypeContent");
        String serverTypeId = map.get("serverTypeId");
        String healthSituationContent = map.get("healthSituationContent");
        String healthSituationId = map.get("healthSituationId");
        String diseaseTypeContent = map.get("diseaseTypeContent");
        String diseaseTypeId = map.get("diseaseTypeId");
        String sendType = map.get("sendType");
        String content = map.get("content");
        List<Patient> list = getSendPatients(conditionType, scope, city, town, community, serverTypeId, healthSituationId, diseaseTypeId);
        //需要审核的通知公告主表
        WlyyAuditNotice notice = wlyyAuditNoticeDao.findOne(noticeId);
//        notice.setApplyTime(new Date());
//        notice.setApplyUserHospital(user.getOrganizationId()+"");
//        notice.setApplyUserId(user.getCode());
//        notice.setApplyUserName(user.getName());
        notice.setConditionDescription(conditionDescription);
        notice.setContent(content);
        //审核者自己的通知直接发送短信,状态为“4”
        if (isAuditor(user)) {
            notice.setStatus("4");
        } else {
            notice.setStatus("2");
        }
        notice.setSendType(sendType);
        if("1".equals(sendType)){
            notice.setSendTime(DateUtil.strToDateLong(map.get("sendTime")+":00"));
        }
        notice.setTitle(map.get("title"));
        notice.setTotalCount(list.size());
        wlyyAuditNoticeDao.save(notice);
        //消息公告对象范围主表
        WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeDao.findByNoticeId(noticeId);
        noticeScope.setScope(scope);
        noticeScope.setScopeContent(scopeContent);
        noticeScope.setScopeId(scopeId);
        noticeScope.setCondition(conditionType);
        noticeScope.setServerTypeId(serverTypeId);
        noticeScope.setServerTypeContent(serverTypeContent);
        noticeScope.setHealthSituationId(healthSituationId);
        noticeScope.setHealthSituationContent(healthSituationContent);
        noticeScope.setDiseaseTypeId(diseaseTypeId);
        noticeScope.setDiseaseTypeContent(diseaseTypeContent);
        noticeScope.setConditionDescription(conditionDescription);
        wlyyAuditNoticeScopeDao.save(noticeScope);
        //审核者本人修改操作,为待审核状态>>直接通过,发送短信**********************新线程发彩信
        if (isAuditor(user)) {
            sendMsgThread(list, notice);
        }
    }
    //查询通知列表
    public Page<WlyyAuditNotice> searchList(String searchNm, String status, User currentUser, int page, int pageSize) throws Exception {
        //1、根据当前用户判断其角色(是否有审核权限)1):无-查询本人的消息通知;有-管辖范围的所有消息通知(包括本人的)-添加是否为本人的标记(是本人的才有编辑、删除等操作)否则只是审核、查看
        boolean auditor = false;
        List<WlyyUserRole> userRoles = wlyyUserRoleDao.findByUser(currentUser.getCode());
        if (page <= 0) {
            page = 1;
        }
        if (pageSize <= 0) {
            pageSize = 15;
        }
        PageRequest pageRequest = new PageRequest(page - 1, pageSize);
        String filters = "";
        if (!StringUtils.isEmpty(searchNm)) {
            filters = "title?" + searchNm + " g1;applyUserName?" + searchNm + " g1;";
        }
        if (!StringUtils.isEmpty(status)) {
            filters += "status=" + status + ";";
        }
        if (userRoles.size() > 0) {
            auditor = true;
            String[] roleCodes = new String[userRoles.size()];
            for (int i = 0; i < userRoles.size(); i++) {
                roleCodes[i] = userRoles.get(i).getRole();
            }
            //获取管辖机构codes
            String applyUserHospital = "";
            List<String> orgCodeList = wlyyUserRoleService.getRoleOrgCodes(roleCodes);
            if (orgCodeList.size() > 0) {
                applyUserHospital = StringUtils.join(orgCodeList, ",");
                filters += "applyUserHospital=" + applyUserHospital + ";";
            }
        } else {
            filters += "applyUserId=" + currentUser.getCode() + ";";  //非管理员只能查看自己的信息通知
        }
        List<WlyyAuditNotice> list = search("", filters, "", page, pageSize);
        for (WlyyAuditNotice notice : list) {
            if (!StringUtils.equals(notice.getApplyUserId(), currentUser.getCode())) {
                notice.setOwned(false);
            }
            if (auditor) {
                notice.setAuditor(true);
            }
        }
        Page<WlyyAuditNotice> res = new PageImpl<WlyyAuditNotice>(list, pageRequest, getCount(filters));
        return res;
    }
    //删除消息通知,同时删除对应的消息通知范围
    @Transactional
    public boolean deleteNotice(Long noticeId) {
        wlyyAuditNoticeDao.delete(noticeId);
        WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeDao.findByNoticeId(noticeId);
        if (noticeScope != null) {
            wlyyAuditNoticeScopeDao.delete(noticeScope.getId());
        }
        return true;
    }
    //审核通过发送短信,保存发送对象
    @Transactional
    public void approve(long noticeId, WlyyAuditNotice notice, User currentUser) {
        //1) 查找出通知范围对象
        WlyyAuditNoticeScope noticeScope = wlyyAuditNoticeScopeDao.findByNoticeId(noticeId);
        String conditionType = noticeScope.getCondition();//筛选条件:0-全部;1-根据条件
        String scope = noticeScope.getScope();// 0- 全市 1 - 指定区 2 - 指定社区
        String scopeId = noticeScope.getScopeId();//范围明细ID,scope=1时为区ID串,2时为社区id串
        // scope为0时-空值;为1时-区编码;为2时区+社区编码
        String city = "350200";//厦门市
        String town = "";
        String community = "";
        String serverTypeId = noticeScope.getServerTypeId();
        String healthSituationId = noticeScope.getHealthSituationId();
        String diseaseTypeId = noticeScope.getDiseaseTypeId();
        if ("1".equals(scope)) {
            town = scopeId;
        }
        if ("2".equals(scope) && !StringUtils.isEmpty(scopeId)) {
            String[] values = scopeId.split(";|;");
            for (String value : values) {
                if (!StringUtils.isEmpty(value)) {
                    community += value.split(":|:")[1] + ",";
                }
            }
        }
        if (!StringUtils.isEmpty(community)) {
            community = community.substring(community.length() - 1);
        }
        //2)查找居民
        List<Patient> list = getSendPatients(conditionType, scope, city, town, community, serverTypeId, healthSituationId, diseaseTypeId);
        //3)发送短信,保存发送对象信息6
        if ("2".equals(notice.getStatus())) {
            notice.setStatus("4");//消息通知修改状态
            notice.setAuditUserId(currentUser.getCode());//审核者编码
            notice.setAuditUserName(currentUser.getName());//审核者名称
            wlyyAuditNoticeDao.save(notice);
            //审核通过发送短信*******************新线程
            sendMsgThread(list, notice);
        }
    }
    //判断是否具有对当前消息的审核权限
    public boolean isNoticeAuditor(String auditorCode, String noticeHospital) {
        String[] roleCodes = wlyyRoleDao.findRoleCodesByUser(auditorCode);
        if (roleCodes == null || roleCodes.length <= 0) {
            return false;
        }
        List<String> roleOrgCodes = wlyyUserRoleService.getRoleOrgCodes(roleCodes);
        if (roleOrgCodes != null && roleOrgCodes.size() > 0) {
            return roleOrgCodes.contains(noticeHospital);
        }
        return false;
    }
    //判断当前用户是否是审核者
    public boolean isAuditor(User currentUser) {
        List<WlyyUserRole> userCode = wlyyUserRoleService.findByUserCode(currentUser.getCode());
        if (userCode != null && userCode.size() > 0) {
            return true;
        }
        return false;
    }
    //开启发送短信线程
    private void sendMsgThread(List<Patient> list, WlyyAuditNotice notice) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                sendMsg(list, notice);
            }
        });
        t.start();
    }
    //发送短信
    private void sendMsg(List<Patient> list, WlyyAuditNotice notice) {
        WlyyAuditNoticeObject noticeObject = null;
        List<WlyyAuditNoticeObject> objectList = new ArrayList<>();
        String mobiles = "";
        int i = 0;
        for (Patient p : list) {
            noticeObject = new WlyyAuditNoticeObject();
            noticeObject.setNoticeId(notice.getId());
            noticeObject.setToUserId(p.getCode());
            noticeObject.setToUserTel(p.getMobile());
            noticeObject.setContent(notice.getContent());
            noticeObject.setSendTime(new Date());
            noticeObject.setInsertTime(new Date());
            noticeObject.setStatus("1");//TODO 短信发送状态(1为已发送),待修改
            objectList.add(noticeObject);
            i++;
            mobiles += p.getMobile() + ",";
            if (i % 901 == 0) {//900条发一次
                mobiles = mobiles.substring(0, mobiles.length() - 1);
                //smsService.sendMsg(mobiles,content);
                System.out.println("i=" + i + "---mobile=" + mobiles);
                mobiles = "";
            } else if (i == list.size()) {
                mobiles = mobiles.substring(0, mobiles.length() - 1);
                //smsService.sendMsg(mobiles,content);
                System.out.println("i=" + i + "---mobile=" + mobiles);
                mobiles = "";
            }
        }
        //暂时未审核后才保存发送对象+发送短信,那是否有保存改发送对象信息的必要?(数据量大)
//        if (objectList.size() > 0) {
//            wlyyAuditNoticeObjectDao.save(objectList);
//        }
    }
}

+ 92 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/wechat/WechatTemplateService.java

@ -0,0 +1,92 @@
package com.yihu.wlyy.service.manager.wechat;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.*;
import com.yihu.wlyy.service.SMSService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyRoleService;
import com.yihu.wlyy.service.manager.wlyyrole.WlyyUserRoleService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.SQLQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @Description: 微信模板管理业务逻辑
 * @Author: WuJunjie
 * @Date: Created in 2018/3/20 9:30
 */
@Service
public class WechatTemplateService extends BaseJpaService<WlyyAuditNotice, WlyyAuditNoticeDao> {
    @Autowired
    private WlyyRoleDao wlyyRoleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 根据模板自定义名称和场景值查询模板消息
     * @param templateName
     * @param scene
     * @param page
     * @param pageSize
     * @return
     * @throws Exception
     */
    public Page<WechatTemplateConfig> searchList(String templateName, String scene, int page, int pageSize) throws Exception {
        if (page <= 0) {
            page = 1;
        }
        if (pageSize <= 0) {
            pageSize = 15;
        }
        PageRequest pageRequest = new PageRequest(page - 1, pageSize);
        String filters = "";
        if (!StringUtils.isEmpty(templateName)) {
            filters = "templateName?" + templateName + ";";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += "scene=" + scene + ";";
        }
        List<WechatTemplateConfig> list = search("", filters, "", page, pageSize);
        return new PageImpl<WechatTemplateConfig>(list, pageRequest, getCount(filters));
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    public WechatTemplateConfig getTemplate(String templateName, String scene) throws Exception {
        String filters = "";
        if (!StringUtils.isEmpty(templateName)) {
            filters = "templateName=" + templateName + ";";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += "scene=" + scene + ";";
        }
        String sql = "SELECT t.template_name, t.template_title, t.format, c.`first`, " +
                " c.keyword1 , c.keyword2, c.keyword3, c.keyword4, c.keyword5, c.keyword6 , c.keyword7, c.remark " +
                " FROM weixin_template t, weixin_template_config c " +
                " WHERE t.template_name = c.template_name AND c.scene = ''";
        return null;
    }
}

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

@ -221,6 +221,9 @@
								<sec:authorize url="/admin/notification/initial">
								<li><a href="javascript:locationMenu('notification');">消息通知</a></li>
								</sec:authorize>
								<sec:authorize url="/admin/wechatTemplate/initial">
									<li><a href="javascript:locationMenu('wechatTemplate');">微信模板消息管理</a></li>
								</sec:authorize>
								<sec:authorize url="/admin/message/center">
							</ul>
					</div>

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_edit.jsp

@ -187,5 +187,5 @@
</div>
</body>
<%@ include file="../head/page_foot.jsp"%>
<%@ include file="notification_edit_js.jsp" %>
<%@ include file="wechat_edit_js.jsp" %>
</html>

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_list.jsp

@ -40,5 +40,5 @@
</div>
</body>
<%@ include file="../head/page_foot.jsp" %>
<%@ include file="notification_list_js.jsp" %>
<%@ include file="wechat_list_js.jsp" %>
</html>

+ 2 - 1
patient-co-manage/wlyy-manage/src/main/webapp/static/develop/lib/plugin/validate/jValidate.js

@ -487,6 +487,7 @@
                if(first.select) first.select();
                first.focus();
            }
            return this.options.onFormValidate(result, this.jForm);
        },
@ -1054,7 +1055,7 @@
        }],
        ['validate-chinese',/^[\u4e00-\u9fa5]+$/],
        ['validate-phone',/^((0[1-9]{3})?(0[12][0-9])?[-])?\d{6,8}$/],
        ['validate-mobile-phone',/^0?(13[0-9]|15[0-9]|18[0-9]|14[57]|17[0-9])[0-9]{8}$/],
        ['validate-mobile-phone',/^0?(13[0-9]|15[0-9]|18[0-9]|14[57]|17[0-9]|19[0-9])[0-9]{8}$/],
        ['validate-mobile-and-phone', function (v,elm,args,metadata) {
            if(/^((0[1-9]{3})?(0[12][0-9])?[-]?)?\d{6,8}$/.test(v) || /^0?(13[0-9]|15[0-9]|18[0-9]|14[57]|17[0-9])[0-9]{8}$/.test(v))
                return true;

+ 1 - 0
patient-co-manage/wlyy-manage/src/main/webapp/static/js/menu.js

@ -40,6 +40,7 @@ var menu = {
    //消息推送管理
    "notification": "/admin/notification/initial",//人员管理界面
    "wechatTemplate": "/admin/wechatTemplate/initial",//微信模板消息管理
    //问卷调查管理
    "surveyQuestion": "/admin/surveyQuestion/initial",//问题管理界面

+ 1 - 1
patient-co/patient-co-figure-label/pom.xml

@ -81,7 +81,7 @@
        <dependency>
            <groupId>com.yihu</groupId>
            <artifactId>common-data-es-starter</artifactId>
            <version>1.0.2</version>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>

+ 32 - 0
patient-co/patient-co-figure-label/sql/label_es_sql

@ -0,0 +1,32 @@
-- 新增居民标签索引映射
PUT http://172.19.103.45:9200/figure_label_index
{
  "mappings": {
    "figure_label_type": {
      "properties": {
      	"idcard":{
      		"type":"String"
      	},
      	"labelType":{
      		"type":"String"
      	},
      	"labelCode":{
      		"type":"String"
      	},
      	"labeName":{
      		"type":"String"
      	},
      	"labeValue":{
      		"type":"String"
      	},
         "createTime":{
          		"type":"date",
          		"format":"yyyy-MM-dd HH:mm:ss"
        }
      }
    }
  }
}
-- 给索引建立别名
PUT http://172.19.103.45:9200/figure_label_index/figure_label_index_a

+ 2 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/AgeConvert.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeModelIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -32,6 +33,7 @@ public class AgeConvert implements Convert {
                    int age = IdCardUtil.getAgeForIdcard(model.getIdcard());
                    String labelCode = getAgeLabelCode(age);
                    SaveModel saveModel = new SaveModel();
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(labelCode);
                    saveModel.setLabeName(map.get(labelCode));

+ 2 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/BirthConvert.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeModelIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.util.CollectionUtils;
@ -29,6 +30,7 @@ public class BirthConvert implements Convert {
                        e.printStackTrace();
                    }
                    SaveModel saveModel = new SaveModel();
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,birth));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelCode(fLlabelDict.getLabelCode());
                    saveModel.setLabelType(fLlabelDict.getParentCode());

+ 2 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/ConvertHelper.java

@ -6,6 +6,8 @@ import com.yihu.wlyy.figure.label.dao.FLLabelDictDao;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.MD5Util;
import com.yihu.wlyy.figure.label.util.MakeModelIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

+ 2 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SexConvert.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import com.yihu.wlyy.figure.label.util.MakeModelIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.*;
@ -24,6 +25,7 @@ public class SexConvert implements Convert{
                model -> {
                    String sex = IdCardUtil.getSexForIdcard(model.getIdcard());
                    SaveModel saveModel = new SaveModel();
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(sex);
                    saveModel.setLabeName(map.get(sex));

+ 43 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.java

@ -0,0 +1,43 @@
package com.yihu.wlyy.figure.label.convert;
import com.yihu.figure_label.entity.FLlabelDict;
import com.yihu.wlyy.figure.label.model.DataModel;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
import com.yihu.wlyy.figure.label.util.IdCardUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
 * zd
 * 2018-03-21
 */
public class SignStateConvert implements Convert{
    @Override
    public List<SaveModel> convert(List<DataModel> models,List<FLlabelDict> flLabelDictList) {
        List<SaveModel> saveModels = new ArrayList<>();
        if(CollectionUtils.isEmpty(flLabelDictList)){
            return saveModels;
        }
        FLlabelDict one = flLabelDictList.get(0);
        Map<String,String> map = new HashMap<>();
        flLabelDictList.forEach(
                fLlabelDict -> {
                    map.put(fLlabelDict.getLabelCode(),fLlabelDict.getLabelName());
                }
        );
        models.forEach(
                model -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabeName(map.get(model.getLabelCode()));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

+ 35 - 5
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java

@ -88,12 +88,14 @@ public class Mysql2ESJob implements Job {
        this.flJobConfigId = (Long)paramsMap.get("jobConfig");
        this.flJobConfig = flJobConfigDao.findById(this.flJobConfigId);
        this.sqlFiledValue = (String)paramsMap.get(this.flJobConfig.getSqlField().toString());
        //this.sqlFiledValue = (String)paramsMap.get(this.flJobConfig.getSqlField().toString());
        this.sqlFiledValue = String.valueOf(paramsMap.get("sqlFiledValue"));
        this.sqlFiledCondition = paramsMap.getString("sqlFiledCondition");
        //没有传增量值,以数据库配置的默认值为查询条件
        if(StringUtils.isEmpty(this.sqlFiledValue)){
            this.sqlFiledValue = this.flJobConfig.getSqlFieldValue();
            this.sqlFiledCondition=">";
        }
        this.sqlFiledCondition = paramsMap.getString("sqlFiledCondition");
        //1抽取数据
        String sql = this.flJobConfig.getSql();
        String sqlFiled = this.flJobConfig.getSqlField();
@ -149,15 +151,43 @@ public class Mysql2ESJob implements Job {
        if(StringUtils.isEmpty(sqlFiledCondition)){
            return result.toString();
        }
        if (sqlFiledValue.contains(",") && sql.contains("where")) {
        String[] sqlFiledConditionStr = {};
        if (sqlFiledCondition.contains(",")){
            sqlFiledConditionStr = sqlFiledCondition.split(",");
        }
        StringBuffer sqlFiledString = new StringBuffer();
        if (sqlFiledConditionStr.length>0 && sqlFiledValue.contains(",")){
            String[] sqlFiledValues = sqlFiledValue.split(",");
            sqlFiledString.append(sqlFiled).append(sqlFiledConditionStr[0]).append("\'"+sqlFiledValues[0]+"\'").append(" and ").append(sqlFiled).append(sqlFiledConditionStr[1]).append("\'"+sqlFiledValues[1]+"\'");
        }else{
            sqlFiledString.append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }
        if (sql.contains("where")) {
            result.append(" and ").append(sqlFiledString.toString());
        }else if (sql.contains("$")){
            StringBuffer otherCondition = new StringBuffer();
            otherCondition.append(" where ").append(sqlFiledString.toString());
            result.replace(result.indexOf("$"),result.indexOf("$")+1,otherCondition.toString());
        }else {
            result.append(" where ").append(sqlFiledString.toString());
        }
        /*if (sqlFiledValue.contains(",") && sql.contains("where")) {
            String[] sqlFiledValues = sqlFiledValue.split(",");
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[1]+"\'").append(sqlFiledCondition).append("\'"+sqlFiledValues[0]+"\'");
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[1]+"\'").append(" and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValues[0]+"\'");
        }else if(sql.contains("where")){
            result.append("and ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }else if (sql.contains("$")){
            StringBuffer otherCondition = new StringBuffer();
            otherCondition.append("where ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
            result.replace(result.indexOf("$"),result.indexOf("$")+1,otherCondition.toString());
        }else {
            result.append("where ").append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }
        }*/
        return result.toString();
    }
}

+ 17 - 1
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/model/SaveModel.java

@ -2,14 +2,21 @@ package com.yihu.wlyy.figure.label.model;
import io.searchbox.annotations.JestId;
import java.io.Serializable;
/**
 * Created by chenweida on 2018/3/7.
 */
public class SaveModel {
public class SaveModel implements Serializable{
    @JestId
    private String id;
    /**
     * 存入elasticsearch的id由 idcard,sex,parentCode,labelName,labelCode MD5加密而成。不用es自动生成的_id,实现数据插入排重
     */
    private String modelId;
    /**
     * 身份证
     */
@ -36,8 +43,17 @@ public class SaveModel {
    /**
     * 创建时间
     */
    private String createTime;
    public String getModelId() {
        return modelId;
    }
    public void setModelId(String modelId) {
        this.modelId = modelId;
    }
    public String getIdcard() {
        return idcard;
    }

+ 7 - 7
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/service/JobService.java

@ -146,7 +146,7 @@ public class JobService {
    }
    public void productDataByOneDay(String yesterday) throws Exception {
        String sql="select * from wlyy_job_config_new a where  a.del='1' and a.id !=11 order by a.id asc";
        String sql="select * from fl_job_config a where  a.del='1' and a.id !=11 order by a.id asc";
        SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
        Date date = dataSimple.parse(yesterday);
@ -168,7 +168,7 @@ public class JobService {
            params.put("jobConfig", flJobConfig.getId().toString());
            //往quartz框架添加任务
            params.put("sqlFiledValue", daybefore+","+yesterday);
            params.put("sqlFiledCondition", "<");
            params.put("sqlFiledCondition", ">,<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(sleepTime);
@ -206,11 +206,11 @@ public class JobService {
        BeanUtils.copyProperties(FLJobConfig, flJobConfigVO);
        Map<String, Object> params = new HashMap<>();
        params.put("jobConfig", flJobConfigVO.getId().toString());
        params.put("jobConfig", Long.valueOf(flJobConfigVO.getId()));
        //往quartz框架添加任务
        params.put("sqlFiledValue", daybefore + "," + yesterday);
        params.put("sqlFiledCondition", "<");
        params.put("sqlFiledCondition", ">,<");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            Thread.sleep(sleepTime);
@ -231,7 +231,7 @@ public class JobService {
        for (int i = 1; i <= day; i++) {
            //往quartz框架添加任务
            params.put("sqlFiledValue",  getYesterday(0 - i - 1)+","+getYesterday(0 - i));
            params.put("sqlFiledCondition", "<");
            params.put("sqlFiledCondition", ">,<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(sleepTime);
@ -331,7 +331,7 @@ public class JobService {
        //往quartz框架添加任务
        params.put("sqlFiledValue", daybefore + "," + yesterday);
        params.put("sqlFiledCondition", "<");
        params.put("sqlFiledCondition", ">,<");
        if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
            quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
        }
@ -361,7 +361,7 @@ public class JobService {
            params.put("jobConfig", flJobConfigVO.getId().toString());
            //往quartz框架添加任务
            params.put("sqlFiledValue", daybefore + "," + yesterday);
            params.put("sqlFiledCondition", "<");
            params.put("sqlFiledCondition", ">,<");
            if (!StringUtils.isEmpty(FLJobConfig.getJobClass())) {
                quartzHelpers.startNow(getRightClass(FLJobConfig), FLJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);

+ 12 - 4
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/storage/Store2ES.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.figure.label.storage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.base.es.config.ElastricSearchHelper;
import com.yihu.wlyy.figure.label.model.SaveModel;
import com.yihu.wlyy.figure.label.util.ConstantUtil;
@ -18,18 +20,24 @@ public class Store2ES implements Storager {
    @Override
    public void save(List<SaveModel> modelList) {
        List<Object> list = new ArrayList<>();
        List<String> list = new ArrayList<>();
        int saveCount = 0;
        for(SaveModel saveModel:modelList){
            list.add(saveModel);
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                String str =  objectMapper.writeValueAsString(saveModel);
                list.add(str);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
            //防止内存溢出,一次性存储10W条
            if(list.size() >= 100000){
                elastricSearchHelper.save(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list);
                elastricSearchHelper.saveBulkWithCustomId(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list,"modelId");
                list.clear();
                saveCount ++;
            }else if(modelList.size() - saveCount * 100000 == list.size()){
                //剩余的零头
                elastricSearchHelper.save(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list);
                elastricSearchHelper.saveBulkWithCustomId(ConstantUtil.figure_label_es_index, ConstantUtil.figure_label_es_type, list,"modelId");
            }
        }
    }

+ 46 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MD5Util.java

@ -0,0 +1,46 @@
package com.yihu.wlyy.figure.label.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util {
    // 全局数组
    private final static String[] strDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
    public MD5Util() {
    }
    // 返回形式为数字跟字符串
    private static String byteToArrayString(byte bByte) {
        int iRet = bByte;
        // System.out.println("iRet="+iRet);
        if (iRet < 0) {
            iRet += 256;
        }
        int iD1 = iRet / 16;
        int iD2 = iRet % 16;
        return strDigits[iD1] + strDigits[iD2];
    }
    // 转换字节数组为16进制字串
    private static String byteToString(byte[] bByte) {
        StringBuffer sBuffer = new StringBuffer();
        for (int i = 0; i < bByte.length; i++) {
            sBuffer.append(byteToArrayString(bByte[i]));
        }
        return sBuffer.toString();
    }
    public static String GetMD5Code(String strObj) {
        String resultString = null;
        try {
            resultString = new String(strObj);
            MessageDigest md = MessageDigest.getInstance("MD5");
            // md.digest() 该函数返回值为存放哈希值结果的byte数组
            resultString = byteToString(md.digest(strObj.getBytes()));
        } catch (NoSuchAlgorithmException ex) {
            ex.printStackTrace();
        }
        return resultString;
    }
}

+ 40 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/util/MakeModelIDUtil.java

@ -0,0 +1,40 @@
package com.yihu.wlyy.figure.label.util;
import com.yihu.wlyy.figure.label.model.DataModel;
import org.springframework.util.StringUtils;
public class MakeModelIDUtil {
    /**
     * 生成存入es的id,确保数据不会重复
     * id由 idcard,parentCode,labelName,labelCode MD5加密而成。不用es自动生成的_id,实现数据插入排重
     * @param dataModel
     * @param labelValue
     * @return
     */
    public static String makeModelID(DataModel dataModel,String labelValue) {
        StringBuilder idStr = new StringBuilder();
        idStr.append(dataModel.getIdcard()).append("-")
                .append(dataModel.getParentCode()).append("-")
                .append(dataModel.getLabelCode()).append("-")
                .append(dataModel.getLabelName());
       if(!StringUtils.isEmpty(labelValue)){
           idStr.append("-").append(labelValue);
       }
        return MD5Util.GetMD5Code(idStr.toString());
    }
    public static void main(String[] args) {
        DataModel dataModel = new DataModel();
        dataModel.setIdcard("350881199004241228");
        dataModel.setParentCode("2");
        dataModel.setLabelCode("1");
        dataModel.setLabelName("健康人群");
        String MD5ID = makeModelID(dataModel,"165cm");
//        String MD5ID = makeModelID(dataModel,"");
        System.out.println(MD5ID);
        System.out.println(MD5ID.length());
    }
}

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

@ -827,30 +827,33 @@ public class PatientDeviceService extends BaseService {
            json.put("labelType",labelInfo.getLabelType());
            jsonArray.add(json);
        });
        switch (patient.getDiseaseCondition()){
            case 0:
                com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject();
                json1.put("label","0");
                json1.put("labelName","绿标");
                json1.put("labelType","99");
                jsonArray.add(json1);
                break;
            case 1:
                com.alibaba.fastjson.JSONObject json2 = new com.alibaba.fastjson.JSONObject();
                json2.put("label",1);
                json2.put("labelName","黄标");
                json2.put("labelType","99");
                jsonArray.add(json2);
                break;
            case 2:
                com.alibaba.fastjson.JSONObject json3 = new com.alibaba.fastjson.JSONObject();
                json3.put("label",2);
                json3.put("labelName","红标");
                json3.put("labelType","99");
                jsonArray.add(json3);
                break;
            default:break;
        if(patient.getDiseaseCondition()!=null){
            switch (patient.getDiseaseCondition()){
                case 0:
                    com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject();
                    json1.put("label","0");
                    json1.put("labelName","绿标");
                    json1.put("labelType","99");
                    jsonArray.add(json1);
                    break;
                case 1:
                    com.alibaba.fastjson.JSONObject json2 = new com.alibaba.fastjson.JSONObject();
                    json2.put("label",1);
                    json2.put("labelName","黄标");
                    json2.put("labelType","99");
                    jsonArray.add(json2);
                    break;
                case 2:
                    com.alibaba.fastjson.JSONObject json3 = new com.alibaba.fastjson.JSONObject();
                    json3.put("label",2);
                    json3.put("labelName","红标");
                    json3.put("labelType","99");
                    jsonArray.add(json3);
                    break;
                default:break;
            }
        }
        jsonObject.put("labelList",jsonArray);
        //个人信息
        jsonObject.put("sex",patient.getSex());//性別,1男,2女

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

@ -1420,7 +1420,8 @@ public class PatientHealthIndexService extends BaseService {
        sql = sql + conditionApp +
                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                " order by record_date desc ,sort_date desc limit " + 0 + " ," + 1000 + " ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
//        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = findByPatientAndTime(sql,patient,type,1000,gi_type,begin,end);
        for (Map<String, Object> map : list) {
            String value1 = map.get("value1").toString();
            String value2 = map.get("value2").toString();

+ 17 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java

@ -96,11 +96,22 @@ public class PhysicalExaminationRemindService extends BaseService {
     * @return
     */
    public Integer isRemind(String patient){
        List<PatientRemindRecords> records = patientRemindRecordsDao.findByPatientAndType(patient, 1);
        if (records != null && records.size() > 0) {
            return 1;
        Patient people = patientDao.findByCode(patient);
        if (people!=null){
            int age = IdCardUtil.getAgeForIdcard(people.getIdcard()==null?"":people.getIdcard());
            if (age<65){
                return 2;
            }
            List<PatientRemindRecords> records = patientRemindRecordsDao.findByPatientAndType(patient, 1);
            if (records != null && records.size() > 0) {
                return 1;
            }else {
                return 0;
            }
        }else {
            return -1;
        }
        return 0;
    }
    /**
@ -340,7 +351,7 @@ public class PhysicalExaminationRemindService extends BaseService {
        // 推送消息给微信端
        String url = "jkda/html/jiankangtijian.html?openid=" + patient.getOpenid() +"&toUser="+patient.getCode()+"&toName=" + patient.getName();
//        String first = "您的家庭医生" + doctName + "提醒,您可以到签约社区进行65岁以上老年人的免费健康体检啦~";
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_change","qkxz");
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","jktj");
        String first = templateConfig.getFirst();
        first = first.replace("key1",(doctName==null?"":doctName));
        String remark = templateConfig.getRemark();
@ -410,7 +421,7 @@ public class PhysicalExaminationRemindService extends BaseService {
        String accessToken = accessTokenUtils.getAccessToken();
        Boolean flag = true;
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_change","qkxz");
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","jktj");
        String first = templateConfig.getFirst();
        first = first.replace("key1",(doctName==null?"":doctName));
        String remark = templateConfig.getRemark();

+ 5 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -735,7 +735,7 @@ public class PrescriptionInfoService extends BaseService {
        return 1;
    }
    public List<Map<String, Object>> getDoctorPrescription(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size,String isPcim) {
    public List<Map<String, Object>> getDoctorPrescription(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
        StringBuffer pre_sql = new StringBuffer("SELECT " +
                " p.`name`, " +
                " TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, " +
@ -758,11 +758,11 @@ public class PrescriptionInfoService extends BaseService {
                    " WHERE s.prescription_code = pr.code " +
                    " AND s.health_problem = ?");
            params.add(diseases);
            setSQL(pre_sql, params, teamCode, state, startDate, endDate, nameKeyword, patient, page, size, isPcim);
            setSQL(pre_sql, params, teamCode, state, startDate, endDate, nameKeyword, patient, page, size);
        } else {
            //查询所有疾病类型表
            pre_sql.append(" WHERE 1=1 ");
            setSQL(pre_sql, params, teamCode, state, startDate, endDate, nameKeyword, patient, page, size, isPcim);
            setSQL(pre_sql, params, teamCode, state, startDate, endDate, nameKeyword, patient, page, size);
        }
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(), params.toArray());
@ -775,29 +775,14 @@ public class PrescriptionInfoService extends BaseService {
        return rs;
    }
    public void setSQL(StringBuffer pre_sql, List<Object> params, Integer teamCode, String state, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size, String isPcim) {
    public void setSQL(StringBuffer pre_sql, List<Object> params, Integer teamCode, String state, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
        if (teamCode != null && teamCode > 0) {
            pre_sql.append(" AND pr.admin_team_id =?");
            params.add(teamCode);
        }
        if (StringUtils.isNotBlank(state)) {
            //不是pcim新改的用原来的接口-2018.03.09
            if (StringUtils.isNotBlank(isPcim) && "0".equals(isPcim)){
                pre_sql.append(" AND pr.status IN (" + state + ") ");
            }else if (StringUtils.isNotBlank(isPcim) && "1".equals(isPcim)){
                //如果是pcim新改的则状态搜索改变
                //待审核和已完成
                if ("0".equals(state)  || "100".equals(state)){
                    pre_sql.append(" AND pr.status IN (" + state + ") ");
                }else if ("-1".equals(state)){
                    //已取消
                    pre_sql.append(" AND pr.status < (-1) ");
                }else if ("1".equals(state)){
                    //已完成
                    pre_sql.append(" AND pr.status > 0 AND pr.status <100 ");
                }
            }
            pre_sql.append(" AND pr.status IN (" + state + ") ");
        }
        if (StringUtils.isNotBlank(startDate)) {
            pre_sql.append(" AND pr.create_time >= ? ");

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

@ -365,7 +365,7 @@ public class StatisticsESService {
                }
            }
        }
        if (SaveModel.OrgLevel.equals(level + "")) {
        if (SaveModel.OrgLevel.equals(level + "") || SaveModel.teamLevel.equals(lowLevel)) {
            statisticsAllService.translateTeamLeaderName(resultList);
        }
        Collections.sort(resultList, new Comparator<Map<String, Object>>() {

+ 5 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PyhsicExamRemindController.java

@ -101,7 +101,11 @@ public class PyhsicExamRemindController extends BaseController{
                                 @RequestParam(value = "patient", required = true) String patient){
        try {
            Integer re =  physicalExaminationRemindService.isRemind(patient);
            return write(200, "查询成功", "data", re);
            if (re!=-1){
                return write(200, "查询成功", "data", re);
            }else {
                return error(-1, "居民查询失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");

+ 2 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -113,8 +113,6 @@ public class PrescriptionInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/getDoctorPrescription", method = RequestMethod.GET)
    @ApiOperation(value = "获取全科医生/建管师续方列表/搜索")
    public String getDoctorPrescription(@RequestParam(required = false) @ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
@ -125,10 +123,9 @@ public class PrescriptionInfoController extends BaseController {
                                        @RequestParam(required = false) @ApiParam(name = "nameKeyword", value = "患者姓名模糊匹配") String nameKeyword,
                                        @RequestParam(required = false) @ApiParam(name = "patient", value = "患者Code") String patient,
                                        @RequestParam(required = false) @ApiParam(name = "page", value = "起始页") Integer page,
                                        @RequestParam(required = false) @ApiParam(name = "size", value = "每页条数") Integer size,
                                        @RequestParam(required = false , defaultValue = "0") @ApiParam(name = "isPcim",value = "是否在pcim上使用,0否1是")String isPcim) {
                                        @RequestParam(required = false) @ApiParam(name = "size", value = "每页条数") Integer size) {
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getDoctorPrescription(teamCode, state, diseases, startDate, endDate, nameKeyword, patient, page, size,isPcim));
            return write(200, "查询成功!", "data", prescriptionInfoService.getDoctorPrescription(teamCode, state, diseases, startDate, endDate, nameKeyword, patient, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/WechatCoreController.java

@ -97,10 +97,12 @@ public class WechatCoreController extends WeixinBaseController {
                        if (StringUtils.isNotEmpty(json.getString("openId")) && !("undefined".equals(json.getString("openId")))) {
                            pushMsgTask.putWxMsg(getAccessToken(), json.getInt("type"), json.getString("openId"), null, json);
                        }
                    }
                } else {
                    // 返回消息(图文消息)
                    response.setHeader("Content-type", "text/html;charset=UTF-8");
                    //这句话的意思,是告诉servlet用UTF-8转码,而不是用默认的ISO8859
                    response.setCharacterEncoding("UTF-8");
                    response.getWriter().print(xmlStr);
                }
            } else {