suqinyi 1 rok pred
rodič
commit
4bc7d65a05

+ 9 - 0
starter/swagger-starter/pom.xml

@ -12,6 +12,11 @@
    <artifactId>swagger-starter</artifactId>
    <dependencies>
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-spring-boot-starter</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>swagger-bootstrap-ui</artifactId>
@ -37,6 +42,10 @@
            <artifactId>swagger2markup</artifactId>
            <version>${version.swagger2markup}</version>
        </dependency>
    </dependencies>
</project>

+ 5 - 3
starter/swagger-starter/src/main/java/com/yihu/jw/SwaggerConfig.java

@ -1,6 +1,7 @@
package com.yihu.jw;
import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
//import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
@ -21,9 +22,10 @@ import java.util.List;
import static com.google.common.base.Predicates.or;
import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@EnableKnife4j
@EnableSwagger2
@EnableSwaggerBootstrapUI
@Configuration
//@EnableSwaggerBootstrapUI
public class SwaggerConfig {
    public static final String API_VERSION = "v1.0";

+ 2 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/dao/WlyyDoorServiceOrderDao.java

@ -2,11 +2,11 @@ package com.yihu.jw.hospital.module.door.dao;
import com.yihu.jw.entity.door.WlyyDoorServiceOrderDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@ -23,14 +23,13 @@ import java.util.List;
 * </pre>
 * @since 1.
 */
public interface WlyyDoorServiceOrderDao extends PagingAndSortingRepository<WlyyDoorServiceOrderDO, String>, JpaSpecificationExecutor<WlyyDoorServiceOrderDO> {
public interface WlyyDoorServiceOrderDao extends JpaRepository<WlyyDoorServiceOrderDO, String>, JpaSpecificationExecutor<WlyyDoorServiceOrderDO> {
    boolean existsByPatientAndStatusNot(String patient, int status);
    boolean existsByPatientAndStatusIn(String patient, Integer[] status);
    @Modifying
    @Transactional
    @Query("update WlyyDoorServiceOrderDO o set o.conclusionStatus = 1 where o.id = ?1")
    void updateConclusionStatus(String orderId);
@ -38,7 +37,6 @@ public interface WlyyDoorServiceOrderDao extends PagingAndSortingRepository<Wlyy
    List<WlyyDoorServiceOrderDO> getNotFinishOrderByDoctor(String doctor);
    @Modifying
    @Transactional
    @Query("update WlyyDoorServiceOrderDO o set o.prescriptionStatus = 1,o.status = 4, o.prescriptionCode = ?2, o.prescriptionTime = ?3 where o.id = ?1")
    void updatePrescriptionById(String orderId, String prescriptionCode, Date prescriptionTime);

+ 124 - 109
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java

@ -21,7 +21,6 @@ import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.ResponseContant;
@ -29,7 +28,6 @@ import com.yihu.jw.restmodel.qvo.ParamQvo;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.mysql.query.BaseJpaService;
@ -648,120 +646,137 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
     * @param jsonData
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
//    @Transactional(rollbackFor = Exception.class)
//    public JSONObject create(String jsonData) throws Exception {
//        logger.info("创建上门服务jsonData参数:" + jsonData);
//
//        JSONObject result = new JSONObject();
//        JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
//
//        WlyyDoorServiceOrderDO orderDO = EntityUtils.jsonToEntity(
//                jsonObjectParam.get("order").toString(), WlyyDoorServiceOrderDO.class);
//
//        orderDO.setNumber(getRandomIntStr());
//        orderDO.setCreateTime(new Date());
//        orderDO.setCreateUser(orderDO.getProxyPatient());
//        orderDO.setCreateUserName(orderDO.getProxyPatientName());
//        orderDO.setOrderInfo("0");
//
//        if (StringUtils.isEmpty(orderDO.getPatient())) {
//            throw new Exception("当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient());
//        }
//
//        if (StringUtils.isEmpty(orderDO.getProxyPatient())) {
//            String failMsg = "当前代理对象code为空,请联系管理员检查参数!proxyPatient = " + orderDO.getProxyPatient();
//            throw new Exception(failMsg);
//        }
//
//        //判断师傅存在为完成的上门服务订单
//        boolean bool = wlyyDoorServiceOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
//                new Integer[]{WlyyDoorServiceOrderDO.Status.waitForSend.getType(),
//                        WlyyDoorServiceOrderDO.Status.waitForAccept.getType(),
//                        WlyyDoorServiceOrderDO.Status.waitForServe.getType(),
//                        WlyyDoorServiceOrderDO.Status.accept.getType(),
//                });
//
//        if (bool) {
//            String failMsg = "当前服务对象存在未完成的上门服务,请先完成该服务!";
//            throw new Exception(failMsg);
//        }
//
//        orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
//        orderDO.setCreateTime(new Date());
//        //判断创建上门服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
//        if (orderDO.getProxyPatient().equals(orderDO.getPatient())) {
//            orderDO.setType(1);
//        } else if (!orderDO.getProxyPatient().equals(orderDO.getPatient())) {
//            orderDO.setType(2);
//        }
//        orderDO.setServiceStatus("1");
//        //保存服务订单
//        wlyyDoorServiceOrderDao.save(orderDO);
//
//        //创建咨询
//        JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
//        ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
//
//        //新增工单与服务项费用关联关系
//        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO)) {
//            return result;
//        }
//        //获取机构的调度员
//        List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
//        //没有调度员的模式
////        if (dispatcherList.isEmpty()
////                && StringUtils.isEmpty(orderDO.getDoctor())
////                && StringUtils.isEmpty(orderDO.getExpectedDoctorName())) {
////            orderDO.setStatus(2);
////            //应该是康复模板的康复下转,才有签约--先注释
////            orderDO.setDoctor(signFamily.getDoctor());
////            orderDO.setDoctorName(signFamily.getDoctorName());
////            this.save(orderDO);
////            WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findById(orderDO.getId());
////            //新增工单医生关联关系
////            if (orderWithDoctorAdd(result, jsonObjectParam, wlyyDoorServiceOrder)) {
////                return result;
////            }
////            // 给服务医生发接单消息--先注释
////            this.createMessage(orderDO.getId(), orderDO.getProxyPatient(), signFamily.getDoctor(), 407, "服务工单待接单", "您有新的服务工单,请前往处理");
////            //发送智能助手消息-微信消息先注释
////            sendWeixinMessage(4, signFamily.getDoctor(), orderDO.getPatient());
////            result.put(ResponseContant.resultFlag, ResponseContant.success);
////            result.put(ResponseContant.resultMsg, consultTeam);
////            return result;
////        }
//
//        //有调度员
//        if (!dispatcherList.isEmpty()) {
//            for (Map<String, Object> map : dispatcherList) {
//                String dispatcher = map.get("code").toString();
//                // 派单消息-首页
//                this.createMessage(orderDO.getId(), "system", dispatcher, 402, "新增居民预约服务申请", orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
//                // 派单-实时工单消息  430 居民提交工单申请-- 张三提交了服务工单12345678申请
//                this.createMessage(orderDO.getId(), "system", dispatcher, 430, "居民提交工单申请", orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
//            }
//        }
//
//        //给机构调度员发送医生助手消息
//        for (Map<String, Object> map : dispatcherList) {
//            //这边还没有微信消息的功能呢。
//            sendWeixinMessage(3, map.get("user_code") + "", orderDO.getPatient());
//        }
//        result.put(ResponseContant.resultFlag, ResponseContant.success);
//        result.put(ResponseContant.resultMsg, consultTeam);
//
//        //发送 预约卡片信息(2101类型)
//        JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
//        orderInfoContent.put("re_msg_type", 0);//居民预约
//        //发送消息
//        int i = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
////        if (i != 1) {
////            throw new Exception("上门服务工单消息发送失败");
////        }
//
//        if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
//            //服务医生修改,直接转派
//            BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
//            sendOrderToDoctor(orderDO.getId(), null, "system", "系统", transDoctor.getId(), transDoctor.getName(), transDoctor.getJobTitleName());
//        }
//        return result;
//    }
    public JSONObject create(String jsonData) throws Exception {
        logger.info("创建上门服务jsonData参数:" + jsonData);
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
        WlyyDoorServiceOrderDO orderDO = EntityUtils.jsonToEntity(
                jsonObjectParam.get("order").toString(), WlyyDoorServiceOrderDO.class);
        orderDO.setNumber(getRandomIntStr());
        orderDO.setCreateTime(new Date());
        orderDO.setCreateUser(orderDO.getProxyPatient());
        orderDO.setCreateUserName(orderDO.getProxyPatientName());
        orderDO.setOrderInfo("0");
        if (StringUtils.isEmpty(orderDO.getPatient())) {
            throw new Exception("当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient());
        }
        if (StringUtils.isEmpty(orderDO.getProxyPatient())) {
            String failMsg = "当前代理对象code为空,请联系管理员检查参数!proxyPatient = " + orderDO.getProxyPatient();
            throw new Exception(failMsg);
        }
        //判断师傅存在为完成的上门服务订单
        boolean bool = wlyyDoorServiceOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
                new Integer[]{WlyyDoorServiceOrderDO.Status.waitForSend.getType(),
                        WlyyDoorServiceOrderDO.Status.waitForAccept.getType(),
                        WlyyDoorServiceOrderDO.Status.waitForServe.getType(),
                        WlyyDoorServiceOrderDO.Status.accept.getType(),
                });
        if (bool) {
            String failMsg = "当前服务对象存在未完成的上门服务,请先完成该服务!";
            throw new Exception(failMsg);
        }
        orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        orderDO.setCreateTime(new Date());
        //判断创建上门服务类型,发起类型(1本人发起 2家人待预约 3医生代预约)
        if (orderDO.getProxyPatient().equals(orderDO.getPatient())) {
            orderDO.setType(1);
        } else if (!orderDO.getProxyPatient().equals(orderDO.getPatient())) {
            orderDO.setType(2);
        }
        orderDO.setServiceStatus("1");
        WlyyDoorServiceOrderDO orderDO =new WlyyDoorServiceOrderDO();
        //保存服务订单
        wlyyDoorServiceOrderDao.save(orderDO);
        //创建咨询
        JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
        ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO)) {
            return result;
        }
        //获取机构的调度员
        List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        //没有调度员的模式
//        if (dispatcherList.isEmpty()
//                && StringUtils.isEmpty(orderDO.getDoctor())
//                && StringUtils.isEmpty(orderDO.getExpectedDoctorName())) {
//            orderDO.setStatus(2);
//            //应该是康复模板的康复下转,才有签约--先注释
//            orderDO.setDoctor(signFamily.getDoctor());
//            orderDO.setDoctorName(signFamily.getDoctorName());
//            this.save(orderDO);
//            WlyyDoorServiceOrderDO wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findById(orderDO.getId());
//            //新增工单医生关联关系
//            if (orderWithDoctorAdd(result, jsonObjectParam, wlyyDoorServiceOrder)) {
//                return result;
//            }
//            // 给服务医生发接单消息--先注释
//            this.createMessage(orderDO.getId(), orderDO.getProxyPatient(), signFamily.getDoctor(), 407, "服务工单待接单", "您有新的服务工单,请前往处理");
//            //发送智能助手消息-微信消息先注释
//            sendWeixinMessage(4, signFamily.getDoctor(), orderDO.getPatient());
//            result.put(ResponseContant.resultFlag, ResponseContant.success);
//            result.put(ResponseContant.resultMsg, consultTeam);
//            return result;
//        }
        //有调度员
        if (!dispatcherList.isEmpty()) {
            for (Map<String, Object> map : dispatcherList) {
                String dispatcher = map.get("code").toString();
                // 派单消息-首页
                this.createMessage(orderDO.getId(), "system", dispatcher, 402, "新增居民预约服务申请", orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
                // 派单-实时工单消息  430 居民提交工单申请-- 张三提交了服务工单12345678申请
                this.createMessage(orderDO.getId(), "system", dispatcher, 430, "居民提交工单申请", orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
            }
        }
        //给机构调度员发送医生助手消息
        for (Map<String, Object> map : dispatcherList) {
            //这边还没有微信消息的功能呢。
            sendWeixinMessage(3, map.get("user_code") + "", orderDO.getPatient());
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, consultTeam);
        //发送 预约卡片信息(2101类型)
        JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
        orderInfoContent.put("re_msg_type", 0);//居民预约
        //发送消息
        int i = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
//        if (i != 1) {
//            throw new Exception("上门服务工单消息发送失败");
//        }
        if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
            //服务医生修改,直接转派
            BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
            sendOrderToDoctor(orderDO.getId(), null, "system", "系统", transDoctor.getId(), transDoctor.getName(), transDoctor.getJobTitleName());
        }
        return result;
    }
@ -1979,7 +1994,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    if (parArray!=null){
                    if (parArray != null) {
                        parArray.forEach(
                                oneParObj -> {
                                    org.json.JSONObject oneParJson = (org.json.JSONObject) oneParObj;