Преглед на файлове

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

LiTaohong преди 7 години
родител
ревизия
2bf4662b7f
променени са 23 файла, в които са добавени 939 реда и са изтрити 1043 реда
  1. 96 26
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/notification/WechatTemplateController.java
  2. 18 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/wechat/WeixinTemplateDao.java
  3. 55 36
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/DeviceHealthIndexService.java
  4. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyPatientDeviceService.java
  5. 169 24
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/wechat/WechatTemplateService.java
  6. 4 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/deviceHealthIndex_list_js.jsp
  7. 1 1
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/patientDevice_list.jsp
  8. 70 159
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_edit.jsp
  9. 176 533
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_edit_js.jsp
  10. 16 18
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_list.jsp
  11. 67 185
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_list_js.jsp
  12. 49 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/IsOnlineConvert.java
  13. 3 0
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.java
  14. 6 2
      patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/job/Mysql2ESJob.java
  15. 21 6
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PatientConfirmReceiptJob.java
  16. 18 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/wechat/WechatTemplateConfigDao.java
  17. 10 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PatientPhysicalExaminationService.java
  18. 38 7
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  19. 58 14
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionNoticesService.java
  20. 25 8
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java
  21. 32 19
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/RemindExpensesTask.java
  22. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  23. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

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

@ -1,19 +1,9 @@
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;
@ -23,7 +13,6 @@ import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @Description: 微信模板管理
@ -36,18 +25,31 @@ public class WechatTemplateController extends BaseController {
    @Autowired
    private WechatTemplateService wechatTemplateService;
    @Autowired
    private WlyyAuditNoticeScopeService wlyyAuditNoticeScopeService;
    @Autowired
    private WlyyUserRoleService wlyyUserRoleService;
    /**
     * 列表页面初始化数据
     * @param model
     * @return
     */
    @RequestMapping(value = "initial", method = RequestMethod.GET)
    @ApiIgnore
    public String notificationListInitial(Model model) {
    public String listInitial(Model model) {
        return "wechat/wechat_list";
    }
    /**
     * 编辑、查看、新增页面初始化数据
     * @param
     * @return
     */
    @RequestMapping(value = "editInitial", method = RequestMethod.GET)
    @ApiIgnore
    public String editInitial(String templateName,String scene,String mode) {
        request.setAttribute("templateName",templateName);
        request.setAttribute("scene",scene);
        request.setAttribute("mode",mode);
        return "wechat/wechat_edit";
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息
     * @param templateName
@ -69,8 +71,9 @@ public class WechatTemplateController extends BaseController {
            @ApiParam(name = "rows")
            @RequestParam(value = "rows") int pageSize) {
        try {
            Page<WechatTemplateConfig> templetes = wechatTemplateService.searchList(templateName, scene, page, pageSize);
            return write(200, "操作成功", page, pageSize, templetes);
            List<WechatTemplateConfig> templetes = wechatTemplateService.searchList(templateName, scene, page, pageSize);
            int count = wechatTemplateService.getListCount(templateName, scene);
            return write(200, "操作成功", page, pageSize,count, templetes);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
@ -88,11 +91,11 @@ public class WechatTemplateController extends BaseController {
    @ResponseBody
    public String getTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene) {
            @RequestParam(value = "scene", required = true) String scene) {
        try {
            WechatTemplateConfig templete = wechatTemplateService.getTemplate(templateName, scene);
            List<Map<String,Object>> templete = wechatTemplateService.getTemplate(templateName, scene);
            return write(200, "操作成功", "data",templete);
        } catch (Exception ex) {
            error(ex);
@ -101,7 +104,7 @@ public class WechatTemplateController extends BaseController {
    }
    /**
     * 新增或修改模板详情
     * 修改模板详情
     * @param templateName
     * @param scene
     * @return
@ -111,10 +114,32 @@ public class WechatTemplateController extends BaseController {
    @ResponseBody
    public String updateTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = false) String templateName,
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = false) String scene) {
            @RequestParam(value = "scene", required = true) String scene,
            @ApiParam(name = "sceneDescription", value = "模板场景描述")
            @RequestParam(value = "sceneDescription", required = true) String sceneDescription,
            @ApiParam(name = "first", value = "first")
            @RequestParam(value = "first", required = false) String first,
            @ApiParam(name = "remark", value = "remark")
            @RequestParam(value = "remark", required = false) String remark,
            @ApiParam(name = "value1", value = "value1")
            @RequestParam(value = "value1", required = false) String value1,
            @ApiParam(name = "value2", value = "value2")
            @RequestParam(value = "value2", required = false) String value2,
            @ApiParam(name = "value3", value = "value3")
            @RequestParam(value = "value3", required = false) String value3,
            @ApiParam(name = "value4", value = "value4")
            @RequestParam(value = "value4", required = false) String value4,
            @ApiParam(name = "value5", value = "value5")
            @RequestParam(value = "value5", required = false) String value5,
            @ApiParam(name = "value6", value = "value6")
            @RequestParam(value = "value6", required = false) String value6,
            @ApiParam(name = "value7", value = "value7")
            @RequestParam(value = "value7", required = false) String value7) {
        try {
            wechatTemplateService.updateTemplate(templateName, scene,sceneDescription,first,remark,
                    value1,value2,value3,value4,value5,value6,value7);
            return write(200, "操作成功", "data","");
        } catch (Exception ex) {
            error(ex);
@ -122,5 +147,50 @@ public class WechatTemplateController extends BaseController {
        }
    }
    /**
     * 新增模板详情
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "saveTemplate", method = RequestMethod.POST)
    @ResponseBody
    public String saveTemplate(
            @ApiParam(name = "templateName", value = "模板名称")
            @RequestParam(value = "templateName", required = true) String templateName,
            @ApiParam(name = "scene", value = "模板场景值")
            @RequestParam(value = "scene", required = true) String scene,
            @ApiParam(name = "sceneDescription", value = "模板场景描述")
            @RequestParam(value = "sceneDescription", required = true) String sceneDescription,
            @ApiParam(name = "first", value = "first")
            @RequestParam(value = "first", required = false) String first,
            @ApiParam(name = "remark", value = "remark")
            @RequestParam(value = "remark", required = false) String remark,
            @ApiParam(name = "value1", value = "value1")
            @RequestParam(value = "value1", required = false) String value1,
            @ApiParam(name = "value2", value = "value2")
            @RequestParam(value = "value2", required = false) String value2,
            @ApiParam(name = "value3", value = "value3")
            @RequestParam(value = "value3", required = false) String value3,
            @ApiParam(name = "value4", value = "value4")
            @RequestParam(value = "value4", required = false) String value4,
            @ApiParam(name = "value5", value = "value5")
            @RequestParam(value = "value5", required = false) String value5,
            @ApiParam(name = "value6", value = "value6")
            @RequestParam(value = "value6", required = false) String value6,
            @ApiParam(name = "value7", value = "value7")
            @RequestParam(value = "value7", required = false) String value7) {
        try {
            Map<String,Object> result = wechatTemplateService.saveTemplate(templateName, scene,sceneDescription,first,remark,
                    value1,value2,value3,value4,value5,value6,value7);
            int code = Integer.parseInt(result.get("code").toString());
            String msg = result.get("msg").toString();
            return write(code, msg);
        } catch (Exception ex) {
            error(ex);
            return error(-1, "操作失败");
        }
    }
}

+ 18 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/wechat/WeixinTemplateDao.java

@ -0,0 +1,18 @@
package com.yihu.wlyy.repository.wechat;
import com.yihu.wlyy.entity.wechat.WeixinTemplate;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @Description: 模板记录信息
 * @Author: WuJunjie
 * @Date: Created in 2018/2/23 11:51
 */
public interface WeixinTemplateDao extends PagingAndSortingRepository<WeixinTemplate, Long>, JpaSpecificationExecutor<WeixinTemplate> {
    //根据自定义模板名称、微信公众号原始ID获取模板ID等信息
    @Query("select t  from WeixinTemplate t where t.accId=?1 and t.templateName=?2 and t.status = 1 ")
    WeixinTemplate findByName(String accId, String templateName);
}

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

@ -65,33 +65,34 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
        User loginUser = (User) request.getSession().getAttribute("userInfo");
        Pageable pageRequest = new PageRequest(page-1,pageSize);
        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  ";
        String sql =" SELECT i.* ,s.name userName FROM device.wlyy_patient_health_index i , wlyy.wlyy_sign_family s WHERE s. STATUS > 0  and i.user=s.patient ";
        String countSql =" SELECT count(1) as num FROM device.wlyy_patient_health_index i, wlyy.wlyy_sign_family s WHERE s. STATUS > 0  and i.user=s.patient ";
        //1、管理员  2、医生 0、其他
        if(loginUser.getType()==2){
            Doctor doctor = doctorDao.findByCode(loginUser.getCode());
            if(doctor!=null &&StringUtils.isNotEmpty(doctor.getHospital())){
                sql += " AND a.hospital = '"+doctor.getHospital()+"' ";
                filter.append(" AND s.hospital = '"+doctor.getHospital()+"' ");
            }
        }
        //根据患者名称过滤
        if(!StringUtils.isEmpty(userName)){
            sql +=" AND b.NAME LIKE '%"+userName+"%'";
            filter.append(" AND s.NAME LIKE '%"+userName+"%' ");
        }
        //根据健管师或医生名称过滤
        if(!StringUtils.isEmpty(doctorName)){
            sql += " and (a.doctor_name like '%"+doctorName+"%' or a.doctor_health_name like '%"+doctorName+"%') ";
            filter.append(" and (s.doctor_name like '%"+doctorName+"%' or s.doctor_health_name like '%"+doctorName+"%') ");
        }
        List<String> patientList = jdbcTemplate.queryForList(sql,String.class);
        if(!StringUtils.isEmpty(deviceSn)){
            filter.append("deviceSn="+deviceSn+";");
            filter.append(" and i.deviceSn="+deviceSn);
        }
        if(!StringUtils.isEmpty(idcard)){
            filter.append("idcard="+idcard+";");
            filter.append(" and i.idcard="+idcard);
        }
        //体征数据创建时间
        if(!StringUtils.isEmpty(date)){
            Date startTimeTemp  =  DateTimeUtil.simpleDateParse(date);
            Calendar calendar = new GregorianCalendar();
@ -101,63 +102,81 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
            calendar.set(Calendar.SECOND,59);
            calendar.set(Calendar.MILLISECOND,999);
            Date endTimeTemp = calendar.getTime();
            filter.append("czrq>=" + DateTimeUtil.utcDateTimeFormat(startTimeTemp)+ ";");
            filter.append("czrq<=" + DateTimeUtil.utcDateTimeFormat(endTimeTemp)+ ";");
            filter.append(" and i.czrq>=" + DateTimeUtil.utcDateTimeFormat(startTimeTemp));
            filter.append(" and i.czrq<=" + DateTimeUtil.utcDateTimeFormat(endTimeTemp));
        }
        if(patientList != null && patientList.size() >0){
            String temp = StringUtils.join(patientList, ",");
//            temp = temp.substring(0,temp.length()-1);
            filter.append("user="+temp+";");
        }else {
            return new PageImpl<DeviceHealthIndexVO>(new ArrayList<>(), pageRequest, 0);
        }
        //指标类型
        if(!StringUtils.isEmpty(indexType)){
            filter.append("type="+indexType+";");
            filter.append(" and i.type="+indexType);
        }
        //体征数据
        if("1".equals(indexType)||"2".equals(indexType)||"4".equals(indexType)){
            if(indexTypeMin1!=null){
                filter.append("value1>="+indexTypeMin1+";");
                filter.append(" and value1>="+indexTypeMin1);
            }
            if(indexTypeMax1!=null){
                filter.append("value1<="+indexTypeMax1+";");
                filter.append(" and value1<="+indexTypeMax1);
            }
            if(indexTypeMin2!=null){
                filter.append("value2>="+indexTypeMin2+";");
                filter.append(" and value2>="+indexTypeMin2);
            }
            if(indexTypeMax2!=null){
                filter.append("value2<="+indexTypeMax2+";");
                filter.append(" and value2<="+indexTypeMax2);
            }
        }else{
            if(indexTypeMin1!=null){
                filter.append("value3>="+indexTypeMin1+";");
                filter.append(" and value3>="+indexTypeMin1);
            }
            if(indexTypeMax1!=null){
                filter.append("value3<="+indexTypeMax1+";");
                filter.append(" and value3<="+indexTypeMax1);
            }
            if(indexTypeMin2!=null){
                filter.append("value4>="+indexTypeMin2+";");
                filter.append(" and value4>="+indexTypeMin2);
            }
            if(indexTypeMax2!=null){
                filter.append("value4<="+indexTypeMax2+";");
                filter.append(" and value4<="+indexTypeMax2);
            }
        }
        List<DeviceHealthIndex> list = (List<DeviceHealthIndex>)search("", filter.toString(), "-czrq", page, pageSize);
        String f = filter.toString();
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql+f+" order by i.czrq desc "+" limit "+(page-1)+","+pageSize);
        if(resultList.size()<=0){
            return new PageImpl<DeviceHealthIndexVO>(new ArrayList<>(), pageRequest, 0);
        }
        long count = 0;
        String regex = "(\\w{3})(\\w+)(\\w{3})";
        List<DeviceHealthIndexVO> listTemp = new ArrayList<>();
        if(list !=null && list.size()>0){
            count = getCount(filter.toString());
            for (DeviceHealthIndex info : list){
        if(resultList !=null && resultList.size()>0){
//            count = getCount(filter.toString());
            count = jdbcTemplate.queryForObject(countSql+filter.toString(),Long.class);
            for (Map<String, Object> info : resultList){
                DeviceHealthIndexVO bean = new DeviceHealthIndexVO();
                BeanUtils.copyProperties(info, bean);
//                BeanUtils.copyProperties(bean, info);
                Patient patient = findPatient(bean.getUser());
                bean.setUserName(patient== null?"":patient.getName());
                bean.setId(Long.getLong(info.get("id")+""));
                bean.setCzrq(info.get("czrq")!=null?(Date)info.get("czrq"):null);
                bean.setDel(info.get("del")!=null?info.get("del")+"":null);
                bean.setDeviceSn(info.get("device_sn")!=null?info.get("device_sn")+"":null);
                bean.setIdcard(info.get("idcard")!=null?info.get("idcard")+"":null);
                bean.setIntervene(info.get("intervene")!=null?info.get("intervene")+"":null);
                bean.setRecordDate(info.get("record_date")!=null?(Date)info.get("record_date"):null);
                bean.setSortDate(info.get("sort_date")!=null?(Date)info.get("sort_date"):null);
                bean.setStatus(info.get("status")!=null?(Integer)info.get("status"):null);
                bean.setType(info.get("type")!=null?(Integer)info.get("type"):0);
                bean.setUser(info.get("user")!=null?info.get("user")+"":null);
                bean.setUserName(info.get("userName")!=null?info.get("userName")+"":null);
                bean.setValue1(info.get("value1")!=null?info.get("value1")+"":null);
                bean.setValue2(info.get("value2")!=null?info.get("value2")+"":null);
                bean.setValue3(info.get("value3")!=null?info.get("value3")+"":null);
                bean.setValue4(info.get("value4")!=null?info.get("value4")+"":null);
                bean.setValue5(info.get("value5")!=null?info.get("value5")+"":null);
                bean.setValue6(info.get("value6")!=null?info.get("value6")+"":null);
                bean.setValue7(info.get("value7")!=null?info.get("value7")+"":null);
//                BeanUtils.copyProperties(info, bean);
//                Patient patient = findPatient(bean.getUser());
//                bean.setUserName(patient== null?"":patient.getName());
                if(StringUtils.isNotBlank(bean.getIdcard())){
                    bean.setIdcard(bean.getIdcard().replaceAll(regex, "$1****$3"));
                }
                bean.setHealthStandard(gethealthStandard(info.getType(),info.getUser()).toString());
                bean.setHealthStandard(gethealthStandard(bean.getType(),bean.getUser()).toString());
                listTemp.add(bean);
            }
        }

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

@ -162,7 +162,7 @@ public class WlyyPatientDeviceService extends BaseJpaService<WlyyPatientDevice,W
        }
        
        if(StringUtils.isNotBlank(doctorName)){
            sql = sql + "AND s.doctor_name like '%"+doctorName+"%' ";
            sql = sql + "AND (s.doctor_name like '%"+doctorName+"%' or s.doctor_health_name like '%"+doctorName+"%') ";
        }
        
        if(StringUtils.isNotBlank(userName)){

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

@ -2,24 +2,22 @@ package com.yihu.wlyy.service.manager.wechat;
import com.yihu.wlyy.entity.*;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.entity.wechat.WeixinTemplate;
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.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.repository.wechat.WeixinTemplateDao;
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.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
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.HashMap;
import java.util.List;
import java.util.Map;
@ -31,14 +29,19 @@ import java.util.Map;
@Service
public class WechatTemplateService extends BaseJpaService<WlyyAuditNotice, WlyyAuditNoticeDao> {
    @Autowired
    private WlyyRoleDao wlyyRoleDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WechatTemplateConfigDao wechatTemplateConfigDao;
    @Autowired
    private WeixinTemplateDao weixinTemplateDao;
    @Value("${wechat.accId}")
    private String accId;
    /**
     * 根据模板自定义名称和场景值查询模板消息
     *
     * @param templateName
     * @param scene
     * @param page
@ -46,47 +49,189 @@ public class WechatTemplateService extends BaseJpaService<WlyyAuditNotice, WlyyA
     * @return
     * @throws Exception
     */
    public Page<WechatTemplateConfig> searchList(String templateName, String scene, int page, int pageSize) throws Exception {
    public List<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 + ";";
            filters = "and t.template_name= '" + templateName + "' ";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += "scene=" + scene + ";";
            filters += " and t.scene= '" + scene + "' ";
        }
        filters += " order by t.id asc limit " + (page-1)*pageSize +"," +pageSize;
        String sql = "SELECT t.* FROM `weixin_template_config` t WHERE t.`status` = 1 "
                + filters ;
        List<WechatTemplateConfig> WechatTemplateConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(WechatTemplateConfig.class));
        return WechatTemplateConfigs;
    }
        List<WechatTemplateConfig> list = search("", filters, "", page, pageSize);
        return new PageImpl<WechatTemplateConfig>(list, pageRequest, getCount(filters));
    /**
     * 根据模板自定义名称和场景值查询模板消息
     *
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    public int getListCount(String templateName, String scene) throws Exception {
        String filters = "";
        if (!StringUtils.isEmpty(templateName)) {
            filters = "and t.template_name= '" + templateName + "' ";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += " and t.scene= '" + scene + "' ";
        }
        filters += " order by t.id asc ";
        String sql = "SELECT t.* FROM `weixin_template_config` t WHERE t.`status` = 1 "
                + filters ;
        List<WechatTemplateConfig> WechatTemplateConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(WechatTemplateConfig.class));
        return WechatTemplateConfigs.size();
    }
    /**
     * 根据模板自定义名称和场景值查询模板消息详情
     *
     * @param templateName
     * @param scene
     * @return
     * @throws Exception
     */
    public WechatTemplateConfig getTemplate(String templateName, String scene) throws Exception {
    public List<Map<String,Object>> getTemplate(String templateName, String scene) throws Exception {
        String filters = "";
        if (!StringUtils.isEmpty(templateName)) {
            filters = "templateName=" + templateName + ";";
            filters = " AND t.template_name= '" + templateName + "' ";
        }
        if (!StringUtils.isEmpty(scene)) {
            filters += "scene=" + scene + ";";
            filters += " AND c.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 " +
        String sql = "SELECT " +
                " t.template_name templateName, " +
                " c.scene, " +
                " c.scene_description sceneDescription, " +
                " 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;
                " WHERE t.template_name = c.template_name and t.acc_id = '" + accId + "' " +
                filters;
        List<Map<String,Object>> WechatTemplateConfig = jdbcTemplate.queryForList(sql);
        return WechatTemplateConfig;
    }
    /**
     * 修改模板详细信息
     *
     * @param templateName
     * @param scene
     * @param sceneDescription
     * @param first
     * @param remark
     * @param value1
     * @param value2
     * @param value3
     * @param value4
     * @param value5
     * @param value6
     * @param value7
     * @return
     * @throws Exception
     */
    public void updateTemplate(String templateName, String scene, String sceneDescription, String first, String remark,
                               String value1, String value2, String value3, String value4, String value5, String value6, String value7) throws Exception {
//      保持数据唯一性
        WechatTemplateConfig wechatTemplateConfig = wechatTemplateConfigDao.findByScene(templateName, scene);
        if (wechatTemplateConfig != null) {
            wechatTemplateConfig.setTemplateName(templateName);
            wechatTemplateConfig.setScene(scene);
            wechatTemplateConfig.setSceneDescription(sceneDescription);
            wechatTemplateConfig.setFirst(first);
            wechatTemplateConfig.setRemark(remark);
            wechatTemplateConfig.setKeyword1(value1);
            wechatTemplateConfig.setKeyword2(value2);
            wechatTemplateConfig.setKeyword3(value3);
            wechatTemplateConfig.setKeyword4(value4);
            wechatTemplateConfig.setKeyword5(value5);
            wechatTemplateConfig.setKeyword6(value6);
            wechatTemplateConfig.setKeyword7(value7);
            wechatTemplateConfig.setStatus(1);
            if (StringUtils.isEmpty(first)) {
                wechatTemplateConfig.setFirst("");
            }
            wechatTemplateConfigDao.save(wechatTemplateConfig);
        }
    }
    /**
     * 保存模板详细信息
     *
     * @param templateName
     * @param scene
     * @param sceneDescription
     * @param first
     * @param remark
     * @param value1
     * @param value2
     * @param value3
     * @param value4
     * @param value5
     * @param value6
     * @param value7
     * @return
     * @throws Exception
     */
    public Map<String,Object> saveTemplate(String templateName, String scene, String sceneDescription, String first, String remark,
                               String value1, String value2, String value3, String value4, String value5, String value6, String value7) throws Exception {
        Map<String,Object> result = new HashMap<>();
        result.put("code",200);
        result.put("msg","保持成功!");
        WeixinTemplate template = weixinTemplateDao.findByName(accId,templateName);
        if (template == null){
            result.put("code",-1);
            result.put("msg","该名称的模板消息不存在!");
            return result;
        }
        //      保持数据唯一性
        WechatTemplateConfig wechatTemplateConfig = wechatTemplateConfigDao.findByScene(templateName, scene);
        if (wechatTemplateConfig != null) {
            result.put("code",-1);
            result.put("msg","该模板消息场景已存在!");
            return result;
        }else {
            wechatTemplateConfig = new WechatTemplateConfig();
        }
//        规范数据
        wechatTemplateConfig.setTemplateName(templateName);
        wechatTemplateConfig.setScene(scene);
        wechatTemplateConfig.setSceneDescription(sceneDescription);
        wechatTemplateConfig.setFirst(first);
        wechatTemplateConfig.setRemark(StringUtils.isNotEmpty(remark)?remark:null);
        wechatTemplateConfig.setKeyword1(StringUtils.isNotEmpty(value1)?value1:null);
        wechatTemplateConfig.setKeyword2(StringUtils.isNotEmpty(value2)?value2:null);
        wechatTemplateConfig.setKeyword3(StringUtils.isNotEmpty(value3)?value3:null);
        wechatTemplateConfig.setKeyword4(StringUtils.isNotEmpty(value4)?value4:null);
        wechatTemplateConfig.setKeyword5(StringUtils.isNotEmpty(value5)?value5:null);
        wechatTemplateConfig.setKeyword6(StringUtils.isNotEmpty(value6)?value6:null);
        wechatTemplateConfig.setKeyword7(StringUtils.isNotEmpty(value7)?value7:null);
        wechatTemplateConfig.setStatus(1);
        if (StringUtils.isEmpty(first)) {
            wechatTemplateConfig.setFirst("");
        }
        wechatTemplateConfigDao.save(wechatTemplateConfig);
        return result;
    }
}

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

@ -211,6 +211,8 @@
                                        }else {
                                            return "<span style='color:red;'>"+row.value1+"</span>";
                                        }
                                    }else{
                                        return row.value1;
                                    }
                                }
                            },
@ -231,6 +233,8 @@
                                        }else {
                                            return "<span style='color:red;'>"+row.value2+"</span>";
                                        }
                                    }else{
                                        return row.value2;
                                    }
                                }
                            },

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

@ -33,7 +33,7 @@
				<input type="text" id="inp_user_name" placeholder="请输入居民姓名" class="f-ml10" data-attr-scan="userName"/>
			</div>
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_doctor_name" placeholder="请输入医生姓名" class="f-ml10" data-attr-scan="doctorName"/>
				<input type="text" id="inp_doctor_name" placeholder="请输入医生/健管师姓名" class="f-ml10" data-attr-scan="doctorName"/>
			</div>
			<sec:authorize url="/admin/patientDevice/list">
				<div id="btn_search" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >

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

@ -1,187 +1,98 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
	<%@ include file="../head/page_head.jsp"%>
	<title>机构管理</title>
	<title>模板详情</title>
	<style type="text/css">
		.m-form-group label.label_title{width: 100px}
	</style>
</head>
<style>
	.m-form-group label.label_title {
		width: 100px
	}
	.m-form-group p.tip {
		width: auto;
        margin-left: 100px;
        line-height: 20px;
	}
	.m-form-group ul li{
		line-height: 30px;
		margin-left: 100px;
	}
	.m-form-group .inpRadio{
		 vertical-align: bottom;
		 margin: 8px 0 0;
	 }
	.m-form-group .inpChkb{
		vertical-align: sub;
	}
	.m-form-group .l-text-date{
		width: 140px;
	}
	.m-form-group .sendTime{
		width: 138px;
	}
    .m-form-group  span.community{
        width: 50px;
        display: inline-flex;
    }
	.f-pa{
		position: relative;
	}
	.f-pa .m-form-control{
		margin-left: 200px;
		margin-top: 10px;
	}
	.wordwrap{
		float: left;
		display: block;
		margin: 140px 0 0 10px;
	}
	.wordCount .word{
		color: red;
		padding: 0 4px;
	}
	#messageContent .j-text-wrapper{
		float: left;
	}
	#messageContent .l-text-trigger-cancel{
		display: none!important;
	}
</style>
<body>
<div id="div_roles_info_form" class="m-form-inline f-mt20 f-ml30"
	 data-role-form>
	<input type="hidden" id="uuid" value='${UUID}'/>
	<input type="hidden" id="cityAuthority" value='${cityAuthority}'/>
	<input type="hidden" id="areaAuthority" value='${areaAuthority}'/>
	<input type="hidden" id="communityAuthority" value='${communityAuthority}'/>
	<input type="hidden" id="mode" value='${mode}'/>
	<input type="hidden" id="scopeId"/>
	<input type="hidden" id="diseaseTypeId"/>
	<input type="hidden" id="healthSituationId"/>
	<input type="hidden" id="serverTypeId"/>
	<input type="hidden" id="noticeId" value='${id}' data-attr-scan="id" />
<div id="div_template_info_form" data-role-form class="m-form-inline f-mt20 f-ml30" data-role-form>
	<input type="hidden" id="inp_mode" value='${mode}'/>
	<div class="m-form-group" style="padding:10 0 10 0">
		<label class="label_title" style="width:120px">模板名称</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_templateName"  class="required useTitle ajax f-w240 validate-special-char" required-title="模板名称不能为空"  data-attr-scan="templateName" value='${templateName}'/>
		</div>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="">发送范围:</label>
		<div class="u-radio-wrap m-form-control">
			<input type="radio" value="0" name="scope" id="cityScope" class="inpRadio" data-attr-scan=""> 全市
			<input type="radio" value="1" name="scope" id="areaScope" class="inpRadio" data-attr-scan=""> 指定区
			<input type="radio" value="2" name="scope" id="communityScope" class="inpRadio" data-attr-scan=""> 指定社区
		<label class="label_title" style="width:120px">模板场景值</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_scene"  class="required useTitle f-w240 validate-special-char"  required-title="模板场景值不能为空"  data-attr-scan="scene" value='${scene}'/>
		</div>
	</div>
	<div class="m-form-group" id="scope_area" style="display: none">
		<label class="label_title" style="">选择区:</label>
		<div class="u-checkbox-wrap m-form-control scope_areaDiv">
			<%--<input type="checkbox" name="scope_area" class="inpChkb" value="1" data-attr-scan>选项一--%>
			<%--<input type="checkbox" name="scope_area" class="inpChkb" value="2" data-attr-scan>选项二--%>
			<%--<input type="checkbox" name="scope_area" class="inpChkb" value="3" data-attr-scan>选项三--%>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">模板场景描述</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_sceneDescription"  class="required useTitle f-w240 validate-special-char" required-title="模板场景描述不能为空"  required-title="请输入模板场景描述"  data-attr-scan="sceneDescription"/>
		</div>
	</div>
	<div class="m-form-group" id="scope_community" style="display: none">
		<label class="label_title" style="">选择社区:</label>
		<div class="m-form-control scope_communityDiv" style="margin-top: 5px;">
			<%--<input type="checkbox" name="scope_community" class="inpChkb" value="1" data-attr-scan>选项一--%>
			<%--<input type="checkbox" name="scope_community" class="inpChkb" value="2" data-attr-scan>选项二--%>
			<%--<input type="checkbox" name="scope_community" class="inpChkb" value="3" data-attr-scan>选项三--%>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">first</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text"  id="inp_first"  class="required useTitle f-w240 validate-special-char" required-title="first不能为空"  required-title="请输入first内容"  data-attr-scan="first"/>
		</div>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">remark</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_remark"  class="useTitle f-w240"  data-attr-scan="remark"/>
		</div>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="">筛选条件:</label>
		<div class="u-radio-wrap m-form-control">
			<input type="radio" value="0" name="condition_type" class="inpRadio" data-attr-scan=""> 全部居民
			<input type="radio" value="1" name="condition_type" class="inpRadio" data-attr-scan=""> 设置条件
		<label class="label_title" style="width:120px">keyword1</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_value1"  class="useTitle f-w240"  data-attr-scan="value1"/>
		</div>
	</div>
	<div class="m-form-group" id="inpCondition" style="display: none;padding-bottom: 0px">
		<label class="label_title" style=""></label>
		<div class="u-checkbox-wrap m-form-control">
			<input type="checkbox" name="condition" class="inpChkb" value="1" data-class=".serverType" data-name="serverType" data-tip="服务类型" data-attr-scan>按服务类型
			<input type="checkbox" name="condition" class="inpChkb" value="2" data-class=".health_situation" data-name="health_situation" data-tip="健康情况" data-attr-scan>按健康情况
			<input type="checkbox" name="condition" class="inpChkb" value="3" data-class=".diease" data-name="diease" data-tip="疾病类型" data-attr-scan>按疾病类型
	<div class="m-form-group">
		<label class="label_title" style="width:120px">keyword2</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_value2" class="useTitle f-w240"  data-attr-scan="value2"/>
		</div>
	</div>
	<div class="m-form-group" style=" ">
		<ul style="display: block; vertical-align: middle;">
			<li>
				<div class="m-form-group serverType" style="display: none;padding-bottom: 0px;">
					<label class="label_title" style="text-align: left;width: auto;line-height: 20px;">服务类型:</label>
					<div class="u-checkbox-wrap m-form-control serverTypeDiv" style="line-height: 20px;">
						<%--<input type="checkbox" name="server" class="inpChkb" value="1" data-attr-scan>按服务类型--%>
						<%--<input type="checkbox" name="server" class="inpChkb" value="2" data-attr-scan>按健康情况--%>
						<%--<input type="checkbox" name="server" class="inpChkb" value="3" data-attr-scan>按疾病类型--%>
					</div>
				</div>
			</li>
			<li>
				<div class="m-form-group health_situation" style="display: none;padding-bottom: 0px;">
					<label class="label_title" style="text-align: left;width: auto;line-height: 20px;">健康情况:</label>
					<div class="u-checkbox-wrap m-form-control health_situationDiv" style="line-height: 20px;">
						<%--<input type="checkbox" name="health_situation" class="inpChkb" value="1" data-attr-scan>按服务类型--%>
						<%--<input type="checkbox" name="health_situation" class="inpChkb" value="2" data-attr-scan>按健康情况--%>
						<%--<input type="checkbox" name="health_situation" class="inpChkb" value="3" data-attr-scan>按疾病类型--%>
					</div>
				</div>
			</li>
			<li>
				<div class="m-form-group diease" style="display: none;padding-bottom: 0px;">
					<label class="label_title" style="text-align: left;width: auto;line-height: 20px;">疾病类型:</label>
					<div class="u-checkbox-wrap m-form-control dieaseDiv" style="line-height: 20px;">
						<%--<input type="checkbox" name="diease" class="inpChkb" value="1" data-attr-scan>按服务类型--%>
						<%--<input type="checkbox" name="diease" class="inpChkb" value="2" data-attr-scan>按健康情况--%>
						<%--<input type="checkbox" name="diease" class="inpChkb" value="3" data-attr-scan>按疾病类型--%>
					</div>
				</div>
			</li>
		</ul>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">keyword3</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_value3" class="useTitle f-w240"  data-attr-scan="value3"/>
		</div>
	</div>
	<div class="m-form-group" style="">
		<label class="label_title" style="">通知标题:</label>
		<div class="l-text-wrapper m-form-control essential">
			<input type="text" id="title" class="required useTitle validate-special-char" required-title="请输入通知标题" placeholder="请输入通知标题" data-attr-scan="title" />
	<div class="m-form-group">
		<label class="label_title" style="width:120px">keyword4</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_value4" class="useTitle f-w240"  data-attr-scan="value4"/>
		</div>
	</div>
    <div class="m-form-group">
        <label class="label_title" style="">通知内容:</label>
        <div class="l-text-wrapper m-form-control" id="messageContent">
				<textarea type="text" id="content"  maxlength="120"
                          class="required max-length-120 validate-special-char" placeholder="请输入通知具体内容,最多120字,因每条短信限制70字,若大于70字可能将被分割成两条短信" data-attr-scan="content"></textarea>
				<span class="wordwrap" id="wordwrap"><var class="word">0</var>/120</span>
        </div>
    </div>
	<div class="m-form-group">
		<label class="label_title">发送时间:</label>
		<div class="l-text-wrapper m-form-control useTitle ajax validate-special-char">
			<input id="send_type_combo_select" data-type="text" class="" data-name="text" data-attr-scan="sendType">
		<label class="label_title" style="width:120px">keyword5</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_value5" class="useTitle f-w240" data-attr-scan="value5"/>
		</div>
		<div class="m-form-control essential send_time" style="margin-left: 10px;">
			<input type="text" id="send_time" class="sendTime required" placeholder="输入发送时间"  required-title="不能为空" data-attr-scan="sendTime"/>
	</div>
	<div class="m-form-group">
		<label class="label_title" style="width:120px">keyword6</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_value6" class="useTitle f-w240"   data-attr-scan="value6"/>
		</div>
	</div>
	<div class="m-form-group">
		<p class="tip">1、立即发送,则审核通过后立即发送</p>
		<p class="tip">2、定时发送,则审核通过后将在指定时间发送。如在指定时间前未审核通过,则将自动撤回</p>
		<label class="label_title" style="width:120px">keyword7</label>
		<div class="l-text-wrapper m-form-control">
			<input type="text"  id="inp_value7" class="useTitle f-w240"  data-attr-scan="value7"/>
		</div>
	</div>
	<div class="m-form-group" id="format_show">
		<label class="label_title" style="width:120px">format</label>
		<div class="l-text-wrapper m-form-control">
			<textarea id="inp_format" class="useTitle f-w240" data-attr-scan="format" readonly="readonly" cols="30" rows="10"></textarea>
		</div>
	</div>
	</div>
	<div class="m-form-group f-pa" id="btn_save_close" style="right: 10px;bottom: 0;">
		<div class="m-form-control">
			<input type="button" value="提    交" id="btn_save" class="l-button u-btn u-btn-primary u-btn-large f-ib f-vam" />
			<div id="btn_cancel" class="l-button u-btn u-btn-cancel u-btn-large f-ib f-vam" >
				<span>关闭</span>
			</div>
	<div class="m-form-group" id="btn_save_close"  style="display: none;margin:10px auto 20px;">
		<div class="m-form-control" style="width: 203px;margin: 0 auto;">
			<input type="button" value="保存" id="btn_save" class="l-button u-btn u-btn-primary u-btn-large f-ib f-vam" />
			<input type="button" value="关闭" id="btn_cancel" class="l-button u-btn u-btn-cancel u-btn-large f-ib f-vam" />
		</div>
	</div>
</div>

+ 176 - 533
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_edit_js.jsp

