提交 48a823a5 authored 作者: 李秋林's avatar 李秋林

勤策数据拉取;门店 - 查询名称模糊查询、有效数据查询

上级 292af7e5
package com.wangxiaolu.promotion.controller.user;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.pojo.user.vo.ClienteleStoreQueryVo;
import com.wangxiaolu.promotion.service.user.QinCeClienteleDataQueryService;
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 java.util.List;
/**
* @author : liqiulin
* @date : 2024-04-22 17
* @describe : 【勤策 - 客户数据】查询
*/
@RestController
@RequestMapping("/user/clientele/query")
public class QinCeClienteleDataQueryController {
@Autowired
QinCeClienteleDataQueryService qinCeClienteleDataQueryService;
/**
* 【勤策 - 客户数据 - 终端】数据查询
* 模糊查询门店名称
*/
@PostMapping("/store/list")
public List<QinCeClienteleStoreDto> getStoreList(@RequestBody ClienteleStoreQueryVo storeQueryVo){
return qinCeClienteleDataQueryService.getStoreList(storeQueryVo);
}
}
package com.wangxiaolu.promotion.domain.user.dao;
import com.alibaba.fastjson.JSONArray;
import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-04-22 16
* @describe :
*/
public interface QinCeClienteleShopDao {
public interface QinCeClienteleStoreDao {
/**
* 勤策人员数据同步
*/
void shopDetailAllTask(JSONArray responseDatas);
List<QinCeClienteleStoreDto> getStoreList(StoreWrapper storeWrapper);
}
package com.wangxiaolu.promotion.domain.user.dao.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleShopDao;
import com.wangxiaolu.promotion.domain.user.mapper.QinCeClienteleShopMapper;
import com.wangxiaolu.promotion.domain.user.mapper.entity.QinCeClienteleShopDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-04-22 16
* @describe :
*/
@Slf4j
@Service
public class QinCeClienteleShopDaoImpl implements QinCeClienteleShopDao {
@Autowired
QinCeClienteleShopMapper qinCeClienteleShopMapper;
@Override
public void shopDetailAllTask(JSONArray responseDatas) {
LambdaQueryWrapper<QinCeClienteleShopDO> qw = new LambdaQueryWrapper<>();
for (Object responseData : responseDatas) {
qw.clear();
QinCeClienteleShopDO qinCeShopDO = JSONObject.parseObject(responseData.toString(), QinCeClienteleShopDO.class);
qw.eq(QinCeClienteleShopDO::getQcId, qinCeShopDO.getQcId());
QinCeClienteleShopDO doExist = qinCeClienteleShopMapper.selectOne(qw);
if (Objects.isNull(doExist)) {
qinCeClienteleShopMapper.insert(qinCeShopDO);
} else {
qinCeShopDO.setId(doExist.getId());
qinCeClienteleShopMapper.updateById(qinCeShopDO);
}
}
}
}
package com.wangxiaolu.promotion.domain.user.dao.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleStoreDao;
import com.wangxiaolu.promotion.domain.user.mapper.QinCeClienteleStoreMapper;
import com.wangxiaolu.promotion.domain.user.mapper.entity.QinCeClienteleStoreDO;
import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-04-22 16
* @describe :
*/
@Slf4j
@Service
public class QinCeClienteleStoreDaoImpl implements QinCeClienteleStoreDao {
@Autowired
QinCeClienteleStoreMapper qinCeClienteleStoreMapper;
/**
* 拉取信息
* @param responseDatas 信息json格式数据
*/
@Override
public void shopDetailAllTask(JSONArray responseDatas) {
LambdaQueryWrapper<QinCeClienteleStoreDO> qw = new LambdaQueryWrapper<>();
for (Object responseData : responseDatas) {
qw.clear();
QinCeClienteleStoreDO qinCeShopDO = JSONObject.parseObject(responseData.toString(), QinCeClienteleStoreDO.class);
qw.eq(QinCeClienteleStoreDO::getQcId, qinCeShopDO.getQcId());
QinCeClienteleStoreDO doExist = qinCeClienteleStoreMapper.selectOne(qw);
if (Objects.isNull(doExist)) {
qinCeClienteleStoreMapper.insert(qinCeShopDO);
} else {
qinCeShopDO.setId(doExist.getId());
qinCeClienteleStoreMapper.updateById(qinCeShopDO);
}
}
}
/**
* 查询门店列表
* @param storeWrapper 查询条件
*/
@Override
public List<QinCeClienteleStoreDto> getStoreList(StoreWrapper storeWrapper) {
LambdaQueryWrapper<QinCeClienteleStoreDO> qw = builderQueryWrapper(storeWrapper);
// 指定字段查询
qw.select(QinCeClienteleStoreDO::getQcId,
QinCeClienteleStoreDO::getStoreName,
QinCeClienteleStoreDO::getStoreAddr);
List<QinCeClienteleStoreDO> qinCeClienteleStoreDOS = qinCeClienteleStoreMapper.selectList(qw);
List<QinCeClienteleStoreDto> storeDtos = transitionDtos(qinCeClienteleStoreDOS);
return storeDtos;
}
private LambdaQueryWrapper<QinCeClienteleStoreDO> builderQueryWrapper(StoreWrapper storeWrapper){
LambdaQueryWrapper<QinCeClienteleStoreDO> qw = new LambdaQueryWrapper<>();
// 按门店名称模糊查询
if (Objects.nonNull(storeWrapper.getStoreNameVague())){
qw.like(QinCeClienteleStoreDO::getStoreName,storeWrapper.getStoreNameVague());
}
/**
* 默认查询有效数据
* 门店删除状态。0:删除,1:正常:store_status = 1
* 门店审批状态。1:待审批,2:审批打回,3:审批通过:store_approval_status = 3
*/
qw.eq(QinCeClienteleStoreDO::getStoreStatus,storeWrapper.getStoreStatus());
qw.eq(QinCeClienteleStoreDO::getStoreApprovalStatus,storeWrapper.getStoreApprovalStatus());
return qw;
}
/**
* DO to DTO (单个对象)
* @param storeDO DO对象
* @return DTO对象
*/
private QinCeClienteleStoreDto transitionDto(QinCeClienteleStoreDO storeDO){
QinCeClienteleStoreDto storedDto = null;
if (!Objects.isNull(storeDO)){
storedDto = new QinCeClienteleStoreDto();
BeanUtils.copyProperties(storeDO, storedDto);
}
return storedDto;
}
private List<QinCeClienteleStoreDto> transitionDtos(List<QinCeClienteleStoreDO> storeDOs) {
if (CollectionUtils.isEmpty(storeDOs)) {
return new ArrayList<>();
}
List<QinCeClienteleStoreDto> dtos = new ArrayList<>(storeDOs.size() * 2);
for (QinCeClienteleStoreDO storeDO : storeDOs) {
QinCeClienteleStoreDto storeDto = transitionDto(storeDO);
dtos.add(storeDto);
}
return dtos;
}
}
package com.wangxiaolu.promotion.domain.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wangxiaolu.promotion.domain.user.mapper.entity.QinCeClienteleShopDO;
import com.wangxiaolu.promotion.domain.user.mapper.entity.QinCeClienteleStoreDO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
......@@ -13,7 +13,7 @@ import org.springframework.stereotype.Repository;
*/
@Mapper
@Repository
public interface QinCeClienteleShopMapper extends BaseMapper<QinCeClienteleShopDO> {
public interface QinCeClienteleStoreMapper extends BaseMapper<QinCeClienteleStoreDO> {
}
......
package com.wangxiaolu.promotion.domain.user.wrapperQo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* @author : liqiulin
* @date : 2024-04-22 17
* @describe : 门店信息查询对象
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Accessors(chain = true)
public class StoreWrapper {
/**
* 按名称模糊查询
*/
private String storeNameVague;
/**
* 默认查询有效数据
* 门店删除状态。0:删除,1:正常:store_status = 1
* 门店审批状态。1:待审批,2:审批打回,3:审批通过:store_approval_status = 3
*/
private String storeStatus = "1";
private String storeApprovalStatus = "3";
}
package com.wangxiaolu.promotion.pojo.user.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* @author : liqiulin
* @date : 2024-04-22 18
* @describe : store-DTO
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Accessors(chain = true)
public class QinCeClienteleStoreDto {
/**
* 勤策的门店唯一ID
*/
private String qcId;
private String storeName;
private String storeAddr;
}
package com.wangxiaolu.promotion.pojo.user.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* @author : liqiulin
* @date : 2024-04-22 17
* @describe : 按条件查询门店信息
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Accessors(chain = true)
public class ClienteleStoreQueryVo {
/**
* 按名称模糊查询
*/
private String storeNameVague;
/**
* 默认查询有效数据
* 门店删除状态。0:删除,1:正常:store_status = 1
* 门店审批状态。1:待审批,2:审批打回,3:审批通过:store_approval_status = 3
*/
private String storeStatus = "1";
private String storeApprovalStatus = "3";
}
package com.wangxiaolu.promotion.service.user;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.pojo.user.vo.ClienteleStoreQueryVo;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-04-22 17
* @describe :
*/
public interface QinCeClienteleDataQueryService {
List<QinCeClienteleStoreDto> getStoreList(ClienteleStoreQueryVo storeQueryVo);
}
package com.wangxiaolu.promotion.service.user.impl;
import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleStoreDao;
import com.wangxiaolu.promotion.domain.user.wrapperQo.StoreWrapper;
import com.wangxiaolu.promotion.pojo.user.dto.QinCeClienteleStoreDto;
import com.wangxiaolu.promotion.pojo.user.vo.ClienteleStoreQueryVo;
import com.wangxiaolu.promotion.service.user.QinCeClienteleDataQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author : liqiulin
* @date : 2024-04-22 17
* @describe :
*/
@Slf4j
@Service
public class QinCeClienteleDataQueryServiceImpl implements QinCeClienteleDataQueryService {
@Autowired
QinCeClienteleStoreDao qinCeClienteleStoreDao;
@Override
public List<QinCeClienteleStoreDto> getStoreList(ClienteleStoreQueryVo storeQueryVo) {
StoreWrapper sw = new StoreWrapper();
BeanUtils.copyProperties(storeQueryVo,sw);
return qinCeClienteleStoreDao.getStoreList(sw);
}
}
......@@ -2,7 +2,7 @@ package com.wangxiaolu.promotion.service.user.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleShopDao;
import com.wangxiaolu.promotion.domain.user.dao.QinCeClienteleStoreDao;
import com.wangxiaolu.promotion.domain.user.dao.QinCeDepartmentDao;
import com.wangxiaolu.promotion.domain.user.dao.QinCeEmployeeDao;
import com.wangxiaolu.promotion.service.user.QinCeDataTaskService;
......@@ -30,7 +30,7 @@ public class QinCeDataTaskServiceImpl implements QinCeDataTaskService {
@Autowired
QinCeEmployeeDao qinCeEmployeeDao;
@Autowired
QinCeClienteleShopDao qinCeClienteleShopDao;
QinCeClienteleStoreDao qinCeClienteleShopDao;
@Override
public void departmentSyncTask() {
......
......@@ -2,9 +2,9 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wangxiaolu.promotion.domain.user.mapper.QinCeClienteleShopMapper">
<mapper namespace="com.wangxiaolu.promotion.domain.user.mapper.QinCeClienteleStoreMapper">
<resultMap id="BaseResultMap" type="com.wangxiaolu.promotion.domain.user.mapper.entity.QinCeClienteleShopDO">
<resultMap id="BaseResultMap" type="com.wangxiaolu.promotion.domain.user.mapper.entity.QinCeClienteleStoreDO">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="qcId" column="qc_id" jdbcType="VARCHAR"/>
<result property="storeId" column="store_id" jdbcType="VARCHAR"/>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论