chengf
2026-01-29 67460d9dd51a5185dc0f7cb872dce43789d54643
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/demo/customer/controller/CustomerController.java
@@ -15,6 +15,7 @@
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.contract.controller.ContractController;
import org.jeecg.modules.demo.contract.entity.Contract;
import org.jeecg.modules.demo.contract.entity.ContractFile;
import org.jeecg.modules.demo.contract.entity.SemanticWord;
@@ -32,6 +33,7 @@
import org.jeecg.modules.system.controller.SysUserController;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -64,7 +66,9 @@
public class CustomerController extends JeecgController<Customer, ICustomerService> {
   @Autowired
   private ICustomerService customerService;
     @Autowired
     private ISysUserService sysUserService;
   /**
    * 分页列表查询
    *
@@ -90,6 +94,9 @@
            queryWrapper.eq(Customer::getAgentsName,customer.getAgentsNameToCustomer());
            queryWrapper.or();
            queryWrapper.eq(Customer::getCreateBy,customer.getAgentsNameToCustomer());
            queryWrapper.or();
            queryWrapper.exists("SELECT 1 FROM contract WHERE contract.agents_name = {0} AND contract.customer_name = customer.enterprise_name",
                    customer.getAgentsNameToCustomer());
            // 2. 查询字段值,返回Object列表
            List<Object> objList = customerService.listObjs(queryWrapper);
@@ -108,6 +115,49 @@
      IPage<Customer> pageList = customerService.page(page, queryWrapper);
      return Result.OK(pageList);
   }
     @Operation(summary="客户表-查询总客户数")
     @GetMapping(value = "/count")
     public Result<IPage<Customer>> count(Customer customer,
                                          @RequestParam(name="role", defaultValue="无") String role,
                                          @RequestParam(name="user", defaultValue="无") String user,
                                                  HttpServletRequest req) {
         if (customer.getAgentsNameToCustomer() != null) {
             // 1. 构建Lambda查询条件,指定查询enterpriseName字段并去重
             LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<Customer>()
                     .select(Customer::getEnterpriseName); // 关联实体的getter方法
             // 可选:添加原有条件(如agentsName不为空)
             queryWrapper.eq(Customer::getAgentsName,customer.getAgentsNameToCustomer());
             queryWrapper.or();
             queryWrapper.eq(Customer::getCreateBy,customer.getAgentsNameToCustomer());
             queryWrapper.or();
             queryWrapper.exists("SELECT 1 FROM contract WHERE contract.agents_name = {0} AND contract.customer_name = customer.enterprise_name",
                     customer.getAgentsNameToCustomer());
             // 2. 查询字段值,返回Object列表
             List<Object> objList = customerService.listObjs(queryWrapper);
             // 3. 转换为String类型,并过滤null值
             if (CollectionUtils.isEmpty(objList)) {
                 return Result.ok(List.of().toString());
             }
             return Result.ok(objList.stream()
                     .filter(Objects::nonNull) // 过滤null值
                     .map(Object::toString) // 转换为String
                     .collect(Collectors.toList()).toString());
         }
         QueryWrapper<Customer> queryWrapper = QueryGenerator.initQueryWrapper(customer, req.getParameterMap());
         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);
         }
         long count = customerService.count(queryWrapper);
         return Result.OK(count+"");
     }
     @Operation(summary="客户表-分页列表查询")
     @GetMapping(value = "/listAgents")
@@ -254,6 +304,9 @@
     @Autowired
     private ISemanticWordService semanticWordService;
     @Autowired
     private ContractController  contractController;
     @RequiresPermissions("customer:customer:importCustomerContractWord")
     @RequestMapping(value = "/importCustomerContractWord", method = RequestMethod.POST)
     public Result<String> importCustomerContractWord(@RequestBody Customer customer) {
@@ -337,6 +390,7 @@
             contractFileService.save(contractFile);
         }
         contractController.addContract(customer.getContract(),customer.getSemanticWordList());
         return Result.OK("添加成功!");
     }
}