Browse Source

代码修改

LAPTOP-KB9HII50\70708 1 year ago
parent
commit
210e441e51

+ 98 - 0
business/base-service/src/main/java/com/yihu/jw/common/CommonSmsService.java

@ -0,0 +1,98 @@
package com.yihu.jw.common;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
/**
 * Created by yeshijie on 2023/12/26.
 */
@Service
public class CommonSmsService {
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private RedisTemplate redisTemplate;
    //通用发送短信接口
    public MixEnvelop sendSms(String client_id,String phoneNum,Integer expire,String type,MixEnvelop mixEnvelop){
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("isNeedSMS","isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            store(client_id, phoneNum, captcha, expire,type);
            mixEnvelop.setMessage("验证码发送成功");
        }else {
            String captcha = getCodeNumber();
            System.out.println("=====================当前短信验证码============="+captcha+"=====================");
            System.out.println("发送174医院验证码开始");
            int result = 1;
//                result = zhongShanSMSService.ZhongShangSendSMS(phoneNum, "您好,您当前操作的验证码是:" + captcha + ",5分钟内有效。如非本人操作,请忽略");
            if (0 == result) {
                store(client_id, phoneNum, captcha, expire,type);
                mixEnvelop.setMessage("验证码发送成功");
            } else {
                mixEnvelop.setMessage("验证码发送失败");
                mixEnvelop.setStatus(500);
            }
        }
        return mixEnvelop;
    }
    public void store(String client_id, String username, String code, int expire,String type) {
        String key = client_id + ":" + username + "_"+type;
        redisTemplate.opsForValue().set(key, code);
        redisTemplate.expire(key, expire, TimeUnit.SECONDS);
        String intervalKey = key + ":" + code + "_interval";
        redisTemplate.opsForValue().set(intervalKey, 60);
        redisTemplate.expire(intervalKey, 60, TimeUnit.SECONDS);
    }
    public boolean isIntervalTimeout(String client_id, String username,String type) {
        String key = client_id + ":" + username + "_"+type;
        String code = (String) redisTemplate.opsForValue().get(key);
        if (null == code) {
            return true;
        }
        String intervalKey = key + ":" + code + "_interval";
        if (redisTemplate.opsForValue().get(intervalKey) != null) {
            return false;
        }
        return true;
    }
    //生成6位随机数
    public String getCodeNumber() {
        return (int) ((Math.random() * 9 + 1) * 100000) + "";
    }
    //验证验证码
    public boolean verification(String client_id, String username, String code,String type) {
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("isNeedSMS").orElse(null);
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
            if (code.equalsIgnoreCase(wlyyHospitalSysDictDO.getDictValue())){
                return true;
            }else {
                return false;
            }
        }
        if (StringUtils.isEmpty(code)) {
            return false;
        }
        String key = client_id + ":" + username + "_"+type;
        String _code = (String) redisTemplate.opsForValue().get(key);
        if (null == _code) {
            return false;
        }
        if (code.equalsIgnoreCase(_code)) {
            return true;
        }
        return false;
    }
}

+ 11 - 0
business/base-service/src/main/java/com/yihu/jw/common/dao/BaseSequenceDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.common.dao;
import com.yihu.jw.entity.base.common.BaseSequence;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2023/12/27.
 */
public interface BaseSequenceDao extends JpaRepository<BaseSequence, Long>, JpaSpecificationExecutor<BaseSequence> {
}

+ 12 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatItemDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.BaseNatItemDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2023/12/28.
 */
public interface BaseNatItemDao extends JpaRepository<BaseNatItemDO, String>, JpaSpecificationExecutor<BaseNatItemDO> {
}

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionExpressageDao.java

