客户资源管理后台管理列表查询...

master
river 4 years ago
parent 015da39810
commit 43a53991a0
  1. 2
      dq-financial-api/src/main/java/com/daqing/financial/hrms/EmployeeControllerApi.java
  2. 44
      dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java
  3. 9
      dq-financial-crms/src/main/java/com/daqing/financial/crms/feign/HrmsFeignService.java
  4. 20
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java
  5. 2
      dq-financial-crms/src/test/java/com/daqing/financial/crms/DqFinancialCrmsApplicationTests.java
  6. 6
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/controller/EmployeeController.java
  7. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/dao/EmployeeDao.java
  8. 2
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/service/impl/EmployeeServiceImpl.java
  9. 4
      dq-financial-hrms/src/main/resources/mapper/hrms/EmployeeDao.xml
  10. 3
      dq-financial-hrms/src/test/java/com/daqing/financial/hrms/DqFinancialHrmsApplicationTests.java

@ -18,5 +18,5 @@ public interface EmployeeControllerApi {
* 根据id查询员工的基本信息和部门信息 * 根据id查询员工的基本信息和部门信息
*/ */
@ApiOperation(value = "根据id查询员工的基本信息和部门信息", notes = "根据id查询员工的基本信息和部门信息") @ApiOperation(value = "根据id查询员工的基本信息和部门信息", notes = "根据id查询员工的基本信息和部门信息")
ResponseResult getEmployeeAndDeptById(List<Long> ids); ResponseResult getEmployeeAndDeptById(Long[] ids);
} }

@ -40,48 +40,4 @@ public class CustomerController implements CustomerControllerApi {
} }
/**
* 信息
*/
@GetMapping("/info/{id}")
//@RequiresPermissions("crms:customer:info")
public ResponseResult info(@PathVariable("id") Long id) {
CustomerEntity customer = customerService.getById(id);
return new ResponseResult<CustomerEntity>().SUCCESS(customer);
}
/**
* 保存
*/
@PostMapping("/save")
//@RequiresPermissions("crms:customer:save")
public ResponseResult save(@RequestBody CustomerEntity customer) {
customerService.save(customer);
return ResponseResult.SUCCESS();
}
/**
* 修改
*/
@PutMapping("/update")
//@RequiresPermissions("crms:customer:update")
public ResponseResult update(@RequestBody CustomerEntity customer) {
customerService.updateById(customer);
return ResponseResult.SUCCESS();
}
/**
* 删除
*/
@DeleteMapping("/delete")
//@RequiresPermissions("crms:customer:delete")
public ResponseResult delete(@RequestBody Long[] ids) {
customerService.removeByIds(Arrays.asList(ids));
return ResponseResult.SUCCESS();
}
} }

@ -4,10 +4,7 @@ import com.daqing.framework.domain.hrms.ext.EmployeeTO;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -21,6 +18,6 @@ public interface HrmsFeignService {
@GetMapping("/hrms/dept/list") @GetMapping("/hrms/dept/list")
ResponseResult list(@RequestParam Map<String, Object> params); ResponseResult list(@RequestParam Map<String, Object> params);
@GetMapping("/hrms/employee/getEmployeeAndDeptById/{ids}") @GetMapping("/hrms/employee/getEmployeeAndDeptById/{ids}") // 远程调用传递集合类型的参数必须以数组封装,不然会导致数据接收不完整
ResponseResult<List<EmployeeTO>> getEmployeeAndDeptById(@PathVariable("ids") List<Long> ids); ResponseResult<List<EmployeeTO>> getEmployeeAndDeptById(@PathVariable("ids") Long[] ids);
} }

@ -1,6 +1,5 @@
package com.daqing.financial.crms.service.impl; package com.daqing.financial.crms.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -20,6 +19,7 @@ import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service("customerService") @Service("customerService")
@ -43,7 +43,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
* @param page 当前页 * @param page 当前页
* @param size 每页条数 * @param size 每页条数
* @param customerRequest 请求参数 * @param customerRequest 请求参数
* @return 所有客户以及信息集合 * @return 所有客户以及关联信息并完成分页的集合
*/ */
@Override @Override
public PageUtils queryList(Integer page, Integer size, CustomerRequest customerRequest) { public PageUtils queryList(Integer page, Integer size, CustomerRequest customerRequest) {
@ -55,6 +55,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
customerRequest.setStartTime(pastTime); customerRequest.setStartTime(pastTime);
} }
} }
// 选择了自定义时间且选择了固定时间则固定时间无效 // 选择了自定义时间且选择了固定时间则固定时间无效
if (customerRequest.getCreateTime() != null && (customerRequest.getStartTime() != null || customerRequest.getEndTime() != null)) { if (customerRequest.getCreateTime() != null && (customerRequest.getStartTime() != null || customerRequest.getEndTime() != null)) {
customerRequest.setCreateTime(null); customerRequest.setCreateTime(null);
@ -65,20 +66,19 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
// 获取所有的客户基本信息 // 获取所有的客户基本信息
List<CustomerEntity> customers = customerEntityIPage.getRecords(); List<CustomerEntity> customers = customerEntityIPage.getRecords();
// 获取所有的客户经理id // 获取所有的客户经理id
List<Long> ids = customers.stream().map(CustomerEntity::getId).collect(Collectors.toList()); Long[] ids = customers.stream().map(CustomerEntity::getId).toArray(Long[]::new);
// 用于拼装客户信息和员工及部门信息的集合 // 用于拼装客户信息和员工及部门信息的集合
List<CustomerTO> customerTOS = new ArrayList<>(); List<CustomerTO> customerTOS = new ArrayList<>();
CustomerTO customerTO = new CustomerTO(); CustomerTO customerTO;
//TODO 远程调用查询客户经理信息的接口 //TODO 远程调用查询客户经理信息的接口
ResponseResult result = hrmsFeignService.getEmployeeAndDeptById(ids); ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids);
List<EmployeeTO> employeeTO = (List<EmployeeTO>) result.getData(); List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData();
/*String data = (String) responseResult.getData();
List<EmployeeTO> employeeTO = JSON.parseArray(data, EmployeeTO.class);*/
// 将客户信息和客户经理及部门信息拼装起来 // 将客户信息和客户经理及部门信息拼装起来
for (CustomerEntity customer : customers) { for (CustomerEntity customer : customers) {
// 每一个客户对应一个不同的对象
customerTO = new CustomerTO();
for (EmployeeTO anEmployeeTO : employeeTO) { for (EmployeeTO anEmployeeTO : employeeTO) {
if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) { if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) {
customerTO.setId(customer.getId()); customerTO.setId(customer.getId());
@ -91,7 +91,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
customerTOS.add(customerTO); customerTOS.add(customerTO);
} }
} }
if (!Objects.equals(customerTO.getId(), customer.getId())){ if (!Objects.equals(customerTO.getId(), customer.getId())) {
customerTO.setId(customer.getId()); customerTO.setId(customer.getId());
customerTO.setCode(customer.getCode()); customerTO.setCode(customer.getCode());
customerTO.setName(customer.getName()); customerTO.setName(customer.getName());

@ -28,7 +28,7 @@ public class DqFinancialCrmsApplicationTests {
/* customerRequest.setStartTime("2020-09-07"); /* customerRequest.setStartTime("2020-09-07");
customerRequest.setEndTime("2020-09-10");*/ customerRequest.setEndTime("2020-09-10");*/
customerRequest.setCustomerType(1); customerRequest.setCustomerType(1);
customerRequest.setCreateTime(3); customerRequest.setCreateTime(12);
PageUtils list = customerServiceimpl.queryList(1, 10, customerRequest); PageUtils list = customerServiceimpl.queryList(1, 10, customerRequest);
List<CustomerTO> list1 = (List<CustomerTO>) list.getList(); List<CustomerTO> list1 = (List<CustomerTO>) list.getList();
list1.forEach(customerEntity -> System.out.println(customerEntity)); list1.forEach(customerEntity -> System.out.println(customerEntity));

@ -82,8 +82,8 @@ public class EmployeeController implements EmployeeControllerApi{
*/ */
@GetMapping("/getEmployeeAndDeptById/{ids}") @GetMapping("/getEmployeeAndDeptById/{ids}")
@Override @Override
public ResponseResult getEmployeeAndDeptById(@PathVariable("ids") List<Long> ids) { public ResponseResult getEmployeeAndDeptById(@RequestBody @PathVariable("ids") Long[] ids) {
List<EmployeeTO> byId = employeeService.getEmployeeAndDeptById(ids); List<EmployeeTO> employeeTO = employeeService.getEmployeeAndDeptById(Arrays.asList(ids));
return new ResponseResult<List<EmployeeTO>>().SUCCESS(byId); return new ResponseResult<List<EmployeeTO>>().SUCCESS(employeeTO);
} }
} }

@ -1,7 +1,5 @@
package com.daqing.financial.hrms.dao; package com.daqing.financial.hrms.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.domain.hrms.EmployeeEntity; import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.daqing.framework.domain.hrms.ext.EmployeeTO; import com.daqing.framework.domain.hrms.ext.EmployeeTO;

@ -14,7 +14,7 @@ public class EmployeeServiceImpl extends ServiceImpl<EmployeeDao, EmployeeEntity
/** /**
* 根据员工id查询员工的姓名和部门信息 * 根据员工id查询员工的姓名和部门信息
* @param ids * @param ids 员工id集合
* @return * @return
*/ */
@Override @Override

@ -27,6 +27,7 @@
</collection> </collection>
</resultMap> </resultMap>
<!-- 根据员工id查询员工的姓名和部门信息 -->
<select id="getEmployeeAndDeptById" resultMap="employeeTO"> <select id="getEmployeeAndDeptById" resultMap="employeeTO">
SELECT e.id eid,e.name emp_name,d.name dept_name SELECT e.id eid,e.name emp_name,d.name dept_name
FROM hrms_employee e FROM hrms_employee e
@ -34,7 +35,8 @@
ON e.id = ed.employee_id ON e.id = ed.employee_id
LEFT JOIN hrms_dept d LEFT JOIN hrms_dept d
ON d.id = ed.dept_id ON d.id = ed.dept_id
WHERE e.id = WHERE e.id
IN
<foreach collection="ids" open="(" separator="," close=")" item="id"> <foreach collection="ids" open="(" separator="," close=")" item="id">
#{id} #{id}
</foreach> </foreach>

@ -26,6 +26,9 @@ public class DqFinancialHrmsApplicationTests {
@Test @Test
public void contextLoads() { public void contextLoads() {
ids.add(1L); ids.add(1L);
ids.add(2L);
ids.add(3L);
ids.add(4L);
List<EmployeeTO> list = employeeServiceimpl.getEmployeeAndDeptById(ids); List<EmployeeTO> list = employeeServiceimpl.getEmployeeAndDeptById(ids);
for (EmployeeTO employeeTO : list) { for (EmployeeTO employeeTO : list) {
System.out.println(employeeTO); System.out.println(employeeTO);

Loading…
Cancel
Save