Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/ScrmStores' into ScrmStores

yjwang 1 nedēļu atpakaļ
vecāks
revīzija
066d6f1663

+ 6 - 0
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -507,6 +507,12 @@ public class Task {
         boolean isAudit = (boolean)config.get("isAutoPrescribeAudit");
         if (isAudit){
             fsPrescribeService.auditPrescribe();
+
+            try {
+                fsPrescribeService.auditPrescribe580();
+            }catch (Exception e){
+                log.error("审核580处方异常",e);
+            }
         }
     }
 

+ 77 - 4
fs-doctor-app/src/main/java/com/fs/app/controller/PrescribeController.java

@@ -2,7 +2,12 @@ package com.fs.app.controller;
 
 
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fs.app.annotation.Login;
 import com.fs.common.core.domain.R;
 import com.fs.common.utils.StringUtils;
@@ -13,7 +18,15 @@ import com.fs.his.param.*;
 import com.fs.his.service.*;
 import com.fs.his.vo.FsDoctorPrescribeListDVO;
 import com.fs.his.vo.FsPrescribeListDVO;
+import com.fs.hisStore.config.MedicalMallConfig;
+import com.fs.hospital580.entity.Hospital580PrescriptionMedicineScrmEntity;
+import com.fs.hospital580.entity.Hospital580PrescriptionScrmEntity;
+import com.fs.hospital580.service.Hospital580PrescriptionMedicineScrmService;
+import com.fs.hospital580.service.Hospital580PrescriptionScrmService;
+import com.fs.hospital580.vo.res.PrescriptionListRes;
 import com.fs.im.service.IImService;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.service.ISysConfigService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
@@ -26,10 +39,9 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
+import java.time.ZoneId;
+import java.util.*;
+import java.util.stream.Collectors;
 
 
 @Api("处方接口")
@@ -56,6 +68,13 @@ public class PrescribeController extends  AppBaseController {
     @Autowired
     private IImService imService;
 
+    @Autowired
+    private ISysConfigService configService;
+
+    @Autowired
+    private Hospital580PrescriptionScrmService orderScrmService;
+    @Autowired
+    private Hospital580PrescriptionMedicineScrmService medicineScrmService;
     @Login
     @GetMapping("/getDoctorPrescribeList")
     public R getDoctorPrescribeList(FsDoctorPrescribeListDParam param)
@@ -72,6 +91,50 @@ public class PrescribeController extends  AppBaseController {
     @GetMapping("/getPrescribeList")
     public R getPrescribeList(FsPrescribeListDParam param)
     {
+        if (getPrescribeType()){
+            // 问诊列表
+            IPage<Hospital580PrescriptionScrmEntity> page = orderScrmService.page(
+                    new Page<Hospital580PrescriptionScrmEntity>(param.getPageNum(), param.getPageSize())
+                    , new LambdaQueryWrapper<Hospital580PrescriptionScrmEntity>()
+                            .eq(Hospital580PrescriptionScrmEntity::getDoctorId,param.getDoctorId())
+                            .orderByDesc(Hospital580PrescriptionScrmEntity::getCreateTime)
+            );
+            List<FsPrescribeListDVO> list = page.getRecords().stream()
+                    .map(order -> {
+                        FsPrescribeListDVO vo = new FsPrescribeListDVO();
+                        vo.setPrescribeId(order.getPreId());
+                        vo.setPrescribeType(Integer.valueOf(order.getServiceType()));
+                        vo.setPrescribeCode(order.getSerialNo());
+                        vo.setPatientAge(order.getUserFamilyAge().toString());
+                        vo.setPatientName(order.getUserFamilyName());
+                        vo.setPatientGender(order.getUserFamilyGender().toString());
+                        vo.setPrescribeImgUrl(order.getDstFilePath());
+                        vo.setAuditReason(order.getReason());
+                        vo.setDiagnose(order.getTags());
+                        vo.setAuditTime(Date.from(order.getAuditTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant()));
+                        vo.setCreateTime(Date.from(order.getCreateTime().atZone(ZoneId.of("Asia/Shanghai")).toInstant()));
+
+                        List<Hospital580PrescriptionMedicineScrmEntity> list1 = medicineScrmService.list(new LambdaQueryWrapper<Hospital580PrescriptionMedicineScrmEntity>()
+                                .eq(Hospital580PrescriptionMedicineScrmEntity::getPreId, order.getPreId()));
+                        vo.setDrugs(list1.stream()
+                                .map(medicine -> {
+                                    FsPrescribeDrug drug = new FsPrescribeDrug();
+                                    drug.setDrugName(medicine.getDrugName());
+                                    drug.setDrugNum(Long.valueOf(medicine.getAmount()));
+                                    drug.setUsageMethod(medicine.getInstructions());
+                                    drug.setDrugSpec(medicine.getSpec());
+                                    return drug;
+                                })
+                                .collect(Collectors.toList()));
+                        return vo;
+                    })
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toList());
+            PageInfo<FsPrescribeListDVO> listPageInfo=new PageInfo<>(list);
+            return R.ok().put("data",listPageInfo);
+        }
+
+
         PageHelper.startPage(param.getPageNum(), param.getPageSize());
         param.setDoctorId(Long.parseLong(getDoctorId()));
         param.setDoctorDrugId(Long.parseLong(getDoctorId()));
@@ -80,6 +143,16 @@ public class PrescribeController extends  AppBaseController {
         return R.ok().put("data",listPageInfo);
     }
 
+    private Boolean getPrescribeType() {
+        try {
+            SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
+            MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
+            return medicalMallConfig.getPrescribeType().equals(1);
+        }catch (Exception e){
+            return false;
+        }
+    }
+
 
     @Login
     @GetMapping("/getPrescribeById")

+ 3 - 0
fs-service/src/main/java/com/fs/his/service/IFsPrescribeService.java

@@ -82,6 +82,7 @@ public interface IFsPrescribeService
     void auditPrescribe();
 
     R audit(FsPrescribeAuditParam param);
+    R audit580(FsPrescribeAuditParam param);
 
      String PrescribeImg(Long prescribeId);
 
@@ -104,4 +105,6 @@ public interface IFsPrescribeService
     List<Long> selectFsPrescribeByPrescribeIdByOrderType();
 
     void PrescribeStoreImg(Long id);
+
+    void auditPrescribe580();
 }

+ 61 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.his.service.impl;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
@@ -23,6 +24,8 @@ import com.fs.his.service.IFsStoreOrderService;
 import com.fs.his.utils.ConfigUtil;
 import com.fs.his.utils.qrcode.QRCodeUtils;
 import com.fs.his.vo.*;
+import com.fs.hospital580.entity.Hospital580PrescriptionScrmEntity;
+import com.fs.hospital580.service.Hospital580PrescriptionScrmService;
 import com.fs.im.dto.MsgCustomDTO;
 import com.fs.im.dto.MsgDTO;
 import com.fs.im.dto.MsgDataDTO;
@@ -45,6 +48,7 @@ import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
 import java.util.*;
 import java.util.List;
 
@@ -80,6 +84,10 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     ConfigUtil configUtil;
     @Autowired
     FsExportTaskMapper fsExportTaskMapper;
+
+    @Autowired
+    private Hospital580PrescriptionScrmService orderScrmService;
+
     /**
      * 查询处方
      *
@@ -778,6 +786,59 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
 
     }
 
+    @Override
+    public void auditPrescribe580() {
+        List<Hospital580PrescriptionScrmEntity> prescriptionScrmEntities = orderScrmService.list(new LambdaQueryWrapper<Hospital580PrescriptionScrmEntity>()
+                .eq(Hospital580PrescriptionScrmEntity::getPrescriptionStatus, 1)
+                .eq(Hospital580PrescriptionScrmEntity::getAuditStatus, 1));
+        for (Hospital580PrescriptionScrmEntity fsPrescribe : prescriptionScrmEntities) {
+            // 西药
+            Long id = doctorMapper.selectFsDoctorType2Ids(1);
+            FsPrescribeAuditParam param=new FsPrescribeAuditParam();
+            param.setDoctorId(id);
+            param.setPrescribeId(fsPrescribe.getPreId());
+            param.setStatus(1);
+            audit580(param);
+        }
+    }
+
+    @Override
+    @Transactional
+    public R audit580(FsPrescribeAuditParam param){
+        Hospital580PrescriptionScrmEntity prescribe=orderScrmService.getById(param.getPrescribeId());
+        prescribe.setAuditStatus(param.getStatus().equals(1)?2:3);
+        prescribe.setAuditTime(LocalDateTime.now());
+        FsDoctor doctor=doctorService.selectFsDoctorByDoctorId(param.getDoctorId());
+        prescribe.setAuditApothecaryName(doctor.getDoctorName());
+        prescribe.setReason(param.getAuditReason());
+        prescribe.updateById();
+        if(param.getStatus().equals(1)){
+            //发送信息
+            String orderId= String.valueOf(prescribe.getStoreOrderId());
+            MsgDTO msgDTO=new MsgDTO();
+            MsgCustomDTO customDTO=new MsgCustomDTO();
+            customDTO.setType("inquiry");
+            customDTO.setOrderId(orderId);
+            customDTO.setImType(1);
+            customDTO.setOrderType(prescribe.getServiceType().equals(0)?1:2);
+            msgDTO.setCloudCustomData(JSONUtil.toJsonStr(customDTO));
+            msgDTO.setFrom_Account("D-"+prescribe.getDoctorId());
+            msgDTO.setTo_Account("U-"+prescribe.getUserId());
+            List<MsgDataDTO> msgs=new ArrayList<>();
+            MsgDataDTO msg=new MsgDataDTO();
+            String ext= JSONUtil.toJsonStr(prescribe);
+
+            msg.setMsgContent(new MsgDataFormatDTO("prescribe",ext,orderId));
+            msg.setMsgType("TIMCustomElem");//TIMCustomElem
+            msgs.add(msg);
+            msgDTO.setMsgBody(msgs);
+            imService.sendMsg(msgDTO);
+            return R.ok();
+        }
+        return R.ok("操作成功");
+
+    }
+
     private String getFsPrescribeStoreZyImg(PrescribeZyImgParam o) {
         File mb = new File("C:\\fs\\zycf.jpg");
         if (!mb.exists()) {

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/config/MedicalMallConfig.java

@@ -27,4 +27,7 @@ public class MedicalMallConfig {
 
     //是否三方入驻
     private boolean isThreePartyEntry;
+
+    //处方类型 0,易诊通 1,580
+    private Integer PrescribeType = 0;
 }

+ 1 - 1
fs-service/src/main/java/com/fs/hospital580/entity/Hospital580PrescriptionScrmEntity.java

@@ -171,7 +171,7 @@ public class Hospital580PrescriptionScrmEntity extends Model<Hospital580Prescrip
 
     @ApiModelProperty("处方审核状态:1为待审核,2为审核通过,3为审核不通过")
     @TableField("audit_status")
-    private Boolean auditStatus;
+    private Integer auditStatus;
 
     @ApiModelProperty("审方时间")
     @TableField("audit_time")

+ 9 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/StoreOrderScrmController.java

@@ -29,6 +29,8 @@ import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
 import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
 import com.fs.hisStore.vo.FsStoreOrderItemVO;
+import com.fs.hospital580.entity.Hospital580PrescriptionScrmEntity;
+import com.fs.hospital580.service.Hospital580PrescriptionScrmService;
 import com.fs.huifuPay.domain.HuiFuCreateOrder;
 import com.fs.huifuPay.domain.HuifuCreateOrderResult;
 import com.fs.huifuPay.service.HuiFuService;
@@ -118,6 +120,8 @@ public class StoreOrderScrmController extends AppBaseController {
     @Qualifier("k9OrderScrmServiceImpl")
     private IErpOrderService k9OrderService;
 
+    @Autowired
+    private Hospital580PrescriptionScrmService orderScrmService;
     @Autowired
     private ConfigUtil configUtil;
     //TODO 应该没用到
@@ -204,6 +208,11 @@ public class StoreOrderScrmController extends AppBaseController {
         FsPrescribeScrm prescribe=null;
         if(order.getPrescribeId()!=null){
             prescribe=prescribeService.selectFsPrescribeById(order.getPrescribeId());
+            if (ObjectUtil.isEmpty(prescribe)){
+                Hospital580PrescriptionScrmEntity byId = orderScrmService.getById(order.getPrescribeId());
+                prescribe = new FsPrescribeScrm();
+                prescribe.setPatientId(byId.getPreId());
+            }
         }
         //处理是否可以申请售后
         Integer isAfterSales=0;

+ 8 - 0
fs-user-app/src/main/java/com/fs/app/facade/impl/Hospital580FacadeServiceImpl.java

@@ -70,6 +70,8 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
     @Autowired
     private IFsStoreProductScrmService productScrmService;
 
+    @Autowired
+    private IFsStoreOrderScrmService orderService;
     @Override
     @Transactional(rollbackFor = Exception.class)
     @DistributeLock(key = "#vo.userId", scene = "savePreDemand", waitTime = 5000, errorMsg = "新增问诊信息失败")
@@ -139,6 +141,7 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
         Hospital580PrescriptionScrmEntity prescription = orderScrmService.getById(vo.getBizOrderId());
         BeanUtil.copyProperties(vo, prescription);
         prescription.setPrescriptionStatus(vo.getStatus());
+        prescription.setAuditStatus(1);
         // 更新处方记录
         prescription.updateById();
         List<PrescriptionMedicineScrmVo> drugRspList = vo.getDrugRspList();
@@ -150,6 +153,11 @@ public class Hospital580FacadeServiceImpl implements Hospital580FacadeService {
             entity.insert();
         });
 
+        FsStoreOrderScrm storeOrderScrm = new FsStoreOrderScrm();
+        storeOrderScrm.setId(prescription.getStoreOrderId());
+        storeOrderScrm.setIsPrescribe(1);
+        storeOrderScrm.setPrescribeId(prescription.getPreId());
+        orderService.updateFsStoreOrder(storeOrderScrm);
         ThreadUtil.execute(() -> {
             // 同步聊天记录
             TextRecordDto build = TextRecordDto.builder().diagnosisId(prescription.getDiagnosisId()).pageSize(100).pageNum(1).build();