Selaa lähdekoodia

Merge branch 'dev' of wujunjie/patient-co-management into dev

yeshijie 7 vuotta sitten
vanhempi
commit
cbb8ffcac7

+ 1 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/SpringSecurityConfig.java

@ -39,6 +39,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
                "/admin/device/toExcel",
                "/admin/patientDevice/toExcel",
                "/admin/healthIndex/toExcel",
                "/admin/healthIndex/getExcelByFilter",
                "/admin/static/prescription/toExcel",
                "/admin/static/wechat/listToExcel",
                "/admin/static/wechat/hosipitaTotalToExcel",

+ 92 - 9
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/device/DeviceHealthIndexController.java

@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -52,8 +53,36 @@ public class DeviceHealthIndexController extends BaseController{
    }
    
    //导出报表
    @ResponseBody
    @RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(
            @RequestParam(value = "town",required = false)String town,
            @RequestParam(value = "hospital",required = false)String hospital,
            HttpServletResponse response){
        try {
            List<DeviceHealthIndexExportVO> wlyyDevices = healthIndexService.exportDeviceHealthIndexList(town,hospital);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceHealthIndexDataList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os,wlyyDevices);
        }catch (Exception ex){
            error(ex);
        }
    }
    /**
     * 按筛选条件导出居民体征数据报表
     * @param deviceSn 设备sn码
     * @param date 查询日期
     * @param idcard 居民身份证号
     * @param userName 居民姓名
     * @param indexType 体征类别
     * @param indexTypeMin 体征最小值
     * @param indexTypeMax 体征最大值
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value="getExcelByFilter",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public  String exportList(
            @RequestParam(value = "deviceSn",required = false) String deviceSn,
            @RequestParam(value = "date",required = false) String date,
@ -64,15 +93,15 @@ public class DeviceHealthIndexController extends BaseController{
            @RequestParam(value = "indexTypeMax",required = false) String indexTypeMax,
            HttpServletResponse response){
        try {
//            List<DeviceHealthIndexExportVO> wlyyDevices = healthIndexService.exportDeviceHealthIndexList(town,hospital);
            List<DeviceHealthIndexVO> deviceHealthIndexes = healthIndexService.getExcelByFilter(deviceSn,date, idcard, userName, indexType,indexTypeMin,indexTypeMax);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceHealthIndexDataList.xls"));
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "patientHealthIndexDataList.xls"));
            OutputStream os = response.getOutputStream();
//            this.write(os,wlyyDevices);
//            write(200, "操作成功!");
//            Map<Object, Object> map = new HashMap<Object, Object>();
//            map.put("status", 200);
//            map.put("msg", "操作成功!");
            this.writePatientHealth(os,deviceHealthIndexes);
            write(200, "操作成功!");
            Map<Object, Object> map = new HashMap<Object, Object>();
            map.put("status", 200);
            map.put("msg", "操作成功!");
            return write(200, "操作成功");
        }catch (Exception ex){
            error(ex);
@ -80,7 +109,6 @@ public class DeviceHealthIndexController extends BaseController{
        }
    }
    
    
    public void addHeader(WritableSheet ws) throws WriteException {
        
        String[] header = {"居民姓名","手机号","身份证","设备码","设备名称","签约医生", "地址"};
@ -90,6 +118,16 @@ public class DeviceHealthIndexController extends BaseController{
            i++;
        }
    }
    public void addPatientHealthHeader(WritableSheet ws) throws WriteException {
        String[] header = {"SN码","创建日期","身份证号","姓名","数据类型","value1","value2","value3","value4","value5","value6","value7"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    
    public void write(WritableWorkbook wwb, List ls) throws Exception {
        try {
@ -115,9 +153,54 @@ public class DeviceHealthIndexController extends BaseController{
            throw e;
        }
    }
    public void writePatientHealth(WritableWorkbook wwb, List ls) throws Exception {
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addPatientHealthHeader(ws);
            int i = 1;
            for (DeviceHealthIndexVO m : (List<DeviceHealthIndexVO>) ls) {
                String type = "未知";
                if (m.getType()==1){
                    type = "血糖";
                }else if (m.getType()==2){
                    type = "血压";
                }else if (m.getType()==3){
                    type = "体重";
                }else if (m.getType()==4){
                    type = "腰围";
                }
                addCell(ws, i, 0, m.getDeviceSn(),"");
                addCell(ws, i, 1, format.format(m.getCzrq()),"");
                addCell(ws, i, 2, m.getIdcard(),"");
                addCell(ws, i, 3, m.getUserName(),"");
                addCell(ws, i, 4, "","");
                addCell(ws, i, 5, m.getValue1(),"");
                addCell(ws, i, 6, m.getValue2(),"");
                addCell(ws, i, 7, m.getValue3(),"");
                addCell(ws, i, 8, m.getValue4(),"");
                addCell(ws, i, 9, m.getValue5(),"");
                addCell(ws, i, 10, m.getValue6(),"");
                addCell(ws, i, 11, m.getValue7(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void write(OutputStream os, List ls) throws Exception{
        write(Workbook.createWorkbook(os), ls);
    }
    public void writePatientHealth(OutputStream os, List ls) throws Exception{
        writePatientHealth(Workbook.createWorkbook(os), ls);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
        Label label = new Label(column ,row, data);

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

@ -102,6 +102,56 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
        return new PageImpl<DeviceHealthIndexVO>(listTemp,pageRequest,count);
    }
    public List<DeviceHealthIndexVO> getExcelByFilter(String deviceSn,String date,String idcard,
                                                String userName,String indexType,String indexTypeMin,String indexTypeMax)throws Exception{
        StringBuilder filter = new StringBuilder();
        if(!StringUtils.isEmpty(deviceSn)){
            filter.append("deviceSn="+deviceSn+";");
        }
        if(!StringUtils.isEmpty(idcard)){
            filter.append("idcard="+idcard+";");
        }
        if(!StringUtils.isEmpty(date)){
            Date startTimeTemp  =  DateTimeUtil.simpleDateParse(date);
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(startTimeTemp);
            calendar.set(Calendar.HOUR,23);
            calendar.set(Calendar.MINUTE,59);
            calendar.set(Calendar.SECOND,59);
            calendar.set(Calendar.MILLISECOND,999);
            Date endTimeTemp = calendar.getTime();
            filter.append("czrq>=" + DateTimeUtil.utcDateTimeFormat(startTimeTemp)+ ";");
            filter.append("czrq<=" + DateTimeUtil.utcDateTimeFormat(endTimeTemp)+ ";");
        }
        if(!StringUtils.isEmpty(userName)){
            String[] codes = patientDao.findByName(userName);
            if(codes != null && codes.length >0){
                filter.append("user="+StringUtils.join(codes, ","));
            }
        }
        if(!StringUtils.isEmpty(indexType)){
            filter.append("type="+indexType+";");
        }
        List<DeviceHealthIndex> list = (List<DeviceHealthIndex>)search(filter.toString());
        String regex = "(\\w{3})(\\w+)(\\w{3})";
        List<DeviceHealthIndexVO> listTemp = new ArrayList<>();
        if(list !=null && list.size()>0){
            for (DeviceHealthIndex info : list){
                DeviceHealthIndexVO bean = new DeviceHealthIndexVO();
                BeanUtils.copyProperties(info, bean);
                Patient patient = findPatient(bean.getUser());
                bean.setUserName(patient== null?"":patient.getName());
                if(StringUtils.isNotBlank(bean.getIdcard())){
                    bean.setIdcard(bean.getIdcard().replaceAll(regex, "$1****$3"));
                }
                bean.setHealthStandard(gethealthStandard(info.getType(),info.getUser()).toString());
                listTemp.add(bean);
            }
        }
        return listTemp;
    }
    //查询居民姓名
    public Patient findPatient(String patientCode){
        if(StringUtils.isEmpty(patientCode)){

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

@ -41,7 +41,7 @@
					<span>查询</span>
				</div>
			</sec:authorize>
			<sec:authorize url="/admin/healthIndex/toExcel">
			<sec:authorize url="/admin/healthIndex/getExcelByFilter">
				<div id="btn_excel" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
					<span>导出</span>
				</div>

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

@ -109,7 +109,7 @@
//                        master.toExcel();
                        var myform = $("<form></form>");
                        myform.attr('method','post')
                        myform.attr('action',ctx + '/admin/healthIndex/toExcel');
                        myform.attr('action',ctx + '/admin/healthIndex/getExcelByFilter');
                        self.$element.attrScan();
                        var values = self.$element.Fields.getValues();

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -84,7 +84,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            //同步智业字典 每晚1点同步
            if (!quartzHelper.isExistJob("zy_dict_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("zy_dict_job");
               // quartzHelper.addJob(ZyDictJob.class, trigger, "zy_dict_job", new HashMap<String, Object>());
                quartzHelper.addJob(ZyDictJob.class, trigger, "zy_dict_job", new HashMap<String, Object>());
                logger.info("zy_dict_job job success");
            } else {
                logger.info("zy_dict_job job exist");

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

@ -66,7 +66,7 @@ public class PatientConfirmReceiptJob implements Job {
            String jobRunning = systemDictDao.findByDictNameAndCode("JOB_RUNNING","PatientConfirmReceiptJob");
            if("1".equals(jobRunning)) {
                List<Prescription> list = new ArrayList<>();
                //1.找出状态是已支付未完成且取药方式不是健管师配送的续方
                //1.找出状态是已发药未完成且取药方式不是健管师配送的续方
                List<Prescription> PrescriptionList = prescriptionDao.findUndelivered();
                for (Prescription prescription : PrescriptionList) {
                    String patient = prescription.getPatient();

+ 2 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -29,7 +29,7 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Query("update Prescription p set p.jwPayStatus=1 where p.code=?1")
    void updatejwPayStatus(String prescriptionCode);
    //查询居民已支付未完成且为自取及快递的续方
    @Query("from Prescription p where p.status >= 50 and p.status< 100 and p.dispensaryType in (1,2) ")
    //查询居民已发药未完成且为自取及快递的续方
    @Query("from Prescription p where p.status >= 60 and p.status< 100 and p.dispensaryType in (1,2) ")
    List<Prescription> findUndelivered();
}

+ 6 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -119,6 +119,12 @@ public class PrescriptionService extends BaseService {
            Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
            if (type == 1){
                int status = prescription.getStatus();
                if (!(status>=60 && status <100)){
                    result.put("code",-1);
                    result.put("msg","该订单未发药,不能确认收药");
                    return  result;
                }
                //直接更改状态为已完成
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.finish.getValue());
                payLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.patientConfirm.getValue(), 1, 1);