Commit a3b2d1ba authored by 法拉51246's avatar 法拉51246

增加部门管理得数据隔离,增加地图逆解析接口,选择地图自动填充省市区

首页大屏bug修复,业务员数量进行数据隔离
手机号取消校验
客户信息中得客户姓名非必填
parent 084e290c
......@@ -38,7 +38,7 @@ public class UserSaveReqVO {
private String remark;
@Schema(description = "部门编号", example = "我是一个用户")
@NotBlank(message = "部门编号不能为空")
@NotNull(message = "部门编号不能为空")
@DiffLogField(name = "部门", function = DeptParseFunction.NAME)
private Long deptId;
......
......@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@Mapper
public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
......@@ -48,4 +49,7 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
return selectList(AdminUserDO::getDeptId, deptIds);
}
default List<AdminUserDO> selectListInDeptIds(Set<Long> deptCondition){
return selectList(new LambdaQueryWrapperX<AdminUserDO>().inIfPresent(AdminUserDO::getDeptId, deptCondition));
}
}
......@@ -30,7 +30,6 @@ public class CustomerImportExcelVO {
private String customerName;
@ExcelProperty("联系方式")
@Pattern(regexp = "^$|^\\d{11}$", message = "联系方式必须是11位数字")
private String contact;
@ExcelProperty("公司名称")
......
......@@ -24,8 +24,8 @@ public class CustomerInfoRespVO {
@ExcelProperty("客户姓名")
private String customerName;
@Schema(description = "联系方式(客户手机号)", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("联系方式(客户手机号)")
@Schema(description = "联系方式", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("联系方式")
private String contact;
@Schema(description = "公司名称", requiredMode = Schema.RequiredMode.REQUIRED)
......
......@@ -14,11 +14,9 @@ public class CustomerInfoSaveReqVO {
private Long id;
@Schema(description = "客户姓名", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "客户姓名不能为空")
private String customerName;
@Schema(description = "联系方式")
@Pattern(regexp = "^$|^\\d{11}$", message = "联系方式必须是11位数字")
private String contact;
@Schema(description = "公司名称", requiredMode = Schema.RequiredMode.REQUIRED)
......
package cn.iocoder.yudao.module.visit.controller.admin.home;
import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.visit.controller.admin.home.vo.*;
import cn.iocoder.yudao.module.visit.service.customerinfo.CustomerInfoService;
import cn.iocoder.yudao.module.visit.service.home.HomeService;
import cn.iocoder.yudao.module.visit.service.product.ProductService;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
......@@ -17,6 +19,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Year;
import java.time.YearMonth;
import java.util.Map;
import java.util.Objects;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
......@@ -154,5 +157,13 @@ public class HomeController {
return new LocalDateTime[]{startTime, endTime};
}
@GetMapping("/api/map/geocoder")
public CommonResult<Map<String, Object>> getGeocoder(@RequestParam String lat, @RequestParam String lng) {
String key = "2OZBZ-WUCE7-SLKXP-HJVOW-3P6RF-WVB7H";
String url = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + lat + "," + lng + "&key=" + key;
String json = HttpUtil.get(url);
return success(JSON.parseObject(json));
}
}
\ No newline at end of file
......@@ -21,7 +21,7 @@ public class InfoPageReqVO extends PageParam {
@Schema(description = "客户姓名")
private String customerName;
@Schema(description = "联系方式(客户手机号)")
@Schema(description = "联系方式")
private String contact;
@Schema(description = "客户公司名称")
......
......@@ -29,8 +29,8 @@ public class InfoRespVO {
@ExcelProperty("客户姓名")
private String customerName;
@Schema(description = "联系方式(客户手机号)", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("联系方式(客户手机号)")
@Schema(description = "联系方式", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("联系方式")
private String contact;
@Schema(description = "客户公司名称", requiredMode = Schema.RequiredMode.REQUIRED)
......
......@@ -20,8 +20,7 @@ public class InfoSaveReqVO {
@NotEmpty(message = "客户姓名不能为空")
private String customerName;
@Schema(description = "联系方式(客户手机号)")
@Pattern(regexp = "^$|^\\d{11}$", message = "联系方式必须是11位数字")
@Schema(description = "联系方式")
private String contact;
@Schema(description = "客户公司名称", requiredMode = Schema.RequiredMode.REQUIRED)
......
......@@ -2,10 +2,13 @@ package cn.iocoder.yudao.module.visit.service.home;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.visit.controller.admin.customerinfo.vo.CustomerInfoPageReqVO;
import cn.iocoder.yudao.module.visit.controller.admin.home.vo.*;
import cn.iocoder.yudao.module.visit.controller.admin.info.vo.InfoPageReqVO;
......@@ -29,6 +32,8 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
/**
* 主页 Service 实现类
*
......@@ -48,13 +53,20 @@ public class HomeServiceImpl implements HomeService {
private AdminUserMapper userMapper;
@Resource
private DictDataApi dictDataApi;
@Resource
private DeptService deptService;
//首页第一排数据
@Override
public HomeFirstRespVO getHomeInfoFirst(HomeReqVO reqVO) {
HomeFirstRespVO homeFirstRespVO = new HomeFirstRespVO();
//业务员数量(不按时间)
List<AdminUserDO> userDOS = userMapper.selectList();
Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();//查出登录用户的deptId
Set<Long> deptCondition = Collections.emptySet();//默认不限制
if (loginUserDeptId == null || !loginUserDeptId.equals(100L)) {//说明是总公司,不限制
deptCondition = getDeptCondition(loginUserDeptId);//不是总公司了,就递归查询该部门以及子部门的所有id
}
List<AdminUserDO> userDOS = userMapper.selectListInDeptIds(deptCondition);
homeFirstRespVO.setYwysl(String.valueOf(userDOS.size()));
//按创建时间查这段时间的客户数量
CustomerInfoPageReqVO customerInfoPageReqVO = new CustomerInfoPageReqVO();
......@@ -92,7 +104,20 @@ public class HomeServiceImpl implements HomeService {
.count()));
return homeFirstRespVO;
}
/**
* 获得部门条件:查询指定部门的子部门编号们,包括自身
*
* @param deptId 部门编号
* @return 部门编号集合
*/
private Set<Long> getDeptCondition(Long deptId) {
if (deptId == null) {
return Collections.emptySet();
}
Set<Long> deptIds = convertSet(deptService.getChildDeptList(deptId), DeptDO::getId);
deptIds.add(deptId); // 包括自身
return deptIds;
}
//拜访周统计
@Override
public HomeBfztjRespVO getHomeInfoBfztj(HomeReqVO reqVO) {
......@@ -114,7 +139,7 @@ public class HomeServiceImpl implements HomeService {
List<Integer> counts = new ArrayList<>();
for (int i = 0; i < 10; i++) {
LocalDateTime weekStart = start.plusWeeks(i);
LocalDateTime weekStart = start.plusWeeks(i).with(LocalTime.MIN);;
LocalDateTime weekEnd = weekStart.plusDays(6).with(LocalTime.MAX);
LocalDateTime[] week = new LocalDateTime[]{weekStart, weekEnd};
if (weekStart.isAfter(end)) break;
......
......@@ -38,4 +38,8 @@ export const homesApi = {
getHomeInfoBfcplxzbqk: async (params: any) => {
return await request.get({ url: `/visit/home/getHomeInfoBfcplxzbqk`, params })
},
// 地图逆解析
getMapGeocoder: async (params: any) => {
return await request.get({ url: `/visit/home/api/map/geocoder`, params })
},
}
......@@ -104,6 +104,7 @@ import {FormRules} from 'element-plus'
import {getRefreshToken, getTenantId, setToken} from "@/utils/auth";
import axios from "axios";
import {config} from "@/config/axios/config";
import {useUserStoreWithOut} from "@/store/modules/user";
defineOptions({ name: 'SystemUserForm' })
......@@ -194,6 +195,8 @@ const submitForm = async () => {
const refreshTokenRes = await refreshToken()
// 2.1 刷新成功,则回放队列的请求 + 当前请求
setToken((await refreshTokenRes).data.data)
const userStore = useUserStoreWithOut()
await userStore.setUserInfoAction()
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
......
......@@ -230,7 +230,7 @@ const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
if (userStore.user.deptId!==100){//如果不是总公司用户,再过滤,总公司用户可以看到所有
if (userStore.user.deptId!==100&&(queryParams.deptId===null||queryParams.deptId===undefined)){//如果不是总公司用户,再过滤,总公司用户可以看到所有
queryParams.deptId = userStore.user.deptId
}
try {
......
......@@ -104,6 +104,7 @@ import { CustomerInfoApi, CustomerInfoVO } from '@/api/visit/customerinfo'
import { pcaTextArr } from 'element-china-area-data'
import MapPicker from '../util/MapPicker.vue'
import productTable from './productTable.vue'
import {homesApi} from "@/api/visit/home";
/** 客户信息 表单 */
defineOptions({ name: 'CustomerInfoForm' })
......@@ -152,7 +153,6 @@ const formData = ref<CustomerFormData>({
department: undefined,
})
const formRules = reactive({
customerName: [{ required: true, message: '客户姓名不能为空', trigger: 'blur' }],
companyName: [{ required: true, message: '公司名称不能为空', trigger: 'blur' }],
customerType: [{ required: true, message: '性质等级不能为空', trigger: 'change' }],
department: [{ required: true, message: '客户部门不能为空', trigger: 'change' }],
......@@ -199,6 +199,36 @@ const handleLocation = ({ lat, lng, address }) => {
formData.value.locationImage = mapUrl
//逆地址解析
const params: any = {
lat: lat,
lng: lng
}
homesApi.getMapGeocoder(params).then(res => {
console.log('逆地址解析结果:', res)
if (res.status === 0) {
const comp = res.result.address_component
// 赋值到 formData
formData.value.provinceName = comp.province || ''
formData.value.cityName = comp.city || ''
formData.value.areaName = comp.district || ''
formData.value.regionFullName = comp.province + comp.city + comp.district
const province = formData.value.provinceName ?? ''
let city = formData.value.cityName ?? ''
const area = formData.value.areaName ?? ''
//将省市区修改格式赋值给selectedOptions
if(province.match(/(北京|上海|天津|重庆)/)){
city = '市辖区'
}
selectedOptions.value = [province, city, area]//专门回显用的
} else {
console.warn('逆地址解析失败:', res.data.message)
}
}).catch(err => {
console.log(err)
})
}
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
......
......@@ -142,6 +142,8 @@ import productTable from "@/views/visit/customerinfo/productTable.vue";
import { pcaTextArr } from 'element-china-area-data'
import MapPicker from '../util/MapPicker.vue'
import { onMounted } from 'vue'
import request from "@/config/axios";
import {homesApi} from "@/api/visit/home";
/** 客户拜访记录 表单 */
defineOptions({ name: 'InfoForm' })
......@@ -299,6 +301,35 @@ const handleLocation = ({ lat, lng, address }) => {
const mapUrl = `https://apis.map.qq.com/ws/staticmap/v2/?center=${lat},${lng}&zoom=13&size=600*300&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${lat},${lng}&key=${mapKey}`
formData.value.locationImage = mapUrl
//逆地址解析
const params: any = {
lat: lat,
lng: lng
}
homesApi.getMapGeocoder(params).then(res => {
console.log('逆地址解析结果:', res)
if (res.status === 0) {
const comp = res.result.address_component
// 赋值到 formData
formData.value.provinceName = comp.province || ''
formData.value.cityName = comp.city || ''
formData.value.areaName = comp.district || ''
formData.value.regionFullName = comp.province + comp.city + comp.district
const province = formData.value.provinceName ?? ''
let city = formData.value.cityName ?? ''
const area = formData.value.areaName ?? ''
//将省市区修改格式赋值给selectedOptions
if(province.match(/(北京|上海|天津|重庆)/)){
city = '市辖区'
}
selectedOptions.value = [province, city, area]//专门回显用的
} else {
console.warn('逆地址解析失败:', res.data.message)
}
}).catch(err => {
console.log(err)
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment