Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan 4 years ago
parent
commit
60d8d23409
23 changed files with 836 additions and 475 deletions
  1. 19 3
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java
  2. 2 0
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  3. 87 12
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  4. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/door/WlyyDoorServiceOrderDO.java
  5. 24 0
      svr/svr-door-serivce/sql/初始sql.sql
  6. 29 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/common/EntranceController.java
  7. 13 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorController.java
  8. 68 12
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoorOrderController.java
  9. 13 13
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoorStatisticAnalyzeController.java
  10. 85 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/DoorCommentController.java
  11. 101 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorCommentService.java
  12. 43 131
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorOrderService.java
  13. 1 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorServiceApplicationService.java
  14. 21 98
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/WlyyDoorServiceOrderService.java
  15. 57 32
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/ServerPackageService.java
  16. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/WlyyMessageService.java
  17. 47 11
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/statics/DoorStatisticAnalyzeService.java
  18. 6 4
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/statics/StatisticsUtilService.java
  19. 147 146
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/util/MessageUtil.java
  20. 42 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/util/StreamUtil.java
  21. 11 11
      svr/svr-door-serivce/src/main/resources/application.yml
  22. 8 1
      svr/svr-door-serivce/src/main/resources/bootstrap.yml
  23. 1 0
      svr/svr-door-serivce/src/main/resources/conclusion.mht

+ 19 - 3
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/TnyyEntranceService.java

