Browse Source

ETC账户列表查询

master
qiubh 1 month ago
parent
commit
b4e7df7066

+ 1
- 1
gly-base-core/src/main/java/cn/com/taiji/core/repo/jpa/basic/QtkCustomerInfoRepo.java View File

@@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query;
import java.util.List;

public interface QtkCustomerInfoRepo extends AbstractJpaRepo<QtkCustomerInfo, String>{
@Query(" from QtkCustomerInfo where customerTel = ?1 ")
@Query(" from QtkCustomerInfo where customerTel = ?1 order by insertTime")
public List<QtkCustomerInfo> listByMobile(String mobile);

@Query("from QtkCustomerInfo where customerId=?1")

+ 4
- 0
gly-base-core/src/main/java/cn/com/taiji/core/repo/jpa/basic/QtkVehicleInfoRepo.java View File

@@ -27,4 +27,8 @@ public interface QtkVehicleInfoRepo extends AbstractJpaRepo<QtkVehicleInfo, Stri

@Query("select count(1) from QtkVehicleInfo where customerId = ?1 ")
public Integer countByCustomerId(String customerId);

@Query("select customerId, count(1) from QtkVehicleInfo where customerId in ?1 group by customerId")
public List<Object[]> groupByCustomerId(List<String> customerIds);

}

+ 34
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/api/comm/CustomerController.java View File

@@ -0,0 +1,34 @@
package cn.com.taiji.iaw.api.comm;

import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.common.web.ApiResponse;
import cn.com.taiji.core.dto.AbstractBizRequestDTO;
import cn.com.taiji.iaw.api.MyValidController;
import cn.com.taiji.iaw.dto.comm.CustomerQueryResponseDTO;
import cn.com.taiji.iaw.manager.comm.CustomerManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

@Api(tags = {"ETC账户查询"})
@RestController
@RequestMapping("/api/customer")
public class CustomerController extends MyValidController {

@Autowired
private CustomerManager manager;

@ApiOperation("地址列表查询")
@PostMapping("/query")
public ApiResponse<List<CustomerQueryResponseDTO>> query(@Valid @RequestBody AbstractBizRequestDTO dto) throws ManagerException {
return ApiResponse.of(manager.query(dto));
}

}

+ 1
- 1
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/api/comm/OcrController.java View File

@@ -24,7 +24,7 @@ public class OcrController extends MyValidController {
@Autowired
private OcrManager manager;

@ApiOperation(value = "CR识别接口")
@ApiOperation(value = "OCR识别接口")
@PostMapping(value = "/do")
public ApiResponse<AbstractAtsResponse> doOcr(@Valid @RequestBody OcrRequestDTO reqDto) throws ManagerException {
AbstractAtsResponse resDto = manager.ocr(reqDto);

+ 31
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/dto/comm/CustomerQueryResponseDTO.java View File

@@ -0,0 +1,31 @@
package cn.com.taiji.iaw.dto.comm;

import cn.com.taiji.common.model.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@ApiModel(description = "客戶列表查询")
@Getter
@Setter
@Accessors(chain = true)
public class CustomerQueryResponseDTO extends BaseModel {

@ApiModelProperty(value = "用户编号",required = true)
private String customerId;
@ApiModelProperty(value = "证件号码",required = true)
private String idNum;
@ApiModelProperty(value = "证件类型ID_TYPE",required = true)
private Integer idType;
@ApiModelProperty(value = "用户类型USER_TYPE",required = true)
private Integer userType;
@ApiModelProperty(value = "用户名称",required = true)
private String userName;// 用户姓名/企业名称
@ApiModelProperty(value = "部门",required = false)
private String department;
@ApiModelProperty(value = "车辆数",required = true)
private Integer vehicleCount;

}

+ 15
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/comm/CustomerManager.java View File

@@ -0,0 +1,15 @@
package cn.com.taiji.iaw.manager.comm;


import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.core.dto.AbstractBizRequestDTO;
import cn.com.taiji.iaw.dto.comm.CustomerQueryResponseDTO;

import java.util.List;

public interface CustomerManager {


List<CustomerQueryResponseDTO> query(AbstractBizRequestDTO dto) throws ManagerException;

}

+ 61
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/comm/CustomerManagerImpl.java View File

@@ -0,0 +1,61 @@
package cn.com.taiji.iaw.manager.comm;

import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.core.dto.AbstractBizRequestDTO;
import cn.com.taiji.core.entity.basic.QtkCustomerInfo;
import cn.com.taiji.core.entity.user.AccountInfo;
import cn.com.taiji.core.repo.jpa.basic.QtkCustomerInfoRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkVehicleInfoRepo;
import cn.com.taiji.iaw.dto.comm.CustomerQueryResponseDTO;
import cn.com.taiji.iaw.manager.AbstractCommManager;
import com.google.common.collect.Maps;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service
public class CustomerManagerImpl extends AbstractCommManager implements CustomerManager {

@Autowired
private QtkCustomerInfoRepo customerInfoRepo;
@Autowired
private QtkVehicleInfoRepo vehicleInfoRepo;

@Override
public List<CustomerQueryResponseDTO> query(AbstractBizRequestDTO dto) throws ManagerException {
AccountInfo accountInfo = findAccountInfoByToken(dto.getAccessToken());
List<CustomerQueryResponseDTO> list = Lists.newArrayList();
// 未实名认证
if (hasText(accountInfo.getIdNum()))
return list;
List<QtkCustomerInfo> customerInfoList = customerInfoRepo.listByMobile(accountInfo.getMobile());
if (isEmpty(customerInfoList))
return list;
// 统计车辆情况
List<Object[]> result = vehicleInfoRepo.groupByCustomerId(customerInfoList.stream().map(QtkCustomerInfo :: getCustomerId).collect(Collectors.toList()));
Map<String, Object[]> vehicleMap = Maps.newConcurrentMap();
if (isEmpty(result)) {
vehicleMap = result.stream().collect(Collectors.toMap(o -> o[0].toString(), Function.identity()));
}
for (QtkCustomerInfo customerInfo : customerInfoList) {
CustomerQueryResponseDTO model = new CustomerQueryResponseDTO();
model.setCustomerId(customerInfo.getCustomerId());
model.setIdNum(customerInfo.getCustomerIdNum());
model.setIdType(customerInfo.getCustomerIdType().getCode());
model.setUserType(customerInfo.getUserType().getCode());
model.setUserName(customerInfo.getCustomerName());
model.setDepartment(customerInfo.getDepartment());
Object[] vehicleCount = vehicleMap.get(model.getCustomerId());
model.setVehicleCount(vehicleCount==null?0:Integer.valueOf(vehicleCount[1].toString()));
list.add(model);
}
return list;
}


}

Loading…
Cancel
Save