| | |
| | | import java.util.*; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.jeecg.common.api.vo.Result; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.jeecg.modules.demo.contract.entity.Contract; |
| | | import org.jeecg.modules.demo.contract.entity.SemanticWord; |
| | | import org.jeecg.modules.demo.contract.service.IContractService; |
| | | import org.jeecg.modules.demo.contract.service.ISemanticWordService; |
| | |
| | | semanticWord.setCreateBy(null); |
| | | queryWrapper = QueryGenerator.initQueryWrapper(semanticWord, req.getParameterMap(), customeRuleMap); |
| | | sysUserQueryWrapper.eq("agent_sales", user); |
| | | Result<IPage<SysUser>> iPageResult = sysUserService.queryPageList(req, sysUserQueryWrapper, pageSize, pageNo); |
| | | List<SysUser> iPageResult = sysUserService.list(sysUserQueryWrapper); |
| | | List<String> name = new ArrayList<>(); |
| | | for (SysUser sysUser : iPageResult.getResult().getRecords()) { |
| | | for (SysUser sysUser : iPageResult) { |
| | | name.add(sysUser.getUsername()); |
| | | } |
| | | name.add(user); |
| | |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | //@AutoLog(value = "语义词-查询语义总量") |
| | | @Operation(summary="语义词-查询语义总量") |
| | | @GetMapping(value = "/count") |
| | | public Result<IPage<SemanticWord>> queryPageList(Contract contract, |
| | | SemanticWord semanticWord, |
| | | @RequestParam(name="role", defaultValue="无") String role, |
| | | @RequestParam(name="user", defaultValue="无") String user, |
| | | HttpServletRequest req) { |
| | | |
| | | // 自定义查询规则 |
| | | Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>(); |
| | | if (contract.getCreateBy() != null) { |
| | | user = contract.getCreateBy(); |
| | | } |
| | | // 自定义多选的查询规则为:LIKE_WITH_OR |
| | | customeRuleMap.put("reviewStatus", QueryRuleEnum.LIKE_WITH_OR); |
| | | QueryWrapper<Contract> queryWrapper = QueryGenerator.initQueryWrapper(contract, req.getParameterMap(),customeRuleMap,true); |
| | | if (contract.getAgentAuditorIsNull() != null) { |
| | | if (contract.getAgentAuditorIsNull().equals("false")) { |
| | | queryWrapper.isNotNull("agents_name"); |
| | | } else{ |
| | | queryWrapper.and(wrapper -> wrapper.isNull("agents_name").or().eq("agents_name", "")); |
| | | |
| | | } |
| | | } |
| | | if (!user.equals("无")){ |
| | | QueryWrapper qw = new QueryWrapper<SysUser>(); |
| | | qw.eq("id", user); |
| | | String userName = ((SysUser)((Page) sysUserService.queryPageList(req, qw, 1, 1).getResult()).getRecords().get(0)).getUsername(); |
| | | queryWrapper.eq("create_by", userName); |
| | | } |
| | | if (role.equals("无")); |
| | | else if (role.equals("1972228581703651330")){//销售 |
| | | // else{ |
| | | // if (user.equals("无")){ |
| | | // return Result.error("请输入销售名称");//销售根据用户筛选 |
| | | // } |
| | | QueryWrapper<SysUser> sysUserQueryWrapper = new QueryWrapper<>(); |
| | | sysUserQueryWrapper.eq("agent_sales", user); |
| | | Result<IPage<SysUser>> iPageResult = sysUserService.queryPageList(req, sysUserQueryWrapper, 100, 1); |
| | | List<String> name = new ArrayList<>(); |
| | | for (SysUser sysUser : iPageResult.getResult().getRecords()){ |
| | | name.add(sysUser.getUsername()); |
| | | } |
| | | name.add(user); |
| | | queryWrapper.nested(wrapper -> { |
| | | // 内层第一个条件:(create_by IN (name) AND review_status != 2) |
| | | wrapper.nested(w1 -> w1.in("create_by", name).ne("review_status", 2)); |
| | | // 内层 OR 条件:(create_by = 最后一个name AND review_status = 2) |
| | | wrapper.or(w2 -> w2.eq("create_by", name.get(name.size()-1)).eq("review_status", 2)); |
| | | }); |
| | | } |
| | | if (role.equals("1972228688033452034")){//财务 |
| | | queryWrapper.ne("review_status", "8"); |
| | | } |
| | | queryWrapper.orderBy( |
| | | true, // condition:是否启用该排序(true=启用) |
| | | false, // isAsc:是否升序(false=降序,让 1 在前、0 在后) |
| | | "CASE WHEN review_status = 1 THEN 1 ELSE 0 END" // R column:虚拟排序列(直接传 SQL 片段) |
| | | ); |
| | | |
| | | queryWrapper.orderBy( |
| | | true, // condition:是否启用该排序(true=启用) |
| | | false, // isAsc:是否升序(false=降序,让 1 在前、0 在后) |
| | | "CASE WHEN review_status = 2 THEN 1 ELSE 0 END" // R column:虚拟排序列(直接传 SQL 片段) |
| | | ); |
| | | |
| | | queryWrapper.orderBy( |
| | | true, // condition:是否启用该排序(true=启用) |
| | | true, // isAsc:是否升序(false=降序,让 1 在前、0 在后) |
| | | "emergency_status" // R column:虚拟排序列(直接传 SQL 片段) |
| | | ); |
| | | |
| | | queryWrapper.orderBy( |
| | | true, // condition:是否启用该排序(true=启用) |
| | | false, // isAsc:是否升序(false=降序,让 1 在前、0 在后) |
| | | "create_time" // R column:虚拟排序列(直接传 SQL 片段) |
| | | ); |
| | | |
| | | // ========== 核心修改部分 ========== |
| | | // 1. 只查询符合条件的合同ID(优化性能,避免查询全量字段) |
| | | queryWrapper.select("id"); // 只选择合同ID字段 |
| | | List<Contract> contractList = contractService.list(queryWrapper); |
| | | |
| | | // 2. 统计semantic_word表的记录数 |
| | | long semanticWordCount = 0L; |
| | | if (!CollectionUtils.isEmpty(contractList)) { |
| | | // 提取所有符合条件的合同ID |
| | | List<String> contractIds = new ArrayList<>(); |
| | | for (Contract c : contractList) { |
| | | contractIds.add(c.getId()); // 假设合同ID字段是id,类型为Long |
| | | } |
| | | |
| | | // 构建semantic_word表的查询条件 |
| | | QueryWrapper<SemanticWord> swQueryWrapper = new QueryWrapper<>(); |
| | | // 假设semantic_word表中关联合同的字段是contract_id,请根据实际表结构调整 |
| | | swQueryWrapper.in("contract_id", contractIds); |
| | | |
| | | // 统计记录数(需要注入SemanticWord对应的Service) |
| | | semanticWordCount = semanticWordService.count(swQueryWrapper); |
| | | } |
| | | |
| | | // 最终结果:semanticWordCount 就是你需要的总记录数 |
| | | System.out.println("semantic_word表总记录数:" + semanticWordCount); |
| | | return Result.OK(semanticWordCount+""); |
| | | } |
| | | |
| | | @Autowired |
| | | private IContractService contractService; |
| | | /** |
| | |
| | | @RequiresPermissions("semanticword:semantic_word:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody SemanticWord semanticWord) { |
| | | if (semanticWord.getStatus().equals("7")){ |
| | | semanticWord.setDistributionTime(new Date()); |
| | | } |
| | | semanticWordService.updateById(semanticWord); |
| | | return Result.OK("编辑成功!"); |
| | | } |