zjh
2024-07-02 a51a70b780ef0ed24abb81b096c80649a0255ece
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java
@@ -1,18 +1,26 @@
package com.ltkj.web.controller.system;
import java.io.*;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.ltkj.common.core.domain.TreeSelect;
import com.ltkj.common.core.domain.entity.SysRole;
import com.ltkj.common.core.domain.entity.SysUser;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.common.core.text.Convert;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.common.utils.bean.BeanUtils;
import com.ltkj.framework.config.MatchUtils;
@@ -21,9 +29,8 @@
import com.ltkj.hosp.service.*;
import com.ltkj.system.domain.SysPost;
import com.ltkj.system.domain.SysUserPost;
import com.ltkj.system.service.ISysPostService;
import com.ltkj.system.service.ISysUserPostService;
import com.ltkj.system.service.ISysUserService;
import com.ltkj.system.service.*;
import com.ltkj.web.controller.his.HisApiGetMethodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -46,7 +53,6 @@
import com.ltkj.common.core.domain.entity.SysDept;
import com.ltkj.common.enums.BusinessType;
import com.ltkj.common.utils.StringUtils;
import com.ltkj.system.service.ISysDeptService;
import javax.annotation.Resource;
@@ -101,7 +107,14 @@
    public RedisTemplate<Object,Object> redisTemplate;
    @Resource
    private TestMapper testMapper;
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private ITjFlowingWaterService tjFlowingWaterService;
    @Autowired
    private HisApiGetMethodService hisApiGetMethodService;
    @Autowired
    private LtkjJianchajianyanTreeService ltkjJianchajianyanTreeService;
    /**
     * 该体检科室下客户列表显示接口
@@ -1366,7 +1379,7 @@
                    if (null != summaryList && summaryList.size()>0 && !summaryList.contains(null)) {
                        one.setSummary(Joiner.on(";").join(orderRemark.getSummaryList()));
                    }
                    one.setDeptId(orderRemark.getDeptId());
//                    one.setDeptId(orderRemark.getDeptId());
                    one.setDoctorName(orderRemark.getDoctorName());
                    one.setType(1);
                    remarkService.updateById(one);
@@ -1387,6 +1400,7 @@
     * @param tjNumber
     * @return
     */
    @Transactional
    @GetMapping("/getParentList")
    @ApiOperation(value = "医生点击体检信息详情(只显示父项目列表)")
    public AjaxResult getParentList(@ApiParam(value = "客户体检号") @RequestParam String tjNumber) {
@@ -1400,6 +1414,99 @@
            }
            ksId = Math.toIntExact(sysUser.getDeptId());
        }
        String configByKey = configService.selectConfigByKey("sfkqdyhis");
        if (configByKey.equals("Y")){
            // 判断是否收费 请求接口
            LambdaQueryWrapper<TjOrder> tjOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
            tjOrderLambdaQueryWrapper.eq(TjOrder::getTjNumber,tjNumber);
            TjOrder tjOrder = orderService.getOne(tjOrderLambdaQueryWrapper);
            LambdaQueryWrapper<TjFlowingWater> tjFlowingWaterLambdaQueryWrapper = new LambdaQueryWrapper<>();
            tjFlowingWaterLambdaQueryWrapper.eq(TjFlowingWater::getOrderId,tjOrder.getOrderId());
            tjFlowingWaterLambdaQueryWrapper.ne(TjFlowingWater::getPayStasus,2);
            tjFlowingWaterLambdaQueryWrapper.eq(TjFlowingWater::getIsAddition,"N");
            TjFlowingWater tjFlowingWater = tjFlowingWaterService.getOne(tjFlowingWaterLambdaQueryWrapper);
//            if (tjFlowingWater1.getPayStasus() != 1){
                LambdaQueryWrapper<TjCustomer> tjCustomerLambdaQueryWrapper = new LambdaQueryWrapper<>();
                tjCustomerLambdaQueryWrapper.eq(TjCustomer::getCusId,tjOrder.getUserId());
                TjCustomer tjCustomer = tjCustomerService.getOne(tjCustomerLambdaQueryWrapper);
                HashMap<String, Object> hisRequestParams = new HashMap<>();
                // 不在需要身份证号
//                hisRequestParams.put("card_no",tjCustomer.getCusIdcard());
                hisRequestParams.put("patientId",tjOrder.getCardId());
                AjaxResult queryPay = hisApiGetMethodService.getHISDataNew("QueryPay", hisRequestParams);
                if (Integer.parseInt(queryPay.get("code").toString()) == 200) {
                    List<Map<String, String>> data = (List<Map<String, String>>) queryPay.get("data");
                    ArrayList<String> sqdhs = new ArrayList<>();
                    ArrayList<String> xmfls = new ArrayList<>();
                    BigDecimal cateFeeAll = BigDecimal.ZERO;
                    for (Map<String, String> datum : data) {
                        String advId = datum.get("Adv_Id").split("_")[1];
                        BigDecimal cateFee = new BigDecimal(datum.get("CateFee"));
                        String cateCode = datum.get("CateCode");
                        cateFeeAll = cateFeeAll.add(cateFee);
                        sqdhs.add(advId);
                        xmfls.add(cateCode);
                    }
                    LambdaQueryWrapper<LtkjJianchajianyanTree> queryWrapper = new LambdaQueryWrapper<>();
                    queryWrapper.in(LtkjJianchajianyanTree::getSqdh, sqdhs)
                            .in(LtkjJianchajianyanTree::getXmfl, xmfls)
                            .eq(LtkjJianchajianyanTree::getCardId,tjOrder.getCardId())
                            .groupBy(LtkjJianchajianyanTree::getType)
                            .select(LtkjJianchajianyanTree::getFyhj);
                    List<LtkjJianchajianyanTree> results = ltkjJianchajianyanTreeService.list(queryWrapper);
                    BigDecimal total = results.stream()
                            .map(item -> new BigDecimal(item.getFyhj()))
                            .reduce(BigDecimal.ZERO, BigDecimal::add);
                    if (cateFeeAll.compareTo(total) != 0){
                        return AjaxResult.error("存在未缴费项目");
                    }
                    tjFlowingWater.setPayStasus(1L);
                    tjFlowingWater.setPayType(0L);
                    tjFlowingWater.setTollCollectorId("148");
                    tjFlowingWaterService.updateById(tjFlowingWater);
                    Long tjSerialNumber = tjFlowingWater.getTjSerialNumber();
                    LambdaQueryWrapper<TjOrderDetail> tjOrderDetailLambdaQueryWrapper = new LambdaQueryWrapper<>();
                    tjOrderDetailLambdaQueryWrapper.eq(TjOrderDetail::getOrderId,tjOrder.getOrderId());
                    List<TjOrderDetail> tjOrderDetails = detailService.list(tjOrderDetailLambdaQueryWrapper);
                    List<Long> detailIds = tjOrderDetails.stream().map(TjOrderDetail::getOrderDetailId).collect(Collectors.toList());
                    LambdaUpdateWrapper<TjOrderDetail> tjOrderDetailLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
                    tjOrderDetailLambdaUpdateWrapper.set(TjOrderDetail::getFlowingWaterId,tjSerialNumber);
                    tjOrderDetailLambdaUpdateWrapper.in(TjOrderDetail::getOrderDetailId,detailIds);
                    detailService.update(tjOrderDetailLambdaUpdateWrapper);
                }else {
                    return AjaxResult.error("未查询到缴费记录");
                }
//            }
        }
        String config = configService.selectConfigByKey("qt_open_xdt");
        String byKey = configService.selectConfigByKey("qt_kjksid");
        List<Integer> split = new ArrayList<>(); // 存放转换后的integer类型结果
        if("Y".equals(config)){
            List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
            if(null !=roles && roles.size()>0){
                List<SysRole> list = roles.stream().filter(item -> item.getRoleName().contains("前台")).collect(Collectors.toList());
                if(list.size()>0){
                    if(null !=ksId && ksId==100){
                        ksId=999;
                    }
                    if(null !=byKey && !"".equals(byKey)){
                        String[] arr = byKey.split(","); // 根据逗号进行切割
                        for (String s : arr) {
                            int num = Integer.parseInt(s); // 将每个子字符串转换为integer类型
                            split.add(num); // 添加到列表中
                        }
                    }
                }else {
                    split.add(ksId);
                }
            }else {
                split.add(ksId);
            }
        }else {
            split.add(ksId);
        }
        //判断当前登陆的人是不是管理员。管理员可以看当前体检号下所有项目
