Parcourir la source

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

wangzhinan il y a 3 jours
Parent
commit
c90ab8da29

+ 1 - 26
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/TimeoutOverDueService.java

@ -218,18 +218,7 @@ public class TimeoutOverDueService {
                        businessOrderService.ylzOrderRefund(wechatId, wlyyOutpatientDO.getPatient(), businessOrderDO.getOrderNo(), businessOrderDO.getPayPrice(), description);
    */
                    }
                    if("ff80808199e1e6650199e76d0f6c10a5".equals(wlyyOutpatientDO.getId())) {
                        Map<String, Object> entry2 = jdbcTemplate.queryForMap("SELECT id,status,DOCTOR_CANCEL_REMARK,DOCTOR_CANCEL_TYPE,DOCTOR_CANCEL_VALUE,end_time,OPERATOR FROM \"WLYY_OUTPATIENT\" WHERE id='ff80808199e1e6650199e76d0f6c10a5'");
                        logger.info("entry2"+JSON.toJSONString(entry2));
                    }
                    logger.info("保存"+wlyyOutpatientDO.getDoctor()+"-"+wlyyOutpatientDO.getId()+":"+JSON.toJSONString(wlyyOutpatientDO));
                    wlyyOutpatientDO = outpatientDao.save(wlyyOutpatientDO);
                    logger.info("保存2"+wlyyOutpatientDO.getDoctor()+"-"+wlyyOutpatientDO.getId()+":"+JSON.toJSONString(wlyyOutpatientDO));
                    if("ff80808199e1e6650199e76d0f6c10a5".equals(wlyyOutpatientDO.getId())) {
                        Map<String, Object> entry3 = jdbcTemplate.queryForMap("SELECT id,status,DOCTOR_CANCEL_REMARK,DOCTOR_CANCEL_TYPE,DOCTOR_CANCEL_VALUE,end_time,OPERATOR FROM \"WLYY_OUTPATIENT\" WHERE id='ff80808199e1e6650199e76d0f6c10a5'");
                        logger.info("entry3"+JSON.toJSONString(entry3));
                    }
                    logger.info(wlyyOutpatientDO.getId()+"的门诊记录设置为取消");
                    consultCode = imService.getConsultCodeByOutpatientId(outPatientId);