@ -1,575 +1,218 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<script language="javascript">
    $(function(){
        //先选出 textarea 和 统计字数 dom 节点
        var wordCount = $("#messageContent"),
                textArea = wordCount.find("textarea"),
                word = wordCount.find(".word");
        //调用
        statInputNum(textArea,word);
    });
    /*
     * 剩余字数统计
     * 注意 最大字数只需要在放数字的节点哪里直接写好即可 如:<var class="word">200</var>
     */
    function statInputNum(textArea,numItem) {
        var max = numItem.text(), curLength;
        curLength = textArea.val().length;
        numItem.text(max - curLength);
        textArea.on('input propertychange', function () {
            var _value = $(this).val().replace(/\n/gi,"");
            numItem.text(_value.length);
        });
    }
</script>
<script>
    (function ($, win) {
	(function ($, win) {
		$(function () {
			/* ************************** 变量定义 ******************************** */
			var Util = $.Util;
			var notificationInfo = null;
            var serviceLabelType = 1;
            var healthLabelType = 2;
            var dieaseLabelType = 3;
			var province = 350000;
			var city = 350200;
			var isAuditor = ${isAuditor};
			// 表单校验工具类
			var templateName = $('#inp_templateName').val();
			var scene = $('#inp_scene').val();
            var type = $('#inp_mode').val();
			var info = "";
			var jValidation = $.jValidation;
			/* *************************** 函数定义 ******************************* */
			//页面初始化
			function pageInit() {
				notificationInfo.init();
                info.init();
				info.initForm();
			}
			//发送范围事件
            $(":radio[name='scope']").click(function(){
                var scope = $(this).val();
                var scopeId = $("#scopeId").val();//修改时选中值
                if(scope=="0"){
                    $("#scope_area").hide();
                    $("#scope_community").hide();
                }else if(scope=="1"){//展示区
                    $.ajax({
                        url: ctx + "/common/districtAuthority",
                        method: "post",
                        dataType: "json",
                        data: {"type": 3, "code": city},
                        success: function (data) {
                            if(data.status=='200'){
                                var html = "";
                                if(scopeId){
                                    var scopeIds = scopeId.split(",");
                                    for(var i=0;i<data.list.length;i++){
                                        var town = data.list[i];
                                        if(scopeId.indexOf(town.code)<0){
                                            html +="<input type='checkbox' name='scope_area' class='inpChkb' data-name='"+town.name+"' value='"+town.code+"' >"+town.name+"&nbsp;";
                                        }else{
                                            html +="<input type='checkbox' checked='checked' name='scope_area' class='inpChkb' data-name='"+town.name+"' value='"+town.code+"' >"+town.name+"&nbsp;";
                                        }
                                    }
                                }else{
                                    for(var i=0;i<data.list.length;i++){
                                        var town = data.list[i];
                                        html +="<input type='checkbox' name='scope_area' class='inpChkb' data-name='"+town.name+"' value='"+town.code+"' >"+town.name+"&nbsp;";
                                    }
                                }
                                $(".scope_areaDiv").html(html);
                            }else{
                                $.Notice.error(data.msg);
                            }
                        }
                    });
                    $("#scope_area").show();
                    $("#scope_community").hide();
                }else if(scope=="2"){//展示社区
                    $.ajax({
                        url: ctx + "/admin/hos/community",
                        method: "post",
                        dataType: "json",
                        data: {"city": city},
                        success: function (data) {
                            if(data.status=='200'){
                                var communityAuthority = $("#communityAuthority").val();
                                var html = "";
                                var attrTown = "";
                                for(var i=0;i<data.list.length;i++){
                                    var town = data.list[i];
                                    attrTown += town.town+";";
                                    var tn = town.town.split(":");
                                    html +="<div  class='m-form-group u-checkbox-wrap m-form-control' style='height: auto;line-height: 15px;'>";
                                    if("2"==communityAuthority||scopeId.indexOf(tn[0])>=0){
                                        html +="<input type='checkbox' name='"+tn[0]+"' checked='checked' class='inpChkb chkCommunity' data-name='"+town.town+"' data-area='"+tn[1]+"' value='"+tn[0]+"' >"+tn[1]+"&nbsp;";
                                    }else{
                                        html +="<input type='checkbox' name='"+tn[0]+"' class='inpChkb chkCommunity' data-name='"+town.town+"' data-area='"+tn[1]+"' value='"+tn[0]+"' >"+tn[1]+"&nbsp;";
                                    }
                                    for(var j=0;j<town.community.length;j++){
                                        community = town.community[j];
                                        if(j>0&&j%6==0){
                                            html+="<br><span style='display: inline-block;width: 61px;'></span>";
                                        }
                                        var comName = community.name;
                                        comName = comName.substring(3,comName.length);
                                        if("2"==communityAuthority||scopeId.indexOf(community.code)>=0){
                                            html +="<input type='checkbox' name='"+town.town+"' checked='checked' class='inpChkb' data-name='"+comName+"' value='"+community.code+"' ><span class='community'>"+comName+"</span>&nbsp;";
                                        }else{
                                            html +="<input type='checkbox' name='"+town.town+"' class='inpChkb' data-name='"+comName+"' value='"+community.code+"' ><span class='community'>"+comName+"</span>&nbsp;";
                                        }
                                    }
                                    html +="</div>"
                                    html +="<br>";
                                }
                                $(".scope_communityDiv").attr("attr-towns",attrTown);
                                $(".scope_communityDiv").html(html);
                            }else{
                                $.Notice.error(data.msg);
                            }
                        }
                    });
                    $("#scope_area").hide();
                    $("#scope_community").show();
                }
            });
            //选择区 全选/反选 社区
            $(document).on("click",".chkCommunity",function () {
                var name = $(this).attr("data-name");
                $("[name = '"+name+"']:checkbox").prop("checked", $(this).is(':checked'));
            });
            //筛选条件
            $(":radio[name='condition_type']").click(function(){
                var condition_type = $(this).val();
                if(condition_type=="0"){
                    $("#inpCondition").hide();
                    $("[name = 'condition']:checkbox").prop("checked",false);
                    $(".serverType").hide();
                    $(".health_situation").hide();
                    $(".diease").hide();
                }else if(condition_type=="1"){
                    $("#inpCondition").show();
                }
            });
            //标签事件
            $(":checkbox[name='condition']").change(function () {
                var chkValue = $(this).val();
                var selClass = $(this).attr("data-class");
                if($(this).is(':checked')){
                    $.ajax({
                        url: ctx + "/common/label/signPatientLabel",
                        method: "post",
                        dataType: "json",
                        data: {"labelType": chkValue},
                        success: function (data) {
                            if(data.status=='200'){
                                var html = "";
                                var name = selClass.substring(1,selClass.length);
                                for(var i=0;i<data.list.length;i++){
                                    var patiemtLabel = data.list[i];
                                    if(i>0&&i%6==0){
                                        html+="<br>";
                                    }
                                    var selectId = "";
                                    if("1"==chkValue){
                                        selectId = $("#serverTypeId").val();
                                    }
                                    if("2"==chkValue){
                                        selectId = $("#healthSituationId").val();
                                    }
                                    if("3"==chkValue){
                                        selectId = $("#diseaseTypeId").val();
                                    }
                                    if(selectId&&selectId.indexOf(patiemtLabel.code)>=0){
                                        html +="<input type='checkbox' name='"+name+"' checked='checked' class='inpChkb' data-name='"+patiemtLabel.name+"' value='"+patiemtLabel.code+"' >"+patiemtLabel.name+"&nbsp;";
                                    }else{
                                        html +="<input type='checkbox' name='"+name+"' class='inpChkb' data-name='"+patiemtLabel.name+"' value='"+patiemtLabel.code+"' >"+patiemtLabel.name+"&nbsp;";
                                    }
                                }
                                $(selClass+"Div").html(html);
                            }else{
                                $.Notice.error(data.msg);
                            }
                            $(selClass).show();
                        }
                    });
                }else{
                    $(selClass).hide();
                }
            });
			/* *************************** 模块初始化 ***************************** */
			notificationInfo = {
				$form: $("#div_roles_info_form"),
				$scope: $("input[name='scope']"),//发送范围
				$scope_area: $("input[name='scope_area']"),//指定区
				$scope_community: $("input[name='scope_community']"),//指定社区
				$condition_type: $("input[name='condition_type']"),//筛选条件
				$condition: $("input[name='condition']"),//筛选条件
				$server: $("input[name='server']"),//服务类型
				$health_situation: $("input[name='health_situation']"),//健康情况
				$diease: $("input[name='diease']"),//疾病类型
				$title: $("#title"),//消息标题
				$content: $("#content"),//消息内容
				$send_type_combo_select: $("#send_type_combo_select"),//发送方式
				$send_time: $("#send_time"),//发送时间
				$btnsave: $("#btn_save"),//保存按钮
				$btncancle: $("#btn_cancel"),//结束按钮
			info = {
				//变量
				$form: $("#div_template_info_form"),
				$templateName: $('#inp_templateName'),
				$scene: $('#inp_scene'),
				$sceneDescription: $('#inp_sceneDescription'),
				$first: $('#inp_first'),
				$remark: $("#inp_remark"),
                $value1:$("#inp_value1"),
                $value2:$("#inp_value2"),
                $value3:$("#inp_value3"),
                $value4:$("#inp_value4"),
                $value5:$("#inp_value5"),
                $value6:$("#inp_value6"),
                $value7:$("#inp_value7"),
                $format:$("#inp_format"),
				init: function () {
					_this = this;
                    //范围权限控制
                    var cityAuthority = $("#cityAuthority").val();
                    var areaAuthority = $("#areaAuthority").val();
                    var communityAuthority = $("#communityAuthority").val();
                    if("0"==cityAuthority){
                        $("#cityScope").attr("disabled", false);
                        $("#cityScope").attr("disabled","disabled")
                    }
                    if("0"==areaAuthority){
                        $("#areaScope").attr("disabled", false);
                        $("#areaScope").attr("disabled", "disabled");
				    //input样式
					this.$form.attrScan();
					this.$templateName.ligerTextBox({width: 340});
					this.$scene.ligerTextBox({width: 340});
                    this.$sceneDescription.ligerTextBox({width: 340});
					this.$first.ligerTextBox({width: 340});
					this.$remark.ligerTextBox({width: 340});
					this.$value1.ligerTextBox({width: 340});
					this.$value2.ligerTextBox({width: 340});
					this.$value3.ligerTextBox({width: 340});
					this.$value4.ligerTextBox({width: 340});
					this.$value5.ligerTextBox({width: 340});
					this.$value6.ligerTextBox({width: 340});
					this.$value7.ligerTextBox({width: 340});
					this.$format.ligerTextBox({width: 340,height:150});
				},
				initForm: function () {
                    this.bindEvents();
					if (type == "view") {
					    //查看时只读属性不可更新数据
                        $('input').attr('readonly','readonly')
						$(".essential").addClass("XXXtest");
						$(".essential").removeClass("essential");
						$("#btn_save_close").css("display", "none");
					} else {
						$(".XXXtest").addClass("essential");
						$("#btn_save_close").css("display", "block");
                        if(type == "edit"){
                            $("#new_psw_div").css("display", "block");
                            $("#old_psw_div").css("display", "block");
                        }
					}
					if(type == 'new'){
					    $('#format_show').css("display", "none")
                    }
                    if("0"==communityAuthority){
                        $("#communityScope").attr("disabled", false);
                        $("#communityScope").attr("disabled", "disabled");
                    if(type == 'edit'){
                        $('#inp_templateName').attr('readonly','readonly')
                        $('#inp_scene').attr('readonly','readonly')
                    }
//                    if("2"==communityAuthority){
//                        $("#communityScope").attr("checked", true);
//                    }
					this.$form.show();
				},
					this.$title.ligerTextBox({width: 240, validate: {required: true}});
				//绑定事件
				bindEvents: function () {
					var validator = new jValidation.Validation(this.$form, {
						immediate: true, onSubmit: false,
						onElementValidateForAjax: function (elm) {
                    var sendTypeSelect = this.$send_type_combo_select.ligerComboBox({
                        with:180,
                        data: [
                            { text: "立即发送", id: "0" },
//                            { text: "定时发送", id: "1" }//暂时只做立即发送(有审核权限-新增时立即发送,无权限-审核通过后立即发送)
                        ],
                        valueField: 'id',
                        textField: 'text',
                        cancelable: false,
                        initIsTriggerEvent: false,
                        onSelected: function (newvalue){
                            if(newvalue=="0"){
                                $(".send_time").hide();
                            }else{
                                $(".send_time").show();
                            }
                        }
                    });
						}
					});
                    sendTypeSelect.setValue("0");
                    this.$content.ligerTextBox({width: 430, height: 150, validate: {required: true}});
					this.$form.attrScan();
					_this = this;
					var self = this;
					$("#btn_save").click(function () {
					    //保存按钮
                        var values = self.$form.Fields.getValues();
                        if (!validator.validate()) {
                            return;
                        }
                        if (type == "edit") {
                            update(values);
                        }else if(type == "new"){
                            save(values);
                        }
					var noticeId = $("#noticeId").val();
					var mode = $("#mode").val();//模式  (新增/修改/查看)
                    });
					if (isNoEmpty(noticeId) && noticeId != 0) {
						//id不为空时 :为修改页面,进行修改操作
						//异步根据id获取消息信息
                    //查看模板信息
                    function getData(templateName,scene) {
                        // var dataModel = $.DataModel.init();
                        $.ajax({
                            url: ctx + "/admin/notification/notice",
                            url: ctx + "/admin/wechatTemplate/getTemplate",
                            async: false,
                            method: "post",
                            dataType: "json",
                            data: {id: noticeId},
                            success: function (result) {
                                if (result.status == '200') {
                                    var notice = result.data;
                                    var scope = notice.scope;
                                    var scopeId = notice.scopeId;
                                    $("#scopeId").val(scopeId);//范围
                                    $(":radio[name='scope'][value='" + scope + "']").click();
                                    var conditionType = notice.condition;//筛选条件
                                    var diseaseTypeId = notice.diseaseTypeId;
                                    var healthSituationId = notice.healthSituationId;
                                    var serverTypeId = notice.serverTypeId;
                                    $("#serverTypeId").val(serverTypeId);
                                    $("#healthSituationId").val(healthSituationId);
                                    $("#diseaseTypeId").val(diseaseTypeId);
                                    $(":radio[name='condition_type'][value='" + conditionType + "']").click();
                                    if(serverTypeId){
                                        $(":checkbox[name='condition'][value='1']").click();
                                    }
                                    if(healthSituationId){
                                        $(":checkbox[name='condition'][value='2']").click();
                                    }
                                    if(diseaseTypeId){
                                        $(":checkbox[name='condition'][value='3']").click();
                                    }
                                    _this.$form.Fields.fillValues({
                                        title: notice.title,
                                        content: notice.content,
                            data: {
                                "templateName": templateName,
                                "scene":scene
                            },
                            success: function (data) {
                                if (data.status == 200) {
                                    var data = data.data[0]
                                    self.$form.Fields.fillValues({
                                        templateName: data.templateName,
                                        scene: data.scene,
                                        sceneDescription: data.sceneDescription,
                                        first: data.first,
                                        remark: data.remark,
                                        value1: data.keyword1,
                                        value2: data.keyword2,
                                        value3: data.keyword3,
                                        value4: data.keyword4,
                                        value5: data.keyword5,
                                        value6: data.keyword6,
                                        value7: data.keyword7,
                                        format: data.format
                                    });
                                    $(".word").text(notice.content.length);
                                    //发送方式
                                    var sendType = notice.sendType;
                                    if("1"==sendType){
                                        var sendTime = notice.sendTime;
                                        sendTime = sendTime.substring(0,16);
                                        sendTypeSelect.setValue(sendType);
                                        $("#send_time").ligerDateEditor({showTime: true,initValue: sendTime});
                                        $(".send_time").show();
                                    }
                                    // parent.window.reloadMasterGrid(data.data);
                                    // parent.window.closeUserInfoDialog();
                                } else {
                                    $.Notice.error(result.msg);
                                    $.Notice.error(data.msg);
                                }
                            },
                            error: function (data) {
                                $.Notice.error("系统异常,请联系管理员!");
                            }
                        });
					}else{
                        this.$send_time.ligerDateEditor({showTime: true});
                    }
					this.$form.show();
					this.bindEvents();
				},
				bindEvents: function () {
					var self = this;
					var flag = false;
					$("#btn_save").click(function () {
						var values = self.$form.Fields.getValues();
						if (values.id == '') {
							values.id = 0;
						}
                        values.city = city+"";
                        var s = self.$send_type_combo_select;
                        values.sendType = self.$send_type_combo_select.ligerComboBox().getValue();
                        values.sendTime = self.$send_time.val();
                        values.communityAuthority = $("#communityAuthority").val();
						if (isEmpty(values.scope)) {
							$.Notice.error("请选择发送范围!");
							return false;
						}
						if(values.scope=="0"){
                            values.conditionDescription = "厦门市 全市";
                        }else if(values.scope=="1"){
                            var area = "";
                            var areaName = "";
                            $("input[name='scope_area']:checked").each(function(){
                                area+=$(this).val()+",";
                                areaName+=$(this).attr("data-name")+",";
                            });
                            if(area==""){
                                $.Notice.error("请至少选择一个区!");
                                return false;
                            }
                            areaName = areaName.substring(0,areaName.length-1);
                            area = area.substring(0,area.length-1);
                            values.town = area;
                            values.scopeId = area;
                            values.scopeContent = areaName;
                            values.conditionDescription = "厦门市 "+areaName;
                        }else if(values.scope=="2"){
                            var attrTowns = $(".scope_communityDiv").attr("attr-towns");
                            if(attrTowns.length==0){
                                $.Notice.error("请至少选择一个社区!");
                                return false;
                            }
                            var towns = attrTowns.split(";");
                            var selctCommunity = "";
                            var townCommunity = "";
                            var conditionDescription = "";
                            for(var i=0;i<towns.length;i++){
                                var townName = towns[i];
                                var strCom = "";
                                var strComName = "";
                                $("input[name='"+townName+"']:checked").each(function(){
                                    strCom+=$(this).val()+",";
                                    strComName+=$(this).attr("data-name")+",";
                                });
                                if(strCom.length>0){
                                    //selctCommunity += strCom.substring(0,strCom.length-1);
                                    selctCommunity += strCom;
                                    townCommunity += townName.split(":")[0] +":"+strCom.substring(0,strCom.length-1)+";";
                                    conditionDescription += townName.split(":")[1] +":"+strComName.substring(0,strComName.length-1)+";\n ";
                                }
                            }
                            if(selctCommunity.length==0){
                                $.Notice.error("请至少选择一个社区!");
                                return false;
                            }
                            values.community = selctCommunity.substring(0,selctCommunity.length-1);
                            //values.townCommunity = townCommunity;
                            values.scopeId = townCommunity.substring(0,townCommunity.length-1);
                            values.scopeContent = conditionDescription;
                            values.conditionDescription = "厦门市 "+ conditionDescription;
                        }
                        if (isEmpty(values.condition_type)) {
                            $.Notice.error("请选择筛选条件!");
                            return false;
                        }
						if (values.condition_type=='0') {//全部居民
							var condition = "0";
							var conditionId = "";
							values.condition = condition;
							values.conditionId = conditionId;
						}
                        if(values.condition_type=='1'){
                            var condition = "";
                            var conditionId = "";
                            $("input[name='condition']:checked").each(function(){
                                condition+=$(this).val()+",";
                                var conDetail = "";
                                var nameDetail = "";
                                var dataName = $(this).attr("data-name");
                                $("input[name='"+dataName+"']:checked").each(function(){
                                    conDetail+=$(this).val()+",";
                                    conditionId+=$(this).val()+",";
                                    nameDetail+=$(this).attr("data-name")+",";
                                });
                                if(conDetail.length==0){
                                    $.Notice.error("请至少选择一个"+$(this).attr("data-tip")+"!");
                                    return false;
                                }
                                if(dataName=="serverType"){
                                    values.serverTypeId = conDetail.substring(0,conDetail.length-1);
                                    values.serverTypeContent = nameDetail.substring(0,nameDetail.length-1);
                                }else if(dataName=="health_situation"){
                                    values.healthSituationId = conDetail.substring(0,conDetail.length-1);
                                    values.healthSituationContent = nameDetail.substring(0,nameDetail.length-1);
                                }else if(dataName=="diease"){
                                    values.diseaseTypeId = conDetail.substring(0,conDetail.length-1);
                                    values.diseaseTypeContent= nameDetail.substring(0,nameDetail.length-1);
                                }
                            });
                            if(condition.length==0){
                                $.Notice.error("请至少选择一个设置条件!");
                                return false;
                            }
                            values.condition = condition;
                            values.conditionId = conditionId;
                        }
                        var validator = new jValidation.Validation(self.$form, {
                            immediate: true, onSubmit: false,
                            onElementValidate: function (result,elm) {
                                if (Util.isStrEquals($(elm).attr("id"), 'title')) {
                                    if (isEmpty(values.title)) {
                                        result.setResult(false);
                                        return result;
                                    }
                                }
                                if (Util.isStrEquals($(elm).attr("id"), 'content')) {
                                    if (isEmpty(values.content)) {
                                        result.setResult(false);
                                        return result;
                                    }
                                }
                                if (Util.isStrEquals($(elm).attr("id"), 'send_time')) {
                                    if (values.sendType=="1"&&isEmpty(values.sendTime)) {
                                        result.setResult(false);
                                        return result;
                                    }
                                }
                            }
                        });
                        validator.validate();
						if (isEmpty(values.title)) {
							$.Notice.error("通知标题不能为空!");
							return false;
						}
                        if (isEmpty(values.content)) {
                            $.Notice.error("通知内容不能为空!");
                            return false;
                        }
                        if(values.sendType=="1"&&isEmpty(values.sendTime)){
                            $.Notice.error("发送时间不能为空!");
                            return false;
                        }
						var ddf = $.ligerDialog.open({
                            height: 100,
                            width: 300,
                            title: "提示",
                            isHidden: true,
                            target: "<div style='margin: 0 auto; width: 200px;' >是否确认提交消息通知?提交后无法变更</div>",
							buttons: [
								{
									text: '立即提交', onclick: function (i, d) {
									d.hide();
									update(values);
								}
								},
                                { text: '我在看看', onclick: function (i, d) { d.hide(); }}
                            ]
                        });
//                        $.ajax({
//                            url: ctx + "/admin/notification/isNoticeAuditor",
//                            async: false,
//                            method: "post",
//                            dataType: "json",
//                            data: {},
//                            success: function (data) {
//                                if (data.status == 200) {
//                                    var authority = data.authority;
//
//                                    $.ligerDialog.open({
//                                        height: 250,
//                                        width: 300,
//                                        title: "tishi",
//                                        isHidden: true,
//                                        target: "是否确认提交消息通知?提交后无法变更",
//                                        buttons: [  { text: '立即提交', onclick: function (i, d) { update(values); }},
//                                            { text: '我在看看', onclick: function (i, d) { d.hide(); }}
//                                        ]
//                                    });
//                                } else {
//                                    $.Notice.error(data.msg);
//                                }
//                            }
//                        });
					});
                    if(type == "edit" || type == "view"){
                        getData(templateName,scene);
                    }
                    //编辑模板信息
					function update(values) {
						var dataModel = $.DataModel.init();
						var message = "保存中...";
						var url = "update";
						if (values.id == 0) {
							url = "create";
						}
						var wattingDialog = $.Notice.waitting(message);
						dataModel.updateRemote(ctx + "/admin/notification/" + url, {
							data: {jsonData: JSON.stringify(values)},
						// var dataModel = $.DataModel.init();
						$.ajax({
							url: ctx + "/admin/wechatTemplate/updateTemplate",
							async: false,
							method: "post",
							dataType: "json",
							data: {
                                "templateName": values.templateName,
                                "scene":values.scene,
                                "sceneDescription":values.sceneDescription,
                                "first":values.first,
                                "remark":values.remark,
                                "value1":values.value1,
                                "value2":values.value2,
                                "value3":values.value3,
                                "value4":values.value4,
                                "value5":values.value5,
                                "value6":values.value6,
                                "value7":values.value7
                            },
							success: function (data) {
								wattingDialog.close();
								if (data.status == 200) {
									parent.window.reloadMasterGrid(data.msg);
									parent.window.closeInfoDialog();
									parent.window.closeUserInfoDialog();
								} else {
									$.Notice.error(data.msg);
								}
							},
							error: function (data) {
								wattingDialog.close();
								$.Notice.error("系统异常,请联系管理员!");
							}
						});
					}
                    //新增模板信息
                    function save(values) {
                        // var dataModel = $.DataModel.init();
                        $.ajax({
                            url: ctx + "/admin/wechatTemplate/saveTemplate",
                            async: false,
                            method: "post",
                            dataType: "json",
                            data: {
                                "templateName": values.templateName,
                                "scene":values.scene,
                                "sceneDescription":values.sceneDescription,
                                "first":values.first,
                                "remark":values.remark,
                                "value1":values.value1,
                                "value2":values.value2,
                                "value3":values.value3,
                                "value4":values.value4,
                                "value5":values.value5,
                                "value6":values.value6,
                                "value7":values.value7
                            },
                            success: function (data) {
                                if (data.status == 200) {
                                    parent.window.reloadMasterGrid(data.msg);
                                    parent.window.closeUserInfoDialog();
                                } else {
                                    $.Notice.error(data.msg);
                                }
                            }
                        });
                    }
					$("#btn_cancel").click(function () {
						parent.window.closeInfoDialog();
						parent.window.closeUserInfoDialog();
					});
				}
			};
			/* *************************** 页面初始化 **************************** */
			}
			pageInit();
		})
	})(jQuery, window);
		});
	})(jQuery, window)
</script>

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

@ -4,37 +4,35 @@
<html lang="en">
<head>
	<%@ include file="../head/page_head.jsp" %>
	<title>用户管理</title>
	<title>微信模板消息管理</title>
</head>
<style>
</style>
<body>
<div id="div_wrapper">
	<!-- 检索条件 -->
	<div class="m-retrieve-area f-h50 f-dn f-pr m-form-inline" data-role-form style='display: block;'>
		<div class="m-form-group f-mt10">
			<%--<sec:authorize url="/admin/roles/rolesList">--%>
			<div class="m-form-control f-fs12 f-ml10">
				<input type="text" id="inp_searchNm" placeholder="请输入标题/提交人">
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_templateName" placeholder="请输入微信模板名称" class="f-ml10" data-attr-scan="templateName"/>
			</div>
			<div class="m-form-control f-fs12 f-ml10">
				<input id="sel_status" placeholder="选择状态"/>
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_scene" placeholder="请输入模板场景值" class="f-ml10" data-attr-scan="scene"/>
			</div>
			<%--</sec:authorize>--%>
			<%--<sec:authorize url="/admin/roles/create">--%>
			<div class="m-form-control f-mr20" style="float: right">
				<div id="div_new_notice" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam">
					<span>新增消息通知</span>
			<sec:authorize url="/admin/wechatTemplate/list">
			<div id="btn_search" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
				<span>查询</span>
			</div>
			</sec:authorize>
			<sec:authorize url="/admin/wechatTemplate/editInitial">
			<div class="m-form-control m-form-control-fr">
				<div id="btn_add" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam" style="margin-right: 20px;">
					<span>新增</span>
				</div>
			</div>
			<%--</sec:authorize>--%>
			</sec:authorize>
		</div>
	</div>
	<!-- 列表 -->
	<div id="div_notice_list">
	<div id="div_template_list">
	</div>
</div>

+ 67 - 185
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/wechat/wechat_list_js.jsp

@ -9,9 +9,6 @@
			var retrieve = null;
			var master = null;
			var isFirstPage = false;
			var status = '';
			var isAuditor = ${isAuditor};
			/* *************************** 函数定义 ******************************* */
			function pageInit() {
@ -21,144 +18,73 @@
			function reloadGrid(params) {
				if (isFirstPage) {
					master.grid.options.newPage = 1;
					this.grid.options.newPage = 1;
				}
				master.grid.setOptions({parms: params});
				master.grid.loadData(true);
				this.grid.setOptions({parms: params});
				this.grid.loadData(true);
			}
			/* *************************** 模块初始化 ***************************** */
			retrieve = {
				$element: $('.m-retrieve-area'),
				$addBtn: $('#div_new_notice'),
				$searchNm: $("#inp_searchNm"),
				$status: $('#sel_status'),
				$searchBtn: $('#btn_search'),
				$addBtn: $('#btn_add'),
				$templateName: $("#inp_templateName"),
				$scene: $("#inp_scene"),
				init: function () {
					_this = this;
					this.$searchNm.ligerTextBox({
						width: 240, isSearch: true, search: function () {
							master.reloadGrid();//参数:标签/提交人+消息通知状态
						}
					})
					//状态复选框,选择时也刷新列表
					_this.statusBox = _this.$status.ligerComboBox({
						width: 180,
						data: [
							{text: '全部', statusId: ''},
							{text: '待提交', statusId: '1'},
							{text: '待审核', statusId: '2'},
							{text: '待发送', statusId: '3'},
							{text: '已发送', statusId: '4'},
							{text: '已拒绝', statusId: '5'},
							{text: '已撤回', statusId: '6'},
						],
						initIsTriggerEvent: false,
						valueFieldID: 'statusId',
						valueField: 'statusId',
						onSelected: function (newvalue) {
							status = newvalue;
							if (!master || !master.grid) {
								return
							}
							master.reloadGrid();//参数:标签/提交人+消息通知状态
						},
					this.$element.show();
					this.$element.attrScan();
					window.form = this.$element;
					this.$templateName.ligerTextBox({width: 200});
					this.$scene.ligerTextBox({width: 200})
					this.bindEvents();
				},
				bindEvents: function () {
					var self = this;
					self.$searchBtn.click(function () {
						master.grid.options.newPage = 1;
						master.reloadGrid();
					});
                    this.bindEvents();
					if (isAuditor) {
						_this.statusBox.setValue('2');//根据是否是审核者设置默认值,审核者:默认选中待审核
					} else {
						_this.statusBox.setValue('');//根据是否是审核者设置默认值,审核者:待审核;非:默认全部
					}
				},bindEvents: function () {
                    var self = this;
                    self.$addBtn.click(function () {
                        master.infoDialog = $.ligerDialog.open({
                            height: 550,
                            width: 750,
                            title: '新增消息',
                            url: ctx + '/admin/notification/infoInit/' + "0" + "?mode=add"
                        })
                    });
                }
					self.$addBtn.click(function () {
						$.publish("info:create", [''])
					});
				}
			};
			master = {
				infoDialog: null,
				grid: null,
				init: function () {
					this.grid = $("#div_notice_list").ligerGrid($.LigerGridEx.config({
						url: ctx + '/admin/notification/list',
						parms: {status: status},
					var data;
					this.grid = $("#div_template_list").ligerGrid($.LigerGridEx.config({
						url: ctx + '/admin/wechatTemplate/list',
						parms: {},
						ajaxHeader: ajaxHeaderName,
						ajaxHeaderValue: ajaxHeaderValue,
						columns: [
							{display: 'ID', name: 'id', hide: true},
							{display: '标题', name: 'title', width: '14%', align: "left"},
							{display: '状态', name: 'status', hide: true},
							{
								display: '状态', name: 'status', width: '6%', align: "center",
								render: function (row) {
									var html = '';
									if (row.status == '0') {
										return "创建中"
									}
									;
									if (row.status == '1') {
										return "待提交"
									}
									;
									if (row.status == '2') {
										return "待审核"
									}
									;
									if (row.status == '3') {
										return "待发送"
									}
									;
									if (row.status == '4') {
										return "已发送"
									}
									;
									if (row.status == '5') {
										return "已拒绝"
									}
									;
									if (row.status == '6') {
										return "已撤回"
									}
									;
								}
							},
							{display: '通知总人数', name: 'totalCount', width: '15%', align: "center"},
//							{display: '定时发送时间', name: 'sendTime', width: '15%', align: "center"},
							{display: '提交人Id', name: 'applyUserId', hide: true},
							{display: '提交人', name: 'applyUserName', width: '10%', align: "center"},
							{display: '提交时间', name: 'applyTime', width: '15%', align: "center"},
							{display: '审核Id', name: 'auditUserId', hide: true},
							{display: '审核人', name: 'auditUserName', width: '10%', align: "center"},
							{display: '审核时间', name: 'auditTime', width: '15%', align: "center"},
                            {display: 'ID', name: 'id', hide: true},
                            {display: '模板名称', name: 'templateName', width: '15%', align: "left"},
                            {display: '场景值', name: 'scene', width: '5%', align: "left"},
                            {display: '场景描述', name: 'sceneDescription', width: '15%', align: "center"},
                            {display: 'first', name: 'first', width: '10%', align: "center"},
                            {display: 'remark', name: 'remark', width: '10%', align: "center"},
                            {display: 'keyword1', name: 'keyword1', width: '5%', align: "center"},
                            {display: 'keyword2', name: 'keyword2', width: '5%', align: "center"},
                            {display: 'keyword3', name: 'keyword3', width: '5%', align: "center"},
                            {display: 'keyword4', name: 'keyword4', width: '5%', align: "center"},
                            {display: 'keyword5', name: 'keyword5', width: '5%', align: "center"},
                            {display: 'keyword6', name: 'keyword6', width: '5%', align: "center"},
                            {display: 'keyword7', name: 'keyword7', width: '5%', align: "center"},
							{
								display: '操作', name: 'operator', width: '15%', align: "center", isSort: false,
								display: '操作', name: 'operator', width: '10%', align: "center", isSort: false,
								render: function (row) {
									var html = '';
									html += '<a  href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:view", row.id) + '">查看</a>';
									if (row.owned == true) {
										if (row.status == 5 || row.status == 6) {
											html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:edit", row.id) + '">编辑</a>';
											html += '<a  style="margin-left:10px;" title="删除" href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:del", row.id) + '">删除</a>';
										}
										if (row.status == 2) {
											html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:revoke", row.id) + '">撤回</a>';
										}
										if (row.status == 1) {
											html += '<a  style="margin-left:10px;" title="删除" href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:del", row.id) + '">删除</a>';
										}
									}
									<%--<sec:authorize url="/admin/user/update">--%>
									if (row.owned == false && row.auditor == true && row.status == 2) {
										html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "info:edit", row.id) + '">审核</a>';
									html += '<a  href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:view", row.templateName,row.scene) + '">查看</a>';
									<sec:authorize url="/admin/wechatTemplate/editInitial">
									if (!Util.isStrEquals(row.code, "admin")) {
										html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "info:edit", row.templateName,row.scene) + '">编辑</a>';
									}
									<%--</sec:authorize>--%>
									</sec:authorize>
									return html;
								}
							}
@ -174,82 +100,49 @@
						//如果是新增,直接刷新页面
						master.grid.loadData();
					} else {
						debugger
						//如果是查询(获取查询参数)
						var searchNm = retrieve.$searchNm.val() || '';
						var status = retrieve.statusBox.getValue() || '';
						var values = {
							searchNm: searchNm,
							status: status
						}
						//如果是查询
						retrieve.$element.attrScan();
						var values = retrieve.$element.Fields.getValues();
						reloadGrid.call(this, values);
					}
				},
				delRecord: function (id, code) {
					var self = this;
					$.ajax({
						url: ctx + "/admin/notification/delete",
						data: {"id": id},
						method: "post",
						dataType: "json",
						success: function (result) {
							if (result.status == '200') {
								window.reloadMasterGrid(result.msg);
							} else {
								$.Notice.error(result.msg);
							}
						},
						error: function (data) {
							$.Notice.error("系统异常,请联系管理员!");
						}
					})
				},
				bindEvents: function () {
					var self = this;
					$.subscribe('info:view', function (event, id) {
						var title = '消息通知详情';
					$.subscribe('info:view', function (event,templateName,scene) {
						var title = '查看微信模板';
						self.infoDialog = $.ligerDialog.open({
							height: 550,
							width: 750,
							urlParms: {"id": id, "mode": "view"},
							width: 600,
							urlParms: {"templateName": templateName, "scene": scene, "mode": "view"},
							title: title,
							url: ctx + '/admin/notification/view'
							url: ctx + '/admin/wechatTemplate/editInitial'
						})
					});
                    $.subscribe('info:revoke', function (event, id) {
                        var title = '消息通知撤回';
                        self.infoDialog = $.ligerDialog.open({
                            height: 550,
                            width: 750,
                            urlParms: {"id": id, "mode": "revoke"},
                            title: title,
                            url: ctx + '/admin/notification/view'
                        })
                    });
					$.subscribe('info:edit', function (event, id) {
						var title = '编辑用户信息';
					$.subscribe('info:edit', function (event, templateName,scene) {
						var title = '编辑微信模板';
						self.infoDialog = $.ligerDialog.open({
							height: 550,
							width: 750,
							width: 600,
							urlParms: {"templateName": templateName,"scene":scene,"mode": "edit"},
							title: title,
                            url: ctx + '/admin/notification/infoInit/' + id + "?mode=edit"
							url: ctx + '/admin/wechatTemplate/editInitial'
						})
					});
					$.subscribe('info:create', function (event, id) {
						var title = '新增消息';
					$.subscribe('info:create', function (event) {
						var title = '新增微信模板';
						self.infoDialog = $.ligerDialog.open({
							height: 460,
							width: 490,
							height: 550,
							width: 600,
							urlParms: {"mode": "new"},
							title: title,
							url: ctx + '/notification/infoInit' + "0" + "?mode=add"
							url: ctx + '/admin/wechatTemplate/editInitial'
						})
					});
					$.subscribe('info:del', function (event, id, code) {
					$.subscribe('info:del', function (event, templateName, scene) {
						$.ligerDialog.confirm('确认删除该行信息?<br>如果是请点击确认按钮,否则请点击取消。', function (yes) {
							if (yes) {
								self.delRecord(id, code);
								self.delRecord(templateName, scene);
							}
						});
					})
@ -266,17 +159,6 @@
			win.closeUserInfoDialog = function () {
				master.infoDialog.close();
			};
            win.closeInfoDialog = function () {
                master.infoDialog.close();
            };
			win.openEditInfoDialog = function (id) {
				master.infoDialog.close();
				$.publish("info:edit", id);
			}
			win.deleteNoticeDialog = function (id) {
				master.delRecord(id);
				master.infoDialog.close();
			}
			/* *************************** 页面初始化 **************************** */
			pageInit();
		});

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

@ -0,0 +1,49 @@
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 com.yihu.wlyy.figure.label.util.MakeModelIDUtil;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
 * 适用于线上/线下的签约、缴费
 */
@Component
public class IsOnlineConvert 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.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabelCode(model.getLabelCode());
                    saveModel.setLabeName(map.get(model.getLabelCode()));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));
                    saveModels.add(saveModel);
                }
        );
        return saveModels;
    }
}

+ 3 - 0
patient-co/patient-co-figure-label/src/main/java/com/yihu/wlyy/figure/label/convert/SignStateConvert.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;
@ -32,6 +33,8 @@ public class SignStateConvert implements Convert{
                model -> {
                    SaveModel saveModel = new SaveModel();
                    saveModel.setIdcard(model.getIdcard());
                    saveModel.setModelId(MakeModelIDUtil.makeModelID(model,""));
                    saveModel.setLabelCode(model.getLabelCode());
                    saveModel.setLabelType(one.getParentCode());
                    saveModel.setLabeName(map.get(model.getLabelCode()));
                    saveModel.setCreateTime(DateFormatUtils.format(new Date(), ConstantUtil.date_format));

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

@ -164,11 +164,15 @@ public class Mysql2ESJob implements Job {
            sqlFiledString.append(sqlFiled).append(sqlFiledCondition).append("\'"+sqlFiledValue+"\'");
        }
        if (sql.contains("where")) {
        if (sql.contains("where") &&  !sql.contains("$")) {
            result.append(" and ").append(sqlFiledString.toString());
        }else if (sql.contains("$")){
            StringBuffer otherCondition = new StringBuffer();
            otherCondition.append(" where ").append(sqlFiledString.toString());
            if (sql.contains("where")){
                otherCondition.append(" and ").append(sqlFiledString.toString());
            }else{
                otherCondition.append(" where ").append(sqlFiledString.toString());
            }
            result.replace(result.indexOf("$"),result.indexOf("$")+1,otherCondition.toString());
        }else {
            result.append(" where ").append(sqlFiledString.toString());

+ 21 - 6
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PatientConfirmReceiptJob.java

@ -4,10 +4,12 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PhysicalExaminationRecords;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.physicalExamination.PatientPhysicalExaminationDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.physicalExamination.PatientPhysicalExaminationService;
import com.yihu.wlyy.service.app.prescription.PrescriptionLogService;
import com.yihu.wlyy.task.PushMsgTask;
@ -57,6 +59,8 @@ public class PatientConfirmReceiptJob implements Job {
    private PatientPhysicalExaminationService examinationService;
    @Autowired
    private PrescriptionLogService payLogService;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
@ -134,11 +138,16 @@ public class PatientConfirmReceiptJob implements Job {
        if (type == 1) {
            String url = "prescription/html/order_tracking.html?code=" + PrescriptionCode +"&represented="+patient;
            String first = name + "您好,您的续方订单将在4天后自动确认收药,如您已经取药,请点击本消息完成确认收药操作,结束订单";
            String remark = "如果您希望延长自动确认收药时间,请点击本消息后进行延长收药操作。";
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_change","syytx");
            String first = templateConfig.getFirst();
            first = first.replace("key1",(name==null?"":name));
            String remark = templateConfig.getRemark();
            String keyword3 = templateConfig.getKeyword3();
//            String first = name + "您好,您的续方订单将在4天后自动确认收药,如您已经取药,请点击本消息完成确认收药操作,结束订单";
//            String remark = "如果您希望延长自动确认收药时间,请点击本消息后进行延长收药操作。";
            sendJson.put("keyword1", name);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("keyword3", "续方订单状态");
            sendJson.put("keyword3", keyword3);
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url+ "&openid=" + openId +"&toUser=" + patient + "&toName=" +name);//带参数的模板跳转链接
@ -163,11 +172,17 @@ public class PatientConfirmReceiptJob implements Job {
            logger.info("sendJson: " + sendJson);
        }else if (type == 2) {
            String url = "prescription/html/order_tracking.html?code=" + PrescriptionCode +"&represented="+patient;
            String first = name + "您好,您的续方订单已自动确认收药";
            String remark = "如果您未收到续方药品,请及时与社区药房工作人员联系。";
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_change","sytx");
            String first = templateConfig.getFirst();
            first = first.replace("key1",(name==null?"":name));
            String remark = templateConfig.getRemark();
            String keyword3 = templateConfig.getKeyword3();
//            String first = name + "您好,您的续方订单已自动确认收药";
//            String remark = "如果您未收到续方药品,请及时与社区药房工作人员联系。";
            sendJson.put("keyword1", name);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("keyword3", "续方订单状态");
            sendJson.put("keyword3", keyword3);
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url+ "&openid=" + openId +"&toUser=" + patient + "&toName=" +name);//带参数的模板跳转链接

+ 18 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/wechat/WechatTemplateConfigDao.java

@ -0,0 +1,18 @@
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;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @Description: 分场景值查询模板文案内容
 * @Author: WuJunjie
 * @Date: Created in 2018/2/23 11:51
 */
public interface WechatTemplateConfigDao extends PagingAndSortingRepository<WechatTemplateConfig, Long>, JpaSpecificationExecutor<WechatTemplateConfig> {
    //根据自定义模板名称、场景值查询有效模板内容
    @Query("select t  from WechatTemplateConfig t where t.templateName=?1 and t.scene=?2 and t.status = 1 ")
    WechatTemplateConfig findByScene(String templateName, String scene);
}

+ 10 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PatientPhysicalExaminationService.java

@ -5,11 +5,13 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientRemindRecords;
import com.yihu.wlyy.entity.patient.PhysicalExaminationRecords;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.physicalExamination.PatientPhysicalExaminationDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.IdCardUtil;
@ -48,6 +50,8 @@ public class PatientPhysicalExaminationService extends BaseService {
    private WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
    private PatientPhysicalExaminationDao examinationDao;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    public void sendExaminationTemplate() throws Exception {
@ -57,10 +61,14 @@ public class PatientPhysicalExaminationService extends BaseService {
        c.add(Calendar.YEAR, -1);
        Date yesteryear = c.getTime();
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","cqjktj");
        String first = templateConfig.getFirst();
        String keyword1 = templateConfig.getKeyword1();
        JSONObject json = new JSONObject();
        String first = "温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行65岁以上老年人的免费健康体检哟~(如今年已体检请忽略)";
//        String first = "温馨提醒,您已经超过一年没有到社区进行健康体检啦,为了您和您的家庭医生了解您近期的健康状况,请及时到签约社区进行65岁以上老年人的免费健康体检哟~(如今年已体检请忽略)";
        json.put("remark", "");
        json.put("keyword1", "健康体检");
        json.put("keyword1", keyword1);
        json.put("keyword2", format.format(new Date()));
        String accessToken = accessTokenUtils.getAccessToken();

+ 38 - 7
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -8,12 +8,14 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorRecord;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PrenatalInspectorPlanDao;
import com.yihu.wlyy.repository.patient.PrenatalInspectorRecordDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.JwMaternalChildService;
import com.yihu.wlyy.task.PushMsgTask;
@ -58,6 +60,8 @@ public class PrenatalInspectorPreCardService extends BaseService {
    private DoctorDao doctorDao;
    @Autowired
    private JwMaternalChildService jwMaternalChildService;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    Logger logger = LoggerFactory.getLogger(PrenatalInspectorPreCardService.class);
@ -127,22 +131,49 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    record.setSendTime(new Date());
                    if (day == 7) {
                        //产检提醒
                        json.put("remark", "产检内容以医生实际检查为准。点击进行预约");
                        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","cjtx");
                        String first = templateConfig.getFirst();
                        first = first.replace("key1",(name==null?"":name));
                        String remark = templateConfig.getRemark();
                        String keyword1 = templateConfig.getKeyword1();
                        String keyword2 = templateConfig.getKeyword2();
                        keyword2 = keyword2.replace("key1",(DateUtil.getStringDateShort()==null?"":DateUtil.getStringDateShort()))
                                .replace("key2",(plan.getCheckItem()==null?"":plan.getCheckItem()))
                                .replace("br","\n");
//                        json.put("remark", "产检内容以医生实际检查为准。点击进行预约");
//                        json.put("first", name + ",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略");
                        json.put("remark", remark);
                        json.put("first", name + ",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略");
                        json.put("url", "wdyy/html/appointment-register.html?openid=" + openId + "&toUser=" + patientCode + "&toName=" + name);
                        json.put("keyword1", "产检提醒");
                        String keyword2 = DateUtil.getStringDateShort() + "\n产检内容:" + plan.getCheckItem();
                        json.put("keyword1", keyword1);
//                        String keyword2 = DateUtil.getStringDateShort() + "\n产检内容:" + plan.getCheckItem();
                        json.put("keyword2", keyword2);
                        pushMsgTask.sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                        recordDao.save(record);
                    } else if (day == 1) {
                        //产检就诊提醒
                        json.put("remark", "产检内容以医生实际检查为准。点击查看预约记录");
                        json.put("first", name + ",您好!您和您的宝宝即将进行产检啦~请按时就诊,如已就诊,请忽略");
                        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","cjjztx");
                        String first = templateConfig.getFirst();
                        first = first.replace("key1",(name==null?"":name));
                        String remark = templateConfig.getRemark();
                        String keyword1 = templateConfig.getKeyword1();
                        String keyword2 = templateConfig.getKeyword2();
                        keyword2 = keyword2.replace("key1",(DateUtil.getStringDateShort()==null?"":DateUtil.getStringDateShort()))
                                .replace("key2",(plan.getCheckItem()==null?"":plan.getCheckItem()))
                                .replace("br","\n");
//                        json.put("remark", "产检内容以医生实际检查为准。点击查看预约记录");
//                        json.put("first", name + ",您好!您和您的宝宝即将进行产检啦~请按时就诊,如已就诊,请忽略");
                        json.put("url", "wdyy/html/my-appointment.html?openid=" + openId + "&toUser=" + patientCode + "&toName=" + name);
                        json.put("keyword1", "产检就诊提醒");
                        String keyword2 = DateUtil.getStringDateShort() + "\n产检内容:" + plan.getCheckItem();
//                        json.put("keyword1", "产检就诊提醒");
//                        String keyword2 = DateUtil.getStringDateShort() + "\n产检内容:" + plan.getCheckItem();
                        json.put("remark", remark);
                        json.put("first", first);
                        json.put("keyword1", keyword1);
                        json.put("keyword2", keyword2);
                        pushMsgTask.sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                        recordDao.save(record);

+ 58 - 14
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionNoticesService.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -29,6 +31,8 @@ public class PrescriptionNoticesService extends BaseService {
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    private static final Logger LOGGER = LoggerFactory.getLogger(PrescriptionNoticesService.class);
@ -64,9 +68,16 @@ public class PrescriptionNoticesService extends BaseService {
        if (type == 1) {
            switch (status) {
                case 0:
                    first = name + "您好,你的续方申请医生已审核。";
                    WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_audit","xfbtg");
                    first = templateConfig.getFirst();
                    first = first.replace("key1",(name==null?"":name));
                    remark = templateConfig.getRemark();
                    String keyword1 = templateConfig.getKeyword1();
                    /*first = name + "您好,你的续方申请医生已审核。";
                    remark = "您可点击消息查看详情,修改续方信息后重新提交。";
                    sendJson.put("keyword1", "审核不通过");
                    sendJson.put("keyword1", "审核不通过");*/
                    sendJson.put("keyword1", keyword1);
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
@ -90,9 +101,16 @@ public class PrescriptionNoticesService extends BaseService {
                    }
                    break;
                case 1:
                    first = name + "您好,你的续方申请医生已审核。";
                    templateConfig = templateConfigDao.findByScene("template_doctor_audit","xftg");
                    first = templateConfig.getFirst();
                    first = first.replace("key1",(name==null?"":name));
                    remark = templateConfig.getRemark();
                    String keyword = templateConfig.getKeyword1();
                    /*first = name + "您好,你的续方申请医生已审核。";
                    remark = "您可点击消息查看详情并完成支付。";
                    sendJson.put("keyword1", "审核通过");
                    sendJson.put("keyword1", "审核通过");*/
                    sendJson.put("keyword1", keyword);
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
@ -116,9 +134,16 @@ public class PrescriptionNoticesService extends BaseService {
                    }
                    break;
                case 2:
                    first = name + "您好,您的续方申请医生已修改处方清单并审核。";
                    templateConfig = templateConfigDao.findByScene("template_doctor_audit","tztg");
                    first = templateConfig.getFirst();
                    first = first.replace("key1",(name==null?"":name));
                    remark = templateConfig.getRemark();
                    String keyword2 = templateConfig.getKeyword1();
                    /*first = name + "您好,您的续方申请医生已修改处方清单并审核。";
                    remark = "您可点击消息查看详情并完成支付。";
                    sendJson.put("keyword1", "审核通过");
                    sendJson.put("keyword1", "审核通过");*/
                    sendJson.put("keyword1", keyword2);
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
@ -143,9 +168,15 @@ public class PrescriptionNoticesService extends BaseService {
                    break;
            }
        } else if (type == 2) {
            first = name + "您好,您的续方订单已完成配药,请尽快致社区医院取药。";
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","xfqy");
            first = templateConfig.getFirst();
            first = first.replace("key1",(name==null?"":name));
            String keyword1 = templateConfig.getKeyword1();
//            first = name + "您好,您的续方订单已完成配药,请尽快致社区医院取药。";
            remark = "";
            sendJson.put("keyword1", "续方订单取药");
            sendJson.put("keyword1", keyword1);
//            sendJson.put("keyword1", "续方订单取药");
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
@ -169,11 +200,17 @@ public class PrescriptionNoticesService extends BaseService {
            }
        }
        if (type == 3) {
            first = name + "您好,您的续方订单配送员" + doctName + "已顺利取药,续方状态变更为配送中。";
            remark = "您可点击消息查看详情。";
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_change","xfqy");
            first = templateConfig.getFirst();
            remark = templateConfig.getRemark();
            first = first.replace("key1",(name==null?"":name)).replace("key2",(doctName==null?"":doctName));
            String keyword3 = templateConfig.getKeyword3();
           /* first = name + "您好,您的续方订单配送员" + doctName + "已顺利取药,续方状态变更为配送中。";
            remark = "您可点击消息查看详情。";*/
            sendJson.put("keyword1", doctName);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("keyword3", "续方状态");
            sendJson.put("keyword3", keyword3);
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
@ -196,9 +233,16 @@ public class PrescriptionNoticesService extends BaseService {
            }
        }
        if (type == 4) {
            first = name + ",您好!您的续方订单已成功配送。";
            remark = "感谢您的使用。";
            sendJson.put("keyword1", "续方申请");
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_service","xfwc");
            first = templateConfig.getFirst();
            remark = templateConfig.getRemark();
            first = first.replace("key1",(name==null?"":name));
            String keyword1 = templateConfig.getKeyword1();
//            first = name + ",您好!您的续方订单已成功配送。";
//            remark = "感谢您的使用。";
//            sendJson.put("keyword1", "续方申请");
            sendJson.put("keyword1", keyword1);
            sendJson.put("keyword2", doctName);//审核医生姓名 开处方的医生(团队长?)
            sendJson.put("keyword3", ordenTime);//订单完成时间
            sendJson.put("first", first);

+ 25 - 8
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.service.template;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -35,6 +37,8 @@ public class DoctorFeldsherTemplateService extends BaseService {
    private PatientDao patientDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    private static final Logger logger = LoggerFactory.getLogger(DoctorFeldsherTemplateService.class);
    /**
@ -55,12 +59,18 @@ public class DoctorFeldsherTemplateService extends BaseService {
        JSONObject sendJson = new JSONObject();
        if (type == 1) {
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","xtjc");
            String first = templateConfig.getFirst();
            first = first.replace("key1",(name==null?"":name)).replace("key2",(comment==null?"":comment));
            String remark = templateConfig.getRemark();
            String keyword1 = templateConfig.getKeyword1();
            String url = "jkjl/html/health-index-add-bloodsugar.html?represented="+patient;
            String first = name + "您好,请按照您的血糖监测方案测量" + comment + "血糖数据。";
            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1", "血糖测量");
//            String first = name + "您好,请按照您的血糖监测方案测量" + comment + "血糖数据。";
//            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1", keyword1);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
@ -75,7 +85,7 @@ public class DoctorFeldsherTemplateService extends BaseService {
                        JSONObject j = jsonArray.getJSONObject(i);
                        Patient member = (Patient) j.get("member");
                        JSONObject newJson =  new JSONObject();
                        newJson.put("keyword1", "血糖测量");
                        newJson.put("keyword1", keyword1);
                        newJson.put("keyword2", dateFormat.format(new Date()));
                        newJson.put("remark", remark);
                        newJson.put("toUser", member.getCode());//带参数的模板跳转链接
@ -89,9 +99,16 @@ public class DoctorFeldsherTemplateService extends BaseService {
            logger.info("sendJson: " + sendJson);
        }else if (type == 2) {
            String url = "jkjl/html/health-index-add-bloodpressure.html?represented="+patient;
            String first = name + "您好,请按照您的血压监测方案测量血压数据。";
            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1", "血压测量");
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","xyjc");
            String first = templateConfig.getFirst();
            first = first.replace("key1",(name==null?"":name));
            String remark = templateConfig.getRemark();
            String keyword1 = templateConfig.getKeyword1();
//            String first = name + "您好,请按照您的血压监测方案测量血压数据。";
//            String remark = "您可使用智能设备测量后自动上传数据,或点击详情手动上传测量数据";
            sendJson.put("keyword1",keyword1);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
@ -106,7 +123,7 @@ public class DoctorFeldsherTemplateService extends BaseService {
                        JSONObject j = jsonArray.getJSONObject(i);
                        Patient member = (Patient) j.get("member");
                        JSONObject newJson =  new JSONObject();
                        newJson.put("keyword1", "血压测量");
                        newJson.put("keyword1", keyword1);
                        newJson.put("keyword2", dateFormat.format(new Date()));
                        newJson.put("remark", remark);
                        newJson.put("toUser", member.getCode());//带参数的模板跳转链接

+ 32 - 19
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/RemindExpensesTask.java

@ -3,6 +3,8 @@ package com.yihu.wlyy.task;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.consult.ConsultService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.util.DateUtil;
@ -36,6 +38,8 @@ public class RemindExpensesTask implements Runnable {
    ConsultService consultService;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    private SMSService smsService;
@ -60,6 +64,13 @@ public class RemindExpensesTask implements Runnable {
                    }
                    sb.append(p.getMobile());
                }
                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_expenses_remind","jftx");
                String first = templateConfig.getFirst();
                String remark = templateConfig.getRemark();
                first = first.replace("key1",( doctor.getName()==null?"": doctor.getName()));
                remark = remark.replace("key1",(p.getName()==null?"":p.getName())).replace("key2",(hospital.getName()==null?"":hospital.getName()))
                        .replace("key3",(hospital.getAddress()==null?"":hospital.getAddress()));
                // 微信提醒
                JSONObject json = new JSONObject();
                json.put("first", "缴费提醒");
@ -67,39 +78,41 @@ public class RemindExpensesTask implements Runnable {
                json.put("represented",p.getCode());//被代理人
                json.put("name", p.getName());
                json.put("doctor", doctor.getCode());
                json.put("doctorName", doctor.getName());
//                json.put("doctorName", doctor.getName());
                json.put("doctorName", first);
                json.put("date", DateUtil.dateToStrShort(new Date()));
                json.put("content", p.getName() + ",您好!为完成家庭医生签约,尽早为您提供家庭医生服务,请尽快到" + hospital.getName() + "(地址:" + hospital.getAddress() + ")缴费");
//                json.put("content", p.getName() + ",您好!为完成家庭医生签约,尽早为您提供家庭医生服务,请尽快到" + hospital.getName() + "(地址:" + hospital.getAddress() + ")缴费");
                json.put("content", remark);
                json.put("remark", "");
                if (StringUtils.isNotEmpty(p.getOpenid())) {
                    // 添加到发送队列
                    pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 8, p.getOpenid(), p.getName(), json);
                }
                //发送代理人
                JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(),p.getOpenid());
                if(jsonArray!=null&&jsonArray.length()>0){
                    String first = (String) json.get("doctorName");
                    for (int i = 0;i<jsonArray.length();i++){
                        JSONObject j  = jsonArray.getJSONObject(i);
                        Patient member = (Patient) j.get("member");
                        JSONObject data = json;
                        data.remove("toUser");
                        data.put("toUser",member.getCode());
                        data.remove("doctorName");
                        data.put("doctorName", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) +"\n"+first);
                        pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 8, member.getOpenid(), p.getName(), data);
                }else {
                    //发送代理人
                    JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
                    if (jsonArray != null && jsonArray.length() > 0) {
                        first = (String) json.get("doctorName");
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject j = jsonArray.getJSONObject(i);
                            Patient member = (Patient) j.get("member");
                            JSONObject data = json;
                            data.remove("toUser");
                            data.put("toUser", member.getCode());
                            data.remove("doctorName");
                            data.put("doctorName", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + "\n" + first);
                            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 8, member.getOpenid(), p.getName(), data);
                        }
                    }
                }
                //发送IM
                consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p.getCode(), doctor.getName() + "医生提醒您:为完成家庭医生签约," +
                        "尽早为您提供家庭医生服务,请尽快到" + doctor.getName() + "(地址:" + hospital.getAddress() + ")缴费", "1", p.getName());
                consultService.sendMucMessageBySingnType(doctor.getCode(), doctor.getName(), p.getCode(), doctor.getName() + "医生提醒您:"+remark, "1", p.getName());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        JSONObject result = smsService.sendMsg(sb.toString(), doctor.getName() + "医生提醒您:为完成家庭医生签约," +
                "尽早为您提供家庭医生服务,请尽快到" + hospital.getName() + "(地址:" + hospital.getAddress() + ")缴费");
                "尽早为您提供家庭医生服务,您可登录微信账号,进入签约管理,选择待缴费的签约记录进行缴费操作,如需线下缴费,请尽快到" + hospital.getName() + "(地址:" + hospital.getAddress() + ")缴费");
    }
}

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

@ -5087,7 +5087,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/service/jimeiJkEdu/JMJkEduArticleService.java

@ -1120,6 +1120,10 @@ public class JMJkEduArticleService extends BaseService {
                            String	secondLevelCategoryName,String firstLevelCategoryId,String firstLevelCategoryName,String content,String operatorRoleCode,
                            String opertorRoleLevel,Integer userScope,String articleId,Integer roleType) throws Exception {
        //避免前端上传图片失败还传递失败信息到后台
        if(image.startsWith("{")&&image.endsWith("}")){
            throw new Exception("上传图片失败!");
        }
        if(!StringUtils.isEmpty(articleId)){
            JSONObject obj = thirdJkEduArticleService.getArticalById(articleId,null,"");
            if(!StringUtils.isEmpty(image)&&!(obj.get("articleCover")+"").equals(image)){
@ -1323,7 +1327,7 @@ public class JMJkEduArticleService extends BaseService {
            heapm.setLeaveWords(one.getLeaveWords());//医生留言
            doctor = doctorDao.findByCode(one.getDoctorCode());
            heapm.setPhoto(doctor.getPhoto());
            heapm.setTotalData(total);
//            heapm.setTotalData(total);
            result.add(heapm);
            // heapm.setTime();//时间  xx小时前  2017-10-11
        }