| | |
| | | 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; |
| | |
| | | |
| | | 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; |
| | |
| | | public class CustomerController extends JeecgController<Customer, ICustomerService> { |
| | | @Autowired |
| | | private ICustomerService customerService; |
| | | |
| | | |
| | | @Autowired |
| | | private ISysUserService sysUserService; |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | |
| | | 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); |
| | |
| | | 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") |
| | |
| | | @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) { |
| | |
| | | } |
| | | Customer one = customerService.getOne(queryWrapper); |
| | | customer.getContract().setCustomerName(one.getEnterpriseName()); |
| | | contractService.save(customer.getContract()); |
| | | |
| | | |
| | | QueryWrapper<Contract> queryWrapper1 = new QueryWrapper<>(); |
| | | queryWrapper1.eq("customer_name",customer.getContract().getCustomerName()); |
| | | queryWrapper1.eq("contract_name",customer.getContract().getContractName()); |
| | | |
| | | if(contractService.count(queryWrapper1) != 0) { |
| | | return Result.error("该合同已存在"); |
| | | } |
| | | contractService.save(customer.getContract()); |
| | | |
| | | Contract one1 = contractService.getOne(queryWrapper1); |
| | | for (SemanticWord semanticWord : customer.getSemanticWordList()){ |
| | | semanticWord.setContractId(one1.getId()); |
| | |
| | | contractFileService.save(contractFile); |
| | | } |
| | | |
| | | contractController.addContract(customer.getContract(),customer.getSemanticWordList()); |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | } |