Commit 41a5659c by 杨林龙

试驾报表导出增加区省市 巡回员字段

1 parent 0f68f121
......@@ -6,12 +6,27 @@ import lombok.Data;
@Data
public class BaseOrgDto {
/**
* 区
*/
@ExcelIgnore
private String area;
/**
* 省
*/
@ExcelIgnore
private String province;
/**
* 市
*/
@ExcelIgnore
private String city;
/**
* 创建人Id
*/
@ExcelIgnore
private Long createdBy;
......
package cn.com.glsx.admin.modules.model;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
@Data
public class ReportOrgDto {
/**
* 区
*/
@ExcelProperty(value = "区", index = 0)
private String area;
/**
* 省
*/
@ExcelProperty(value = "省", index = 1)
private String province;
/**
* 市
*/
@ExcelProperty(value = "市", index = 2)
private String city;
/**
* 巡回员
*/
@ExcelProperty(value = "巡回员", index = 3)
private String itineracy;
/**
* 创建人id
*/
@ExcelIgnore
private Long createdBy;
}
package cn.com.glsx.admin.modules.model.export;
import cn.com.glsx.admin.modules.model.ReportOrgDto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
......@@ -10,125 +11,125 @@ import lombok.Data;
* @Date 2021/1/19
*/
@Data
public class ElectricInStoreExport {
public class ElectricInStoreExport extends ReportOrgDto {
/**
* 车辆Id
*/
@ExcelIgnore
private Long vehicleId;
@ExcelProperty(value = "特约店代码", index = 0)
@ExcelProperty(value = "特约店代码", index = 4)
private String shopCode;
@ExcelProperty(value = "特约店名称", index = 1)
@ExcelProperty(value = "特约店名称", index = 5)
private String shopName;
@ExcelProperty(value = "车型", index = 2)
@ExcelProperty(value = "车型", index = 6)
private String modelName;
@ExcelProperty(value = "设备号", index = 3)
@ExcelProperty(value = "设备号", index = 7)
private String sn;
@ExcelProperty(value = "车架号VIN码", index = 4)
@ExcelProperty(value = "车架号VIN码", index = 8)
private String vin;
// 年月
@ExcelProperty(value = "时间", index = 5)
@ExcelProperty(value = "时间", index = 9)
private String statDate;
@ExcelProperty(value = "1日", index = 6)
@ExcelProperty(value = "1日", index = 10)
private Integer dayNum1;
@ExcelProperty(value = "2日", index = 7)
@ExcelProperty(value = "2日", index = 11)
private Integer dayNum2;
@ExcelProperty(value = "3日", index = 8)
@ExcelProperty(value = "3日", index = 12)
private Integer dayNum3;
@ExcelProperty(value = "4日", index = 9)
@ExcelProperty(value = "4日", index = 13)
private Integer dayNum4;
@ExcelProperty(value = "5日", index = 10)
@ExcelProperty(value = "5日", index = 14)
private Integer dayNum5;
@ExcelProperty(value = "6日", index = 11)
@ExcelProperty(value = "6日", index = 15)
private Integer dayNum6;
@ExcelProperty(value = "7日", index = 12)
@ExcelProperty(value = "7日", index = 16)
private Integer dayNum7;
@ExcelProperty(value = "8日", index = 13)
@ExcelProperty(value = "8日", index = 17)
private Integer dayNum8;
@ExcelProperty(value = "9日", index = 14)
@ExcelProperty(value = "9日", index = 18)
private Integer dayNum9;
@ExcelProperty(value = "10日", index = 15)
@ExcelProperty(value = "10日", index = 19)
private Integer dayNum10;
@ExcelProperty(value = "11日", index = 16)
@ExcelProperty(value = "11日", index = 20)
private Integer dayNum11;
@ExcelProperty(value = "12日", index = 17)
@ExcelProperty(value = "12日", index = 21)
private Integer dayNum12;
@ExcelProperty(value = "13日", index = 18)
@ExcelProperty(value = "13日", index = 22)
private Integer dayNum13;
@ExcelProperty(value = "14日", index = 19)
@ExcelProperty(value = "14日", index = 23)
private Integer dayNum14;
@ExcelProperty(value = "15日", index = 20)
@ExcelProperty(value = "15日", index = 24)
private Integer dayNum15;
@ExcelProperty(value = "16日", index = 21)
@ExcelProperty(value = "16日", index = 25)
private Integer dayNum16;
@ExcelProperty(value = "17日", index = 22)
@ExcelProperty(value = "17日", index = 26)
private Integer dayNum17;
@ExcelProperty(value = "18日", index = 23)
@ExcelProperty(value = "18日", index = 27)
private Integer dayNum18;
@ExcelProperty(value = "19日", index = 24)
@ExcelProperty(value = "19日", index = 28)
private Integer dayNum19;
@ExcelProperty(value = "20日", index = 25)
@ExcelProperty(value = "20日", index = 29)
private Integer dayNum20;
@ExcelProperty(value = "21日", index = 26)
@ExcelProperty(value = "21日", index = 30)
private Integer dayNum21;
@ExcelProperty(value = "22日", index = 27)
@ExcelProperty(value = "22日", index = 31)
private Integer dayNum22;
@ExcelProperty(value = "23日", index = 28)
@ExcelProperty(value = "23日", index = 32)
private Integer dayNum23;
@ExcelProperty(value = "24日", index = 29)
@ExcelProperty(value = "24日", index = 33)
private Integer dayNum24;
@ExcelProperty(value = "25日", index = 30)
@ExcelProperty(value = "25日", index = 34)
private Integer dayNum25;
@ExcelProperty(value = "26日", index = 31)
@ExcelProperty(value = "26日", index = 35)
private Integer dayNum26;
@ExcelProperty(value = "27日", index = 32)
@ExcelProperty(value = "27日", index = 36)
private Integer dayNum27;
@ExcelProperty(value = "28日", index = 33)
@ExcelProperty(value = "28日", index = 37)
private Integer dayNum28;
@ExcelProperty(value = "29日", index = 34)
@ExcelProperty(value = "29日", index = 38)
private Integer dayNum29;
@ExcelProperty(value = "30日", index = 35)
@ExcelProperty(value = "30日", index = 39)
private Integer dayNum30;
@ExcelProperty(value = "31日", index = 36)
@ExcelProperty(value = "31日", index = 40)
private Integer dayNum31;
@ExcelProperty(value = "总计", index = 37)
@ExcelProperty(value = "总计", index = 41)
private Integer summation;
}
package cn.com.glsx.admin.modules.model.export;
import cn.com.glsx.admin.modules.model.ReportOrgDto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
......@@ -10,7 +11,7 @@ import lombok.Data;
* @Date 2021/1/19
*/
@Data
public class TrialDriveReportExport {
public class TrialDriveReportExport extends ReportOrgDto {
// 每种类型的统计数量
@ExcelIgnore
private Integer cnttotal;
......@@ -23,118 +24,118 @@ public class TrialDriveReportExport {
@ExcelIgnore
private Long vehicleId;
@ExcelProperty(value = "特约店代码", index = 0)
@ExcelProperty(value = "特约店代码", index = 4)
private String shopCode;
@ExcelProperty(value = "特约店名称", index = 1)
@ExcelProperty(value = "特约店名称", index = 5)
private String shopName;
@ExcelProperty(value = "车型", index = 2)
@ExcelProperty(value = "车型", index = 6)
private String vehicleTypeName;
@ExcelProperty(value = "设备号", index = 3)
@ExcelProperty(value = "设备号", index = 7)
private String sn;
@ExcelProperty(value = "车架号VIN码", index = 4)
@ExcelProperty(value = "车架号VIN码", index = 8)
private String vin;
// 年月
@ExcelProperty(value = "时间", index = 5)
@ExcelProperty(value = "时间", index = 9)
private String statDate;
@ExcelProperty(value = "1日", index = 6)
@ExcelProperty(value = "1日", index = 10)
private Integer dayNum1;
@ExcelProperty(value = "2日", index = 7)
@ExcelProperty(value = "2日", index = 11)
private Integer dayNum2;
@ExcelProperty(value = "3日", index = 8)
@ExcelProperty(value = "3日", index = 12)
private Integer dayNum3;
@ExcelProperty(value = "4日", index = 9)
@ExcelProperty(value = "4日", index = 13)
private Integer dayNum4;
@ExcelProperty(value = "5日", index = 10)
@ExcelProperty(value = "5日", index = 14)
private Integer dayNum5;
@ExcelProperty(value = "6日", index = 11)
@ExcelProperty(value = "6日", index = 15)
private Integer dayNum6;
@ExcelProperty(value = "7日", index = 12)
@ExcelProperty(value = "7日", index = 16)
private Integer dayNum7;
@ExcelProperty(value = "8日", index = 13)
@ExcelProperty(value = "8日", index = 17)
private Integer dayNum8;
@ExcelProperty(value = "9日", index = 14)
@ExcelProperty(value = "9日", index = 18)
private Integer dayNum9;
@ExcelProperty(value = "10日", index = 15)
@ExcelProperty(value = "10日", index = 19)
private Integer dayNum10;
@ExcelProperty(value = "11日", index = 16)
@ExcelProperty(value = "11日", index = 20)
private Integer dayNum11;
@ExcelProperty(value = "12日", index = 17)
@ExcelProperty(value = "12日", index = 21)
private Integer dayNum12;
@ExcelProperty(value = "13日", index = 18)
@ExcelProperty(value = "13日", index = 22)
private Integer dayNum13;
@ExcelProperty(value = "14日", index = 19)
@ExcelProperty(value = "14日", index = 23)
private Integer dayNum14;
@ExcelProperty(value = "15日", index = 20)
@ExcelProperty(value = "15日", index = 24)
private Integer dayNum15;
@ExcelProperty(value = "16日", index = 21)
@ExcelProperty(value = "16日", index = 25)
private Integer dayNum16;
@ExcelProperty(value = "17日", index = 22)
@ExcelProperty(value = "17日", index = 26)
private Integer dayNum17;
@ExcelProperty(value = "18日", index = 23)
@ExcelProperty(value = "18日", index = 27)
private Integer dayNum18;
@ExcelProperty(value = "19日", index = 24)
@ExcelProperty(value = "19日", index = 28)
private Integer dayNum19;
@ExcelProperty(value = "20日", index = 25)
@ExcelProperty(value = "20日", index = 29)
private Integer dayNum20;
@ExcelProperty(value = "21日", index = 26)
@ExcelProperty(value = "21日", index = 30)
private Integer dayNum21;
@ExcelProperty(value = "22日", index = 27)
@ExcelProperty(value = "22日", index = 31)
private Integer dayNum22;
@ExcelProperty(value = "23日", index = 28)
@ExcelProperty(value = "23日", index = 32)
private Integer dayNum23;
@ExcelProperty(value = "24日", index = 29)
@ExcelProperty(value = "24日", index = 33)
private Integer dayNum24;
@ExcelProperty(value = "25日", index = 30)
@ExcelProperty(value = "25日", index = 34)
private Integer dayNum25;
@ExcelProperty(value = "26日", index = 31)
@ExcelProperty(value = "26日", index = 35)
private Integer dayNum26;
@ExcelProperty(value = "27日", index = 32)
@ExcelProperty(value = "27日", index = 36)
private Integer dayNum27;
@ExcelProperty(value = "28日", index = 33)
@ExcelProperty(value = "28日", index = 37)
private Integer dayNum28;
@ExcelProperty(value = "29日", index = 34)
@ExcelProperty(value = "29日", index = 38)
private Integer dayNum29;
@ExcelProperty(value = "30日", index = 35)
@ExcelProperty(value = "30日", index = 39)
private Integer dayNum30;
@ExcelProperty(value = "31日", index = 36)
@ExcelProperty(value = "31日", index = 40)
private Integer dayNum31;
@ExcelProperty(value = "总计", index = 37)
@ExcelProperty(value = "总计", index = 41)
private Integer summation;
}
......@@ -23,6 +23,9 @@ public class ElectricInStoreDriveService {
@Autowired
private ElectricInStoreDriveMapper inStoreDriveMapper;
@Autowired
private OrganizationApiService organizationApiService;
public List<String> getYearWithData() {
return inStoreDriveMapper.getYearWithData();
}
......@@ -299,6 +302,7 @@ public class ElectricInStoreDriveService {
electricInStoreExport.setDayNum31(replaceDayNum(electricInStoreExport.getDayNum31()));
}
}
organizationApiService.drawReportOrganization(electricInStoreExportList);
return electricInStoreExportList;
}
......
......@@ -2,28 +2,38 @@ package cn.com.glsx.admin.modules.service;
import cn.com.glsx.admin.modules.model.BaseOrgDto;
import cn.com.glsx.admin.modules.model.OrgVehicleTree;
import cn.com.glsx.admin.modules.model.ReportOrgDto;
import cn.com.glsx.admin.modules.model.param.VehicleTreeSearch;
import cn.com.glsx.usercenter.api.dto.request.FindOrgRequest;
import cn.com.glsx.usercenter.api.dto.response.Organization;
import cn.com.glsx.usercenter.api.dto.response.User;
import cn.com.glsx.usercenter.api.dto.tree.OrgTreeModel;
import cn.com.glsx.usercenter.api.feign.OrganizationService;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
public class OrganizationApiService {
@Autowired
private OrganizationService organizationService;
@Autowired
private UserApiService userApiService;
public void drawOrganization(List<? extends BaseOrgDto> list) {
if (CollectionUtils.isEmpty(list)) {
return;
......@@ -107,4 +117,44 @@ public class OrganizationApiService {
return list;
}
public void drawReportOrganization(List<? extends ReportOrgDto> list) {
if (CollectionUtils.isEmpty(list)) {
return;
}
List<Long> userIds = list.stream().map(ReportOrgDto::getCreatedBy).collect(Collectors.toList());
R<List<Organization>> orgsR = organizationService.getTenantPathsByUserIds(userIds);
List<Organization> orgList = orgsR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
if (CollectionUtils.isNotEmpty(orgList)) {
list.forEach(efd -> {
List<Organization> organizations = orgList.stream().filter(index -> index.getUserId().equals(efd.getCreatedBy())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(organizations)) {
int size = organizations.size();
if (size < 2) {
return;
} else {
efd.setArea(organizations.get(1).getOrgName());
if (size > 2) {
efd.setProvince(organizations.get(2).getOrgName());
}
if (size > 3) {
efd.setCity(organizations.get(3).getOrgName());
}
}
}
});
Map<Long, User> superiorUserMap = userApiService.getSuperiorUserMapByIds(userIds);
log.info("superiorUserMap===" + JSON.toJSONString(superiorUserMap));
if (CollectionUtil.isNotEmpty(superiorUserMap)) {
list.forEach(efd -> {
User user = superiorUserMap.get(efd.getCreatedBy());
if (user != null) {
efd.setItineracy(user.getUsername());
}
});
}
}
}
}
......@@ -25,6 +25,9 @@ public class TrialDriveReportService {
@Autowired
private TrialDriveReportMapper trialDriveReportMapper;
@Autowired
private OrganizationApiService organizationApiService;
public List<TrialDriveReportExport> search(TrialDriveReportSearch search) {
// 没有年月查询消息时 默认显示当前年月
if (StringUtils.isNullOrEmpty(search.getMonth()) && StringUtils.isNullOrEmpty(search.getYear())) {
......@@ -33,6 +36,7 @@ public class TrialDriveReportService {
}
List<TrialDriveReportExport> testDrivePageList = trialDriveReportMapper.getTestDrivePageList(search);
testDrivePageList = listEffectiveTestDriveReportPage(search, testDrivePageList);
organizationApiService.drawReportOrganization(testDrivePageList);
return testDrivePageList;
}
......
......@@ -81,7 +81,7 @@ public class UserApiService {
}.getType());
Map<Long, User> userMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(userList)) {
userMap = userList.stream().collect(Collectors.toMap(User::getMId, Function.identity()));
userMap = userList.stream().collect(Collectors.toMap(User::getMid, Function.identity()));
}
return userMap;
}
......
......@@ -35,7 +35,8 @@
tv.vin,
tv.id as vehicleId,
tv.model_name as modelName,
GROUP_CONCAT(td.sn) as sn
GROUP_CONCAT(td.sn) as sn,
tv.created_by as createdBy
FROM t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
LEFT JOIN t_vehicle_device tvd on tvd.vehicle_id = tv.id
......
......@@ -32,7 +32,8 @@
tv.vin,
tv.id as vehicleId,
tv.model_name as vehicleTypeName,
GROUP_CONCAT(td.sn) as sn
GROUP_CONCAT(td.sn) as sn,
tv.created_by as createdBy
FROM t_vehicle tv
inner join t_trial_drive_vehicle ttdv on ttdv.vehicle_id = tv.id
LEFT JOIN t_vehicle_device tvd on tvd.vehicle_id = tv.id
......
......@@ -40,9 +40,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
......@@ -83,6 +84,9 @@ public class VehicleServiceTest {
@Autowired
private DeviceService deviceService;
@Autowired
private UserApiService userApiService;
@Before
public void runBeforeTestMethod() {
SyntheticUser user = new SyntheticUser();
......@@ -2153,7 +2157,7 @@ public class VehicleServiceTest {
}
@Test
public void test15(){
public void test15() {
Device device = deviceService.getDeviceBySn("1190000009");
device.setActivateTime(null);
device.setActivateStatus(0);
......@@ -2161,15 +2165,19 @@ public class VehicleServiceTest {
}
@Test
public void test16(){
public void test16() {
String pattern = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{17}$";
String line = "1231231234qwe54789";
boolean matches = line.matches(pattern);
if (matches){
if (matches) {
System.out.println("matches = " + matches);
}
}
@Test
public void test() {
User superiorUserById = userApiService.getSuperiorUserById(8102L);
System.out.println("superiorUserById = " + JSON.toJSONString(superiorUserById));
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!