parent
cc9c3d5b05
commit
19ab4f5aa6
20 changed files with 357 additions and 74 deletions
@ -0,0 +1,21 @@ |
|||||||
|
package com.daqing.financial.hrms; |
||||||
|
|
||||||
|
import com.daqing.framework.model.response.ResponseResult; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @auther River |
||||||
|
* @date 2020/9/9 17:41 |
||||||
|
*/ |
||||||
|
@Api(value = "员工管理相关操作", tags = "提供员工信息增删改查等相关方法") |
||||||
|
public interface EmployeeControllerApi { |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据id查询员工的基本信息和部门信息 |
||||||
|
*/ |
||||||
|
@ApiOperation(value = "根据id查询员工的基本信息和部门信息", notes = "根据id查询员工的基本信息和部门信息") |
||||||
|
ResponseResult getEmployeeAndDeptById(List<Long> ids); |
||||||
|
} |
@ -1,17 +1,22 @@ |
|||||||
package com.daqing.financial.crms.dao; |
package com.daqing.financial.crms.dao; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||||
import com.daqing.framework.domain.crms.CustomerEntity; |
import com.daqing.framework.domain.crms.CustomerEntity; |
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.daqing.framework.domain.crms.request.CustomerRequest; |
||||||
import org.apache.ibatis.annotations.Mapper; |
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
/** |
/** |
||||||
* 记录客户基本信息 |
* 记录客户基本信息 |
||||||
* |
* |
||||||
* @author gongsj |
* @author gongsj |
||||||
* @email gongsj@gmail.com |
* @email gongsj@gmail.com |
||||||
* @date 2020-09-08 09:57:32 |
* @date 2020-09-08 09:57:32 |
||||||
*/ |
*/ |
||||||
@Mapper |
@Mapper |
||||||
public interface CustomerDao extends BaseMapper<CustomerEntity> { |
public interface CustomerDao extends BaseMapper<CustomerEntity> { |
||||||
|
|
||||||
|
IPage<CustomerEntity> queryList(Page page, @Param("cr") CustomerRequest customerRequest); |
||||||
} |
} |
||||||
|
@ -1,43 +1,124 @@ |
|||||||
package com.daqing.financial.crms.service.impl; |
package com.daqing.financial.crms.service.impl; |
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
||||||
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.service.impl.ServiceImpl; |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
import com.daqing.financial.crms.dao.CustomerDao; |
import com.daqing.financial.crms.dao.CustomerDao; |
||||||
|
import com.daqing.financial.crms.feign.HrmsFeignService; |
||||||
import com.daqing.financial.crms.service.CustomerService; |
import com.daqing.financial.crms.service.CustomerService; |
||||||
import com.daqing.framework.domain.crms.CustomerEntity; |
import com.daqing.framework.domain.crms.CustomerEntity; |
||||||
|
import com.daqing.framework.domain.crms.ext.CustomerTO; |
||||||
import com.daqing.framework.domain.crms.request.CustomerRequest; |
import com.daqing.framework.domain.crms.request.CustomerRequest; |
||||||
|
import com.daqing.framework.domain.hrms.ext.EmployeeTO; |
||||||
|
import com.daqing.framework.model.response.ResponseResult; |
||||||
import com.daqing.framework.utils.PageUtils; |
import com.daqing.framework.utils.PageUtils; |
||||||
import com.daqing.framework.utils.Query; |
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
import java.util.Map; |
import java.text.SimpleDateFormat; |
||||||
|
import java.util.*; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
|
||||||
@Service("customerService") |
@Service("customerService") |
||||||
public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity> implements CustomerService { |
public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity> implements CustomerService { |
||||||
|
|
||||||
/*@Override |
@Autowired |
||||||
public PageUtils queryPage(Map<String, Object> params) { |
private CustomerDao customerDao; |
||||||
IPage<CustomerEntity> page = this.page( |
|
||||||
new Query<CustomerEntity>().getPage(params), |
@Autowired |
||||||
new QueryWrapper<CustomerEntity>() |
private HrmsFeignService hrmsFeignService; |
||||||
); |
|
||||||
|
|
||||||
|
public void t() { |
||||||
|
hrmsFeignService.list(new HashMap<>()); |
||||||
|
} |
||||||
|
|
||||||
return new PageUtils(page); |
|
||||||
}*/ |
|
||||||
|
|
||||||
/** |
/** |
||||||
* 查询客户列表(所有)、根据创建时间筛选、根据客户类型筛选、根据客户编号或者名称搜索 |
* 查询客户列表(所有)、根据创建时间筛选、根据客户类型筛选、根据客户编号或者名称搜索 |
||||||
* @param page |
* |
||||||
* @param size |
* @param page 当前页 |
||||||
* @param customerRequest |
* @param size 每页条数 |
||||||
* @return |
* @param customerRequest 请求参数 |
||||||
|
* @return 所有客户以及信息集合 |
||||||
*/ |
*/ |
||||||
@Override |
@Override |
||||||
public PageUtils queryList(Integer page, Integer size, CustomerRequest customerRequest) { |
public PageUtils queryList(Integer page, Integer size, CustomerRequest customerRequest) { |
||||||
|
|
||||||
return null; |
// 没有选择自定义时间且选择了固定的"3个月内、6个月内、9个月内...."时间
|
||||||
|
if (customerRequest.getStartTime() == null && customerRequest.getEndTime() == null && customerRequest.getCreateTime() != null) { |
||||||
|
if (customerRequest.getCreateTime() != 0) { |
||||||
|
String pastTime = pastTime(customerRequest.getCreateTime()); |
||||||
|
customerRequest.setStartTime(pastTime); |
||||||
|
} |
||||||
|
} |
||||||
|
// 选择了自定义时间且选择了固定时间则固定时间无效
|
||||||
|
if (customerRequest.getCreateTime() != null && (customerRequest.getStartTime() != null || customerRequest.getEndTime() != null)) { |
||||||
|
customerRequest.setCreateTime(null); |
||||||
|
} |
||||||
|
Page<Object> pages = new Page<>(page, size); |
||||||
|
IPage<CustomerEntity> customerEntityIPage = customerDao.queryList(pages, customerRequest); |
||||||
|
|
||||||
|
// 获取所有的客户基本信息
|
||||||
|
List<CustomerEntity> customers = customerEntityIPage.getRecords(); |
||||||
|
// 获取所有的客户经理id
|
||||||
|
List<Long> ids = customers.stream().map(CustomerEntity::getId).collect(Collectors.toList()); |
||||||
|
|
||||||
|
// 用于拼装客户信息和员工及部门信息的集合
|
||||||
|
List<CustomerTO> customerTOS = new ArrayList<>(); |
||||||
|
CustomerTO customerTO = new CustomerTO(); |
||||||
|
//TODO 远程调用查询客户经理信息的接口
|
||||||
|
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids); |
||||||
|
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 (EmployeeTO anEmployeeTO : employeeTO) { |
||||||
|
if (Objects.equals(customer.getManager(), anEmployeeTO.getId())) { |
||||||
|
customerTO.setId(customer.getId()); |
||||||
|
customerTO.setCode(customer.getCode()); |
||||||
|
customerTO.setName(customer.getName()); |
||||||
|
customerTO.setPhone(customer.getPhone()); |
||||||
|
customerTO.setType(customer.getType()); |
||||||
|
customerTO.setManager(anEmployeeTO.getEmpName()); |
||||||
|
customerTO.setDepartments(anEmployeeTO.getDeptNames()); |
||||||
|
customerTOS.add(customerTO); |
||||||
|
} |
||||||
|
} |
||||||
|
if (!Objects.equals(customerTO.getId(), customer.getId())){ |
||||||
|
customerTO.setId(customer.getId()); |
||||||
|
customerTO.setCode(customer.getCode()); |
||||||
|
customerTO.setName(customer.getName()); |
||||||
|
customerTO.setPhone(customer.getPhone()); |
||||||
|
customerTO.setType(customer.getType()); |
||||||
|
customerTOS.add(customerTO); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
|
||||||
|
IPage<CustomerTO> iPage = new Page<>(); |
||||||
|
BeanUtils.copyProperties(customerEntityIPage, iPage); |
||||||
|
iPage.setRecords(customerTOS); |
||||||
|
|
||||||
|
return new PageUtils(iPage); |
||||||
} |
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 得到过去number月内的时间 |
||||||
|
* |
||||||
|
* @param number |
||||||
|
* @return 字符串类型 |
||||||
|
*/ |
||||||
|
private String pastTime(Integer number) { |
||||||
|
Date date = new Date(); |
||||||
|
Calendar calendar = Calendar.getInstance(); |
||||||
|
calendar.setTime(date); |
||||||
|
calendar.add(Calendar.MONTH, -number); |
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm"); |
||||||
|
return sdf.format(calendar.getTime()); |
||||||
|
} |
||||||
} |
} |
@ -1,13 +1,43 @@ |
|||||||
package com.daqing.financial.crms; |
package com.daqing.financial.crms; |
||||||
|
|
||||||
|
import com.daqing.financial.crms.service.impl.CustomerServiceImpl; |
||||||
|
import com.daqing.framework.domain.crms.CustomerEntity; |
||||||
|
import com.daqing.framework.domain.crms.ext.CustomerTO; |
||||||
|
import com.daqing.framework.domain.crms.request.CustomerRequest; |
||||||
|
import com.daqing.framework.utils.PageUtils; |
||||||
import org.junit.Test; |
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
import org.springframework.boot.test.context.SpringBootTest; |
import org.springframework.boot.test.context.SpringBootTest; |
||||||
|
import org.springframework.test.context.junit4.SpringRunner; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
@SpringBootTest |
@SpringBootTest |
||||||
class DqFinancialCrmsApplicationTests { |
@RunWith(SpringRunner.class) |
||||||
|
public class DqFinancialCrmsApplicationTests { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private CustomerServiceImpl customerServiceimpl; |
||||||
|
|
||||||
|
CustomerRequest customerRequest = new CustomerRequest(); |
||||||
|
|
||||||
@Test |
@Test |
||||||
void contextLoads() { |
public void queryListTest(){ |
||||||
|
customerRequest.setCodeOrName("20200909"); |
||||||
|
/* customerRequest.setStartTime("2020-09-07"); |
||||||
|
customerRequest.setEndTime("2020-09-10");*/ |
||||||
|
customerRequest.setCustomerType(1); |
||||||
|
customerRequest.setCreateTime(3); |
||||||
|
PageUtils list = customerServiceimpl.queryList(1, 10, customerRequest); |
||||||
|
List<CustomerTO> list1 = (List<CustomerTO>) list.getList(); |
||||||
|
list1.forEach(customerEntity -> System.out.println(customerEntity)); |
||||||
} |
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void t() { |
||||||
|
customerServiceimpl.t(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
} |
} |
||||||
|
@ -1,13 +1,35 @@ |
|||||||
package com.daqing.financial.hrms; |
package com.daqing.financial.hrms; |
||||||
|
|
||||||
|
import com.daqing.financial.hrms.service.impl.EmployeeServiceImpl; |
||||||
|
import com.daqing.framework.domain.crms.CustomerEntity; |
||||||
|
import com.daqing.framework.domain.hrms.EmployeeEntity; |
||||||
|
import com.daqing.framework.domain.hrms.ext.EmployeeTO; |
||||||
|
import com.daqing.framework.utils.PageUtils; |
||||||
import org.junit.Test; |
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
import org.springframework.boot.test.context.SpringBootTest; |
import org.springframework.boot.test.context.SpringBootTest; |
||||||
|
import org.springframework.test.context.junit4.SpringRunner; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
@SpringBootTest |
@SpringBootTest |
||||||
class DqFinancialHrmsApplicationTests { |
@RunWith(SpringRunner.class) |
||||||
|
public class DqFinancialHrmsApplicationTests { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private EmployeeServiceImpl employeeServiceimpl; |
||||||
|
|
||||||
|
List<Long> ids = new ArrayList<>(); |
||||||
|
|
||||||
@Test |
@Test |
||||||
void contextLoads() { |
public void contextLoads() { |
||||||
|
ids.add(1L); |
||||||
|
List<EmployeeTO> list = employeeServiceimpl.getEmployeeAndDeptById(ids); |
||||||
|
for (EmployeeTO employeeTO : list) { |
||||||
|
System.out.println(employeeTO); |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
@ -0,0 +1,52 @@ |
|||||||
|
package com.daqing.framework.domain.crms.ext; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import lombok.ToString; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 返回客户信息包装类 |
||||||
|
* |
||||||
|
* @auther River |
||||||
|
* @date 2020/9/9 10:10 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ToString |
||||||
|
public class CustomerTO implements Serializable { |
||||||
|
|
||||||
|
/** |
||||||
|
* id |
||||||
|
*/ |
||||||
|
private Long id; |
||||||
|
/** |
||||||
|
* 客户编号 |
||||||
|
*/ |
||||||
|
private String code; |
||||||
|
|
||||||
|
/** |
||||||
|
* 客户姓名 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 联系电话 |
||||||
|
*/ |
||||||
|
private String phone; |
||||||
|
|
||||||
|
/** |
||||||
|
* 客户类型 |
||||||
|
*/ |
||||||
|
private Integer type; |
||||||
|
|
||||||
|
/** |
||||||
|
* 客户经理 |
||||||
|
*/ |
||||||
|
private String manager; |
||||||
|
|
||||||
|
/** |
||||||
|
* 所属部门 |
||||||
|
*/ |
||||||
|
private List<String> departments; |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.daqing.framework.domain.hrms.ext; |
||||||
|
|
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.NoArgsConstructor; |
||||||
|
import lombok.ToString; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @auther River |
||||||
|
* @date 2020/9/9 17:53 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ToString |
||||||
|
@NoArgsConstructor |
||||||
|
@AllArgsConstructor |
||||||
|
public class EmployeeTO implements Serializable { |
||||||
|
|
||||||
|
/** |
||||||
|
* id |
||||||
|
*/ |
||||||
|
private Long id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 员工姓名 |
||||||
|
*/ |
||||||
|
private String empName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 部门名称 |
||||||
|
*/ |
||||||
|
private List<String> deptNames; |
||||||
|
} |
Loading…
Reference in new issue