Trick 5 anos atrás
pai
commit
5b5a800c85

+ 87 - 29
business/base-service/src/main/java/com/yihu/jw/doctor/service/excel/DoctorWorkTimeExcelReader.java

@ -1,6 +1,8 @@
package com.yihu.jw.doctor.service.excel;
import com.yihu.jw.util.excel.poi.AExcelReader;
import com.yihu.jw.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.stereotype.Component;
@ -56,7 +58,7 @@ public class DoctorWorkTimeExcelReader extends AExcelReader {
                            Integer day = (sw+1)/3;
                            excelDO.setDateOfMonth(day+"");
                            excelDO.setType("1");
                            list.add(excelDO);
                        }
@ -67,8 +69,26 @@ public class DoctorWorkTimeExcelReader extends AExcelReader {
                    int xw = 3;
                    while (xw<=93){
                        //
                        System.out.println("col:"+xw);
                        System.out.println("day:"+(xw)/3);
//                        System.out.println("col:"+xw);
//                        System.out.println("day:"+(xw)/3);
                        String workflag =  replaceBlank(getCellCont(sheet,i,xw));
                        //判断是否有排班
                        if("1".equals(workflag)){
                            //如果有排班,生成当天排班记录
                            DoctorWorkTimeExcelDO excelDO = new DoctorWorkTimeExcelDO();
                            excelDO.setName(name);
                            excelDO.setIdCard(idCard);
                            //标记行列
                            excelDO.setRow(i);
                            excelDO.setCol(xw);
                            Integer day = (xw+1)/3;
                            excelDO.setDateOfMonth(day+"");
                            excelDO.setType("2");
                            list.add(excelDO);
                        }
                        xw = xw+3;
                    }
@ -76,12 +96,36 @@ public class DoctorWorkTimeExcelReader extends AExcelReader {
                    int ws = 4;
                    while (ws<=94){
                        //
                        System.out.println("col:"+ws);
                        System.out.println("day:"+(ws-1)/3);
                        ws = ws+3;
                    }
//                        System.out.println("col:"+ws);
//                        System.out.println("day:"+(ws-1)/3);
                        String workflag =  replaceBlank(getCellCont(sheet,i,ws));
                        //判断是否有排班
                        if("1".equals(workflag)){
                            //如果有排班,生成当天排班记录
                            DoctorWorkTimeExcelDO excelDO = new DoctorWorkTimeExcelDO();
                            excelDO.setName(name);
                            excelDO.setIdCard(idCard);
                            //标记行列
                            excelDO.setRow(i);
                            excelDO.setCol(ws);
                            Integer day = (ws+1)/3;
                            excelDO.setDateOfMonth(day+"");
                            excelDO.setType("3");
                            list.add(excelDO);
                        }
                        ws = ws+3;
                    }
                    //设置本月排班
                    main.setWorkTime(list);
                    String rs = checkMain(main);
                    if("1".equals(rs)){
                        getCorrectLs().add(main);
                    }else {
                        getErrorLs().add(main);
                    }
                }
            }