@ -19,6 +19,9 @@ public interface PrescriptionExpressageDao extends JpaRepository<WlyyPrescriptio
    @Query("from WlyyPrescriptionExpressageDO p where p.outpatientId=?1 order by p.createTime desc")
    List<WlyyPrescriptionExpressageDO> findByOutpatientId(String outpatientId);
    @Query("from WlyyPrescriptionExpressageDO p where p.relationCode=?1 and p.relationType=?2 order by p.createTime desc")
    List<WlyyPrescriptionExpressageDO> findByRelationCode(String relationCode,String relationType);
    @Modifying
    @Query("update WlyyPrescriptionExpressageDO p set p.mailno=?2  where p.id=?1")
    void updateMailNoById(String id, String mailno);

+ 84 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/NatService.java

@ -0,0 +1,84 @@
package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.BaseNatItemDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.BaseNatItemDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2023/12/28.
 */
@Service
public class NatService {
    @Autowired
    private BaseNatItemDao natItemDao;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    //新增或修改医技预约项目
    public BaseNatItemDO createOrUpd(String jsonData){
        BaseNatItemDO natItemDO = JSONObject.parseObject(jsonData,BaseNatItemDO.class);
        if(StringUtils.isNotBlank(natItemDO.getId())){
            //修改
            BaseNatItemDO natItemOld = natItemDao.findById(natItemDO.getId()).orElse(null);
            natItemDO.setCreateTime(natItemOld.getCreateTime());
            natItemDO = natItemDao.save(natItemDO);
        }else {
            //新增
            natItemDO.setCreateTime(new Date());
            natItemDO = natItemDao.save(natItemDO);
        }
        return natItemDO;
    }
    //获取医技预约项目详情
    public BaseNatItemDO findDetailById(String id){
        BaseNatItemDO natItemDO = natItemDao.findById(id).orElse(null);
        if(natItemDO!=null){
            WlyyHospitalSysDictDO dictDO = wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("isEffect",natItemDO.getStatus());
        }
        return natItemDO;
    }
    //修改状态
    public BaseNatItemDO updStatus(String id,String status){
        BaseNatItemDO natItemDO = natItemDao.findById(id).orElse(null);
        natItemDO.setStatus(status);
        return natItemDO;
    }
    //医技预约项目分页
    public PageEnvelop natItemPage(String name,String status,String suitableCrowd,Integer page,Integer size){
        String sql = "select * ";
        String countSql = "select count(*) ";
        String filter = " from base_nat_item where 1=1 ";
        if(StringUtils.isNotBlank(name)){
            filter += " and name like '%"+name+"%'";
        }
        if(StringUtils.isNotBlank(status)){
            filter += " and status = '"+status+"'";
        }
        if(StringUtils.isNotBlank(suitableCrowd)){
            filter += " and suitable_crowd like '%"+suitableCrowd+"%'";
        }
        String orderBy = " order by create_time desc limit "+(page-1)*size+","+size;
        List<BaseNatItemDO> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(BaseNatItemDO.class));
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
}

+ 65 - 8
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionExpressageService.java

@ -3,11 +3,13 @@ package com.yihu.jw.hospital.prescription.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.prescription.*;
import com.yihu.jw.hospital.prescription.dao.*;
import com.yihu.jw.hospital.prescription.service.entrance.util.SFUtils;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BaseMedicalRecordCopyingApplyDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.sfutils.HttpClientUtils;
@ -90,6 +92,8 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    PrescriptionService prescriptionService;
    @Autowired
    private BaseMedicalRecordCopyingApplyDao medicalRecordCopyingApplyDao;
    private PrescriptionExpressageService(){}
