1
lige
2023-12-06 e44fea2d4845aed7848f163152da532f19ccce41
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjRulesController.java
@@ -1,5 +1,7 @@
package com.ltkj.web.controller.system;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -7,11 +9,13 @@
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.checkerframework.checker.units.qual.A;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -200,4 +204,57 @@
        }
        return toAjax(true);
    }
    /**
     * 规则自动计算
     */
    @GetMapping("/AutoGetRule")
    @ApiOperation(value = "规则自动计算")
    public AjaxResult AutoGetRule(@ApiParam(value = "项目") @RequestParam String proId,
                                  @ApiParam(value = "客户") @RequestParam String cusId,
                                  @ApiParam(value = "关键字") @RequestParam(required = false) String keyWord,
                                  @ApiParam(value = "结果值") @RequestParam(required = false) BigDecimal keyNum) {
        List<TjRules> res = new ArrayList<>();
        TjCustomer byId = customerService.getById(cusId);
        LambdaQueryWrapper<TjRules> wq = new LambdaQueryWrapper<>();
        wq.eq(TjRules::getProId, proId);
        wq.lt(TjRules::getAgeLt, MatchUtils.getAgeByIdCard(byId.getCusIdcard()));
        wq.gt(TjRules::getAgeGt, MatchUtils.getAgeByIdCard(byId.getCusIdcard()));
        wq.in(TjRules::getSex, 0, byId.getCusSex());
        final List<TjRules> list = tjRulesService.list(wq);
        for (TjRules tjRules : list) {
            //判断规则类型:数值/文字
            if ("2".equals(tjRules.getRuleType())) {
                if (new BigDecimal(0).equals(tjRules.getRuleLt()) && new BigDecimal(0).equals(tjRules.getRuleGt())) {
                    res.add(tjRules);
                } else {
                    if (keyNum != null) {
                        if (tjRules.getRuleLt().compareTo(keyNum) < 0 && tjRules.getRuleGt().compareTo(keyNum) > 0) {
                            res.add(tjRules);
                        }
                    }
                }
            } else if ("1".equals(tjRules.getRuleType())) {
                if (keyWord!=null){
                    if (tjRules.getRuleStr().contains(keyWord)) {
                        res.add(tjRules);
                    }
                }
            }
        }
        if (res.size() > 0) {
            //建议赋值
            for (TjRules re : res) {
                LambdaQueryWrapper<TjRuleAdvice> wq1 = new LambdaQueryWrapper<>();
                wq1.eq(TjRuleAdvice::getBz, re.getAid());
                final List<TjRuleAdvice> list1 = tjRuleAdviceService.list(wq1);
                re.setRuleAdvices(list1);
            }
        }
        return AjaxResult.success(res);
    }
}