Просмотр исходного кода

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

zd_123 7 лет назад
Родитель
Сommit
2e09dc5476
14 измененных файлов с 268 добавлено и 899 удалено
  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. 1 0
      patient-co-manage/wlyy-manage/src/main/webapp/static/js/menu.js
  12. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java
  13. 17 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java
  14. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PyhsicExamRemindController.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>

+ 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",//问题管理界面

+ 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 - 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, "查询失败");