@ -95,29 +139,43 @@ public class DoctorWorkTimeExcelReader extends AExcelReader {
        }
    }
    public static void main(String ag[]){
        int sw = 2;
        while (sw<=92){
            //
            System.out.println("col:"+sw);
            System.out.println("day:"+(sw+1)/3);
            sw = sw+3;
    public String checkMain(DoctorWorkTimeMainExcelDO main){
        String idCard = main.getIdCard();
        String name = main.getName();
        if(StringUtils.isBlank(idCard)){
            main.setErrorMes("第"+(main.getRow()+1)+"身份证号为空!\n");
            return "0";
        }
        int xw = 3;
        while (xw<=93){
            //
            System.out.println("col:"+xw);
            System.out.println("day:"+(xw)/3);
            xw = xw+3;
        }
        int ws = 4;
        while (ws<=94){
            //
            System.out.println("col:"+ws);
            System.out.println("day:"+(ws-1)/3);
            ws = ws+3;
        if(StringUtils.isBlank(name)){
            main.setErrorMes("第"+(main.getRow()+1)+"姓名为空!\n");
            return "0";
        }
        return "1";
    }
//    public static void main(String ag[]){
//        int sw = 2;
//        while (sw<=92){
//            //
//            System.out.println("col:"+sw);
//            System.out.println("day:"+(sw+1)/3);
//            sw = sw+3;
//        }
//
//        int xw = 3;
//        while (xw<=93){
//            //
//            System.out.println("col:"+xw);
//            System.out.println("day:"+(xw)/3);
//            xw = xw+3;
//        }
//
//        int ws = 4;
//        while (ws<=94){
//            //
//            System.out.println("col:"+ws);
//            System.out.println("day:"+(ws-1)/3);
//            ws = ws+3;
//        }
//    }
}

+ 0 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/doctor/dao/DoctorWorkTimeDao.java

@ -22,6 +22,4 @@ public interface DoctorWorkTimeDao extends PagingAndSortingRepository<WlyyDoctor
    @Query("from WlyyDoctorWorkTimeDO a where a.doctor = ?1 and a.startTime >= ?2 and a.startTime <= ?3 order by a.startTime asc")
    List<WlyyDoctorWorkTimeDO> findDoctorWorkTimeByTime(String doctor, Date startDate,Date endDate);
    @Query("from WlyyDoctorWorkTimeDO a where a.doctor = ?1 and a.startTime <= ?2 and a.endDate >= ?2")
    List<WlyyDoctorWorkTimeDO> checkDoctorWork(String doctor, Date Date);
}

+ 107 - 7
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/WorkTimeService.java

@ -1,18 +1,30 @@
package com.yihu.jw.hospital.prescription.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.service.excel.DoctorWorkTimeExcelDO;
import com.yihu.jw.doctor.service.excel.DoctorWorkTimeMainExcelDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
import com.yihu.jw.entity.hospital.prescription.WlyyHospitalWorkRuleDO;
import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao;
import com.yihu.jw.hospital.prescription.dao.WlyyHospitalWorkRuleDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2020/3/24.
@ -32,6 +44,18 @@ public class WorkTimeService {
    @Autowired
    private DoctorWorkTimeDao doctorWorkTimeDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BaseDoctorHospitalDao hospitalDao;
    @Autowired
    private BaseOrgDao baseOrgDao;
    /**
     * 保存排班规则
     * @param workTimeRuleJson
@ -67,17 +91,90 @@ public class WorkTimeService {
     * @return
     */
    public Boolean checkDoctorWork(String doctor){
        List<WlyyDoctorWorkTimeDO> list = doctorWorkTimeDao.checkDoctorWork(doctor,new Date());
        String sql = "SELECT " +
                " t.id " +
                " FROM " +
                " wlyy_doctor_work_time t " +
                " WHERE " +
                " t.doctor =:doctor " +
                " AND t.start_time <=:startTime " +
                " ANd t.end_time >=:endTime";
        Map<String,Object> params = new HashedMap();
        params.put("doctor",doctor);
        Date date = new Date();
        params.put("startTime",date);
        params.put("endTime",date);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql,params);
        if(list!=null&&list.size()>0){
            return true;
        }
        return false;
    }
    public String saveWorkInfo(List<DoctorWorkTimeMainExcelDO> list,String date,String hospital){
        Map<String,Object> rs = new HashedMap();
        List<DoctorWorkTimeMainExcelDO> error =new ArrayList<>();
        List<DoctorWorkTimeMainExcelDO> succ = new ArrayList<>();
        if(list!=null&&list.size()>0){
            for(DoctorWorkTimeMainExcelDO excelDO:list){
                List<BaseDoctorDO> doctorDOs = baseDoctorDao.findByIdcard(excelDO.getIdCard());
                if(doctorDOs==null||doctorDOs.size()==0){
                    excelDO.setErrorMes("第"+(excelDO.getRow()+1)+"行,医生身份证号不存在!");
                    error.add(excelDO);
                    continue;
                }
                BaseDoctorDO doctorDO = doctorDOs.get(0);
                BaseOrgDO orgDO = baseOrgDao.findByCode(hospital);
                WlyyHospitalWorkRuleDO ruleDO = findWorkTimeRule(hospital);
                //判断是否为本月
                String dm = DateUtil.dateToStr(new Date(),"yyyy-MM");
                if(dm.equals(date)){
                    //本月
                }else{
                    //判断日期是否大于本月
                    Date now = DateUtil.strToDate(dm,"yyyy-MM");
                    Date work = DateUtil.strToDate(date,"yyyy-MM");
                    if(now.before(work)){
                        //
                        //导入的月份大于当前月份,删除导入月份所有历史排班记录
                        List<WlyyDoctorWorkTimeDO> timeDOs = doctorWorkTimeDao.findDoctorWorkTimeByMonth(doctorDO.getId(),"%"+date+"%");
                        if(timeDOs!=null&&timeDOs.size()>0){
                            doctorWorkTimeDao.delete(timeDOs);
                        }
                        List<DoctorWorkTimeExcelDO> worktimes = excelDO.getWorkTime();
                        if(worktimes!=null&&worktimes.size()>0){
                            for(DoctorWorkTimeExcelDO worktime:worktimes){
                                WlyyDoctorWorkTimeDO workTimeDO = new WlyyDoctorWorkTimeDO();
                                workTimeDO.setDoctor(doctorDO.getId());
                                //上午
                                if("1".equals(worktime.getType())){
                                }
//                                workTimeDO.setSourceNumber(ruleDO.);
                            }
                        }
                    }
                }
            }
        }
        return null;
    }
    public static void main(String ag[]){
//    public static void main(String ag[]){
//
//        Date start = DateUtil.stringToDate("2020-03-24 08:00:00","yyyy-MM-dd HH:mm:ss");
//
//        Date end = DateUtil.stringToDate("2020-03-24 12:00:00","yyyy-MM-dd HH:mm:ss");
@ -87,8 +184,11 @@ public class WorkTimeService {
//        Long jg = total/100;
//
//        start.setTime(start.getTime()+jg);
//
//        System.out.println(DateUtil.dateToStr(start,"yyyy-MM-dd HH:mm:ss"));
//    }
        Date now = DateUtil.strToDate("2020-04","yyyy-MM");
        Date work = DateUtil.strToDate("2020-04","yyyy-MM");
        System.out.println(now.before(work));
    }
}

+ 11 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -37,14 +37,16 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
/**
 * Created by Trick on 2019/5/16.
 * Created by Trick on 2019/5/16
 */
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Prescription.PREFIX)
@ -1026,5 +1028,12 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                      @RequestParam(value = "doctor",required = true)String doctor) throws Exception{
        return success(workTimeService.checkDoctorWork(doctor));
    }
//    @PostMapping(value= BaseHospitalRequestMapping.Prescription.checkDoctorWork)
//    @ApiOperation(value = "判断医生是否在班")
//    public Envelop importData(
//            @ApiParam(name = "file", value = "文件", required = true)
//            @RequestPart(value = "file") MultipartFile file,
//            HttpServletRequest request)throws Exception{
//
//    }
}