Commit 99edb783 authored by chenzhao's avatar chenzhao

手动同步代码

parent 20497121
...@@ -221,6 +221,14 @@ public class ExcelUtil { ...@@ -221,6 +221,14 @@ public class ExcelUtil {
return readExcel(reader, rowType, 0); return readExcel(reader, rowType, 0);
} }
public static <T> List<T> readManySheetExcel(MultipartFile excel, Class<T> rowType, int header,int sheetCount) throws Exception {
ExcelReader reader = getReader(excel, header);
if (reader == null) {
return new ArrayList<>();
}
return readExcel(reader, rowType, 0);
}
/** /**
* 读取 Excel(多个 sheet) * 读取 Excel(多个 sheet)
* *
......
...@@ -37,16 +37,18 @@ public class SelectedSheetWriteHandler implements SheetWriteHandler { ...@@ -37,16 +37,18 @@ public class SelectedSheetWriteHandler implements SheetWriteHandler {
selectedMap.forEach((k, v) -> { selectedMap.forEach((k, v) -> {
// 设置下拉列表的行: 首行,末行,首列,末列 // 设置下拉列表的行: 首行,末行,首列,末列
CellRangeAddressList rangeList = new CellRangeAddressList(1, 65536, k, k); CellRangeAddressList rangeList = new CellRangeAddressList(1, 65536, k, k);
// 设置下拉列表的值 if (v.getSource().length > 0){
DataValidationConstraint constraint = helper.createExplicitListConstraint(v.getSource()); // 设置下拉列表的值
// 设置约束 DataValidationConstraint constraint = helper.createExplicitListConstraint(v.getSource());
DataValidation validation = helper.createValidation(constraint, rangeList); // 设置约束
// 阻止输入非下拉选项的值 DataValidation validation = helper.createValidation(constraint, rangeList);
validation.setErrorStyle(DataValidation.ErrorStyle.STOP); // 阻止输入非下拉选项的值
validation.setShowErrorBox(true); validation.setErrorStyle(DataValidation.ErrorStyle.STOP);
validation.setSuppressDropDownArrow(true); validation.setShowErrorBox(true);
validation.createErrorBox("提示", "请输入下拉选项中的内容"); validation.setSuppressDropDownArrow(true);
sheet.addValidationData(validation); validation.createErrorBox("提示", "请输入下拉选项中的内容");
sheet.addValidationData(validation);
}
}); });
} }
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
r.equip_category_name, r.equip_category_name,
r.equip_code, r.equip_code,
r.maintenance_period, r.maintenance_period,
r.resource_type,
(case r.resource_type when 'crane' then rc.height when 'natural' then rn.height end) height, (case r.resource_type when 'crane' then rc.height when 'natural' then rn.height end) height,
(case r.resource_type (case r.resource_type
when 'crane' then rc.status when 'crane' then rc.status
......
...@@ -484,7 +484,7 @@ public class ExcelServiceImpl { ...@@ -484,7 +484,7 @@ public class ExcelServiceImpl {
} }
@Transactional @Transactional
public Object commonUpload(MultipartFile multipartFile, ExcelDto excelDto, String uuidString, HttpServletRequest equest) throws Exception { public Object commonUpload(MultipartFile multipartFile, ExcelDto excelDto, String uuidString, HttpServletRequest equest) throws Exception {
switch (excelDto.getType()) { switch (excelDto.getType()) {
...@@ -1892,6 +1892,155 @@ private void saveuser(OrgUsrTPDlExcelDto orgUsrExcelDto,Set<String> set,String a ...@@ -1892,6 +1892,155 @@ private void saveuser(OrgUsrTPDlExcelDto orgUsrExcelDto,Set<String> set,String a
waterResourceServiceImpl.importByExcel(item); waterResourceServiceImpl.importByExcel(item);
}); });
} }
@Transactional
public void excelImportWaterResourceNew(MultipartFile multipartFile) throws Exception {
List<WaterResourceDto> excelDtoList = new ArrayList<>();
List<WaterExcelPoolDto> waterExcelPoolDtos = ExcelUtil.readManySheetExcel(multipartFile, WaterExcelPoolDto.class, 0, 0);
List<WaterExcelHydrantDto> waterExcelHydrantDtos = ExcelUtil.readManySheetExcel(multipartFile, WaterExcelHydrantDto.class, 0, 1);
List<WaterExcelCraneDto> waterExcelCraneDtos = ExcelUtil.readManySheetExcel(multipartFile, WaterExcelCraneDto.class, 0, 2);
List<WaterExcelNaturalDto> waterExcelNaturalDtos = ExcelUtil.readManySheetExcel(multipartFile, WaterExcelNaturalDto.class, 0, 3);
List<WaterExcelIndustryPoolDto> waterExcelIndustryPoolDtos = ExcelUtil.readManySheetExcel(multipartFile, WaterExcelIndustryPoolDto.class, 0, 4);
List<WaterExcelWaterTankDto> waterExcelWaterTankDtos = ExcelUtil.readManySheetExcel(multipartFile, WaterExcelWaterTankDto.class, 0, 5);
waterExcelPoolDtos.forEach(e->{ WaterResourceDto waterResourceDto = new WaterResourceDto();BeanUtils.copyProperties(e,waterResourceDto); excelDtoList.add(waterResourceDto); });
waterExcelHydrantDtos.forEach(e->{ WaterResourceDto waterResourceDto = new WaterResourceDto();BeanUtils.copyProperties(e,waterResourceDto); excelDtoList.add(waterResourceDto); });
waterExcelCraneDtos.forEach(e->{ WaterResourceDto waterResourceDto = new WaterResourceDto();BeanUtils.copyProperties(e,waterResourceDto); excelDtoList.add(waterResourceDto); });
waterExcelNaturalDtos.forEach(e->{ WaterResourceDto waterResourceDto = new WaterResourceDto();BeanUtils.copyProperties(e,waterResourceDto);excelDtoList.add(waterResourceDto); });
waterExcelIndustryPoolDtos.forEach(e->{ WaterResourceDto waterResourceDto = new WaterResourceDto();BeanUtils.copyProperties(e,waterResourceDto);excelDtoList.add(waterResourceDto); });
waterExcelWaterTankDtos.forEach(e->{ WaterResourceDto waterResourceDto = new WaterResourceDto();BeanUtils.copyProperties(e,waterResourceDto);excelDtoList.add(waterResourceDto); });
excelDtoList.forEach(item -> {
/* Bug 2950 消防水源,缺失设施分类、设施定义等必填字段可以上传成功 陈召 2021-10-09 */
if (item.getEquipName() == null || item.getEquipName().equals(" ")) {
throw new BadRequest("设备定义名称为必填字段,填写后重新上传");
}
// BUG 2953 导入模板没有设备编码生成 2021-09-18 陈召开始
item.setEquipCode(QRCodeUtil.generateQRCode());
// BUG 2953 导入模板没有设备编码生成 2021-09-18 陈召结束
if (item.getResourceTypeName() != null) {
String[] resourceTypeName = item.getResourceTypeName().split("@");
item.setResourceTypeName(resourceTypeName[0]);
item.setResourceType(resourceTypeName[1]);
}
if (item.getHydrantType() != null) {
item.setType(item.getHydrantType());
}
if (item.getSystemType() != null) {
String[] systemType = item.getSystemType().split("@");
item.setSystemType(systemType[0]);
item.setSystemTypeCode(systemType[1]);
}
if (item.getPlaceForm() != null) {
String[] placeForm = item.getPlaceForm().split("@");
item.setPlaceForm(placeForm[0]);
item.setPlaceFormCode(placeForm[1]);
}
if (item.getBelongBuilding() != null) {
String[] belongBuilding = item.getBelongBuilding().split("@");
item.setBelongBuilding(belongBuilding[0]);
item.setBelongBuildingId(Long.valueOf(belongBuilding[1]));
}
if (item.getBelongFightingSystem() != null) {
String[] belongFightingSystem = item.getBelongFightingSystem().split("@");
item.setBelongFightingSystem(belongFightingSystem[0]);
item.setBelongFightingSystemId(Long.valueOf(belongFightingSystem[1]));
}
if (item.getManagementUnit() != null) {
String[] managementUnit = item.getManagementUnit().split("@");
item.setManagementUnit(managementUnit[0]);
item.setManagementUnitId(Long.valueOf(managementUnit[1]));
OrgUsr org = orgUsrService.getById(Long.valueOf(managementUnit[1]));
if(org!=null) {
item.setBizOrgCode(org.getBizOrgCode());
item.setBizOrgName(org.getBizOrgName());
}
}
if (item.getMaintenanceUnit() != null) {
String[] maintenanceUnit = item.getMaintenanceUnit().split("@");
item.setMaintenanceUnit(maintenanceUnit[0]);
item.setMaintenanceUnitId(Long.valueOf(maintenanceUnit[1]));
}
if (item.getHoseConnection() != null) {
String[] hoseConnection = item.getHoseConnection().split("@");
item.setHoseConnection(hoseConnection[0]);
item.setHoseConnectionCode(hoseConnection[1]);
}
if (item.getIntakeForm() != null) {
String[] intakeForm = item.getIntakeForm().split("@");
item.setIntakeForm(intakeForm[0]);
}
if (item.getPipeTypeName() != null) {
String[] pipeTypeName = item.getPipeTypeName().split("@");
item.setPipeTypeName(pipeTypeName[0]);
item.setPipeTypeCode(pipeTypeName[1]);
}
if (item.getStatus() != null) {
String[] status = item.getStatus().split("@");
item.setStatus(status[0]);
item.setStatusCode(status[1]);
}
if (item.getType() != null) {
String[] type = item.getType().split("@");
item.setType(type[0]);
item.setTypeCode(type[1]);
}
if (item.getLevelDeviceName() != null) {
String[] type = item.getLevelDeviceName().split("@");
item.setLevelDeviceName(type[0]);
item.setLevelDeviceId(type[1]);
}
// BUG 2935 优化项 分类从93060000 取得字典数据 by kongfm 2021-09-17
if (item.getEquipCategoryName() != null) {
String[] equipCategory = item.getEquipCategoryName().split("@");
item.setEquipCategoryName(equipCategory[0]);
item.setEquipCategoryId(Long.parseLong(equipCategory[1]));
}
if (item.getHasDrySeasonType() != null) {
boolean flag = "有".equals(item.getHasDrySeasonType()) ? true : false;
item.setHasDrySeason(flag);
}
if (item.getEquipName() != null) {
String[] equipCategory = item.getEquipName().split("@");
item.setEquipId(Long.parseLong(equipCategory[1]));
item.setEquipName(equipCategory[0]);
item.setEquipCategoryId(Long.parseLong(equipCategory[2]));
item.setEquipCategoryName(equipCategory[3]);
switch (equipCategory[3]) {
case "天然水源":
item.setEquipCategoryCode("93060300");
break;
case "水源-消火栓":
item.setEquipCategoryCode("93060400");
break;
case "消火栓":
item.setEquipCategoryCode("93060400");
break;
case "消防水池":
item.setEquipCategoryCode("93060100");
break;
case "消防水鹤":
item.setEquipCategoryCode("93060200");
break;
case "工业水池":
item.setEquipCategoryCode("93060500");
break;
default:
break;
}
}
if (item.getContactUser() != null) {
String[] contactUser = item.getContactUser().split("@");
item.setContactUser(contactUser[0]);
item.setContactUserId(contactUser[1]);
}
item = Bean.toPo(getCurrentInfo(), item);
//水源的isdelete是反着的
item.setIsDelete(true);
waterResourceServiceImpl.importByExcel(item);
});
}
@Transactional @Transactional
public void excelImportFireExperts(MultipartFile multipartFile) throws Exception { public void excelImportFireExperts(MultipartFile multipartFile) throws Exception {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
......
...@@ -219,6 +219,7 @@ ...@@ -219,6 +219,7 @@
a.user_name, a.user_name,
a.dep_name department_name, a.dep_name department_name,
a.dep_id departmentId, a.dep_id departmentId,
wws.name address,
date_format( date_format(
`a`.`check_time`, `a`.`check_time`,
'%Y-%m-%d %H:%i:%s' '%Y-%m-%d %H:%i:%s'
...@@ -249,7 +250,6 @@ ...@@ -249,7 +250,6 @@
) as is_ok, ) as is_ok,
a.score, a.score,
d.`name` AS `route_name`, d.`name` AS `route_name`,
( (
CASE CASE
WHEN a.check_mode = 'QR' WHEN a.check_mode = 'QR'
...@@ -266,9 +266,6 @@ ...@@ -266,9 +266,6 @@
'系统自检' '系统自检'
END END
) as check_mode, ) as check_mode,
e.`name` AS `plan_name`, e.`name` AS `plan_name`,
a.plan_task_id, a.plan_task_id,
a.plan_id, a.plan_id,
...@@ -281,6 +278,7 @@ ...@@ -281,6 +278,7 @@
LEFT JOIN `p_point` `b` ON `a`.`point_id` = `b`.`id` LEFT JOIN `p_point` `b` ON `a`.`point_id` = `b`.`id`
LEFT JOIN `p_route` `d` ON `a`.`route_id` = `d`.`id` LEFT JOIN `p_route` `d` ON `a`.`route_id` = `d`.`id`
LEFT JOIN `p_plan` `e` ON `a`.`plan_id` = `e`.`id` LEFT JOIN `p_plan` `e` ON `a`.`plan_id` = `e`.`id`
LEFT JOIN wl_warehouse_structure wws on wws.id = b.risk_source_id
<if test="dangerId != null and dangerId != ''"> <if test="dangerId != null and dangerId != ''">
LEFT JOIN ( SELECT check_id, GROUP_CONCAT( latent_danger_id ) dangerIds FROM p_latent_danger_patrol GROUP BY check_id ) t ON t.check_id = a.id LEFT JOIN ( SELECT check_id, GROUP_CONCAT( latent_danger_id ) dangerIds FROM p_latent_danger_patrol GROUP BY check_id ) t ON t.check_id = a.id
</if> </if>
......
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