@ -21,14 +21,11 @@ import com.yihu.jw.restmodel.hospital.prescription.*;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import com.yihu.utils.security.MD5;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.signature.qual.IdentifierOrArray;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -779,6 +776,25 @@ public class TnyyEntranceService {
        return new JSONArray();
    }
    /**
     * 上门服务项目
     * @return
     * @throws Exception
     */
    public JSONArray findGY_YLSF() throws Exception{
        String sql = "SELECT * from GY_YLSF h";
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("findGY_YLSF:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if(status!=null&&status == 200){
            return rs.getJSONArray("detailModelList");
        }
        return new JSONArray();
    }
    /**
     * 获取健康档案住院记录

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java

@ -43,6 +43,8 @@ public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String
    @Query("select code as code,name as name from BaseOrgDO where del = 1")
    List<Map<String,Object>> findOrgListBySaasId();
    @Query("select a from BaseOrgDO a where a.del = '1'")
    List<BaseOrgDO> findByAll();
    List<BaseOrgDO> findByCityCode(String cityCode);

+ 87 - 12
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -352,7 +352,7 @@ public class ElasticsearchUtil {
//        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" quotaCode in(" + index + ")  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='6'");
//        sql.append(" and areaLevel='6'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
@ -803,7 +803,7 @@ public class ElasticsearchUtil {
        }
        sql.append(" quotaCode in(" + index + ")  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='6'");
//        sql.append(" and areaLevel='6'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
@ -842,6 +842,7 @@ public class ElasticsearchUtil {
            }
        }
        sql.append(groupBy);
        logger.info("sql :" + sql.toString());
        return excute(sql.toString(), SaveModel.class, "", "");
    }
@ -1757,7 +1758,22 @@ public class ElasticsearchUtil {
        return returnModels;
    }
    public List findDateQuotaWithoutLevel(String startDate, String endDate, String index, String slaveKey) throws Exception {
    /**
     * 将slaveKey1作为筛选条件而不进行group by
     *
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @param area      区域code
     * @param level     等级
     * @param index     指标
     * @param timeLevel 1增量 2到达量
     * @param interval  1日 2周 3月
     * @param lowLevel  下一级区域等级
     * @return
     * @throws Exception
     */
    public List findDateQuotaLevel0BySlaveKey1(String startDate, String endDate, String area, int level, String index, String timeLevel, String interval, String lowLevel, String slaveKey1) throws Exception {
        //时间格式转换  yyyy-MM-dd转成 2017-07-17T00:00:00+0800
        if (StringUtils.isNotEmpty(startDate)) {
            if (startDate.length() > 10) {
@ -1773,17 +1789,76 @@ public class ElasticsearchUtil {
                endDate = changeDate(endDate);
            }
        }
        StringBuffer sql = new StringBuffer();
        StringBuffer groupBy = new StringBuffer();
        String low_level = level + "";
        if (StringUtils.isNotEmpty(lowLevel)) {
            low_level = lowLevel;
        }
        StringBuffer sb = new StringBuffer();
        sb.append("select sum(result1) as result1,sum(result2) as result2 from ").append(esIndex)
                .append(" where city='350200' and quotaCode in(").append(index)
                .append(") and timeLevel='1' and areaLevel='6' and quotaDate>='").append(startDate).append("' ");
        sb.append("and quotaDate<='").append(endDate).append("'");
        if (StringUtils.isNotEmpty(slaveKey)) {
            sb.append(" and slaveKey1='").append(slaveKey).append("'");
        if (SaveModel.deptLevel.equals(low_level)) {
            sql.append("select dept,deptName,sum(result1) result1, sum(result2) result2 from " + esIndex + " where ");
            groupBy.append("  group by dept,deptName");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from " + esIndex + " where ");
            groupBy.append("  group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from " + esIndex + " where ");
            groupBy.append("  group by town,townName");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from " + esIndex + " where ");
            groupBy.append("  group by city,cityName");
        }else if (SaveModel.doctorLevel.equals(low_level)) {
            sql.append("select doctor,doctorName,sum(result1) result1,sum(result2) result2 from " + esIndex + " where ");
            groupBy.append("  group by doctor,doctorName ");
        }
        sb.append(" group by town,townName,hospital,hospitalName order by town,townName, hospital,hospitalName");
        return excute(sb.toString(), SaveModel.class, "", "");
        if (StringUtils.isNotEmpty(area)) {
            if (SaveModel.deptLevel.equals(level + "")) {
                sql.append(" dept='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }else if (SaveModel.doctorLevel.equals(level + "")) {
                sql.append(" doctor='" + area + "'");
            }
            sql.append(" and ");
        }
//        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" quotaCode in(" + index + ")  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
//        sql.append(" and areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
        if (StringUtils.isNotEmpty(endDate)) {
            sql.append(" and quotaDate<='" + endDate + "'");
        }
        if (StringUtils.isNotEmpty(slaveKey1) && !commonParams.equals(slaveKey1)) {
            String[] temp = slaveKey1.split(",");
            String slaveKey1Temp = "";
            for(String one : temp){
                slaveKey1Temp += ",'"+one+"'";
            }
            sql.append(" and slaveKey1 in ("+slaveKey1Temp.substring(1)+")");
        }
        //根据时间维度分组
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month','time_zone'='+08:00','alias'='quotaDate') ");
            } else if (SaveModel.interval_week.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week','time_zone'='+08:00','alias'='quotaDate') ");
            } else if (SaveModel.interval_day.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d','time_zone'='+08:00','alias'='quotaDate') ");
            }
        }
        sql.append(groupBy);
        return excute(sql.toString(), SaveModel.class, "", "");
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/door/WlyyDoorServiceOrderDO.java

@ -550,6 +550,7 @@ public class WlyyDoorServiceOrderDO extends UuidIdentityEntityWithOperator {
    private List<WlyyDoorPrescriptionDO> prescriptionDOList;//上门前开的方
    private List<WlyyDoorPrescriptionDO> afterPrescriptionList;//上门后开的方
    private String outpatientId;//关联门诊记录
    /**
     * 快捷类型,1是快捷类型,其他值不是
@ -1181,4 +1182,13 @@ public class WlyyDoorServiceOrderDO extends UuidIdentityEntityWithOperator {
    public void setShortcutType(String shortcutType) {
        this.shortcutType = shortcutType;
    }
    @Column(name = "outpatient_id")
    public String getOutpatientId() {
        return outpatientId;
    }
    public void setOutpatientId(String outpatientId) {
        this.outpatientId = outpatientId;
    }
}

+ 24 - 0
svr/svr-door-serivce/sql/初始sql.sql

@ -460,6 +460,7 @@ CREATE TABLE `wlyy_door_service_order` (
  `prescription_status` int(1) DEFAULT NULL COMMENT '开方状态:1已完成,0未开方',
  `prescription_code` varchar(100) DEFAULT NULL COMMENT '处方单号,多个用逗号隔开',
  `prescription_time` timestamp NULL DEFAULT NULL COMMENT '开方完成时间',
  `outpatient_id` varchar(50) DEFAULT NULL COMMENT '关联门诊记录',
  `type` tinyint(2) DEFAULT '1' COMMENT '发起类型(1本人发起 2家人待预约 3医生代预约)',
  `authorize_image` varchar(500) DEFAULT NULL COMMENT '电子健康卡授权图片',
  `relation_code` varchar(50) DEFAULT NULL COMMENT '业务关联',
@ -614,6 +615,29 @@ INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('8', NULL, 'PROFESSIONAL_STATE', '7', '1', '不便分类的其他从业人员', '8', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('9', NULL, 'PROFESSIONAL_STATE', '8', '1', '无职业', '9', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('10', NULL, 'door_service_subject_class_dict', '4', '4', '检验费', '2', '上门服务项类型');
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('11', NULL, 'door_service_subject_class_dict', '28', '28', '检查费', '3', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('12', NULL, 'door_service_subject_class_dict', '89', '89', '护理费', '4', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('13', NULL, 'door_service_subject_class_dict', '148', '148', '推拿', '5', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('14', NULL, 'door_service_subject_class_dict', '149', '149', '针灸', '6', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('15', NULL, 'door_service_subject_class_dict', 'door', 'door', '上门护理', '1', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('16', NULL, 'door_service_door_dict', 'door_1', '0', '置/安插胃管', '1', '上门护理');
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('17', NULL, 'door_service_door_dict', 'door_2', '0', '更换尿管', '2', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('18', NULL, 'door_service_door_dict', 'door_3', '0', '黄体酮注射', '3', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('19', NULL, 'door_service_door_dict', 'door_4', '0', '采血', '4', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('20', NULL, 'door_service_door_dict', 'door_5', '0', '压疮护理', '5', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('21', NULL, 'door_service_door_dict', 'door_6', '0', '开奶/催乳/积奶/发汗', '6', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('22', NULL, 'door_service_door_dict', 'door_7', '0', '肌肉皮下注射/皮内注射', '7', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('23', NULL, 'door_service_door_dict', 'door_8', '0', '膀胱冲洗', '8', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('24', NULL, 'door_service_door_dict', 'door_9', '0', 'PICC护理', '9', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('25', NULL, 'door_service_door_dict', 'door_10', '0', '外科拆线', '10', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('26', NULL, 'door_service_door_dict', 'door_11', '0', '口腔护理', '11', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('27', NULL, 'door_service_door_dict', 'door_12', '0', '伤口换药', '12', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('28', NULL, 'door_service_door_dict', 'door_13', '0', '陪诊/陪检', '13', NULL);
CREATE TABLE `wlyy_doctor_quick_reply` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `doctor` varchar(50) NOT NULL COMMENT '医生',

+ 29 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/common/EntranceController.java

@ -0,0 +1,29 @@
package com.yihu.jw.door.controller.common;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2021/1/6.
 */
@RestController
@RequestMapping(value = "entrance")
@Api(value = "内网数据查询", description = "内网数据查询", tags = {"内网数据查询"})
public class EntranceController extends EnvelopRestEndpoint {
    @Autowired
    private TnyyEntranceService tnyyEntranceService;
    @GetMapping(value = "findGY_YLSF")
    @ApiOperation(value = "查询上门服务项目")
    public Envelop findGY_YLSF() throws Exception {
        return success(tnyyEntranceService.findGY_YLSF());
    }
}

+ 13 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorController.java

@ -115,6 +115,19 @@ public class DoctorController extends BaseController {
        }
    }
    @GetMapping(value = "getHospitals")
    @ApiOperation("获取医院")
    public String getHospitals() {
        try {
            List<BaseOrgDO> orgDOs = orgDao.findByAll();
            return write(200, "查询成功", "data", orgDOs);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 医生基本信息查询接口
     *

+ 68 - 12
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoorOrderController.java

@ -11,6 +11,7 @@ import com.yihu.jw.door.service.WlyyDoorServiceOrderService;
import com.yihu.jw.door.service.common.HospitalService;
import com.yihu.jw.door.service.common.ServerPackageService;
import com.yihu.jw.door.service.prescription.JwDoorPrescriptionService;
import com.yihu.jw.door.util.StreamUtil;
import com.yihu.jw.entity.door.WlyyDoorConclusionDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
@ -28,10 +29,7 @@ import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.net.URLEncoder;
import java.util.*;
@ -429,7 +427,7 @@ public class DoorOrderController extends BaseController {
    }
    @ApiOperation("导出工单到excel")
    @GetMapping(value = "/doorOrderOutExcel")
    @GetMapping(value = "excelControl/doorOrderOutExcel")
    public void doorOrderOutExcel(
            @ApiParam(value = "工单id", name = "orderId",required = false)
            @RequestParam(value = "orderId", required = false) String orderId,
@ -440,7 +438,7 @@ public class DoorOrderController extends BaseController {
            @ApiParam(value = "服务机构", name = "hospitalCode",required = false)
            @RequestParam(value = "hospitalCode", required = false) String hospitalCode,
            @ApiParam(value = "工单状态", name = "status",required = false)
            @RequestParam(value = "status", required = false) Integer status,
            @RequestParam(value = "status", required = false) Integer[] status,
            @ApiParam(value = "创建时间开始,格式(yyyy-MM-dd mm:dd:ss)", name = "createTimeStart",required = false)
            @RequestParam(value = "createTimeStart", required = false) String createTimeStart,
            @ApiParam(value = "创建时间结束,格式(yyyy-MM-dd mm:dd:ss)", name = "createTimeEnd",required = false)
@ -520,10 +518,12 @@ public class DoorOrderController extends BaseController {
            @RequestParam(value = "serverItemName", required = false) String serverItemName,
            @ApiParam(value = "类型", name = "type")
            @RequestParam(value = "type", required = false) String type,
            @ApiParam(value = "医生", name = "doctor")
            @RequestParam(value = "doctor", required = false) String doctor,
            @ApiParam(value = "居民", name = "patient")
            @RequestParam(value = "patient", required = false) String patient) {
        try {
            return write(200, "获取成功","dara",serverPackageService.selectServiceByHospital(hospital,serverItemName,type,patient,getUID()));
            return write(200, "获取成功","dara",serverPackageService.selectServiceByHospital(hospital,serverItemName,type,patient,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "获取失败!" + e.getMessage());
@ -1230,7 +1230,7 @@ public class DoorOrderController extends BaseController {
    }
    @ApiOperation("导出服务小结到word")
    @RequestMapping(value = "exportConclusion", method = RequestMethod.GET)
    @RequestMapping(value = "excelControl/exportConclusion", method = RequestMethod.GET)
    public void writeWordFile(@ApiParam(name = "urlString", value = "链接地址") @RequestParam(required = false) String urlString,
                              @ApiParam(name = "orderId", value = "订单id", required = true) @RequestParam String orderId,
                              HttpServletResponse response) {
@ -1245,10 +1245,25 @@ public class DoorOrderController extends BaseController {
            response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
            OutputStream os = response.getOutputStream();
            //获取相对路径
            String pathName = DoorOrderController.class.getResource("/").getPath().replaceFirst("/", "");
            pathName = pathName.replace("target/classes/", "src/main/resources/conclusion.mht");
            Document doc = Jsoup.parse(new File(pathName), "UTF-8");
            String html = doorOrderService.handleData(doc,orderId);
//            String pathName = DoorOrderController.class.getResource("/").getPath().replaceFirst("/", "");
//            pathName = pathName.replace("target/classes/", "src/main/resources/conclusion.mht");
//            Document doc = Jsoup.parse(new File(pathName), "UTF-8");
//            String txt =     StreamUtil.readResources();
//            ByteArrayInputStream ins = new ByteArrayInputStream(txt.getBytes());
//            File file = new File("conclusion.mht");
//            OutputStream os1 = new FileOutputStream(file);
//            int bytesRead = 0;
//            byte[] buffer1 = new byte[8192];
//            while ((bytesRead = ins.read(buffer1, 0, 8192)) != -1) {
//                os1.write(buffer1, 0, bytesRead);
//            }
//            os1.close();
//            ins.close();
//            Document aa = Jsoup.parse(file,"UTF-8");
            Document aa = Jsoup.parse(StreamUtil.readResources());
            String html = doorOrderService.handleData(aa,orderId);
            byte b[] = html.getBytes();
            ByteArrayInputStream bais = new ByteArrayInputStream(b);
            POIFSFileSystem poifs = new POIFSFileSystem();
@ -1263,6 +1278,47 @@ public class DoorOrderController extends BaseController {
        }
    }
    @ApiOperation("批量导出服务小结到word-----pathName  本地测试和线上不一样")
    @RequestMapping(value = "excelControl/exportConclusionList", method = RequestMethod.GET)
    public void writeWordFileList(
            @ApiParam(value = "医生的code", name = "doctorCode",required = false) @RequestParam(value = "doctorCode", required = false) String doctorCode,
            @ApiParam(value = "状态 ;  5-需要,待补录   6-已完成", name = "status",required = false) @RequestParam(value = "status", required = false) Integer status,
            HttpServletResponse response) throws Exception {
        try {
            List<Map<String,Object>> list = doorOrderService.getOrderIdList(status,doctorCode);
            if (list.size()<0){
                response.setStatus(500);
            }else {
                List<String> list1 = new ArrayList<>();
                for (int i=0;i<list.size();i++){
                    list1.add(list.get(i).get("orderId").toString());
                }
                File file = doorOrderService.writeWordFile(list1,response,doctorCode);
                if (file != null) {
                    response.setCharacterEncoding("utf-8");
                    response.setContentType("multipart/form-data");
                    response.setHeader("Content-Disposition", "attachment;fileName=service_summary.zip");
                    InputStream inputStream = new FileInputStream(file);
                    OutputStream outputStream = response.getOutputStream();
                    byte[] b = new byte[2048];
                    int length = 0;
                    while ((length = inputStream.read(b)) > 0) {
                        outputStream.write(b, 0, length);
                    }
                    outputStream.flush();
                    outputStream.close();
                    inputStream.close();
                } else {
                    response.setStatus(500);
                }
            }
        } catch (Exception e) {
            response.setStatus(500);
        }
    }
    @ApiOperation("推送知情同意書")
    @RequestMapping(value = "/sendInformedConsent" , method = RequestMethod.GET)
    public String sendInformedConsent(   @ApiParam(value = "医生code", name = "doctor")

+ 13 - 13
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoorStatisticAnalyzeController.java

@ -71,7 +71,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
            @ApiParam(name = "endDate", value = "搜索,结束时间",required = false)
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(required = false) String lowLevel,
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level
    ){
        try{
@ -98,7 +98,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
            @ApiParam(name = "endDate", value = "搜索,结束时间",required = false)
            @RequestParam(value = "endDate", required = false) String endDate,
            @RequestParam(required = false) String lowLevel,
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level
    ){
        try{
@ -123,7 +123,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
            @RequestParam(value = "startDate", required = false) String startDate,
            @ApiParam(name = "endDate", value = "搜索,结束时间",required = false)
            @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level
    ){
        try{
@ -150,7 +150,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
            @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(name = "type", value = "发起类型(1本人发起 2家人待预约 3医生代预约)",required = false)
            @RequestParam(value = "type", required = false) Integer type,
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level
    ){
        try{
@ -178,7 +178,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
            @RequestParam(required = false) String lowLevel,
            @ApiParam(name = "type", value = "发起类型(1本人发起 2家人待预约 3医生代预约)",required = false)
            @RequestParam(value = "type", required = false) Integer type,
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level
    ){
        try{
@ -205,7 +205,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
            @RequestParam(value = "endDate", required = false) String endDate,
            @ApiParam(name = "roleType", value = "1、调度员,2、服务医生",required = true)
            @RequestParam(value = "roleType", required = true) Integer roleType,
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level
    ){
        try{
@ -234,7 +234,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
            @RequestParam(required = false) String lowLevel,
            @ApiParam(name = "roleType", value = "1、调度员,2、服务医生",required = true)
            @RequestParam(value = "roleType", required = true) Integer roleType,
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level
            @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level
    ){
        try{
@ -449,7 +449,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
    public String doorAggregateAnalysis(
            @ApiParam(name = "area", value = "区域code:如思明区350203,团队641",required = false)
            @RequestParam(value = "area", required = false) String area,
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5团队",required = false)
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5科室 6 医生",required = false)
            @RequestParam(required = true) int level,
            @ApiParam(name = "startDate", value = "搜索,开始时间",required = false)
            @RequestParam(value = "startDate", required = false) String startDate,
@ -478,7 +478,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
    public String getDoorDiagnosisAnalysis(
            @ApiParam(name = "area", value = "区域code:如思明区350203,团队641",required = false)
            @RequestParam(value = "area", required = false) String area,
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5团队",required = false)
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5科室 6医生",required = false)
            @RequestParam(required = true) int level,
            @ApiParam(name = "startDate", value = "搜索,开始时间",required = false)
            @RequestParam(value = "startDate", required = false) String startDate,
@ -510,7 +510,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
    public String getDoorDrugCodeAnalysis(
            @ApiParam(name = "area", value = "区域code:如思明区350203,团队641",required = false)
            @RequestParam(value = "area", required = false) String area,
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5团队",required = false)
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5科室 6医生",required = false)
            @RequestParam(required = true) int level,
            @ApiParam(name = "subjectClass", value = "科目类别,010开头为药品,020为服务项目",required = false)
            @RequestParam(value = "subjectClass", required = false) String subjectClass,
@ -604,7 +604,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
    public String serviceOrderTrend(
            @ApiParam(name = "area", value = "区域code:如思明区350203,团队641",required = false)
            @RequestParam(value = "area", required = false) String area,
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5团队",required = false)
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5科室 6医生",required = false)
            @RequestParam(required = true) int level,
            @ApiParam(name="interval",value="统计类型:1按天,2按周,3按月",defaultValue = "")
            @RequestParam(required = true) String interval,
@ -659,7 +659,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
    public String doorServiceItemAnalysis(
            @ApiParam(name = "area", value = "区域code:如思明区350203,团队641",required = false)
            @RequestParam(value = "area", required = false) String area,
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5团队",required = false)
            @ApiParam(name = "level", value = "等级,2市  3区  4社区 5科室 6团队",required = false)
            @RequestParam(required = true) int level,
            @ApiParam(name = "pageSize", value = "页面大小,默认6 返回全部传999",required = true)
            @RequestParam(value = "pageSize", required = true) Integer pageSize,
@ -694,7 +694,7 @@ public class DoorStatisticAnalyzeController extends BaseController {
                                        @ApiParam(name="slaveKey1",value="类型 5 产后,6 新生儿,7 严重精神疾病,8 80岁以上老人,9 肺结核",defaultValue = "")
                                            @RequestParam(required = false) String slaveKey1,
                                        @ApiParam(name="area",value="区域code",defaultValue = "")@RequestParam(required = true) String area,
                                        @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5团队",defaultValue = "")@RequestParam(required = true) Integer level) {
                                        @ApiParam(name="level",value="1 省 2 市 3 区县 4 机构 5科室 6医生",defaultValue = "")@RequestParam(required = true) Integer level) {
        try {
            JSONObject jsonObject = doorStatisticAnalyzeService.getHomeVisitTotalHead(startDate,endDate,area,level,slaveKey1);
            return write(200, "查询成功", "data", jsonObject);

+ 85 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/DoorCommentController.java

@ -0,0 +1,85 @@
package com.yihu.jw.door.controller.patient;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.door.service.DoorCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by wangpeiqiang on 2019/3/16.
 * 居民端-评分接口.
 */
@RestController
@RequestMapping(value = "/patient/door_comment")
@Api(description = "居民端-评分")
public class DoorCommentController extends BaseController {
    @Autowired
    DoorCommentService doorCommentService;
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加居民评分")
    public String add(
            @ApiParam(name = "orderId", value = "工单id", required = true)
            @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(name = "professionalSkill", value = "专业能力", required = false)
            @RequestParam(value = "professionalSkill", required = false) Integer professionalSkill,
            @ApiParam(name = "serveAttitude", value = "服务态度", required = false)
            @RequestParam(value = "serveAttitude", required = false) Integer serveAttitude,
            @ApiParam(name = "serveEfficiency", value = "服务效率", required = false)
            @RequestParam(value = "serveEfficiency", required = false) Integer serveEfficiency,
            @ApiParam(name = "description", value = "服务描述或建议", required = false)
            @RequestParam(value = "description", required = false) String description,
            @ApiParam(name = "isAnonymous", value = "是否匿名", required = false)
            @RequestParam(value = "isAnonymous", required = false) Integer isAnonymous
    ){
        try {
            if(orderId==null){
                return "工单id不能为空";
            }
            String dc = doorCommentService.add(getUID(), orderId, professionalSkill,serveAttitude,serveEfficiency,description,isAnonymous);
            if("-1".equals(dc)){
                return error(-2,"评分失败");
            }
            return write(200,"评分成功","data",dc);
        } catch (Exception e) {
            error(e);
            return error(-1,"评分失败");
        }
    }
    /**
     * 根据医生code查询居民评价详情
     *
     * @return
     */
    @RequestMapping(value = "/commentDetail", method = RequestMethod.GET)
    @ApiOperation("查询居民评价详情")
    public String commentDetail(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient", required = false)String patient,
            @ApiParam(name = "orderId", value = "工单id", required = true)
            @RequestParam(value = "orderId", required = true) String orderId
    ){
        try {
            if(StringUtils.isEmpty(patient)){
                patient = getUID();
            }
            JSONObject result = doorCommentService.commentDetail(patient,orderId);
            return write(200, "请求成功!","data",result);
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
}

+ 101 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorCommentService.java

@ -0,0 +1,101 @@
package com.yihu.jw.door.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.door.dao.WlyyDoorCommentDao;
import com.yihu.jw.door.dao.WlyyDoorCommentDoctorDao;
import com.yihu.jw.door.dao.WlyyDoorDoctorDao;
import com.yihu.jw.door.dao.WlyyDoorServiceOrderDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.WlyyDoorCommentDO;
import com.yihu.jw.entity.door.WlyyDoorCommentDoctorDO;
import com.yihu.jw.entity.door.WlyyDoorDoctorDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
 * Created by wangpeiqiang on 2019/3/16.
 * 居民端-评分
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DoorCommentService extends BaseJpaService<WlyyDoorCommentDO, WlyyDoorCommentDao> {
    @Autowired
    BasePatientDao patientDao;
    @Autowired
    WlyyDoorCommentDao doorCommentDao;
    @Autowired
    WlyyDoorCommentDoctorDao doorCommentDoctorDao;
    @Autowired
    WlyyDoorServiceOrderDao wlyyDoorServiceOrderDao;
    @Autowired
    WlyyDoorDoctorDao wlyyDoorDoctorDao;
    public String add(String patientCode,String orderId, Integer professionalSkill,Integer serveAttitude,Integer serveEfficiency,String description,Integer isAnonymous){
        BasePatientDO patient =patientDao.findById(patientCode);
        WlyyDoorCommentDO doorComment = new WlyyDoorCommentDO();
        BigDecimal evaluateSplit = BigDecimal.ZERO;
        BigDecimal num = new BigDecimal("3");
        //计算三项评分平均分
        evaluateSplit = evaluateSplit.add(
                (new BigDecimal(professionalSkill).add(new BigDecimal(serveAttitude)).add(new BigDecimal(serveEfficiency))).divide(num,2,BigDecimal.ROUND_HALF_UP)
        );
        doorComment.setOrderId(orderId);
        doorComment.setCode(getCode());
        doorComment.setProfessionalSkill(professionalSkill);
        doorComment.setServeAttitude(serveAttitude);
        doorComment.setServeEfficiency(serveEfficiency);
        doorComment.setEvaluateSplit(evaluateSplit);
        doorComment.setIsAnonymous(isAnonymous);
        doorComment.setDescription(description);
        doorComment.setPatient(patientCode);
        doorComment.setCreateUser(patientCode);
        doorComment.setCreateUserName(patient.getName());
        doorComment.setCreateTime(new Date());
        doorCommentDao.save(doorComment);
        //更新工单状态
        WlyyDoorServiceOrderDO wlyyDoorServiceOrderDO =wlyyDoorServiceOrderDao.findOne(orderId);
        wlyyDoorServiceOrderDO.setStatus(6);
        wlyyDoorServiceOrderDO.setCompleteTime(new Date());
        wlyyDoorServiceOrderDO.setUpdateUser(patientCode);
        wlyyDoorServiceOrderDO.setUpdateUserName(patient.getName());
        wlyyDoorServiceOrderDO.setUpdateTime(new Date());
        wlyyDoorServiceOrderDao.save(wlyyDoorServiceOrderDO);
        List<WlyyDoorDoctorDO> wlyyDoorDoctorDOList =this.wlyyDoorDoctorDao.findByOrderId(orderId);
        for(WlyyDoorDoctorDO wlyyDoorDoctorDO:wlyyDoorDoctorDOList) {
            WlyyDoorCommentDoctorDO doorCommentDoctor = new WlyyDoorCommentDoctorDO();
            doorCommentDoctor.setOrderId(orderId);
            doorCommentDoctor.setCode(getCode());
            doorCommentDoctor.setDoctorCode(wlyyDoorDoctorDO.getDoctor());
            doorCommentDoctor.setProfessionalSkill(professionalSkill);
            doorCommentDoctor.setServeAttitude(serveAttitude);
            doorCommentDoctor.setServeEfficiency(serveEfficiency);
            doorCommentDoctor.setEvaluateSplit(evaluateSplit);
            doorCommentDoctor.setIsAnonymous(isAnonymous);
            doorCommentDoctor.setDescription(description);
            doorCommentDoctor.setPatient(patientCode);
            doorCommentDoctor.setCreateUser(patientCode);
            doorCommentDoctor.setCreateUserName(patient.getName());
            doorCommentDoctor.setCreateTime(new Date());
            doorCommentDoctorDao.save(doorCommentDoctor);
        }
        return"1";
    }
    public JSONObject commentDetail(String patient,String orderId)throws Exception{
        JSONObject result = new JSONObject();
        WlyyDoorCommentDO commentDetail = doorCommentDao.selectCommentDoctor(patient,orderId);
        result.put("commentDetail",commentDetail);
        return result;
    }
}

+ 43 - 131
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorOrderService.java

@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.door.dao.*;
import com.yihu.jw.door.util.MessageUtil;
import com.yihu.jw.door.util.StreamUtil;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
@ -23,7 +24,6 @@ import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import jxl.Workbook;
import jxl.write.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.jsoup.Jsoup;
@ -32,7 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
@ -544,25 +543,7 @@ public class DoorOrderService {
            logger.error(e.getMessage());
        }
        //  待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
        List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,new String[]{"403","407"});
        if (CollectionUtils.isEmpty(messages)){
            logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
        }else {
            messages.forEach(message->{
                systemMessageDao.orderMessageDel(message.getReceiver(),message.getRelationCode());
                if (message.getType().equals("403") ) {
                    BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doorServiceOrder.getDispatcher());//·
                    String msg=doorServiceOrder.getDispatcherName() + "接受了服务工单"+ doorServiceOrder.getNumber();
                    messageUtil.saveSystemMessage(message.getId(),message.getRelationCode(),"医生接单","434",doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName(),
                            doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),null,msg,message.getOver());
                }
                else{
                    message.setOver("0");
                    systemMessageDao.save(message);
                }
            });
        }
        messageUtil.updateMessage(doorServiceOrder,new String[]{"403","407"},"434",null,null);
    }
    /**
@ -586,15 +567,7 @@ public class DoorOrderService {
                BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doorServiceOrder.getDispatcher());//·
                this.createMessage("服务工单拒单待重新派单","404","system","system", doorServiceOrder.getId(), doorServiceOrder.getDispatcher(),baseDoctorDO.getName() , null,doorServiceOrder.getDoctorName() + "拒绝了" + doorServiceOrder.getProxyPatientName() + "的服务预约申请,请重新派单");
                //  调度员-派单-实时工单消息:435 医生拒单-- 王五拒绝了服务工单12345678
                List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,new String[]{"431","433"});
                if (CollectionUtils.isEmpty(messages)) {
                    logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
                } else {
                    SystemMessageDO message = messages.get(0);
                    String msg=doorServiceOrder.getDoctorName() + "拒绝了服务工单" + doorServiceOrder.getNumber() + ", 请重新派单";
                    messageUtil.saveSystemMessage(message.getId(),message.getRelationCode(),"医生拒单","435",doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName(),
                            doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),null,msg,message.getOver());
                }
                messageUtil.updateMessage(doorServiceOrder,new String[]{"431","433"},"435",null,null);
            }
        }
        doorServiceOrder.setDoctor(null);
@ -618,17 +591,9 @@ public class DoorOrderService {
        messageDO.setRelationCode(relationCode);
        messageDO.setReceiver(Receiver);
        messageDO.setReceiverName(ReceiverName);
        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
        data.put("name", ReceiverName);
        data.put("age", IdCardUtil.getAgeForIdcard(idCard));
        try {
            data.put("gender", IdCardUtil.getSexForIdcard(idCard));
        } catch (Exception e) {
            e.printStackTrace();
        }
        data.put("msg", msg);
        messageDO.setData(msg);
        messageDO.setDel("1");
        messageDO.setOver("1");
        messageDO.setCreateTime(new Date());
        systemMessageDao.save(messageDO);
    }
@ -804,15 +769,14 @@ public class DoorOrderService {
    }
    public void doorOrderOutExcel(String orderId,String patientName,String patientPhone,String hospitalCode,
                                  Integer status,String createTimeStart,String createTimeEnd,String serverDoctorName,String doctorCode,Integer examPaperStatus, HttpServletResponse response)throws Exception{
                                  Integer[] status,String createTimeStart,String createTimeEnd,String serverDoctorName,String doctorCode,Integer examPaperStatus, HttpServletResponse response)throws Exception{
        WritableWorkbook book = null;
        OutputStream os = null;
        try {
            String sql = "select DISTINCT o.id as orderId,o.number,o.status,f.hospital,f.hospital_name as hospitalName1,o.is_trans_other_org," +
                    " o.transed_org_code,h.name as hospitalName2,o.patient_name,f.idcard,o.doctor_sign_time,o.total_fee," +
            String sql = "select DISTINCT o.id as orderId,o.number,o.status,o.is_trans_other_org," +
                    " o.transed_org_code,o.patient_name,p.idcard,o.doctor_sign_time,o.total_fee," +
                    " o.patient_phone,o.remark,o.create_time,o.patient as patientCode from wlyy_door_service_order o " +
                    " LEFT JOIN wlyy_sign_family f ON f.patient = o.patient AND f. STATUS = 1 AND f.expenses_status = 1 " +
                    " LEFT JOIN base_org h on h.code=o.transed_org_code and h.del=1 " ;
                    " LEFT JOIN base_patient p on p.id=o.patient " ;
            if(!StringUtils.isEmpty(serverDoctorName)){
                sql+=" RIGHT JOIN wlyy_door_doctor d on d.order_id = o.id";
            }
@ -827,13 +791,15 @@ public class DoorOrderService {
            if (!StringUtils.isEmpty(patientPhone)) {
                sql += " and o.patient_phone ='" + patientPhone + "'";
            }
            if (StringUtils.isNotBlank(hospitalCode) && !hospitalCode.contains("%")) {
                sql += " and (f.hospital = '" + hospitalCode + "' or o.transed_org_code='" + hospitalCode + "') ";
/*            if (StringUtils.isNotBlank(hospitalCode) && !hospitalCode.contains("%")) {
//                sql += " and (h.code = '" + hospitalCode + "' or o.transed_org_code='" + hospitalCode + "') ";
                sql += " and ( o.transed_org_code='" + hospitalCode + "') ";
            }else if(StringUtils.isNotBlank(hospitalCode) && hospitalCode.contains("%")){
                sql += " and (f.hospital like '" + hospitalCode + "' or o.transed_org_code like '" + hospitalCode + "') ";
            }
//                sql += " and (h.code like '" + hospitalCode + "' or o.transed_org_code like '" + hospitalCode + "') ";
                sql += " and ( o.transed_org_code like '" + hospitalCode + "') ";
            }*/
            if (status != null) {
                sql += " and o.status ='" + status + "'";
                sql += " and o.status in ("+StringUtils.strip(Arrays.toString(status),"[]")+") ";
            }
            if (!StringUtils.isEmpty(createTimeStart)) {
                sql += " and o.create_time >='" + createTimeStart + "'";
@ -923,14 +889,7 @@ public class DoorOrderService {
                sheet.addCell(new Label(1, b + 1, statusName,cellFormat));//工单状态
                //工单是否转给其他机构,0-不转,1-已转
                String transOtherOrg = list.get(i).get("is_trans_other_org") + "";
                String hospitalName = null;
                if ("0".equals(transOtherOrg)) {
                    hospitalName = list.get(i).get("hospitalName1") + "";//签约表中的机构
                } else if ("1".equals(transOtherOrg)) {
                    hospitalName = list.get(i).get("hospitalName2") + "";//转机构中的机构
                }else if("null".equals(transOtherOrg)){
                    hospitalName = list.get(i).get("hospitalName1") + "";//签约表中的机构
                }
                String hospitalName = "泰安市中医医院";
                sheet.addCell(new Label(2, b + 1, hospitalName,cellFormat));//服务机构
                Date createTime = (Date) list.get(i).get("create_time");
@ -1080,8 +1039,7 @@ public class DoorOrderService {
        // 更新记录
        this.setUpdateColumnInfo(one);
        doorServiceOrderDao.save(one);
        // 更新居民签约服务包服务项次数
        this.reduceServiceItemTimes(serverPackagePriceByOrderId(orderId), one.getPatient());
        // 发送微信消息通知--用户评价//·
        BasePatientDO patient = patientInfoService.findById(one.getPatient());
        // 获取微信模板  fwyspf-服务医生评分
@ -1285,13 +1243,6 @@ public class DoorOrderService {
        Map<String, Object> map = new HashMap<>();
        BigDecimal serverPackagePrice = new BigDecimal("0.00");
        BigDecimal cashPrice = new BigDecimal("0.00");
        //获取居民签约服务项及次数
//        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        String sql = "SELECT ip.service_item_code as itemCode, sum(ip.service_times) as times  FROM wlyy_server_package_patient pp , wlyy_server_package_item_patient ip " +
                "where pp.`code` = ip.server_package_patient_code and  pp.patient = '" + patient + "' and pp.hospital = '" + "" + "' and pp.`status` = 1 " +
//                "where pp.`code` = ip.server_package_patient_code and  pp.patient = '" + patient + "' and pp.hospital = '" + signFamily.getHospital() + "' and pp.`status` = 1 " +
                "GROUP BY ip.service_item_code ";
        List<Map<String, Object>> list =jdbcTemplate.query(sql, new BeanPropertyRowMapper(String.class));
        JSONArray jsonArray = JSONArray.parseArray(jsonData);
        for(Object o : jsonArray){
@ -1301,67 +1252,13 @@ public class DoorOrderService {
            String itemCode = jsonObject.getString("itemCode");
            BigDecimal fee = jsonObject.getBigDecimal("fee");
            BigDecimal number = jsonObject.getBigDecimal("number");
            //遍历是否是居民签约的服务项,如果是,看还剩多少次数
            for(Map<String, Object> m : list){
                if((m.get(itemCode) + "").equals(itemCode)){
                    b = true;
                    times = (BigDecimal)map.get("times");
                }
            }
            //判断服务包里面的次数是否够抵扣,不够的仍需支付
            if(b){
                if(times.compareTo(number) > -1) {
                    serverPackagePrice = serverPackagePrice.add(fee.multiply(number));
                }else {
                    //还需另外支付次数
                    BigDecimal t = number.subtract(times);
                    cashPrice = cashPrice.add(fee.multiply(t));
                }
            }else {
                cashPrice = cashPrice.add(fee.multiply(number));
            }
            cashPrice = cashPrice.add(fee.multiply(number));
        }
        map.put("serverPackagePrice", serverPackagePrice);
        map.put("cashPrice", cashPrice);
        return map;
    }
    /**
     * 更新居民签约服务包服务项次数
     * @param itemInfo 格式[{"itemCode":"","fee":"","number":""}]
     * @param patient 居民code
     */
    public void reduceServiceItemTimes(String itemInfo, String patient){
        Map<String, Object> map = new HashMap<>();
        //获取居民签约服务项及次数
//        SignFamily signFamily = signFamilyDao.findByPatient(patient);
        String sql = "SELECT ip.`code`,ip.service_item_code as itemCode, ip.service_times as times  FROM wlyy_server_package_patient pp , wlyy_server_package_item_patient ip " +
//                "where pp.`code` = ip.server_package_patient_code and  pp.patient = '" + patient + "' and pp.hospital = '" + signFamily.getHospital() + "' and pp.`status` = 1 " +
                "where pp.`code` = ip.server_package_patient_code and  pp.patient = '" + patient + "' and pp.hospital = '" + "" + "' and pp.`status` = 1 " +
                "order BY pp.end_time ";
        List<Map<String, Object>> list =jdbcTemplate.query(sql, new BeanPropertyRowMapper(String.class));
        JSONArray jsonArray = JSONArray.parseArray(itemInfo);
        for(Object o : jsonArray) {
            JSONObject jsonObject = (JSONObject) o;
            String itemCode = jsonObject.getString("itemCode");
            Integer number = jsonObject.getInteger("number");
            //遍历是否是居民签约的服务项,如果是,看服务项次数够不够减,不够减的继续遍历其他服务项,够减则跳出循环更新次数
            for (Map<String, Object> m : list) {
                if ((m.get(itemCode) + "").equals(itemCode)) {
                    String itemPatientCode = map.get("code") + "";
                    Integer times = (Integer) map.get("times");
                    if (number <= times) {
//                        serverPackageItemPatientDao.updateTimesByCode(itemPatientCode, times - number);
                        break;
                    } else {
//                        serverPackageItemPatientDao.updateTimesByCode(itemPatientCode, 0);
                        number -= times;
                    }
                }
            }
        }
    }
    /**
     * 获取订单下服务包数量、单价
@ -1559,6 +1456,7 @@ public class DoorOrderService {
        html = html.replace("${diagnosticrecord}", conclusionDO.getDiagnosticRecord() == null ? "" : conclusionDO.getDiagnosticRecord());
        html = html.replace("${examresult}",conclusionDO.getExamResult() == null ? "" : conclusionDO.getExamResult());
        String imgsString = "";
        if(StringUtils.isNotBlank(conclusionDO.getImgs())) {
            String imgs = conclusionDO.getImgs();
            String[] imgsArray;
@ -1660,11 +1558,13 @@ public class DoorOrderService {
    }
    public File writeWordFile(List<String> orderId,HttpServletResponse response) throws Exception {
        String zipFileName = "服务小结";
        long time = System.currentTimeMillis();
        String exportConclusionList = time+"exportList";
        String path = this.getClass().getResource("/").getPath() + exportConclusionList;
    public File writeWordFile(List<String> orderId,HttpServletResponse response,String doctorCode) throws Exception {
        String zipFileName = "service_summary";
        String exportConclusionList = doctorCode+"exportList";
        String path = System.getProperty("user.dir") +"/service_summary/" + exportConclusionList;
        System.out.println("path    :"   +path);
        File file = new File(path);
        // 删除文件夹、文件
        if (file.exists()) {
@ -1691,11 +1591,15 @@ public class DoorOrderService {
            fileName = java.net.URLEncoder.encode(fileName,"UTF-8");
            fileName = java.net.URLDecoder.decode(fileName,"UTF-8");
            response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
            String pathName = this.getClass().getResource("/").getPath() + "conclusion.mht";
            System.out.println("路径pathName:" + pathName);
            Document doc = Jsoup.parse(new File(pathName), "UTF-8");
//            String pathName = this.getClass().getResource("/").getPath() + "conclusion.mht";
//            System.out.println("路径pathName:" + pathName);
//            Document doc = Jsoup.parse(new File(pathName), "UTF-8");
            Document doc = Jsoup.parse(StreamUtil.readResources());
            String html = this.handleData(doc, orderId.get(i));//16
            BufferedWriter bw = new BufferedWriter(new FileWriter(path+"/"+fileName));//创建的文件
            bw.write(html);
            bw.close();
            File zipFile = new File(path.replace(exportConclusionList, "") + zipFileName + ".zip");
@ -1710,6 +1614,15 @@ public class DoorOrderService {
            return null;
        }
    }
    public static void main(String[] args) {
        String str = "file:/data/wlyy2.0/svr-door-service/svr-door-service.jar!/BOOT-INF/classes!/1609894996524exportList/";
        String c2=str.substring(0,str.indexOf("!"));//  !前面的
        String c1=str.substring(str.lastIndexOf("!")+1);//  !後面的
        String cc = c2 + c1 ;
        System.out.println(cc.replace("svr-door-service.jar/",""));
    }
    /**
     * 打包文件夹
     *
@ -1807,12 +1720,11 @@ public class DoorOrderService {
   public List<Map<String,Object>> getOrderIdList(Integer status,String doctorCode){
       String sqlList = "select DISTINCT o.id as orderId";
       String sql = " from wlyy_door_service_order o " +
               " LEFT JOIN wlyy_sign_family f ON f.patient = o.patient AND f. STATUS = 1 AND f.expenses_status = 1 " +
               " LEFT JOIN base_org h on h.code=o.hospital and h.del=1 "
               +" LEFT JOIN wlyy_door_doctor d on d.order_id = o.id ";
       sql+= " where 1=1 ";
       if(status == 6){//已完成状态
           sql+=" and o.status ='"+status+"'";
           sql+=" and o.status in (5,6) ";
       }else {//5是待补录状态
           sql+=" and o.conclusion_status =1 ";
       }

+ 1 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorServiceApplicationService.java

@ -690,6 +690,7 @@ public class DoorServiceApplicationService {
//        messageUtil.sendWXMes("xm_ykyy_wx","808080eb73e02e8f0173ebe51e1b007d","210503199507250313",first,contentMsg,remark,url);
        BasePatientDO temp = patientDao.findById("0000000067bab53a0167badd74f00004");
        BasePatientDO patient = patientInfoService.findById("0000000067bab53a0167badd74f00004");
        List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn("2c9081aa6df16adb016df78bc56c66ef",new String[]{"6","9"});
        return "ss";
    }

+ 21 - 98
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/WlyyDoorServiceOrderService.java

@ -16,7 +16,9 @@ import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.org.dao.BaseOrgDao;
@ -169,6 +171,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    private String wxId;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 上门服务工单服务基本信息
@ -470,7 +474,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                // 把医生拉入会话,作为其中一个成员
                if(StringUtils.isNoneBlank(sessionId)){
                    imUtill.updateParticipant(sessionId,doorDoctorDO.getDoctor(),null);
                    imUtill.updateParticipantNew(sessionId,doorDoctorDO.getDoctor(),null);
                }
            }
@ -829,12 +833,12 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            orderDO.setDispatcherName(dispatcherName);
            this.save(orderDO);
            // 先进入会话,再聊天
            imUtill.updateParticipant(sessionId,dispatcher,null);
            imUtill.updateParticipantNew(sessionId,dispatcher,null);
            String noticeContent = hospitalName + dispatcherName + "为您服务";
            this.qucikSendIM(orderId, dispatcher, "智能助手", "1", noticeContent);
        }
        // 把调度员拉入会话,作为其中一个成员
        imUtill.updateParticipant(sessionId,dispatcher,null);
        imUtill.updateParticipantNew(sessionId,dispatcher,null);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "调度员["+dispatcherName+"]进入会话成功");
        return result;
@ -939,7 +943,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        orderBriefInfo.put("prescriptionTime", DateUtil.dateToStr(orderDO.getPrescriptionTime(), "MM-dd HH:mm"));
        orderBriefInfo.put("cancelTime", DateUtil.dateToStr(orderDO.getCancelTime(), "MM-dd HH:mm"));
        // 计算服务包支付多少钱
       /*  // 计算服务包支付多少钱
        List<Map<String, Object>> feeDetailDOS = doorOrderService.getDoorFeeDetailGroupByStatus(id);
        String jsonData = null;
        try {
@ -948,9 +952,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            e.printStackTrace();
        }
        if (!CollectionUtils.isEmpty(feeDetailDOS)) {
            Map<String, Object> map = doorOrderService.countServerPackagePrice(jsonData, orderDO.getPatient());
           Map<String, Object> map = doorOrderService.countServerPackagePrice(jsonData, orderDO.getPatient());
            orderBriefInfo.put("packageFee", map.get("serverPackagePrice"));
        }
        }*/
        orderJson.put("order", orderBriefInfo);
        //关联服务项
@ -1368,38 +1372,10 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        orderDO.setStatus(WlyyDoorServiceOrderDO.Status.cancel.getType());
        this.save(orderDO);
        if(type == WlyyDoorServiceOrderDO.CancelType.dispatcher.getType()){
            List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,new String[]{"402","403","430"});
            if(CollectionUtils.isEmpty(messages)){
                logger.error("当前工单没有系统消息!!orderId:" + orderId);
            } else {
                // 432 调度员拒单即取消工单-- 李四拒绝了张三的服务工单12345678
                messages.forEach(
                        message -> {
                            if (message.getType() .equals("430")) {
                                String msg=orderDO.getDispatcherName() + "拒绝了"+ orderDO.getPatientName() +"的服务工单" + orderDO.getNumber();
                                messageUtil.saveSystemMessage(message.getId(),message.getRelationCode(),"调度员拒单","432",dispatcher,dispatcherName,
                                        dispatcher,dispatcherName,null,msg,message.getOver());
                            }else{
                                message.setOver("0");
                                systemMessageDao.save(message);
                            }
                        }
                );
            }
            messageUtil.updateMessage(orderDO,new String[]{"402","403","430"},"432",dispatcher,dispatcher);
        }
        else if(type == WlyyDoorServiceOrderDO.CancelType.patient.getType()){                   //居民取消,消息列表也应该不显示
            List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,new String[]{"402","403"});
            if(CollectionUtils.isEmpty(messages)){
                logger.error("当前工单没有系统消息!!orderId:" + orderId);
            } else {
                messages.forEach(
                        message -> {
                            message.setOver("0");
                            systemMessageDao.save(message);
                        }
                );
            }
            messageUtil.updateMessage(orderDO,new String[]{"402","403","430"},"patientCancel",dispatcher,dispatcher);
        }
//        else if(type == WlyyDoorServiceOrderDO.CancelType.patient.getType()){                   //居民取消,消息列表也应该不显示
//
@ -2270,33 +2246,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        imUtill.updateParticipant(sessionId,doctor,null);
        // 调度员处理完该单(新增预约的,或者是拒单重新派单的)
        List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,new String[]{"402","404","430","435"});
        if(CollectionUtils.isEmpty(messages)){
            logger.error("当前工单没有 居民新增预约 消息!!orderId:" + orderId);
        }else{
            // 设置消息处理完毕
            messages.forEach(
                    message -> {
                        String title = "调度员派单(派给本社区医生)";
                        if("system".equals(dispatcher)){
                            title = "系统派单(派给服务医生)";
                        }
                        if (message.getType() .equals("430")) {
                            message.setTitle(title);
                            String msg = doorServiceOrderDO.getDispatcherName() + "已将服务工单" + doorServiceOrderDO.getNumber() + "指派给" + doctorName + "医生";
                            messageUtil.saveSystemMessage(message.getId(),message.getRelationCode(),title,"431",dispatcher,dispathcherName,
                                    dispatcher,dispathcherName,null,msg,message.getOver());
                        }else{
                            message.setOver("0");
                            systemMessageDao.save(message);
                        }
                    }
            );
        }
        imUtill.updateParticipantNew(sessionId,doctor,null);
        messageUtil.updateMessage(doorServiceOrderDO,new String[]{"402","403","430","435"},"431",dispatcher,dispatcher);
        // 工单状态变更记录
        WlyyDoorProcessLogDO processLogDO = new WlyyDoorProcessLogDO();
@ -2370,30 +2321,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        imUtill.updateParticipant(sessionId,doctor,null);
        // 调度员处理完该单(新增预约的,或者是拒单重新派单的)
/*        List<Message> messages = messageDao.queryByRelationCodeAndTypeIn(orderId,new Integer[]{402,404,430,435});
        if(CollectionUtils.isEmpty(messages)){
            logger.error("当前工单没有 居民新增预约 消息!!orderId:" + orderId);
        }else{
            // 设置消息处理完毕
            messages.forEach(
                    message -> {
                        if (message.getType() == 430) {
                            message.setTitle("医生转派单(派给本社区医生)");
                            message.setContent(doorServiceOrderDO.getDispatcherName() + "已将服务工单" + doorServiceOrderDO.getNumber() + "转派给" + doctorName + "医生");
                            message.setType(431);
                            message.setReceiver(dispatcher);
                            message.setSender(dispatcher);
                            message.setCreateTime(new Date());
                        }else{
                            message.setOver("0");
                        }
                        messageDao.save(message);
                    }
            );
        }*/
        imUtill.updateParticipantNew(sessionId,doctor,null);
        messageUtil.updateMessage(doorServiceOrderDO,new String[]{"402","403","430","435"},"431",dispatcher,dispatcher);
        // 工单状态变更记录
        WlyyDoorProcessLogDO processLogDO = new WlyyDoorProcessLogDO();
@ -2485,17 +2414,6 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        messageDO.setReceiver(Receiver);
        messageDO.setReceiverName(ReceiverName);
        messageDO.setOver("1");
        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
        data.put("name", ReceiverName);
        try {
            if(StringUtils.isNoneBlank(idCard)){
                data.put("age", IdCardUtil.getAgeForIdcard(idCard));
                data.put("gender", IdCardUtil.getSexForIdcard(idCard));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        data.put("msg", msg);
        messageDO.setData(msg);
        messageDO.setDel("1");
        messageDO.setCreateTime(new Date());
@ -2635,6 +2553,11 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        orderDO.setPrescriptionCode(prescriptionCode);
        orderDO.setPrescriptionTime(new Date());
        orderDO.setPrescriptionStatus(1);
        WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionCode);
        if(prescriptionDO!=null){
            orderDO.setOutpatientId(prescriptionDO.getOutpatientId());
        }
        wlyyDoorServiceOrderDao.save(orderDO);
        //非代预约才发送im消息
        if(orderDO.getType() != null && orderDO.getType() != 3) {

+ 57 - 32
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/ServerPackageService.java

@ -6,6 +6,7 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -25,7 +26,8 @@ public class ServerPackageService  {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${wechat.id}")
    private String wxId;
    /**
@ -85,30 +87,51 @@ public class ServerPackageService  {
//            HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(hospital);
//            buffer.append(" and ziocad.org_code = '"+hospitalMapping.getMappingCode()+"'");
        }
        String sql ="SELECT " +
                "ziocad.org_code AS hospital," +
                "zicd.clinic_code AS diagnosis_code," +
                "zicd.clinic_code AS code," +
                "zicd.clinic_name AS title," +
                "zicd.clinic_spec AS spec," +
                "zicd.clinic_unit AS unit," +
                "ziccad.allot_quantity AS quantity," +
                "zicd.subject_class AS subjectClass," +
                "ziccad.item_code AS itemCode," +
                " SUBSTR(zicd.subject_class, 1, 4) AS subjectCatagory," +
                " (CASE WHEN ISNULL(ziocd.price) THEN 0 ELSE ziocd.price END) as expense " +
                " FROM zy_iv_org_clinic_allot_dict ziocad " +
                " LEFT JOIN zy_iv_clinic_charge_allot_dict ziccad ON ziccad.clinic_code = ziocad.clinic_code AND ziccad.org_code = ziocad.org_code" +
                " LEFT JOIN zy_iv_clinic_dict zicd ON zicd.clinic_code = ziocad.clinic_code" +
                " LEFT JOIN zy_iv_org_charge_allot_dict ziocd ON ziocd.charge_code = ziccad.item_code and ziocd.org_code = ziccad.org_code  " ;
        if("used".equals(type)){
            sql += " LEFT JOIN wlyy_door_order_item i on i.code = zicd.clinic_code and (i.patient = '"+patient+"' or i.doctor='"+doctor+"') ";
            sql += " WHERE SUBSTR(zicd.subject_class, 1, 4) = '"+type+"' ";
        }else{
            sql += " WHERE SUBSTR(zicd.subject_class, 1, 4) = '"+type+"' ";
        String sql = "";
        if("sd_tnzyy_wx".equals(wxId)){
            if("door".equals(type)){
                //上门护理
                sql = "SELECT code,value title,'' unit,0 expense   from base_system_dict_entry WHERE dict_code = 'door_service_door_dict' ORDER BY sort";
            }else{
                sql = "SELECT a.FYXH code,a.FYMC title,a.FYDW unit,a.FYDJ expense from gy_ylsf a ";
                if("used".equals(type)){
                    sql += " JOIN wlyy_door_order_item i on i.code = a.FYXH and (i.patient = '"+patient+"' or i.doctor='"+doctor+"') ";
                }else if("other".equals(type)){
                    sql += " where a.FYGB not in (SELECT code from base_system_dict_entry WHERE dict_code = 'door_service_subject_class_dict')";
                }else{
                    sql += " WHERE a.FYGB ="+type;
                }
            }
        }else {
            sql ="SELECT " +
                    "ziocad.org_code AS hospital," +
                    "zicd.clinic_code AS diagnosis_code," +
                    "zicd.clinic_code AS code," +
                    "zicd.clinic_name AS title," +
                    "zicd.clinic_spec AS spec," +
                    "zicd.clinic_unit AS unit," +
                    "ziccad.allot_quantity AS quantity," +
                    "zicd.subject_class AS subjectClass," +
                    "ziccad.item_code AS itemCode," +
                    " SUBSTR(zicd.subject_class, 1, 4) AS subjectCatagory," +
                    " (CASE WHEN ISNULL(ziocd.price) THEN 0 ELSE ziocd.price END) as expense " +
                    " FROM zy_iv_org_clinic_allot_dict ziocad " +
                    " LEFT JOIN zy_iv_clinic_charge_allot_dict ziccad ON ziccad.clinic_code = ziocad.clinic_code AND ziccad.org_code = ziocad.org_code" +
                    " LEFT JOIN zy_iv_clinic_dict zicd ON zicd.clinic_code = ziocad.clinic_code" +
                    " LEFT JOIN zy_iv_org_charge_allot_dict ziocd ON ziocd.charge_code = ziccad.item_code and ziocd.org_code = ziccad.org_code  " ;
            if("used".equals(type)){
                sql += " LEFT JOIN wlyy_door_order_item i on i.code = zicd.clinic_code and (i.patient = '"+patient+"' or i.doctor='"+doctor+"') ";
                sql += " WHERE SUBSTR(zicd.subject_class, 1, 4) = '"+type+"' ";
            }else{
                sql += " WHERE SUBSTR(zicd.subject_class, 1, 4) = '"+type+"' ";
            }
            sql += buffer;
        }
        sql += buffer;
        List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
        return mapList;
@ -116,14 +139,16 @@ public class ServerPackageService  {
    public List<Map<String,Object>> selectTypes(){
        String sql1 = "SELECT zisc.class_code AS code, zisc.class_name AS type FROM zy_iv_subject_class_dict zisc " +
                "WHERE zisc.class_code IN ( SELECT DISTINCT SUBSTR(zicd.subject_class, 1, 4) AS subjectCatagory " +
                "FROM zy_iv_clinic_dict zicd WHERE LENGTH(zicd.subject_class) > 4 )";
        List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sql1);
        Map<String,Object> map = new HashedMap();
        map.put("code","used");
        map.put("type","常用");
        mapList1.add(map);
        String sql = "SELECT code,value type from base_system_dict_entry WHERE dict_code = 'door_service_subject_class_dict' ORDER BY sort";
        List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sql);
        Map<String,Object> map1 = new HashedMap();
        map1.put("code","used");
        map1.put("type","常用");
        mapList1.add(map1);
        Map<String,Object> map2 = new HashedMap();
        map2.put("code","other");
        map2.put("type","其他");
        mapList1.add(map2);
        return mapList1;
    }

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/WlyyMessageService.java

@ -57,7 +57,7 @@ public class WlyyMessageService {
            object.put("del",one.get("del"));
            object.put("title",one.get("title"));
            object.put("type",one.get("type"));
            object.put("content",one.get("content"));
            object.put("content",one.get("data"));
            object.put("sender",one.get("sender"));
            object.put("id",one.get("id"));
            object.put("relation_code",one.get("relation_code"));

+ 47 - 11
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/statics/DoorStatisticAnalyzeService.java

@ -66,6 +66,8 @@ public class DoorStatisticAnalyzeService {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getHospital));
            } else if (lowLevel.equals("5")) {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDept));
            }else if (lowLevel.equals("6")) {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDoctor));
            }
            for (String one1 : map.keySet()) {
                Map<String, Object> resultMap = new HashMap();
@ -77,6 +79,8 @@ public class DoorStatisticAnalyzeService {
                    resultMap.put("name", list1.get(0).getHospitalName());
                } else if (lowLevel.equals("5")) {
                    resultMap.put("name", list1.get(0).getDeptName());
                }else if (lowLevel.equals("6")) {
                    resultMap.put("name", list1.get(0).getDoctorName());
                }
                Map<String, List<SaveModel>> map2 = list1.stream().collect(Collectors.groupingBy(SaveModel::getSlaveKey1));
                //0、审核中,1、未通过,2、已通过
@ -302,6 +306,8 @@ public class DoorStatisticAnalyzeService {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getHospital));
            } else if (lowLevel.equals("5")) {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDept));
            }else if(lowLevel.equals("6")){
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDoctor));
            }
            for (String one1 : map.keySet()) {
                Map<String, Object> resultMap = new HashMap();
@ -313,6 +319,8 @@ public class DoorStatisticAnalyzeService {
                    resultMap.put("name", list1.get(0).getHospitalName());
                } else if (lowLevel.equals("5")) {
                    resultMap.put("name", list1.get(0).getDeptName());
                }else if (lowLevel.equals("6")) {
                    resultMap.put("name", list1.get(0).getDoctorName());
                }
                Map<String, List<SaveModel>> map2 = list1.stream().collect(Collectors.groupingBy(SaveModel::getSlaveKey1));
                //工单状态:-1-已取消,1-待(调度员)派单,2-待(医生)接单,3-待服务,4-待付款,5-待评价,6-已完成,评价均分-evaluateSplit
@ -417,6 +425,8 @@ public class DoorStatisticAnalyzeService {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getHospital));
            } else if (lowLevel.equals("5")) {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDept));
            }else if (lowLevel.equals("6")) {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDoctor));
            }
            for (String one1 : map.keySet()) {
                Map<String, Object> resultMap = new HashMap();
@ -428,6 +438,8 @@ public class DoorStatisticAnalyzeService {
                    resultMap.put("name", list1.get(0).getHospitalName());
                } else if (lowLevel.equals("5")) {
                    resultMap.put("name", list1.get(0).getDeptName());
                }else if (lowLevel.equals("6")) {
                    resultMap.put("name", list1.get(0).getDoctorName());
                }
                Map<String, List<SaveModel>> map2 = list1.stream().collect(Collectors.groupingBy(SaveModel::getSlaveKey1));
                resultMap.put("h01", map2.get("1").get(0).getResult2().intValue());
@ -580,6 +592,8 @@ public class DoorStatisticAnalyzeService {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getHospital));
            } else if (lowLevel.equals("5")) {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDept));
            }else if (lowLevel.equals("6")) {
                map = esModelList.stream().collect(Collectors.groupingBy(SaveModel::getDoctor));
            }
            for (String one1 : map.keySet()) {
                Map<String, Object> resultMap = new HashMap();
@ -591,6 +605,8 @@ public class DoorStatisticAnalyzeService {
                    resultMap.put("name", list1.get(0).getHospitalName());
                } else if (lowLevel.equals("5")) {
                    resultMap.put("name", list1.get(0).getDeptName());
                }else if (lowLevel.equals("6")) {
                    resultMap.put("name", list1.get(0).getDoctorName());
                }
                //上门出诊人次
                Map<String, List<SaveModel>> map2 = list1.stream().collect(Collectors.groupingBy(SaveModel::getSlaveKey1));
@ -1017,8 +1033,8 @@ public class DoorStatisticAnalyzeService {
            low_level = lowLevel;
        }
        if (SaveModel.deptLevel.equals(low_level)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,sum(result1) result1, sum(result2) result2,quotaDate from " + esIndex + " where ");
            groupBy.append("  group by team,teamName");
            sql.append("select dept,deptName,slaveKey1,slaveKey1Name,sum(result1) result1, sum(result2) result2,quotaDate from " + esIndex + " where ");
            groupBy.append("  group by dept,deptName");
            groupBy.append(",slaveKey1,slaveKey1Name");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2,quotaDate from " + esIndex + " where ");
@ -1032,17 +1048,23 @@ public class DoorStatisticAnalyzeService {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2,quotaDate from " + esIndex + " where ");
            groupBy.append("  group by city,cityName");
            groupBy.append(",slaveKey1,slaveKey1Name");
        }else if (SaveModel.doctorLevel.equals(low_level)) {
            sql.append("select doctor,doctorName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2,quotaDate from " + esIndex + " where ");
            groupBy.append("  group by doctor,doctorName");
            groupBy.append(",slaveKey1,slaveKey1Name");
        }
        if (StringUtils.isNotEmpty(area)) {
            if (SaveModel.deptLevel.equals(level + "")) {
                sql.append(" team='" + area + "'");
                sql.append(" dept='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }else if (SaveModel.doctorLevel.equals(level + "")) {
                sql.append(" doctor='" + area + "'");
            }
            sql.append(" and ");
        }
@ -1148,7 +1170,10 @@ public class DoorStatisticAnalyzeService {
        }else if(level == 4){
            whereSql += "and f.hospital = '" + area + "' ";
        }else if(level == 5){
            whereSql += "and f.admin_team_code='" + area + "' ";
            sql = sql.replace("f.patient = o.patient","f.patient = o.patient join wlyy.wlyy_doctor d on f.doctor = d.code and d.`status`= 1 ");
            whereSql += "and d.dept='" +area + "' ";
        }else if(level == 6){
            whereSql += "and (f.doctor = '"+ area + "' or f.doctor_health = '"+area + "') ";
        }
        Integer doorPatientService = jdbcTemplate.queryForObject(sql + whereSql, Integer.class);
        resMap.put("doorPatientServiceCount", doorPatientService);
@ -1197,7 +1222,10 @@ public class DoorStatisticAnalyzeService {
        }else if(level == 4){
            sql += "and f.hospital = '" + area + "' ";
        }else if(level == 5){
            sql += "and f.admin_team_code='" + area + "' ";
            sql = sql.replace("f.patient = p.patient","f.patient = o.patient join wlyy.wlyy_doctor d on f.doctor = d.code and d.`status`= 1 ");
            sql += "and d.dept='" +area + "' ";
        }else if(level == 6){
            sql += "and (f.doctor = '"+ area + "' or f.doctor_health = '"+area + "') ";
        }
        if(StringUtils.isNotBlank(startDate)){
            sql += "and p.create_time >= '" + startDate + "' ";
@ -1232,7 +1260,10 @@ public class DoorStatisticAnalyzeService {
        }else if(level == 4){
            drugSql += "and f.hospital = '" + area + "' ";
        }else if(level == 5){
            drugSql += "and f.admin_team_code='" + area + "' ";
            drugSql = drugSql.replace("f.patient = p.patient","f.patient = o.patient join wlyy.wlyy_doctor d on f.doctor = d.code and d.`status`= 1 ");
            drugSql += "and d.dept='" +area + "' ";
        }else if(level == 6){
            drugSql += "and (f.doctor = '"+ area + "' or f.doctor_health = '"+area + "') ";
        }
        drugSql += "GROUP BY d.drug_code order by orderCount desc, patientCount desc limit " + (page-1) * pageSize + "," + pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(drugSql);
@ -1261,6 +1292,8 @@ public class DoorStatisticAnalyzeService {
            map1 = slaveList.stream().collect(Collectors.groupingBy(SaveModel::getTown));
        } else if (SaveModel.deptLevel.equals(lowLevel)) {
            map1 = slaveList.stream().collect(Collectors.groupingBy(SaveModel::getDept));
        }else if (SaveModel.doctorLevel.equals(lowLevel)) {
            map1 = slaveList.stream().collect(Collectors.groupingBy(SaveModel::getDoctor));
        }
//        Map<String, List<SaveModel>> map1 = slaveList.stream().collect(Collectors.groupingBy(SaveModel::getHospital));
        for (String one1 : map1.keySet()) {
@ -1273,6 +1306,8 @@ public class DoorStatisticAnalyzeService {
                childrenResultMap.put("name", list1.get(0).getTownName());
            } else if (SaveModel.deptLevel.equals(lowLevel)) {
                childrenResultMap.put("name", list1.get(0).getDeptName());
            }else if (SaveModel.doctorLevel.equals(lowLevel)) {
                childrenResultMap.put("name", list1.get(0).getDoctorName());
            }
            Map<String, List<SaveModel>> map2 = list1.stream().collect(Collectors.groupingBy(SaveModel::getSlaveKey1));
            //工单状态:-1-已取消,1-待(调度员)派单,2-待(医生)接单,3-待服务,4-待服务,5-待评价,6-已完成,评价均分-evaluateSplit
@ -1450,14 +1485,15 @@ public class DoorStatisticAnalyzeService {
        String ddlOrZl = statisticsUtilService.getDDLOrZL(startDate,endDate);
        //服务工单数
        List<SaveModel> slaveList1 = statisticsUtilService.findDateQuotaLevel0BySlaveKey1(startDate, endDate, area, level, "121", ddlOrZl,null, lowLevel,"5,6");
        List<SaveModel> slaveList1 = elasticsearchUtil.findDateQuotaLevel0BySlaveKey1(startDate, endDate, area, level, "121", ddlOrZl,null, lowLevel,"5,6");
        //服务费用
        List<SaveModel> slaveList = elasticsearchUtil.findDateQuotaLevel2(startDate, endDate, area, level, "177", ddlOrZl, slaveKey1,"020", null, lowLevel);
        System.out.println("服务工单数:"+slaveList1.size() + " , 服务费用数:" + slaveList.size());
        for (SaveModel saveModel:slaveList1){
            Map<String, Object> map = statisticsUtilService.getMapTurnDownResult2(saveModel,lowLevel,"num");
            for (SaveModel one:slaveList){
                if(statisticsUtilService.compareSaveModel(saveModel,one,lowLevel)){
                    map.put("price",one.getResult1());
            Map<String, Object> map = statisticsUtilService.getMapTurnDownResult2(saveModel, lowLevel, "num");
            for (SaveModel one : slaveList) {
                if (statisticsUtilService.compareSaveModel(saveModel, one, lowLevel)) {
                    map.put("price", one.getResult1());
                    break;
                }
            }

+ 6 - 4
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/statics/StatisticsUtilService.java

@ -118,14 +118,16 @@ public class StatisticsUtilService {
    }
    public boolean compareSaveModel(SaveModel saveModel1,SaveModel saveModel2,String lowLevel){
        if (SaveModel.OrgLevel.equals(lowLevel)) {
        if (SaveModel.OrgLevel.equals(lowLevel) && saveModel1.getHospital() != null && saveModel2.getHospital() != null) {
            return saveModel1.getHospital().equals(saveModel2.getHospital());
        } else if (SaveModel.townLevel.equals(lowLevel)) {
        } else if (SaveModel.townLevel.equals(lowLevel) && saveModel1.getTown() != null && saveModel2.getTown() != null) {
            return saveModel1.getTown().equals(saveModel2.getTown());
        } else if (SaveModel.cityLevel.equals(lowLevel)) {
        } else if (SaveModel.cityLevel.equals(lowLevel) && saveModel1.getCity() != null && saveModel2.getCity() != null) {
            return saveModel1.getCity().equals(saveModel2.getCity());
        } else if (SaveModel.deptLevel.equals(lowLevel)) {
        } else if (SaveModel.deptLevel.equals(lowLevel) && saveModel1.getDept() != null && saveModel2.getDept() != null) {
            return saveModel1.getDept().equals(saveModel2.getDept());
        }else if (SaveModel.doctorLevel.equals(lowLevel) && saveModel1.getDoctor() != null && saveModel2.getDoctor() != null) {
            return saveModel1.getDoctor().equals(saveModel2.getDoctor());
        }
        return false;
    }

+ 147 - 146
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/util/MessageUtil.java

@ -2,16 +2,14 @@ package com.yihu.jw.door.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
@ -19,11 +17,10 @@ import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
@ -56,13 +53,14 @@ public class MessageUtil {
    private SystemMessageDao systemMessageDao;
    @Autowired
    private WxAccessTokenDao wxAccessTokenDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    //发送微信模板消息
    public static String sendMessageUrl ="http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
    public static String sendMessageUrl = "http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
    /**
     *
     * @param wxId
     * @param patient 患者id
     * @param patient       患者id
     * @param cardNo
     * @param first
     * @param noticeContent
@ -70,52 +68,52 @@ public class MessageUtil {
     * @param redirectUrl
     * @return
     */
    public String sendWXMes(String wxId,String patient,String cardNo,String first,String noticeContent,String remark,String redirectUrl){
        String msg="first:"+first+"contentMsg:"+noticeContent+"remark:"+remark;
        logger.info("发送的信息="+msg);
    public String sendWXMes(String wxId, String patient, String cardNo, String first, String noticeContent, String remark, String redirectUrl) {
        String msg = "first:" + first + "contentMsg:" + noticeContent + "remark:" + remark;
        logger.info("发送的信息=" + msg);
        JSONObject params = new JSONObject();
        params.put("transType","sms.hospital.notice");
        params.put("merchId","3501000014");
        params.put("transType", "sms.hospital.notice");
        params.put("merchId", "3501000014");
        JSONObject p = new JSONObject();
        String openId = "";
        if(StringUtils.isNotBlank(patient)){
            String sql = "select * from base.base_patient_wechat where wechat_id='"+wxId+"'and patient_id='"+patient+"' ";
            List<BasePatientWechatDo> paientWechatDos = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BasePatientWechatDo.class));
            if(paientWechatDos!=null&&paientWechatDos.size()>0){
        if (StringUtils.isNotBlank(patient)) {
            String sql = "select * from base.base_patient_wechat where wechat_id='" + wxId + "'and patient_id='" + patient + "' ";
            List<BasePatientWechatDo> paientWechatDos = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientWechatDo.class));
            if (paientWechatDos != null && paientWechatDos.size() > 0) {
                openId = paientWechatDos.get(0).getOpenid();
                p.put("openId",openId);
                p.put("openId", openId);
            }
        }else {
            p.put("cardNo",cardNo);
        } else {
            p.put("cardNo", cardNo);
        }
        p.put("first",first);
        p.put("noticeTime", DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
        p.put("noticeContent",noticeContent);
        if(StringUtils.isNotBlank(redirectUrl)){
            p.put("redirectUrl",redirectUrl);
        p.put("first", first);
        p.put("noticeTime", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"));
        p.put("noticeContent", noticeContent);
        if (StringUtils.isNotBlank(redirectUrl)) {
            p.put("redirectUrl", redirectUrl);
        }
        p.put("remark",remark);
        params.put("param",p);
        p.put("remark", remark);
        params.put("param", p);
        logger.info("params :"+params.toString());
        logger.info("params :" + params.toString());
        if(StringUtils.isNotBlank(openId)||StringUtils.isNotBlank(cardNo)){
            String rs = HttpUtil.sendPost(sendMessageUrl,params.toJSONString());
        if (StringUtils.isNotBlank(openId) || StringUtils.isNotBlank(cardNo)) {
            String rs = HttpUtil.sendPost(sendMessageUrl, params.toJSONString());
            JSONObject rsJson = JSON.parseObject(rs);
            String resCode = rsJson.getString("respCode");
            if("000000".equals(resCode)){
            if ("000000".equals(resCode)) {
                return "1";
            }
            return "0";
        }else {
        } else {
            return "-1";
        }
    }
    public String ehospitalNotice(String userName, String idCard, String phone, String title, String content, String contentString,String url) {
        String msg="first:"+title+"contentMsg:"+content+"remark:"+contentString;
        logger.info("发送的信息="+msg);
    public String ehospitalNotice(String userName, String idCard, String phone, String title, String content, String contentString, String url) {
        String msg = "first:" + title + "contentMsg:" + content + "remark:" + contentString;
        logger.info("发送的信息=" + msg);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("userName", userName);
        jsonObject.put("idCard", idCard);
@ -130,132 +128,63 @@ public class MessageUtil {
        return responseMsg;
    }
    public void putTemplateWxMessage(String wechatId,String templateName,String scene,String openId,String first,String remark,String url,String ...keywords){
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first, String remark, String url, String... keywords) {
        try {
            WxAccessTokenDO wxAccessTokenDO = getWxAccessTokenById(wechatId);
            if (wxAccessTokenDO==null){
                logger.info("wx_access_token表获取为空,wechatId"+wechatId);
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (wxAccessTokenDO == null) {
                logger.info("wx_access_token表获取为空,wechatId" + wechatId);
                return;
            }
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            String sql="select w.* from base.wx_template_config w where w.wechat_id='"+wechatId+"' and w.template_name='"+templateName+"' and w.scene='"+scene+"' and w.status=1";
            List<WxTemplateConfigDO> configList =  jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(WxTemplateConfigDO.class));
            WxTemplateConfigDO config =null;
            if (configList.size()>0){
                config = configList.get(0);
            }else {
                logger.info("微信模板不存在!请确认wechatId:"+wechatId+",templateName:"+templateName+",scene:"+scene);
            WxTemplateConfigDO newConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
            if (newConfig == null) {
                logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
                return;
            }
            BeanUtils.copyProperties(config, newConfig);
            if (StringUtils.isNoneBlank(url)){
            if (StringUtils.isNoneBlank(url)) {
                newConfig.setUrl(url);
            }
            if (StringUtils.isNoneBlank(remark)){
            if (StringUtils.isNoneBlank(remark)) {
                newConfig.setRemark(remark);
            }
            newConfig.setFirst(first);
            int keyLength = keywords.length;
            if (keyLength>=1){
            if (keyLength >= 1) {
                newConfig.setKeyword1(keywords[0]);
            }
            if (keyLength>=2){
            if (keyLength >= 2) {
                newConfig.setKeyword1(keywords[1]);
            }
            if (keyLength>=3){
            if (keyLength >= 3) {
                newConfig.setKeyword1(keywords[2]);
            }
            if (keyLength>=4){
            if (keyLength >= 4) {
                newConfig.setKeyword1(keywords[3]);
            }
            if (keyLength>=5){
            if (keyLength >= 5) {
                newConfig.setKeyword1(keywords[4]);
            }
            if (keyLength>=6){
            if (keyLength >= 6) {
                newConfig.setKeyword1(keywords[5]);
            }
            if (keyLength>=7){
            if (keyLength >= 7) {
                newConfig.setKeyword1(keywords[6]);
            }
            //发起微信消息模板推送
            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
        }catch (Exception e){
            logger.info("微信模板推送异常");
            e.printStackTrace();
        }
    }
    public WxAccessTokenDO getWxAccessTokenById(String wechatId) {
        try {
            //根据wechatCode查找出appid和appSecret
            String sql ="select * from base.wx_wechat w where w.id = '"+wechatId+"' and w.status!=-1";
            List<WxWechatDO> wxWechatList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(WxWechatDO.class));
            WxWechatDO wxWechat=null;
            if (wxWechatList.size()>0){
                wxWechat = wxWechatList.get(0);
            }
            sql="select * from base.wx_access_token w where w.wechat_id ='"+wechatId+"' order by w.add_timestamp desc ";
            List<WxAccessTokenDO> wxAccessTokens =  jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(WxAccessTokenDO.class));
            if(wxWechat==null){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_wxWechat_is_no_exist, ExceptionCode.common_error_params_code);
            }
            if(wxAccessTokens!=null&&wxAccessTokens.size()>0){
                for (WxAccessTokenDO accessToken : wxAccessTokens) {
                    if ((System.currentTimeMillis() - accessToken.getAddTimestamp()) < (accessToken.getExpiresIn() * 500)) {
                        return accessToken;
                    } else {
                        sql="DELETE  from  base.wx_access_token where wechat_id='"+accessToken.getWechatId()+"' and access_token='"+accessToken.getAccessToken()+"'";
                        jdbcTemplate.execute(sql);
                        break;
                    }
                }
            }
            String token_url = "https://api.weixin.qq.com/cgi-bin/token";
            String appId="";
            String appSecret="";
            appId = wxWechat.getAppId();
            appSecret = wxWechat.getAppSecret();
            if (org.springframework.util.StringUtils.isEmpty(appId)){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appId_is_null, ExceptionCode.common_error_params_code);
            }
            if (org.springframework.util.StringUtils.isEmpty(appSecret)){
                throw new ApiException(WechatRequestMapping.WxConfig.message_fail_appSecret_is_null, ExceptionCode.common_error_params_code);
            }
            Map<String, Object> params = new HashMap<>();
            params.put("grant_type", "client_credential");
            params.put("appid", appId);
            params.put("secret", appSecret);
            String result = HttpUtils.doGet(token_url, params).getContent();
            logger.info("--------------wechat token return:"+result+"---------------");
            org.json.JSONObject json = new org.json.JSONObject(result);
            if (json.has("access_token")) {
                String token = json.get("access_token").toString();
                String expires_in = json.get("expires_in").toString();
                WxAccessTokenDO newaccessToken = new WxAccessTokenDO();
                newaccessToken.setAccessToken(token);
                newaccessToken.setExpiresIn(Long.parseLong(expires_in));
                newaccessToken.setAddTimestamp(System.currentTimeMillis());
                newaccessToken.setCzrq(new Date());
                newaccessToken.setCode(UUID.randomUUID().toString().replace("-",""));
                newaccessToken.setWechatId(wechatId);
                wxAccessTokenDao.save(newaccessToken);
                return newaccessToken;
            } else {
                return null;
            }
        } catch (Exception e) {
            logger.info("微信模板推送异常");
            e.printStackTrace();
            return null;
        }
    }
    /**
     *
     */
    public SystemMessageDO saveSystemMessage(String messageId,String relationCode,String title,String type,String sender,String senderName,String receiver,String receiverName,String idCard,String msg,String over) {
    public SystemMessageDO saveSystemMessage(String messageId, String relationCode, String title, String type, String sender, String senderName, String receiver, String receiverName, String idCard, String msg, String over) {
        SystemMessageDO messageDO = new SystemMessageDO();
        if (StringUtils.isBlank(messageId)){
            messageDO.setId(UUID.randomUUID().toString().replace("-",""));
        if (StringUtils.isBlank(messageId)) {
            messageDO.setId(UUID.randomUUID().toString().replace("-", ""));
        }
        messageDO.setTitle(title);
        messageDO.setType(type);
@ -264,31 +193,103 @@ public class MessageUtil {
        messageDO.setRelationCode(relationCode);
        messageDO.setReceiver(receiver);
        messageDO.setReceiverName(receiverName);
        net.sf.json.JSONObject data = new net.sf.json.JSONObject();
        data.put("name", receiverName);
        try {
            if(StringUtils.isNoneBlank(idCard)){
                data.put("age", IdCardUtil.getAgeForIdcard(idCard));
                data.put("gender", IdCardUtil.getSexForIdcard(idCard));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        data.put("msg", msg);
        messageDO.setData(data.toString());
        messageDO.setData(msg);
        messageDO.setOver(over);
        messageDO.setDel("1");
        messageDO.setCreateTime(new Date());
        systemMessageDao.save(messageDO);
        return messageDO;
    }
    public  void test(){
        String sql="select w.* from base.wx_template_config w where w.wechat_id='xm_ykyy_wx' and w.template_name='template_evaluate_notice' and w.scene='fwqjtx' and w.status=1";
        List<Map<String,Object>> config =  jdbcTemplate.queryForList(sql);
//        wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus("xm_ykyy_wx", "template_pay_notice_jz", "mzxxtx", 1)
        System.out.println("!");
    public void updateMessage(WlyyDoorServiceOrderDO doorServiceOrder,String[] type,String toType,String sender,String receiver){
        String orderId=doorServiceOrder.getId();
        List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,type);
        if (toType.equals("434")){//医生接单
            if (CollectionUtils.isEmpty(messages)){
                logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
            }else {
                messages.forEach(message->{
                    systemMessageDao.orderMessageDel(message.getReceiver(),message.getRelationCode());
                    if (message.getType().equals("403") ) {
                        BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doorServiceOrder.getDispatcher());//·
                        String msg=doorServiceOrder.getDispatcherName() + "接受了服务工单"+ doorServiceOrder.getNumber();
                        saveSystemMessage(message.getId(),message.getRelationCode(),"医生接单","434",doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName(),
                                doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),null,msg,message.getOver());
                    }
                    else{
                        message.setOver("0");
                        systemMessageDao.save(message);
                    }
                });
            }
        }
        if (toType.equals("435")) {//医生拒单
            if (CollectionUtils.isEmpty(messages)) {
                logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
            } else {
                SystemMessageDO message = messages.get(0);
                BaseDoctorDO baseDoctorDO = baseDoctorDao.findById(doorServiceOrder.getDispatcher());
                String msg=doorServiceOrder.getDoctorName() + "拒绝了服务工单" + doorServiceOrder.getNumber() + ", 请重新派单";
                saveSystemMessage(message.getId(),message.getRelationCode(),"医生拒单","435",doorServiceOrder.getDoctor(),doorServiceOrder.getDoctorName(),
                        doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),null,msg,message.getOver());
            }
        }
        if (toType.equals("431")) {//调度员派单(派给本社区医生)
            if(CollectionUtils.isEmpty(messages)){
                logger.error("当前工单没有 居民新增预约 消息!!orderId:" + orderId);
            }else{
                // 设置消息处理完毕
                messages.forEach(
                        message -> {
                            String title = "调度员派单(派给本社区医生)";
                            if("system".equals(doorServiceOrder.getUpdateUser())){
                                title = "系统派单(派给服务医生)";
                            }
                            if (message.getType() .equals("430")) {
                                message.setTitle(title);
                                String msg = doorServiceOrder.getDispatcherName() + "已将服务工单" + doorServiceOrder.getNumber() + "指派给" + doorServiceOrder.getDoctorName() + "医生";
                                saveSystemMessage(message.getId(),message.getRelationCode(),title,"431",doorServiceOrder.getUpdateUser(),doorServiceOrder.getUpdateUserName(),
                                        doorServiceOrder.getUpdateUser(),doorServiceOrder.getUpdateUserName(),null,msg,message.getOver());
                            }else{
                                message.setOver("0");
                                systemMessageDao.save(message);
                            }
                        }
                );
            }
        }
        if (toType.equals("432")){//调度员拒单
            if(CollectionUtils.isEmpty(messages)){
                logger.error("当前工单没有系统消息!!orderId:" + orderId);
            } else {
                // 432 调度员拒单即取消工单-- 李四拒绝了张三的服务工单12345678
                messages.forEach(
                        message -> {
                            if (message.getType() .equals("430")) {
                                String msg=doorServiceOrder.getDispatcherName() + "拒绝了"+ doorServiceOrder.getPatientName() +"的服务工单" + doorServiceOrder.getNumber();
                                saveSystemMessage(message.getId(),message.getRelationCode(),"调度员拒单","432",doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),
                                        doorServiceOrder.getDispatcher(),doorServiceOrder.getDispatcherName(),null,msg,message.getOver());
                            }else{
                                message.setOver("0");
                                systemMessageDao.save(message);
                            }
                        }
                );
            }
        }
        if (toType.equals("patientCancel")){//居民取消 消息列表也应该不显示
            if(CollectionUtils.isEmpty(messages)){
                logger.error("当前工单没有系统消息!!orderId:" + orderId);
            } else {
                messages.forEach(
                        message -> {
                            message.setOver("0");
                            systemMessageDao.save(message);
                        }
                );
            }
        }
    }
    public static void main(String[] args){

+ 42 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/util/StreamUtil.java

@ -0,0 +1,42 @@
package com.yihu.jw.door.util;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import java.io.IOException;
import java.io.InputStream;
/***
 * @ClassName: StreamUtil
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/1/5 19:40
 */
public class StreamUtil {
    /**
     *   jar包,读取resources配置
     *   /conclusion.mht    :resources下文件路径以及文件名
     * @return
     * @throws IOException
     */
    public static String readResources() throws IOException {
        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        Resource[] resources = resolver.getResources("/conclusion.mht");
        Resource resource = resources[0];
//获得文件流,因为在jar文件中,不能直接通过文件资源路径拿到文件,但是可以在jar包中拿到文件流
        InputStream stream = resource.getInputStream();
        StringBuilder buffer = new StringBuilder();
        byte[] bytes = new byte[1024];
        try {
            for (int n; (n = stream.read(bytes)) != -1; ) {
                buffer.append(new String(bytes, 0, n));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return buffer.toString();
    }
}

+ 11 - 11
svr/svr-door-serivce/src/main/resources/application.yml

@ -101,7 +101,7 @@ wechat:
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fweixin.xmtyw.cn%2fwlyy-dev
  accId: gh_ffd64560fb21
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
@ -181,7 +181,7 @@ wechat:
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fehr.yihu.com%2fwlyy
  accId: gh_ffd64560fb21
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
im:
@ -194,11 +194,11 @@ es:
    Statistics: hlw_quota_test
  type:
    Statistics: hlw_quota_test
  host:  http://172.26.0.55:9000
  tHost: 172.26.0.55:9300
  host:  http://172.26.0.112:9200
  tHost: 172.26.0.112:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion
  securityUser: jw:jkzlehr
  user: jw
  password: jkzlehr
wlyy:
  url: http://ehr.yihu.com/wlyy/
@ -260,8 +260,8 @@ wechat:
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fwww.xmtyw.cn%2fwlyy
  accId: gh_ffd64560fb21
  id: xm_ykyy_wx  # base库中,wx_wechat 的id字段
  flag: false #演示环境  true走Mysql数据库  false走Oracle
  id: sd_tnzyy_wx  # base库中,wx_wechat 的id字段
  flag: true #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://27.155.101.77:3000/
@ -308,7 +308,7 @@ systemSetting:
spring:
  profiles: tnJwprod
  datasource:
    url: jdbc:mysql://10.9.1.247:3306/base?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    url: jdbc:mysql://10.9.1.247:3310/base?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: qY#j2n5O
  redis:
@ -330,8 +330,8 @@ server:
  server_url: http://ehr.yihu.com/wlyy/
base:
  url: http://192.168.120.96:10020/svr-base/
  hospitalUrl: http://172.26.0.107:10022/
  url: http://127.0.0.1:10020/svr-base/
  hospitalUrl: http://127.0.0.1:10022/
wechat:
  appId: wxad04e9c4c5255acf

+ 8 - 1
svr/svr-door-serivce/src/main/resources/bootstrap.yml

@ -43,4 +43,11 @@ spring:
  cloud:
    config:
      uri: ${wlyy.spring.config.uri:http://192.168.120.153:1221}
      label: ${wlyy.spring.config.label:prod}
      label: ${wlyy.spring.config.label:prod}
---
spring:
  profiles: tnJwprod
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}

File diff suppressed because it is too large
+ 1 - 0
svr/svr-door-serivce/src/main/resources/conclusion.mht