Browse Source

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

liubing 4 years ago
parent
commit
4a4fd61ad0

+ 67 - 9
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;
@ -24,14 +25,15 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
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 +431,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,
@ -1245,10 +1247,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 +1280,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);
                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")

+ 16 - 22
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;
@ -768,11 +768,10 @@ public class DoorOrderService {
        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";
            }
@ -787,11 +786,13 @@ 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 + "'";
            }
@ -883,14 +884,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");
@ -1583,9 +1577,10 @@ 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);
@ -1699,12 +1694,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 ";
       }

+ 42 - 25
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,45 @@ 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)){
            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,7 +133,7 @@ public class ServerPackageService  {
    public List<Map<String,Object>> selectTypes(){
        String sql = "SELECT code,value type from base_system_dict_entry WHERE dict_code = 'PROFESSIONAL_STATE' ORDER BY sort";
        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");

+ 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();
    }
}

+ 4 - 4
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:
@ -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/