zjh
2025-03-24 30616665503726b49cb627cf59a9460e59523bee
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjXdPictureController.java
@@ -11,20 +11,17 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.hosp.domain.TjCustomer;
import com.ltkj.hosp.domain.TjProject;
import com.ltkj.hosp.domain.TjSampling;
import com.ltkj.hosp.domain.TjXdPicture;
import com.ltkj.hosp.service.ITjCustomerService;
import com.ltkj.hosp.service.ITjProjectService;
import com.ltkj.hosp.service.ITjXdPictureService;
import com.ltkj.hosp.service.TjAsyncService;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.vodomain.CsProVo;
import com.ltkj.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jodd.util.StringUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import com.ltkj.common.annotation.Log;
import com.ltkj.common.core.controller.BaseController;
@@ -49,11 +46,19 @@
    private ITjCustomerService customerService;
    @Autowired
    private ISysConfigService configService;
    @Resource
    private ITjOrderService orderService;
    @Resource
    private ITjOrderDetailService detailService;
    @Resource
    private ITjOrderRemarkService remarkService;
    @Resource
    private ITjProjectService projectService;
    /**
     * 查询体检心电图管理列表
     */
    @PreAuthorize("@ss.hasPermi('picture:picture:list')")
    //@PreAuthorize("@ss.hasPermi('picture:picture:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询体检心电图管理列表(自带默认)")
    public TableDataInfo list(TjXdPicture tjXdPicture) {
@@ -74,24 +79,27 @@
        wq.orderByDesc(TjXdPicture::getCreateTime);
        List<TjXdPicture> list = tjXdPictureService.list(wq);
        List<Map<String,Object>> arrayList=new ArrayList<>();
        if(null !=list && list.size()>0){
        if(null !=list && !list.isEmpty()){
            Map<String, List<TjXdPicture>> stringListMap = list.stream().collect(Collectors.groupingBy(TjXdPicture::getCusId));
            for (Map.Entry<String, List<TjXdPicture>> entry : stringListMap.entrySet()) {
                Map<String,Object>map=new HashMap<>();
                TjCustomer customer = customerService.getById(entry.getKey());
                customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
                customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
                customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
                customer.setTjNumber(entry.getValue().get(0).getTjNum());
                map.put("list",entry.getValue());
                map.put("customer",customer);
                map.put("picturePath",configService.selectConfigByKey("TjXdPicture"));
                arrayList.add(map);
                if(null !=customer){
                    customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
                    customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
                    customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
                    customer.setTjNumber(entry.getValue().get(0).getTjNum());
                    map.put("list",entry.getValue());
                    map.put("customer",customer);
                    map.put("picturePath",configService.selectConfigByKey("TjXdPicture"));
                    arrayList.add(map);
                }
            }
        }
        List<Map<String, Object>> collect =null;
        Map<String,Object>map=new HashMap<>();
        if(arrayList.size()>0){
        if(!arrayList.isEmpty()){
            collect = arrayList.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
        }
        map.put("list",collect);
@@ -102,7 +110,7 @@
    /**
     * 导出体检心电图管理列表
     */
    @PreAuthorize("@ss.hasPermi('picture:picture:export')")
    //@PreAuthorize("@ss.hasPermi('picture:picture:export')")
    @Log(title = "体检心电图管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出体检心电图管理列表")
@@ -115,7 +123,7 @@
    /**
     * 获取体检心电图管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('picture:picture:query')")
    //@PreAuthorize("@ss.hasPermi('picture:picture:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取体检心电图管理详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
@@ -125,7 +133,7 @@
    /**
     * 新增体检心电图管理
     */
    @PreAuthorize("@ss.hasPermi('picture:picture:add')")
    //@PreAuthorize("@ss.hasPermi('picture:picture:add')")
    @Log(title = "体检心电图管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增体检心电图管理")
@@ -136,22 +144,221 @@
    /**
     * 修改体检心电图管理
     */
    @PreAuthorize("@ss.hasPermi('picture:picture:edit')")
    //@PreAuthorize("@ss.hasPermi('picture:picture:edit')")
    @Log(title = "体检心电图管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改体检心电图管理")
    public AjaxResult edit(@RequestBody TjXdPicture tjXdPicture) {
        return toAjax(tjXdPictureService.updateTjXdPicture(tjXdPicture));
        if (tjXdPictureService.updateById(tjXdPicture)) {
            TjOrder order = orderService.getOrderByTjNum(tjXdPicture.getTjNum());
            LambdaQueryWrapper<TjOrderDetail>wq=new LambdaQueryWrapper<>();
            wq.eq(TjOrderDetail::getOrderId,order.getOrderId());
            wq.eq(TjOrderDetail::getProId,tjXdPicture.getProId());
            TjOrderDetail detail = detailService.getOne(wq);
            detail.setProResult(tjXdPicture.getProResult());
            detail.setConclusion(tjXdPicture.getConclusion());
            detail.setTjStatus(1L);
            detailService.updateById(detail);
            TjProject tjProject = projectService.getById(tjXdPicture.getProId());
            TjProject tjProjectp = projectService.getById(tjProject.getProParentId());
            LambdaQueryWrapper<TjOrderDetail>wq1=new LambdaQueryWrapper<>();
            wq1.eq(TjOrderDetail::getOrderId,order.getOrderId());
            wq1.eq(TjOrderDetail::getProId,tjProjectp.getProId());
            TjOrderDetail detailp = detailService.getOne(wq);
            detailp.setTjStatus(1L);
            detailService.updateById(detailp);
            LambdaQueryWrapper<TjOrderRemark> wq2=new LambdaQueryWrapper<>();
            wq2.eq(TjOrderRemark::getTjNumber,tjXdPicture.getTjNum());
            wq2.eq(TjOrderRemark::getProId,tjProjectp.getProId());
            TjOrderRemark remark = remarkService.getOne(wq2);
            remark.setType(1);
            remark.setRemark(tjXdPicture.getConclusion());
            remarkService.updateById(remark);
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
    /**
     * 删除体检心电图管理
     */
    @PreAuthorize("@ss.hasPermi('picture:picture:remove')")
    //@PreAuthorize("@ss.hasPermi('picture:picture:remove')")
    @Log(title = "体检心电图管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除体检心电图管理")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(tjXdPictureService.deleteTjXdPictureByIds(ids));
    }
    @GetMapping ("/getYxJcList")
    @ApiOperation (value = "影像检查列表(骨密度和心电图)")//0待1已
    @Transactional
    public AjaxResult getYxJcList(@ApiParam (value = "页码数(默认1)") @RequestParam (defaultValue = "1") Integer page,
                                @ApiParam (value = "显示条数(默认10)") @RequestParam (defaultValue = "10") Integer pageSize,
                                @ApiParam (value = "体检单号") @RequestParam (required = false) String tjNumber,
                                @ApiParam (value = "单位") @RequestParam (required = false) Long compId,
                                @ApiParam (value = "姓名)") @RequestParam (required = false) String name,
                                @ApiParam (value = "套餐名)") @RequestParam (required = false) String tcm,
                                @ApiParam (value = "开始时间") @RequestParam (required = false) String beginTime,
                                @ApiParam (value = "结束时间") @RequestParam (required = false) String endTime) {
//        DateTime beginTimes = null;
//        DateTime endTimes = null;
//        if (null != beginTime && null != endTime) {
//            beginTimes = DateUtil.beginOfDay(DateUtil.parse(beginTime));
//            endTimes = DateUtil.endOfDay(DateUtil.parse(endTime));
//        }
//        //初始化体检订单表
//        List<TjOrder> orderList = null;
//        List<TjCustomer> customerList = new ArrayList<>();
//        Map<String, Object> map = new HashMap<>();
//
//        if (checkStatus == 0)
//            asyncService.wCScheckSetCustomerLisByRedis(orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes));
//        if (checkStatus == 1)
//            asyncService.yCScheckSetCustomerLisByRedis(orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes));
//
//        //根据姓名查询
//        if (null != name && !"".equals(name)) {
//            List<TjCustomer> list = customerService.getTjCustomerList(name);
//            if (null != list && list.size() > 0) {
//                List<TjCustomer> lists = new ArrayList<>();
//                for (TjCustomer customer : list) {
//                    orderList = orderService.getCsTjOrderListByCusId(customer.getCusId());
//                    if (null != orderList && orderList.size() > 0) {
//                        for (TjOrder tjOrder : orderList) {
//                            customer.setTjNumber(tjOrder.getTjNumber());
//                            customer.setTjStatus(Long.valueOf(tjOrder.getCheckStatus()));
//                            customer.setOrderId(tjOrder.getOrderId());
//                            customer.setTjTime(tjOrder.getCreateTime());
//                            customer.setFinishTime(tjOrder.getFinishTime());
//                            customer.setCusName(MatchUtils.hideCusName(customer.getCusName()));
//                            customer.setCusPhone(MatchUtils.hidePhoneNum(customer.getCusPhone()));
//                            customer.setCusIdcard(MatchUtils.hideIdCardNum(customer.getCusIdcard()));
//                            customer.setConfirmStatus(String.valueOf(tjOrder.getStatus()));
//                            if (tjOrder.getFirmId().equals("0")) {
//                                customer.setTjCompName(null);
//                            } else {
//                                customer.setTjCompName(compService.selectDictCompByDrugManufacturerId(tjOrder.getFirmId()).getCnName());
//                            }
//                            lists.add(customer);
//                        }
//                    }
//                }
//                List<TjCustomer> customers = null;
//                if (lists.size() > 0) {
//                    customers = lists.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
//                }
//                map.put("customers", customers);
//                map.put("total", lists.size());
//                return AjaxResult.success(map);
//            }
//            return AjaxResult.success("暂无数据");
//        }
//
//        //条件查询
//        if (null != tjNumber || null != compId || (null != beginTime && null != endTime)) {
//            orderList = orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes);
//            return getResult(page, pageSize, orderList, customerList, map);
//        }
//
//        List<TjCustomer> customers = null;
//        if (checkStatus == 0) {
//            customers = redisCache.getCacheMapValue("cScheck", "ws");
//        }
//        if (checkStatus == 1) {
//            customers = redisCache.getCacheMapValue("cScheck", "ys");
//        }
//        if (customers != null && customers.size() > 0) {
//            List<TjCustomer> customerLists = customers.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
//            map.put("customers", customerLists);
//            map.put("total", customers.size());
//            return AjaxResult.success(map);
//        } else {
//            orderList = orderService.getCsTjOrderList(tjNumber, checkStatus, compId, beginTimes, endTimes);
//            return getResult(page, pageSize, orderList, customerList, map);
//        }
        String value = String.valueOf(compId);
        if (tjNumber == null) tjNumber = "";
        if (compId == null) value = "";
        if (name == null) name = "";
        if (beginTime == null) beginTime = "";
        if (endTime == null) endTime = "";
        if (tcm == null) tcm = "";
        return AjaxResult.success(orderService.getYxJcList(tjNumber, page, pageSize, value, beginTime, endTime, name,tcm));
    }
    @GetMapping ("/getYxJcXx")
    @ApiOperation (value = "影像检查骨密度心电图页面点击体检人员展示体检项目接口")
    public AjaxResult getYxJcXx(@ApiParam (value = "体检号") @RequestParam String tjNumber) {
        List<CsProVo> list = remarkService.getYxJcXx(tjNumber);
        return AjaxResult.success(list);
    }
    @GetMapping ("/addYxJcXx")
    @ApiOperation (value = "提交影像检查骨密度心电图结果接口")
    @Transactional
    public AjaxResult addYxJcXx(@ApiParam (value = "体检号") @RequestParam String tjNumber,
                                @ApiParam (value = "项目id") @RequestParam String proId,
                                @ApiParam (value = "检查所见") @RequestParam String jcsj,
                                @ApiParam (value = "检查结论") @RequestParam String jcjl) {
        TjOrder order = orderService.getOrderByTjNum(tjNumber);
        if(null !=order){
            TjProject project = projectService.getById(proId);
            if(null !=project){
                List<TjProject> projects = projectService.getTjProjectListBySoneId(proId);
                LambdaQueryWrapper<TjOrderDetail>wq1=new LambdaQueryWrapper<>();
                wq1.eq(TjOrderDetail::getProId,projects.get(0).getProParentId());
                wq1.eq(TjOrderDetail::getOrderId,order.getOrderId());
                TjOrderDetail detail = detailService.getOne(wq1);
                if(null !=detail){
                    detail.setProResult(jcjl+"。"+jcsj);
                    detail.setTjStatus(1L);
                    detailService.updateById(detail);
                    LambdaQueryWrapper<TjOrderRemark>wq2=new LambdaQueryWrapper<>();
                    wq2.eq(TjOrderRemark::getProId,proId);
                    wq2.eq(TjOrderRemark::getTjNumber,tjNumber);
                    TjOrderRemark orderRemark = remarkService.getOne(wq2);
                    if(null !=orderRemark){
                        orderRemark.setType(1);
                        remarkService.updateById(orderRemark);
                    }
                }
            }
            return AjaxResult.success();
        }
        return AjaxResult.error("暂无体检记录");
    }
    @GetMapping ("/getYxJcXxJg")
    @ApiOperation (value = "获取影像检查骨密度心电图结果接口")
    @Transactional
    public AjaxResult getYxJcXxJg(@ApiParam (value = "体检号") @RequestParam String tjNumber,
                                @ApiParam (value = "项目id") @RequestParam String proId) {
        TjOrder order = orderService.getOrderByTjNum(tjNumber);
        if(null !=order){
            TjProject project = projectService.getById(proId);
            if(null !=project){
                List<TjProject> projects = projectService.getTjProjectListBySoneId(proId);
                LambdaQueryWrapper<TjOrderDetail>wq1=new LambdaQueryWrapper<>();
                wq1.eq(TjOrderDetail::getProId,projects.get(0).getProParentId());
                wq1.eq(TjOrderDetail::getOrderId,order.getOrderId());
                TjOrderDetail detail = detailService.getOne(wq1);
                if(null !=detail && StringUtil.isNotBlank(detail.getProResult())){
                    Map<String,Object> map=new HashMap<>();
                    String string = detail.getProResult();
                }
            }
            return AjaxResult.success();
        }
        return AjaxResult.error("暂无体检记录");
    }
}