//        if (sysUser.getUserName().equals("10001")) {
//            QueryWrapper<TjOrderRemark> wqq = new QueryWrapper<>();
@@ -1418,7 +1525,7 @@
//        }
        LambdaQueryWrapper<TjProject> wq2 = new LambdaQueryWrapper<>();
        if ((null != sysUser && !sysUser.getUserName().equals("10001")) && 100!=ksId) {
            wq2.eq(TjProject::getDeptId, ksId);
            wq2.in(TjProject::getDeptId,split);
        }
        //判断该项目是否需要打印报告
        wq2.eq(TjProject::getNeedReport,"Y");
@@ -1481,7 +1588,10 @@
//        }
        TjOrderRemark remark = remarkService.getTjOrderRemarkByTjNumAndProParentId(tjNumber, proParentId);
        List<TjProject> proParentList = projectService.getTjProjectListBySoneId(proParentId);
//        List<TjProject> proParentList = projectService.getTjProjectListBySoneId(proParentId);
        List<TjProject> proParentList = projectService.getTjProjectListByTbTransition(proParentId,tjNumber);
        if (null == proParentList || proParentList.size()==0) {
            Map<String, Object> map = new HashMap<>();
            map.put("xiaoJieIds", null);
@@ -1496,6 +1606,7 @@
            return AjaxResult.success("该用户暂时没有体检数据");
        }
        List<TjOrderDetail> tjOrderDetails = detailService.getTjOrderDetailListInProParentIdList(String.valueOf(one.getOrderId()), proParentIdList);
        List<TjOrderDetail> tjOrderDetailList=new ArrayList<>();
        TjCustomer customer = tjCustomerService.getById(one.getUserId());
        if (null != tjOrderDetails && tjOrderDetails.size() > 0) {
            for (TjOrderDetail tjOrderDetail : tjOrderDetails) {
@@ -1571,6 +1682,7 @@
                } else {
                    tjOrderDetail.setDoctorName(null);
                }
                tjOrderDetailList.add(tjOrderDetail);
            }
        }
        Map<String, Object> map = new HashMap<>();
@@ -1590,7 +1702,7 @@
        } else {
            map.put("xiaoJieIds", null);
        }
        map.put("sons", tjOrderDetails);
        map.put("sons", tjOrderDetailList);
        map.put("xiaoJie", adviceList);
        map.put("remark", remark.getRemark());