Commit cada0614 by 杨林龙

假性离线功能自测

1 parent b3eb0bae
......@@ -13,6 +13,7 @@ import cn.com.glsx.admin.modules.utils.FdfsUtils;
import cn.com.glsx.admin.modules.utils.fileupload.FileConstants;
import cn.com.glsx.admin.modules.utils.fileupload.FileUploadServerData;
import cn.com.glsx.admin.modules.utils.fileupload.FileUploadUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import com.alibaba.excel.EasyExcel;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.web.R;
......@@ -65,7 +66,7 @@ public class FakeOfflineController {
List<FakeOfficeExport> fakeOfficeList = fakeOfflineService.export(fakeOfficeSearch);
// 将文件写入内存流 然后上传到文件服务器 返回文件服务器的地址给前端 前端执行下载
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcel(outputStream, fakeOfficeList, fileName, JudgmentExport.class);
EasyExcelUtils.writeExcel(outputStream, fakeOfficeList, fileName, FakeOfficeExport.class);
FileUploadServerData uploadServerData = FileUploadUtil.uploadToFileSystem(fileName, outputStream.toByteArray(), FileConstants.EXCEL_TYPE_XLSX);
return R.ok().data(uploadServerData.getSecureUrl());
}
......@@ -84,7 +85,9 @@ public class FakeOfflineController {
@PostMapping(value = "/import", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ApiOperation(value = "导入假性离线报表")
public R importWriteList(@RequestParam("file") MultipartFile file) throws Exception {
WhiteListSnImportListener listener = new WhiteListSnImportListener(vehicleService, deviceService, fakeOfflineService);
Long deptId = ShieldContextHolder.getDepartmentId();
Long userId = ShieldContextHolder.getUserId();
WhiteListSnImportListener listener = new WhiteListSnImportListener(vehicleService, deviceService, fakeOfflineService, deptId, userId);
EasyExcel.read(file.getInputStream(), WhiteListSnImport.class, listener)
.head(WhiteListSnImport.class)
.ignoreEmptyRow(true)
......
......@@ -49,7 +49,7 @@ public interface FakeOfflineVinMapper extends CommonBaseMapper<FakeOfflineVin> {
* @param search
* @return
*/
@DataPerm(permTable = "tv", showSql = true)
// @DataPerm(permTable = "tv", showSql = true)
List<FakeOfficeExport> searchFakeOfficeList(FakeOfficeSearch search);
/**
......
......@@ -9,7 +9,6 @@ import lombok.experimental.Accessors;
* @date 2022/3/10 20:13
*/
@Data
@Accessors(chain = true)
public class FakeOfficeExport {
/**
* 业务工单号
......
......@@ -60,11 +60,17 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
private FakeOfflineService fakeOfflineService;
public WhiteListSnImportListener(VehicleService vehicleService, DeviceService deviceService, FakeOfflineService fakeOfflineService) {
private Long deptId;
private Long userId;
public WhiteListSnImportListener(VehicleService vehicleService, DeviceService deviceService, FakeOfflineService fakeOfflineService, Long deptId, Long userId) {
this.failList = new ArrayList<>();
this.vehicleService = vehicleService;
this.deviceService = deviceService;
this.fakeOfflineService = fakeOfflineService;
this.deptId = deptId;
this.userId = userId;
}
/**
......@@ -150,7 +156,7 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
Map<String, String> vehicleAndDeviceMap = vehicleService.getVehicleAndDeviceMap();
// 清空同部门下面的设备号
fakeOfflineService.cleanAllWriteListOnSameDepartment();
fakeOfflineService.cleanAllWriteListOnSameDepartment(deptId);
try {
//大于500 线程处理
......@@ -259,7 +265,7 @@ public class WhiteListSnImportListener extends AnalysisEventListener<WhiteListSn
//4.插入数据
if (CollectionUtil.isNotEmpty(whiteListSnImportList)) {
log.info("开始插入数据到数据库,size:" + whiteListSnImportList.size());
fakeOfflineService.insertFakeOfflineList(whiteListSnImportList);
fakeOfflineService.insertFakeOfflineList(whiteListSnImportList, deptId, userId);
}
succNum.getAndAdd(whiteListSnImportList.size());
}
......
......@@ -90,7 +90,9 @@ public class FakeOfflineService extends AbstractCommonService {
* @return 返回假性离线列表
*/
public List<FakeOfficeExport> buildFakeOfficeResult(FakeOfficeSearch search, Map<String, Integer> reasonMap) {
log.info("假性离线查询参数:" + JSONUtil.toJsonStr(search));
List<FakeOfficeExport> fakeOfficeList = fakeOfflineVinMapper.searchFakeOfficeList(search);
log.info("查询假性离线的列表大小:" + fakeOfficeList.size());
for (FakeOfficeExport fakeOfficeExport : fakeOfficeList) {
String vin = fakeOfficeExport.getVin();
Integer code = reasonMap.get(vin);
......@@ -169,13 +171,11 @@ public class FakeOfflineService extends AbstractCommonService {
// 获取车辆和设备绑定数量Map
Map<String, Integer> vehicleNumMap = Maps.newHashMap();
List<FakeOfficeMapDto> vehicleNumMapList = fakeOfflineVinMapper.getVehicleNumMap();
log.info("vehicleNumMapList===" + JSONUtil.toJsonStr(vehicleNumMapList));
vehicleNumMapList.forEach(vehicleNum -> vehicleNumMap.put(vehicleNum.getVin(), vehicleNum.getNum()));
Map<String, Integer> offlineVehicleNumMap = Maps.newHashMap();
List<FakeOfficeMapDto> offlineVehicleNumMapList = fakeOfflineVinMapper.getOfflineVehicleNumMap();
log.info("offlineVehicleNumMapList===" + JSONUtil.toJsonStr(offlineVehicleNumMapList));
offlineVehicleNumMapList.forEach(offlineVehicleNum -> offlineVehicleNumMap.put(offlineVehicleNum.getVin(), offlineVehicleNum.getNum()));
for (Map.Entry<String, Integer> stringIntegerEntry : offlineVehicleNumMap.entrySet()) {
String vin = stringIntegerEntry.getKey();
Integer num = vehicleNumMap.get(vin);
......@@ -185,11 +185,15 @@ public class FakeOfflineService extends AbstractCommonService {
}
}
singleDeviceOfficeVinList.forEach(vin -> reasonMap.put(vin, FakeOfficeReasonEnum.SINGLE_OFFLINE.getCode()));
log.info("假性离线多设备单离线车架号 size:" + singleDeviceOfficeVinList.size());
log.info("假性离线多设备单离线车架号:" + JSONUtil.toJsonStr(singleDeviceOfficeVinList));
vinList.addAll(singleDeviceOfficeVinList);
// 二 获取设备都离线 最后定位点在家庭围栏或者工作地围栏 获取车架通过权限控制
List<String> fakeOfflineVinByFenceList = fakeOfflineVinMapper.getFakeOfflineVinByFence();
fakeOfflineVinByFenceList.forEach(vin -> reasonMap.put(vin, FakeOfficeReasonEnum.RESIDENCE.getCode()));
log.info("假性触碰工作围栏或者家庭围栏离线车架号 size:" + fakeOfflineVinByFenceList.size());
log.info("假性离线多设备单离线车架号:" + JSONUtil.toJsonStr(fakeOfflineVinByFenceList));
vinList.addAll(fakeOfflineVinByFenceList);
// 三 获取本部门以及下级部门
......@@ -197,8 +201,12 @@ public class FakeOfflineService extends AbstractCommonService {
// 从白名单列表获取白名单设备号及其车架号
List<String> writeListVinList = whitelistSnMapper.getWriteListVin(deptIds);
writeListVinList.forEach(vin -> reasonMap.put(vin, FakeOfficeReasonEnum.WHITELIST.getCode()));
log.info("假性离线白名单车架号 size:" + writeListVinList.size());
log.info("假性离线白名单车架号:" + JSONUtil.toJsonStr(writeListVinList));
vinList.addAll(writeListVinList);
log.info("假性离线车架号集合大小size:" + vinList.size());
log.info("假性离线车架号集合大小data:" + JSONUtil.toJsonStr(vinList));
return vinList;
}
......@@ -207,28 +215,27 @@ public class FakeOfflineService extends AbstractCommonService {
*
* @param whiteListSnImportList 假性离线白名单数据
*/
public void insertFakeOfflineList(List<WhiteListSnImport> whiteListSnImportList) {
log.info("开始插入数据库,insertFakeOfflineList " + JSONUtil.toJsonStr(whiteListSnImportList));
public void insertFakeOfflineList(List<WhiteListSnImport> whiteListSnImportList, Long deptId, Long userId) {
List<WhitelistSn> whitelistSnList = Lists.newArrayList();
for (WhiteListSnImport whiteListSnImport : whiteListSnImportList) {
WhitelistSn whitelistSn = new WhitelistSn();
whitelistSn.setVin(whiteListSnImport.getVin());
whitelistSn.setSn(whiteListSnImport.getSn());
whitelistSn.setDepartmentId(ShieldContextHolder.getDepartmentId());
whitelistSn.setCreatedBy(ShieldContextHolder.getUserId());
whitelistSn.setDepartmentId(deptId);
whitelistSn.setCreatedBy(userId);
whitelistSn.setCreatedDate(new Date());
whitelistSnList.add(whitelistSn);
}
log.info("插入数据的集合为:" + JSONUtil.toJsonStr(whitelistSnList));
whitelistSnMapper.insertList(whitelistSnList);
}
/**
* 逻辑清空同部门下面的所有设备号
*/
public void cleanAllWriteListOnSameDepartment() {
public void cleanAllWriteListOnSameDepartment(Long departmentId) {
log.info("逻辑清空同部门下面的所有设备号" + departmentId);
// 根据部门Id获取所有白名单数据
whitelistSnMapper.logicDeleteSnByDepartmentId(ShieldContextHolder.getDepartmentId());
whitelistSnMapper.logicDeleteSnByDepartmentId(departmentId);
}
public String saveFakeOfflineFailData(List<WhiteListFailExport> failList) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!