@ -99,6 +103,9 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
        this.sf_check_word = sf_check_word;
    }
    public List<WlyyPrescriptionExpressageDO> findByRelationCode(String relationCode,String relationType){
        return prescriptionExpressageDao.findByRelationCode(relationCode, relationType);
    }
    /**
     * 组装请求参数,发送请求
@ -200,6 +207,53 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
    }
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
     * @return
     * @throws Exception
     */
    public WlyyPrescriptionExpressageDO postSFOrderServiceCommon(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        String orgId = "";
        String patientId = "";
        String depositumInfo = "";
        if("1".equals(sfexpress_obj.getRelationType())){
            BaseMedicalRecordCopyingApplyDO applyDO = medicalRecordCopyingApplyDao.findById(sfexpress_obj.getRelationCode()).orElse(null);
            patientId = applyDO.getPatientId();
            orgId = applyDO.getHospital();
            depositumInfo = "病例";
        }
        BaseOrgDO hospital = baseOrgDao.findByCode(orgId);
        BasePatientDO basePatientDO = basePatientDao.findById(patientId).orElse(null);
        JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO,depositumInfo);
        String re = this.SFExpressPostV2(params);
        //xml验证
        logger.info("顺丰快递下订单:re"+re);
        verificationResponV2(re);
        JSONObject respone = JSONObject.parseObject(re);
        String mailno = "";//顺丰运单号
        String bspOrderNo = "";//顺丰业务号
        JSONArray successResult =  respone.getJSONObject("result").getJSONArray("successResult");
        if(!successResult.isEmpty()){
            JSONObject object = successResult.getJSONObject(0);
            mailno = object.getString("mailNo");
            bspOrderNo = object.getString("bspOrderNo");
        }
        logger.info("顺丰快递下订单:mailno"+mailno);
        sfexpress_obj.setMailno(mailno);
        sfexpress_obj.setBspOrderNo(bspOrderNo);
        return sfexpress_obj;
    }
    /**
     * 向顺丰快递下订单
     * @param sfexpress_obj
@ -213,7 +267,7 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient()).orElse(null);
        JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO);
        JSONObject params = SFUtils.postSFOrderServiceV2(sfexpress_obj,hospital,basePatientDO,"药品");
        String re = this.SFExpressPostV2(params);
        //xml验证
        logger.info("顺丰快递下订单:re"+re);
@ -280,11 +334,6 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
     * @throws Exception
     */
    public String postOrderConfirmService(WlyyPrescriptionExpressageDO sfexpress_obj) throws Exception {
        //获取医生所处的医院详细地址,作为寄件人地址
        WlyyOutpatientDO outpatientDO = outpatientDao.findById(sfexpress_obj.getOutpatientId()).orElse(null);
        BaseOrgDO hospital = baseOrgDao.findByCode(outpatientDO.getHospital());
        String xml = SFUtils.SFOrderConfirmXml(sf_code,sfexpress_obj.getId(),sfexpress_obj.getMailno(),2);
        logger.info("顺丰快递取消订单请求:xml"+xml);
        String re = this.SFExpressPost(xml);
@ -747,7 +796,9 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
            //如果成功获取到快递单号,则保存处方物流记录,保存配送日志
            //修改处方状态为配送中
            prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
            if(StringUtils.isNotBlank(sfexpress_obj.getOutpatientId())){
                prescriptionDao.updateStatus(sfexpress_obj.getOutpatientId(),65);
            }
            //保存处方物流记录
            prescriptionExpressageDao.save(sfexpress_obj);
@ -755,6 +806,8 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
            //保存配送日志
            WlyyOutpatientExpressageLogDO outpatiExpressLog = new WlyyOutpatientExpressageLogDO();
            outpatiExpressLog.setOutpatientId(sfexpress_obj.getOutpatientId());
            outpatiExpressLog.setRelationCode(sfexpress_obj.getRelationCode());
            outpatiExpressLog.setRelationType(sfexpress_obj.getRelationType());
            outpatiExpressLog.setId(UUID.randomUUID().toString());
            outpatiExpressLog.setType(8);
            outpatiExpressLog.setCreateTime(new Date());
@ -846,13 +899,17 @@ public class PrescriptionExpressageService extends BaseJpaService<WlyyPrescripti
    public void updatePrescriptionExpressage(WlyyPrescriptionExpressageDO prescriptionExpressage) throws Exception {
        //修改门诊处方状态为配送配送中
        prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
        if(StringUtils.isNotBlank(prescriptionExpressage.getOutpatientId())){
            prescriptionDao.updateStatus(prescriptionExpressage.getId(), 32);
        }
        //保存处方物流记录
        prescriptionExpressageDao.save(prescriptionExpressage);
        //保存门诊配送日志
        WlyyOutpatientExpressageLogDO prescriptionLog = new WlyyOutpatientExpressageLogDO();
        prescriptionLog.setRelationCode(prescriptionExpressage.getRelationCode());
        prescriptionLog.setRelationType(prescriptionExpressage.getRelationType());
        prescriptionLog.setOutpatientId(prescriptionExpressage.getOutpatientId());
        // 类型: -1 失效 1HIS对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成 8物流对接
        prescriptionLog.setType(8);

+ 20 - 18
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/SFUtils.java

@ -13,7 +13,6 @@ import org.apache.commons.lang.StringUtils;
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.stereotype.Component;
import org.springframework.util.CollectionUtils;
import sun.misc.BASE64Encoder;
@ -21,7 +20,6 @@ import sun.misc.BASE64Encoder;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -311,7 +309,7 @@ public class SFUtils {
     * @param hospital
     * @return
     */
    public JSONObject postSFOrderServiceV2(WlyyPrescriptionExpressageDO sfexpress_obj, BaseOrgDO hospital,  BasePatientDO basePatientDO) {
    public JSONObject postSFOrderServiceV2(WlyyPrescriptionExpressageDO sfexpress_obj, BaseOrgDO hospital,  BasePatientDO basePatientDO,String depositumInfo) {
    
        JSONObject params = new JSONObject();//请求参数
        JSONArray orders = new JSONArray();//订单集合
@ -338,27 +336,31 @@ public class SFUtils {
        order.put("destAddress",sfexpress_obj.getStreetName()+sfexpress_obj.getAddress());
        
        order.put("packagesNo",1);
        order.put("depositumInfo","药品");
        order.put("depositumInfo",depositumInfo);
        order.put("productCode","OTHER");
        
        //根据快递物流获取门诊信息,根据门诊信息获取处方订单的药品详情
        List<WlyyPrescriptionDO> prescriptionDOList = prescriptionService.findByField("outpatientId",sfexpress_obj.getOutpatientId());
        
        Set<String> prescriptionIdSet = new HashSet<>();
        prescriptionDOList.forEach(
                onePrescription -> {
                    prescriptionIdSet.add(onePrescription.getId());
                }
        );
        List<WlyyPrescriptionInfoDO> prescriptionInfolist = prescriptionInfoDao.queryAllByPrescriptionIdInAndDel(prescriptionIdSet,1);
        
        if(!prescriptionInfolist.isEmpty()){
            order.put("depositumNo",prescriptionInfolist.size());
        }else{
        if(StringUtils.isNotBlank(sfexpress_obj.getOutpatientId())){
            List<WlyyPrescriptionDO> prescriptionDOList = prescriptionService.findByField("outpatientId",sfexpress_obj.getOutpatientId());
            Set<String> prescriptionIdSet = new HashSet<>();
            prescriptionDOList.forEach(
                    onePrescription -> {
                        prescriptionIdSet.add(onePrescription.getId());
                    }
            );
            List<WlyyPrescriptionInfoDO> prescriptionInfolist = prescriptionInfoDao.queryAllByPrescriptionIdInAndDel(prescriptionIdSet,1);
            if(!prescriptionInfolist.isEmpty()){
                order.put("depositumNo",prescriptionInfolist.size());
            }else{
                order.put("depositumNo",1);
            }
        }else {
            order.put("depositumNo",1);
        }
        
        orders.add(order);
        params.put("orderThirds",orders);
        return params;

+ 155 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/record/service/HospitalPatientInpatientRecordService.java

@ -1,11 +1,33 @@
package com.yihu.jw.hospital.record.service;
import com.yihu.jw.common.dao.BaseSequenceDao;
import com.yihu.jw.entity.base.common.BaseSequence;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyTypeDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionExpressageDO;
import com.yihu.jw.entity.hospital.record.HospitalPatientInpatientRecordDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionExpressageDao;
import com.yihu.jw.hospital.record.dao.HospitalPatientInpatientRecordDao;
import com.yihu.jw.mysql.query.BaseJpaService;
import com.yihu.jw.patient.dao.BaseMedicalRecordCopyingApplyDao;
import com.yihu.jw.patient.dao.BaseMedicalRecordCopyingApplyTypeDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by yeshijie on 2022/11/28.
@ -15,6 +37,139 @@ public class HospitalPatientInpatientRecordService extends BaseJpaService<Hospit
    @Resource
    private HospitalPatientInpatientRecordDao hospitalPatientInpatientRecordDao;
    @Resource
    private BaseMedicalRecordCopyingApplyDao applyDao;
    @Resource
    private BaseMedicalRecordCopyingApplyTypeDao applyTypeDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private BaseSequenceDao baseSequenceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    //取消复印
    public void cancelApply(String id) throws Exception{
        BaseMedicalRecordCopyingApplyDO applyDO = applyDao.findById(id).orElse(null);
        if(!"0".equals(applyDO.getStatus())){
            throw new ServiceException("待审核的申请才能取消");
        }
        applyDO.setStatus("3");
        applyDao.save(applyDO);
    }
    //改为自取
    @Transactional
    public void changePickupWay(String id) throws Exception{
        BaseMedicalRecordCopyingApplyDO applyDO = applyDao.findById(id).orElse(null);
        if(!"0".equals(applyDO.getStatus())){
            throw new ServiceException("待审核的申请才能更改");
        }
        if("1".equals(applyDO.getPickupWay())){
            throw new ServiceException("已是自取,无需更改");
        }
        List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByRelationCode(id,"1");
        expressageDOS.stream().forEach(one->{
            one.setOneselfPickupFlg(1);
        });
        prescriptionExpressageDao.saveAll(expressageDOS);
        applyDao.save(applyDO);
    }
    //申请详情
    public BaseMedicalRecordCopyingApplyDO applyDetail(String id){
        BaseMedicalRecordCopyingApplyDO applyDO = applyDao.findById(id).orElse(null);
        List<BaseMedicalRecordCopyingApplyTypeDO> applyTypeDOList = applyTypeDao.findByApplyId(id);
        applyDO.setApplyTypeList(applyTypeDOList);
        List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByRelationCode(id,"1");
        if(expressageDOS.size()>0){
            applyDO.setExpressageDO(expressageDOS.get(0));
        }
        WlyyHospitalSysDictDO copy_apply_status =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("copy_apply_status",applyDO.getStatus());
        WlyyHospitalSysDictDO copy_use_to =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("copy_use_to",applyDO.getUseTo());
        WlyyHospitalSysDictDO patient_relation =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("patient_relation",applyDO.getPatientRelation());
        WlyyHospitalSysDictDO EXPRESS_STATUS =  wlyyHospitalSysDictDao.findOneByDictNameAndDictCode("EXPRESS_STATUS",applyDO.getPickupWay());
        applyDO.setStatusName(copy_apply_status.getDictValue());
        applyDO.setUseToName(copy_use_to.getDictValue());
        applyDO.setPatientRelationName(patient_relation.getDictValue());
        applyDO.setPickupWayName(EXPRESS_STATUS.getDictValue());
        return applyDO;
    }
    //复印病案申请列表
    public PageEnvelop applyPage(String patientId,Integer page,Integer size,String name,String status,String startTime,String endTime){
        String sql = "select * ";
        String countSql = "select count(*) ";
        String filter = " from base_medical_record_copying_apply where 1=1  ";
        if(StringUtils.isNotBlank(patientId)){
            filter += " and patient_id='"+patientId+"' ";
        }
        if(StringUtils.isNotBlank(name)){
            filter += " and (patient_name like '%"+name+"%' or apply_name like '%"+name+"%')";
        }
        if(StringUtils.isNotBlank(status)){
            filter += " and status='"+status+"' ";
        }
        if(StringUtils.isNotBlank(startTime)){
            filter += " and apply_time>='"+startTime+"' ";
        }
        if(StringUtils.isNotBlank(endTime)){
            filter += " and apply_time<='"+endTime+"' ";
        }
        String orderBy = " order by apply_time desc limit "+(page-1)*size+","+size;
        List<WlyyHospitalSysDictDO> dictDOList =  wlyyHospitalSysDictDao.findByDictName("copy_apply_status");
        Map<String,String> applyStatusMap = dictDOList.stream().collect(Collectors.toMap(WlyyHospitalSysDictDO::getDictCode,WlyyHospitalSysDictDO::getDictValue));
        List<BaseMedicalRecordCopyingApplyDO> list = jdbcTemplate.query(sql+filter+orderBy,new BeanPropertyRowMapper<>(BaseMedicalRecordCopyingApplyDO.class));
        list.stream().forEach(one->{
            one.setStatusName(applyStatusMap.get(one.getStatus()));
        });
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //生成不重复的单号
    public synchronized String getApplyNo(){
        BaseSequence seq = new BaseSequence();
        baseSequenceDao.save(seq);
        Long id = jdbcTemplate.queryForObject("select max(id) from base_sequence",Long.class);
        return "DM"+String.format("%08d", id);
    }
    //病案复印申请
    public void apply(BaseMedicalRecordCopyingApplyDO applyDO){
        List<BaseMedicalRecordCopyingApplyTypeDO> applyTypeList = applyDO.getApplyTypeList();
        WlyyPrescriptionExpressageDO expressageDO = applyDO.getExpressageDO();
        applyDO.setApplyNo(getApplyNo());
        applyDO.setApplyTime(DateUtil.getStringDate());
        applyDO.setStatus("0");
        applyDO.setPayStatus("0");
        applyDO.setTotalNum(10);//先写死-需要对接
        String copyNum = applyDO.getCopyingNum();
        //住院记录信息
        applyDO.setDeptName("骨科一病区");
        applyDO.setHospitalNum("1");
        applyDO.setOutpatientTime("2023-12-27 08:58:00");
        applyDO = applyDao.save(applyDO);
        String applyId = applyDO.getId();
        expressageDO.setRelationCode(applyId);
        expressageDO.setRelationType("1");
        expressageDO.setCreateTime(new Date());
        expressageDO.setDel(1);
        prescriptionExpressageDao.save(expressageDO);
        applyTypeList.stream().forEach(one->{
            one.setApplyId(applyId);
            one.setCopyingNum(copyNum);
        });
        applyTypeDao.saveAll(applyTypeList);
    }
    /**
     * 查找最近一次住院记录

+ 12 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BaseMedicalRecordCopyingApplyDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by yeshijie on 2023/12/26.
 */
public interface BaseMedicalRecordCopyingApplyDao extends JpaRepository<BaseMedicalRecordCopyingApplyDO, String>,
        JpaSpecificationExecutor<BaseMedicalRecordCopyingApplyDO> {
}

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BaseMedicalRecordCopyingApplyTypeDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.base.patient.BaseMedicalRecordCopyingApplyTypeDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
 * Created by yeshijie on 2023/12/26.
 */
public interface BaseMedicalRecordCopyingApplyTypeDao extends JpaRepository<BaseMedicalRecordCopyingApplyTypeDO, String>,
        JpaSpecificationExecutor<BaseMedicalRecordCopyingApplyTypeDO> {
    @Query("select a from BaseMedicalRecordCopyingApplyTypeDO a where a.applyId=?1")
    List<BaseMedicalRecordCopyingApplyTypeDO> findByApplyId(String applyId);
}