@ -246,11 +235,6 @@ public class TimeoutOverDueService {
                    logger.info("自动结束咨询报错 consultCode: "+consultCode);
                }
                if("ff80808199e1e6650199e76d0f6c10a5".equals(wlyyOutpatientDO.getId())) {
                    Map<String, Object> entry4 = jdbcTemplate.queryForMap("SELECT id,status,DOCTOR_CANCEL_REMARK,DOCTOR_CANCEL_TYPE,DOCTOR_CANCEL_VALUE,end_time,OPERATOR FROM \"WLYY_OUTPATIENT\" WHERE id='ff80808199e1e6650199e76d0f6c10a5'");
                    logger.info("entry4"+JSON.toJSONString(entry4));
                }
            } else if(1==2 && currentTime-outpatientTime>23*60*60*1000 && !"1".equals(wlyyOutpatientDO.getHasRemind())) {
                String doctor = wlyyOutpatientDO.getDoctor();
                String question = wlyyOutpatientDO.getIcd10Name();
@ -270,7 +254,7 @@ public class TimeoutOverDueService {
                    data.put("age", IdCardUtil.getAgeForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("gender", IdCardUtil.getSexForIdcard(wlyyOutpatientDO.getIdcard()));
                    data.put("question", question);
                    data.put("type","nnn");
                    data.put("type","144");
                    data.put("msg", "您当前的订单尚未回复,1 小时后系统将自动关闭,请留意处理。");
                    messageDO.setData(data.toString());
@ -319,15 +303,6 @@ public class TimeoutOverDueService {
        logger.info("entry1"+JSON.toJSONString(entry));
        List<WlyyOutpatientDO> timeout = outpatientDao.findAllWaitingOutpatient();
            timeout.stream().filter(item -> {
                if("4028a14770a41b240170a4bbb4da0090".equals(item.getDoctor())) {
                    return true;
                } else {
                    return false;
                }
            }).forEach(item -> {
                System.out.println(JSON.toJSONString(item));
            });
            if (null!=timeout&&timeout.size()>0){
                logger.info("开始结束超时未接诊的门诊");
                String cancelValue = "超时订单系统自动取消";

+ 84 - 7
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultStatisticsEndpoint.java

@ -1,7 +1,9 @@
package com.yihu.jw.hospital.endpoint.consult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
@ -50,6 +52,8 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -221,6 +225,9 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
//			selectSql = selectSql + " limit " + (pageNum-1)*pageSize +","+ pageSize;
			List<Map<String, Object>> list = hibenateUtils.createSQLQuery(selectSql, pageNum, pageSize);
			System.out.println(LocalDateTime.now()+"statisticsData===========================");
			System.out.println(selectSql);
			System.out.println("===========================");
//			List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql);
			Integer total = jdbcTemplate.queryForObject(countSql, Integer.class);
@ -253,7 +260,13 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "deptId", value = "科室id")
			@RequestParam(value = "deptId",required = false) String deptId,
			@ApiParam(name = "doctorId", value = "医生的id")
			@RequestParam(value = "doctorId",required = false) String doctorId) {
			@RequestParam(value = "doctorId",required = false) String doctorId,
			@ApiParam(name = "roleType", value = "1专科医生 2管理员")
			@RequestParam(value = "roleType",required = true) String roleType,
			@ApiParam(name = "userOrgId", value = "医生所属机构id")
			@RequestParam(value = "userOrgId",required = true) String userOrgId,
			@ApiParam(name = "userId", value = "医生id(当前登录用户)")
			@RequestParam(value = "userId",required = true) String userId) {
		try {
			String selectSql = "SELECT " +
@ -278,10 +291,9 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
			if("org".equals(aggField)) {
				selectSql += fromPart;
				if(StringUtils.isBlank(orgId)) {
					throw new ServiceException("参数未传");
				if(!StringUtils.isBlank(orgId)) {
					filterSql += " AND op.scbgjt_org_code='"+orgId+"' ";
				}
				filterSql += " AND op.scbgjt_org_code='"+orgId+"' ";
			} else if("dept".equals(aggField)) {
				selectSql += ",dh.dept_code AS \"deptCode\",dh.dept_name AS \"deptName\" ";
				selectSql += fromPart;
@ -313,12 +325,23 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
				}
			}
			if("1".equals(roleType)) { // 专科医生
				filterSql += " AND op.doctor = '" + userId + "' ";
			} else if("2".equals(roleType)) { // 管理员
				filterSql += " AND dh.org_code = '" + userOrgId + "' ";
			} else {
				throw new ServiceException("角色类型有误");
			}
			selectSql += filterSql;
			selectSql += groupSql;
			selectSql += " ORDER BY TO_CHAR(op.create_time, 'YYYY-MM-DD') ASC ";
			List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql);
			System.out.println(LocalDateTime.now()+"statisticsGraph===========================");
			System.out.println(selectSql);
			System.out.println("===========================");
			JSONObject result = new JSONObject();
			result.put("list",list);
@ -352,12 +375,66 @@ public class DoctorConsultStatisticsEndpoint extends EnvelopRestEndpoint {
			HttpServletResponse response) {
		try {
			ObjEnvelop envelop = this.statisticsData(mediaType, aggField, startTime, endTime, orgId, deptId, roleType,userOrgId, userId, 1, 20000);
			Object list = ((JSONObject) (envelop.getObj())).get("list");
			String sql = "SELECT\n" +
					" op.scbgjt_org_code AS \"scbgjtOrgCode\",\n" +
					" op.scbgjt_org_name AS \"scbgjtOrgName\",\n" +
					" COUNT( * ) AS \"consultNum\",\n" +
					" COUNT( CASE WHEN op.status >= 1 THEN 1 ELSE NULL END ) AS \"haveReceiveNum\",\n" +
					" COUNT( CASE WHEN op.status <= 0 THEN 1 ELSE NULL END ) AS \"noReceiveNum\",\n" +
					" COUNT( CASE WHEN op.status = - 1 THEN 1 ELSE NULL END ) AS \"cancelNum\",\n" +
					" dh.dept_code AS \"deptCode\",\n" +
					" dh.dept_name AS \"deptName\",\n" +
					" op.doctor AS \"doctor\",\n" +
					" op.doctor_name AS \"doctorName\",\n" +
					" dh.doctor_duty_name AS \"doctorDutyName\",\n" +
					" dh.org_code AS \"orgCode\",\n" +
					" dh.org_name AS \"orgName\" \n" +
					"FROM\n" +
					" base_doctor_hospital dh\n" +
					" LEFT JOIN wlyy_outpatient op ON dh.doctor_code = op.doctor \n" +
					"WHERE ";
			String filterSql = " op.scbgjt IS NOT NULL " +
					" AND op.create_time BETWEEN TO_DATE( '"+startTime+"', 'YYYY-MM-DD' ) " +
					" AND TO_DATE( '"+endTime+" 23:59:59', 'YYYY-MM-DD HH24:MI:SS' ) " +
					" AND op.scbgjt_org_code IS NOT NULL ";
			if(StringUtils.isNotBlank(mediaType)) {
				if("1".equals(mediaType)) {
					filterSql += " AND (op.type = 1 AND op.outpatient_type IN (1, 3)) ";
				}
				if("2".equals(mediaType)) {
					filterSql += " AND (op.type = 2 AND op.outpatient_type IN (1, 3)) ";
				}
			}
			if("1".equals(roleType)) { // 专科医生
				filterSql += " AND op.doctor = '" + userId + "' ";
			} else if("2".equals(roleType)) { // 管理员
				filterSql += " AND dh.org_code = '" + userOrgId + "' ";
			} else {
				throw new ServiceException("角色类型有误");
			}
			String groupSql = "GROUP BY\n" +
								" op.scbgjt_org_code,\n" +
								" op.scbgjt_org_name,\n" +
								" dh.dept_code,\n" +
								" dh.dept_name,\n" +
								" op.doctor,\n" +
								" op.doctor_name,\n" +
								" dh.doctor_duty_name,\n" +
								" dh.org_code,\n" +
								" dh.org_name";
			List<Map<String, Object>> list = jdbcTemplate.queryForList(sql + filterSql + groupSql);
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename=" + new String("searchRecordWrite.xls"));
			OutputStream os = response.getOutputStream();
			this.searchRecordWrite(os, (List) list);
			this.searchRecordWrite(os, list);
			return success("操作成功");
		}catch (Exception e){
			return failedListEnvelopException(e);