新需求开发
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE `emergency_resource`
|
||||
ADD COLUMN `job_num` int NULL DEFAULT NULL COMMENT '在岗人数' AFTER `memo`,
|
||||
ADD COLUMN `run_time` int NULL DEFAULT NULL COMMENT '运转时间(分钟)' AFTER `job_num`;
|
||||
+12
@@ -35,4 +35,16 @@ public class HealthRoomBaseVO {
|
||||
*/
|
||||
@Schema(title = "建设时间")
|
||||
private String buildDate;
|
||||
|
||||
/**
|
||||
* 在岗人数
|
||||
*/
|
||||
@Schema(title = "在岗人数")
|
||||
private Integer jobNum;
|
||||
|
||||
/**
|
||||
* 运转时间(分钟)
|
||||
*/
|
||||
@Schema(title = "运转时间(分钟)")
|
||||
private Integer runTime;
|
||||
}
|
||||
|
||||
-2
@@ -96,6 +96,4 @@ public class LargeScreenData implements Serializable {
|
||||
this.name = dto.getName();
|
||||
this.value = dto.getValue();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+15
-2
@@ -70,9 +70,22 @@ public class Resource implements Serializable {
|
||||
/**
|
||||
* 资源类型(1:油田医院 3:健康小屋 5:救护车) 202508xj 项目字典发生变化 , 使用字典resource_type ,
|
||||
*/
|
||||
@Excel(name = "资源类型(1:油田医院 3:健康小屋 5:救护车)", width = 15)
|
||||
@Schema(title = "资源类型(1:油田医院 3:健康小屋 5:救护车 )")
|
||||
@Excel(name = "资源类型(1:油田医院 3:健康小屋 4:AED 5:救护车)", width = 15)
|
||||
@Schema(title = "资源类型(1:油田医院 3:健康小屋 4:AED 5:救护车 )")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 在岗人数
|
||||
*/
|
||||
@Schema(title = "在岗人数")
|
||||
private Integer jobNum;
|
||||
|
||||
/**
|
||||
* 运转时间(分钟)
|
||||
*/
|
||||
@Schema(title = "运转时间(分钟)")
|
||||
private Integer runTime;
|
||||
|
||||
/**
|
||||
* 救治范围
|
||||
*/
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.renkang.emergency.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("xj_aed")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class XjAed implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(title = "主键")
|
||||
private String id;
|
||||
|
||||
@Excel(name = "aed名称", width = 15)
|
||||
@Schema(title = "aed名称")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设置地点", width = 15)
|
||||
@Schema(title = "设置地点")
|
||||
private String address;
|
||||
|
||||
@Excel(name = "经度", width = 15)
|
||||
@Schema(title = "经度(火星坐标系)")
|
||||
private BigDecimal longitude;
|
||||
|
||||
@Excel(name = "纬度", width = 15)
|
||||
@Schema(title = "纬度(火星坐标系)")
|
||||
private BigDecimal latitude;
|
||||
|
||||
@Excel(name = "管理员姓名", width = 15)
|
||||
@Schema(title = "管理员姓名")
|
||||
private String manageName;
|
||||
|
||||
@Excel(name = "管理员电话", width = 15)
|
||||
@Schema(title = "管理员电话")
|
||||
private String managePhone;
|
||||
|
||||
@Schema(title = "orgCode")
|
||||
private String orgCode;
|
||||
|
||||
@Schema(title = "orgName")
|
||||
@TableField(exist = false)
|
||||
private String orgName;
|
||||
|
||||
private Integer delFlag;
|
||||
|
||||
private String createBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package com.renkang.emergency.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class LoveTrendVO {
|
||||
private String id;
|
||||
private String empId;
|
||||
private String treatPlanResponse;
|
||||
private String dietSuggestionResponse;
|
||||
private String sportGuideResponse;
|
||||
private String lifeManageResponse;
|
||||
private String createDate;
|
||||
private String updateDate;
|
||||
private String createBy;
|
||||
private String updateBy;
|
||||
private String delFlag;
|
||||
private String dataLevel;
|
||||
private String negativeList;
|
||||
private Integer flagFat;
|
||||
private BigDecimal bmi;
|
||||
private BigDecimal height;
|
||||
private BigDecimal weight;
|
||||
private BigDecimal bmiCurrent;
|
||||
private String hypertension;
|
||||
private String systolicPressureAvg;
|
||||
private String systolicPressureTarget;
|
||||
private String systolicPressureCurrent;
|
||||
private String diastolicPressureAvg;
|
||||
private String diastolicPressureTarget;
|
||||
private String diastolicPressureCurrent;
|
||||
private String diabetes;
|
||||
private String glu;
|
||||
private String bloodSugarTarget;
|
||||
private String bloodSugarCurrent;
|
||||
private String ldl;
|
||||
private String ldlTarget;
|
||||
private String ldlCurrent;
|
||||
private String tc;
|
||||
private String tcTarget;
|
||||
private String tcCurrent;
|
||||
private String tg;
|
||||
private String tgTarget;
|
||||
private String tgCurrent;
|
||||
private String uricAcid;
|
||||
private String uricAcidTarget;
|
||||
private String uricAcidCurrent;
|
||||
private String homocysteine;
|
||||
private String homocysteineTarget;
|
||||
private String homocysteineCurrent;
|
||||
private String workUnit;
|
||||
private String workUnitId;
|
||||
private Integer age;
|
||||
private String sex;
|
||||
private String name;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.renkang.emergency.controller;
|
||||
|
||||
import com.renkang.emergency.entity.XjAed;
|
||||
import com.renkang.emergency.service.IXjAedService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/emergency/xjAed")
|
||||
public class XjAedController extends JeecgController<XjAed, IXjAedService> {
|
||||
|
||||
private final IXjAedService xjAedService;
|
||||
|
||||
/**
|
||||
* 初始化新疆aed数据
|
||||
*/
|
||||
@GetMapping("dataInit")
|
||||
public void aedDataInit() {
|
||||
xjAedService.aedDataInit();
|
||||
}
|
||||
}
|
||||
+25
-17
@@ -4,26 +4,19 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.renkang.anyan.model.dto.HealthRoomDTO;
|
||||
import com.renkang.anyan.model.dto.HealthSignListParam;
|
||||
import com.renkang.anyan.model.dto.MedicalAbnormalDTO;
|
||||
import com.renkang.anyan.model.vo.BloodSugarClockSList;
|
||||
import com.renkang.anyan.model.vo.HealthRoomBaseVO;
|
||||
import com.renkang.anyan.model.vo.MedicalAbnormalVO;
|
||||
import com.renkang.anyan.model.vo.WeightPressureList;
|
||||
import com.renkang.anyan.model.vo.BloodPressureList;
|
||||
import com.renkang.anyan.model.vo.MedicalPeopleNumStatisticsVO;
|
||||
import com.renkang.anyan.model.vo.MedicalAbnormalStatisticsVO;
|
||||
import com.renkang.emergency.entity.dto.MedicalCenterDTO;
|
||||
import com.renkang.emergency.entity.dto.PhoneListDTO;
|
||||
import com.renkang.emergency.entity.dto.ResourcesAllDTO;
|
||||
import com.renkang.emergency.entity.dto.StatisticsDTO;
|
||||
import com.renkang.emergency.entity.dto.UserHealthCenterDTO;
|
||||
import com.renkang.emergency.largeScreen.entity.dto.HealthRoomBaseDTO;
|
||||
import com.renkang.emergency.entity.dto.LargeScreenDataValueDTO;
|
||||
import com.renkang.anyan.model.vo.*;
|
||||
import com.renkang.emergency.entity.dto.*;
|
||||
import com.renkang.emergency.entity.vo.DataDetailVO;
|
||||
import com.renkang.emergency.entity.vo.LoveTrendVO;
|
||||
import com.renkang.emergency.entity.vo.MedicalDataVO;
|
||||
import com.renkang.emergency.largeScreen.entity.dto.HealthRoomBaseDTO;
|
||||
import com.renkang.emergency.largeScreen.entity.dto.HealthSignDTO;
|
||||
import com.renkang.emergency.largeScreen.entity.dto.MedicalAbnormalStatisticsDTO;
|
||||
import com.renkang.emergency.largeScreen.entity.dto.MedicalPeopleNumStatisticsDTO;
|
||||
import com.renkang.emergency.largeScreen.entity.vo.*;
|
||||
import com.renkang.emergency.largeScreen.entity.vo.HealthRoomVO;
|
||||
import com.renkang.emergency.largeScreen.entity.vo.HealthSignVO;
|
||||
import com.renkang.emergency.largeScreen.entity.vo.HospitalVO;
|
||||
import com.renkang.emergency.largeScreen.entity.vo.LargeScreenMap;
|
||||
import com.renkang.emergency.largeScreen.service.ILargeScreenDataService;
|
||||
import com.renkang.emergency.largeScreen.service.ILargeScreenService;
|
||||
import com.renkang.emergency.service.ITbUserHelpMacService;
|
||||
@@ -54,7 +47,8 @@ public class LargeScreenNewController {
|
||||
|
||||
/**
|
||||
* 获取地图
|
||||
* @param type 1:油田医院 2:健康小屋 5:救护车 不传则全部
|
||||
*
|
||||
* @param type 1:油田医院 3:健康小屋 4:aed 5:救护车 不传则全部
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/map")
|
||||
@@ -175,6 +169,7 @@ public class LargeScreenNewController {
|
||||
|
||||
/**
|
||||
* 编辑或新增
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@@ -185,6 +180,7 @@ public class LargeScreenNewController {
|
||||
|
||||
/**
|
||||
* 编辑整个tab
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@@ -195,6 +191,7 @@ public class LargeScreenNewController {
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@@ -205,6 +202,7 @@ public class LargeScreenNewController {
|
||||
|
||||
/**
|
||||
* 体检医院编辑新增删除
|
||||
*
|
||||
* @param dtoList
|
||||
* @return
|
||||
*/
|
||||
@@ -214,7 +212,6 @@ public class LargeScreenNewController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 假数据查询
|
||||
*/
|
||||
@@ -232,4 +229,15 @@ public class LargeScreenNewController {
|
||||
return Result.ok(largeScreenDataService.medicalDataDetail(centerId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 假数据查询(关爱趋势)
|
||||
*/
|
||||
@GetMapping("loveTrend")
|
||||
public Result<IPage<LoveTrendVO>> loveTrend(@RequestParam(name = "centerId") String centerId,
|
||||
@RequestParam(name = "name", required = false) String name,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
return Result.ok(largeScreenDataService.loveTrend(centerId, name,pageNo,pageSize));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+22
@@ -2,6 +2,7 @@ package com.renkang.emergency.largeScreen.entity.vo;
|
||||
|
||||
import com.renkang.emergency.entity.EmergencyHealthRoom;
|
||||
import com.renkang.emergency.entity.Resource;
|
||||
import com.renkang.emergency.entity.XjAed;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@@ -20,6 +21,14 @@ public class LargeScreenMap {
|
||||
|
||||
private String latitude;
|
||||
|
||||
private Integer jobNum;
|
||||
|
||||
private Integer runTime;
|
||||
|
||||
private String manageName;
|
||||
|
||||
private String managePhone;
|
||||
|
||||
public LargeScreenMap() {}
|
||||
|
||||
public LargeScreenMap(Resource resource) {
|
||||
@@ -29,6 +38,8 @@ public class LargeScreenMap {
|
||||
this.type = resource.getType();
|
||||
this.latitude = String.valueOf(resource.getLatitude());
|
||||
this.longitude = String.valueOf(resource.getLongitude());
|
||||
this.jobNum = resource.getJobNum();
|
||||
this.runTime = resource.getRunTime();
|
||||
}
|
||||
|
||||
public LargeScreenMap(EmergencyHealthRoom room) {
|
||||
@@ -39,4 +50,15 @@ public class LargeScreenMap {
|
||||
this.latitude = room.getLatitude();
|
||||
this.longitude = room.getLongitude();
|
||||
}
|
||||
|
||||
public LargeScreenMap(XjAed xjAed) {
|
||||
this.id = xjAed.getId();
|
||||
this.name = xjAed.getName();
|
||||
this.orgName = xjAed.getOrgCode();
|
||||
this.type = "4";
|
||||
this.latitude = String.valueOf(xjAed.getLatitude());
|
||||
this.longitude = String.valueOf(xjAed.getLongitude());
|
||||
this.manageName = xjAed.getManageName();
|
||||
this.managePhone = xjAed.getManagePhone();
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -1,9 +1,11 @@
|
||||
package com.renkang.emergency.largeScreen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.renkang.emergency.entity.LargeScreenData;
|
||||
import com.renkang.emergency.entity.dto.LargeScreenDataValueDTO;
|
||||
import com.renkang.emergency.entity.vo.DataDetailVO;
|
||||
import com.renkang.emergency.entity.vo.LoveTrendVO;
|
||||
import com.renkang.emergency.entity.vo.MedicalDataVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -27,4 +29,6 @@ public interface ILargeScreenDataService extends IService<LargeScreenData> {
|
||||
DataDetailVO dataDetail(String centerId, String module);
|
||||
|
||||
List<MedicalDataVO> medicalDataDetail(String centerId);
|
||||
|
||||
IPage<LoveTrendVO> loveTrend(String centerId, String name,Integer pageNo,Integer pageSize);
|
||||
}
|
||||
|
||||
+45
-2
@@ -2,22 +2,28 @@ package com.renkang.emergency.largeScreen.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.PageUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.renkang.emergency.entity.LargeScreenData;
|
||||
import com.renkang.emergency.entity.dto.LargeScreenDataValueDTO;
|
||||
import com.renkang.emergency.entity.vo.DataDetailVO;
|
||||
import com.renkang.emergency.entity.vo.LoveTrendVO;
|
||||
import com.renkang.emergency.entity.vo.MedicalDataVO;
|
||||
import com.renkang.emergency.largeScreen.mapper.LargeScreenDataMapper;
|
||||
import com.renkang.emergency.largeScreen.mapper.LargeScreenMapper;
|
||||
import com.renkang.emergency.largeScreen.service.ILargeScreenDataService;
|
||||
import com.renkang.emergency.largeScreen.service.ILargeScreenService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -389,4 +395,41 @@ public class LargeScreenDataServiceImpl extends ServiceImpl<LargeScreenDataMappe
|
||||
}
|
||||
return list.stream().map(MedicalDataVO::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<LoveTrendVO> loveTrend(String centerId, String name, Integer pageNo, Integer pageSize) {
|
||||
try {
|
||||
ClassPathResource resource = new ClassPathResource("tempData/guanaiList.json");
|
||||
String jsonContent = StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8);
|
||||
List<LoveTrendVO> loveTrendVOList = JSONUtil.toList(jsonContent, LoveTrendVO.class);
|
||||
|
||||
if (CollUtil.isEmpty(loveTrendVOList)) {
|
||||
return new Page<>();
|
||||
}
|
||||
|
||||
// 根据 name 过滤
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
loveTrendVOList = loveTrendVOList.stream()
|
||||
.filter(vo -> vo.getName() != null && vo.getName().contains(name))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
int total = loveTrendVOList.size();
|
||||
int[] startEnd = PageUtil.transToStartEnd(pageNo - 1, pageSize);
|
||||
|
||||
// 确保不越界
|
||||
int start = Math.min(startEnd[0], total);
|
||||
int end = Math.min(startEnd[1], total);
|
||||
|
||||
List<LoveTrendVO> pageList = loveTrendVOList.subList(start, end);
|
||||
|
||||
Page<LoveTrendVO> page = new Page<>(pageNo, pageSize, total);
|
||||
page.setRecords(pageList);
|
||||
return page;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new Page<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-2
@@ -19,6 +19,7 @@ import com.renkang.anyan.model.vo.*;
|
||||
import com.renkang.emergency.entity.EmergencyCenter;
|
||||
import com.renkang.emergency.entity.EmergencyHealthRoom;
|
||||
import com.renkang.emergency.entity.Resource;
|
||||
import com.renkang.emergency.entity.XjAed;
|
||||
import com.renkang.emergency.entity.vo.DataDetailVO;
|
||||
import com.renkang.emergency.entity.vo.MedicalDataVO;
|
||||
import com.renkang.emergency.largeScreen.entity.dto.HealthRoomBaseDTO;
|
||||
@@ -35,6 +36,7 @@ import com.renkang.emergency.largeScreen.service.ILargeScreenService;
|
||||
import com.renkang.emergency.service.IEmergencyCenterService;
|
||||
import com.renkang.emergency.service.IEmergencyHealthRoomService;
|
||||
import com.renkang.emergency.service.IResourceService;
|
||||
import com.renkang.emergency.service.IXjAedService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jeecg.util.RedisClientUtil;
|
||||
import org.jeecg.util.RedisKeyPrefix;
|
||||
@@ -64,6 +66,7 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
|
||||
private final String MEDICAL_ABNORMAL_STATISTICS = "medicalAbnormalStatistics";
|
||||
private final String HEALTH_SIGN = "healthSign";
|
||||
private final IEmergencyCenterService centerService;
|
||||
private final IXjAedService xjAedService;
|
||||
private final IResourceService resourceService;
|
||||
private final IEmergencyHealthRoomService roomService;
|
||||
private final RedisClientUtil redisClientUtil;
|
||||
@@ -80,8 +83,14 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
|
||||
.eq(StrUtil.isEmpty(type), Resource::getType, "1"));
|
||||
maps.addAll(list.stream().map(LargeScreenMap::new).collect(Collectors.toList()));
|
||||
}
|
||||
if (StrUtil.isEmpty(type) || type.equals("2")) {
|
||||
List<EmergencyHealthRoom> list = roomService.list();
|
||||
if (StrUtil.isEmpty(type) || type.equals("3")) {
|
||||
List<Resource> list = resourceService.list(new LambdaQueryWrapper<Resource>()
|
||||
.eq(StrUtil.isNotEmpty(type), Resource::getType, type)
|
||||
.eq(StrUtil.isEmpty(type), Resource::getType, "3"));
|
||||
maps.addAll(list.stream().map(LargeScreenMap::new).collect(Collectors.toList()));
|
||||
}
|
||||
if (StrUtil.isEmpty(type) || type.equals("4")){
|
||||
List<XjAed> list = xjAedService.list(new LambdaQueryWrapper<XjAed>().isNotNull(XjAed::getLatitude));
|
||||
maps.addAll(list.stream().map(LargeScreenMap::new).collect(Collectors.toList()));
|
||||
}
|
||||
if (StrUtil.isEmpty(type) || type.equals("5")) {
|
||||
@@ -515,6 +524,8 @@ public class LargeScreenServiceImpl extends ServiceImpl<LargeScreenMapper, Large
|
||||
resource.setId(room.getId());
|
||||
resource.setLatitude(TypeConversionUtil.toBigDecimalOfNull(room.getLat()));
|
||||
resource.setLongitude(TypeConversionUtil.toBigDecimalOfNull(room.getLon()));
|
||||
resource.setJobNum(room.getJobNum());
|
||||
resource.setRunTime(room.getRunTime());
|
||||
resource.setType("2");
|
||||
saveOrUpdateBatchList.add(resource);
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.renkang.emergency.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.renkang.emergency.entity.XjAed;
|
||||
|
||||
public interface XjAedMapper extends BaseMapper<XjAed> {
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.renkang.emergency.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.renkang.emergency.entity.XjAed;
|
||||
|
||||
public interface IXjAedService extends IService<XjAed> {
|
||||
|
||||
void aedDataInit();
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
package com.renkang.emergency.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.renkang.emergency.entity.XjAed;
|
||||
import com.renkang.emergency.mapper.XjAedMapper;
|
||||
import com.renkang.emergency.service.IXjAedService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.jeecg.untils.CoordinateConverter;
|
||||
import org.jeecg.util.TypeConversionUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class XjAedServiceImpl extends ServiceImpl<XjAedMapper, XjAed> implements IXjAedService {
|
||||
|
||||
private final CoordinateConverter converter;
|
||||
|
||||
@Override
|
||||
public void aedDataInit() {
|
||||
String filePath = "D:\\Project\\Java\\rk\\文档\\新疆油田-24\\各二级单位坐标位置更正统计9.15(2).xlsx";
|
||||
|
||||
try (FileInputStream file = new FileInputStream(filePath);
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(file)) {
|
||||
|
||||
// 获取第一个工作表
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
List<XjAed> xjAedList = new ArrayList<>();
|
||||
// 从第二行开始(索引为1)
|
||||
for (int i = 2; i <= sheet.getLastRowNum(); i++) {
|
||||
XSSFRow row = sheet.getRow(i);
|
||||
if (row != null) {
|
||||
// 获取第一个单元格(索引0)的数据 设置地点
|
||||
XSSFCell firstCell = row.getCell(0);
|
||||
String firstCellValue = firstCell != null ? getCellValue(firstCell) : "[空]";
|
||||
|
||||
// 获取第二个单元格(索引1)的数据 经度
|
||||
XSSFCell secondCell = row.getCell(1);
|
||||
String secondCellValue = secondCell != null ? getCellValue(secondCell) : "[空]";
|
||||
|
||||
// 获取第三个单元格(索引1)的数据 纬度
|
||||
XSSFCell threeCell = row.getCell(2);
|
||||
String threeCellValue = secondCell != null ? getCellValue(threeCell) : "[空]";
|
||||
if (firstCellValue.equals("滴12生活点会议室")){
|
||||
System.out.println(1);
|
||||
}
|
||||
XjAed xjAed = new XjAed();
|
||||
xjAed.setName("自动体外除颤仪");
|
||||
xjAed.setAddress(firstCellValue);
|
||||
try {
|
||||
String[] split = converter.run(secondCellValue + "-" + threeCellValue).split("-");
|
||||
CoordinateConverter.Gps gps = CoordinateConverter.GPS84ToGCJ02(
|
||||
TypeConversionUtil.toDoubleOfNull(split[0]), TypeConversionUtil.toDoubleOfNull(split[1]));
|
||||
if (gps != null) {
|
||||
xjAed.setLongitude(BigDecimal.valueOf(gps.getLongitude()));
|
||||
xjAed.setLatitude(BigDecimal.valueOf(gps.getLatitude()));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
xjAedList.add(xjAed);
|
||||
}
|
||||
}
|
||||
// 过滤掉地点为空的数据
|
||||
xjAedList.removeIf(item -> {
|
||||
String address = item.getAddress();
|
||||
return address == null || address.isEmpty() || "/".equals(address) || "无".equals(address);});
|
||||
this.saveBatch(xjAedList);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("读取Excel文件失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单元格的值
|
||||
*/
|
||||
private String getCellValue(XSSFCell cell) {
|
||||
if (cell == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
return cell.getStringCellValue().trim();
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
return cell.getDateCellValue().toString();
|
||||
} else {
|
||||
// 处理数字格式,避免科学计数法
|
||||
double numericValue = cell.getNumericCellValue();
|
||||
if (numericValue == Math.floor(numericValue)) {
|
||||
// 如果是整数
|
||||
return String.valueOf((long) numericValue);
|
||||
} else {
|
||||
// 如果是小数
|
||||
return String.valueOf(numericValue);
|
||||
}
|
||||
}
|
||||
case BOOLEAN:
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
case FORMULA:
|
||||
try {
|
||||
return String.valueOf(cell.getNumericCellValue());
|
||||
} catch (Exception e) {
|
||||
return cell.getStringCellValue().trim();
|
||||
}
|
||||
case BLANK:
|
||||
return "";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
+388
@@ -0,0 +1,388 @@
|
||||
package org.jeecg.untils;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CoordinateConverter {
|
||||
|
||||
public static double pi = 3.1415926535897932384626;
|
||||
public static double a = 6378140.0;//1975年国际椭球体长半轴
|
||||
public static double ee = 0.0033528131778969143;//1975年国际椭球体扁率
|
||||
|
||||
/**
|
||||
* 将经纬度转换为度分秒格式或定位地图
|
||||
* @param xy 经纬度字符串,格式如 "116.404,39.915"
|
||||
* @param mode 1-定位地图,其他值-转换为度分秒
|
||||
* @return 转换结果或错误信息
|
||||
*/
|
||||
public String convertToDMS(String xy, int mode) {
|
||||
xy = xy.replace("°", ""); // 删除度符号
|
||||
|
||||
if (!isValidCoordinate(xy)) {
|
||||
return "经纬度错误!请对照检查:\n"
|
||||
+ "不能为空,且必须是数字;\n"
|
||||
+ "经度不能大于179,不能小于-179;\n"
|
||||
+ "纬度不能大于89,不能小于-89。";
|
||||
}
|
||||
|
||||
if (mode == 1) {
|
||||
String[] parts = xy.split(",");
|
||||
double longitude = Double.parseDouble(parts[0]);
|
||||
double latitude = Double.parseDouble(parts[1]);
|
||||
// 这里调用地图定位功能
|
||||
return "已经定位!\n"
|
||||
+ "上述经纬度位于当前地图的中心点\"+\"处,请查阅。\n"
|
||||
+ "若图像不好,可换卫星图。";
|
||||
} else {
|
||||
return "转换结果是:\n" + convertToDegreeMinuteSecond(xy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否是有效的经纬度
|
||||
*/
|
||||
private boolean isValidCoordinate(String xy) {
|
||||
String[] parts = xy.split(",");
|
||||
if (parts.length != 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
double longitude = Double.parseDouble(parts[0]);
|
||||
double latitude = Double.parseDouble(parts[1]);
|
||||
|
||||
if (Math.abs(longitude) > 179 || Math.abs(latitude) > 89) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将十进制经纬度转换为度分秒格式
|
||||
*/
|
||||
private String convertToDegreeMinuteSecond(String xy) {
|
||||
String[] parts = xy.split(",");
|
||||
double longitude = Double.parseDouble(parts[0]);
|
||||
double latitude = Double.parseDouble(parts[1]);
|
||||
|
||||
String longitudeDMS = decimalToDMS(longitude, true);
|
||||
String latitudeDMS = decimalToDMS(latitude, false);
|
||||
|
||||
return longitudeDMS + "," + latitudeDMS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将十进制转换为度分秒
|
||||
* @param decimal 十进制值
|
||||
* @param isLongitude 是否是经度
|
||||
*/
|
||||
private String decimalToDMS(double decimal, boolean isLongitude) {
|
||||
String direction;
|
||||
if (isLongitude) {
|
||||
direction = decimal >= 0 ? "东经" : "西经";
|
||||
} else {
|
||||
direction = decimal >= 0 ? "北纬" : "南纬";
|
||||
}
|
||||
|
||||
decimal = Math.abs(decimal);
|
||||
int degrees = (int) decimal;
|
||||
double remaining = (decimal - degrees) * 60;
|
||||
int minutes = (int) remaining;
|
||||
double seconds = (remaining - minutes) * 60;
|
||||
|
||||
return String.format("%s%d°%d'%.3f\"", direction, degrees, minutes, seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将度分秒转换为经纬度或定位地图
|
||||
* @param dms 度分秒字符串,格式如 "东经116°23'14.000",北纬39°54'54.000"
|
||||
* @param mode 1-定位地图,其他值-转换为经纬度
|
||||
* @param isWest 是否是西经
|
||||
* @param isSouth 是否是南纬
|
||||
* @return 转换结果或错误信息
|
||||
*/
|
||||
public String convertToDecimal(String dms, int mode, boolean isWest, boolean isSouth) {
|
||||
dms = dms.replace(",", "\",") + "\"";
|
||||
|
||||
if (!isValidDMS(dms)) {
|
||||
return "度°分'秒\"错误!请对照检查:\n"
|
||||
+ "度、分、秒不能为空,必须是数字,且不能是负数;\n"
|
||||
+ "经°不能大于179,纬°不能大于89;分、秒不能大于、等于60。";
|
||||
}
|
||||
|
||||
String longitudePrefix = isWest ? "西经" : "东经";
|
||||
String latitudePrefix = isSouth ? "南纬" : "北纬";
|
||||
|
||||
String formattedDMS = longitudePrefix + dms.replace(",", "," + latitudePrefix);
|
||||
String decimal = dmsToDecimal(formattedDMS);
|
||||
|
||||
// 格式化小数位数
|
||||
String[] parts = decimal.split(",");
|
||||
double longitude = Double.parseDouble(parts[0].replace("经度", ""));
|
||||
double latitude = Double.parseDouble(parts[1].replace("纬度", ""));
|
||||
|
||||
// 保留6位小数
|
||||
String formattedLongitude = String.format("%.6f", longitude);
|
||||
String formattedLatitude = String.format("%.6f", latitude);
|
||||
String formattedResult = formattedLongitude + "-" + formattedLatitude;
|
||||
|
||||
if (mode == 1) {
|
||||
// 这里调用地图定位功能
|
||||
return "已经定位!\n"
|
||||
+ "上述经纬度位于当前地图的中心点\"+\"处,请查阅。\n"
|
||||
+ "若图像不好,可换卫星图。";
|
||||
} else {
|
||||
return formattedResult;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否是有效的度分秒格式
|
||||
*/
|
||||
private boolean isValidDMS(String dms) {
|
||||
String[] parts = dms.split(",");
|
||||
if (parts.length != 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
String longitude = parts[0];
|
||||
String latitude = parts[1];
|
||||
|
||||
String[] lonParts = longitude.split("[°'\"]");
|
||||
String[] latParts = latitude.split("[°'\"]");
|
||||
|
||||
if (lonParts.length < 3 || latParts.length < 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
double lonDegrees = Double.parseDouble(lonParts[0]);
|
||||
double lonMinutes = Double.parseDouble(lonParts[1]);
|
||||
double lonSeconds = Double.parseDouble(lonParts[2]);
|
||||
|
||||
double latDegrees = Double.parseDouble(latParts[0]);
|
||||
double latMinutes = Double.parseDouble(latParts[1]);
|
||||
double latSeconds = Double.parseDouble(latParts[2]);
|
||||
|
||||
if (lonDegrees > 179 || lonDegrees < 0 || latDegrees > 89 || latDegrees < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lonMinutes >= 60 || lonMinutes < 0 || lonSeconds >= 60 || lonSeconds < 0 ||
|
||||
latMinutes >= 60 || latMinutes < 0 || latSeconds >= 60 || latSeconds < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将度分秒转换为十进制
|
||||
*/
|
||||
private String dmsToDecimal(String dms) {
|
||||
String[] parts = dms.split(",");
|
||||
String longitude = parts[0];
|
||||
String latitude = parts[1];
|
||||
|
||||
double lonDecimal = parseDMS(longitude);
|
||||
double latDecimal = parseDMS(latitude);
|
||||
|
||||
// 直接返回未格式化的原始值,由convertToDecimal统一处理格式
|
||||
return lonDecimal + "," + latDecimal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析度分秒字符串为十进制
|
||||
*/
|
||||
private double parseDMS(String dms) {
|
||||
boolean isNegative = dms.startsWith("西经") || dms.startsWith("南纬");
|
||||
dms = dms.replaceAll("[东经西经北纬南纬]", "");
|
||||
|
||||
String[] parts = dms.split("[°'\"]");
|
||||
double degrees = Double.parseDouble(parts[0]);
|
||||
double minutes = Double.parseDouble(parts[1]);
|
||||
double seconds = Double.parseDouble(parts[2]);
|
||||
|
||||
double decimal = degrees + minutes / 60 + seconds / 3600;
|
||||
return isNegative ? -decimal : decimal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量转换度分秒坐标为十进制度坐标
|
||||
* @param coordinates 坐标数组,每个元素格式为 "东经E:84°52′15.564″ 北纬N:45°35′53.948″"
|
||||
* @return 转换结果列表
|
||||
*/
|
||||
public List<String> batchConvertToDecimal(String[] coordinates) {
|
||||
List<String> results = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < coordinates.length; i++) {
|
||||
try {
|
||||
String coord = coordinates[i];
|
||||
// 分割经度和纬度
|
||||
String[] parts = coord.split("\t");
|
||||
if (parts.length < 2) {
|
||||
parts = coord.split("\\s+");
|
||||
}
|
||||
|
||||
if (parts.length >= 2) {
|
||||
String dj = parts[0].trim();
|
||||
String bw = parts[1].trim();
|
||||
|
||||
// 清洗数据格式
|
||||
String cleanDj = cleanCoordinateString(dj, true);
|
||||
String cleanBw = cleanCoordinateString(bw, false);
|
||||
|
||||
// 组合成标准DMS格式
|
||||
String dms = cleanDj + "," + cleanBw;
|
||||
|
||||
// 转换并添加到结果列表
|
||||
String result = convertToDecimal(dms, 0, false, false);
|
||||
results.add((i + 1) + ". " + result.replace("转换结果是:\n", ""));
|
||||
} else {
|
||||
results.add((i + 1) + ". 格式错误: " + coord);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
results.add((i + 1) + ". 转换失败: " + coordinates[i] + " - 错误: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清洗坐标字符串
|
||||
*/
|
||||
private String cleanCoordinateString(String coord, boolean isLongitude) {
|
||||
// 替换各种符号为统一格式
|
||||
String cleaned = coord.replace(":", ":")
|
||||
.replace("′", "'")
|
||||
.replace("″", "\"")
|
||||
.replace("‘", "'")
|
||||
.replace("'", "'")
|
||||
.replace("\"", "\"")
|
||||
.replace(" ", "");
|
||||
|
||||
// 移除前缀
|
||||
if (isLongitude) {
|
||||
cleaned = cleaned.replaceAll("[东经E]", "");
|
||||
} else {
|
||||
cleaned = cleaned.replaceAll("[北纬N]", "");
|
||||
}
|
||||
|
||||
// 移除冒号
|
||||
cleaned = cleaned.replace(":", "").trim();
|
||||
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
public String run(String msg){
|
||||
String[] split = msg.split("-");
|
||||
String dj = split[0];
|
||||
String bw = split[1];
|
||||
String cleanDj = dj.replace(":", ":")
|
||||
.replace("′", "'")
|
||||
.replace("″", "\"")
|
||||
.replaceAll("[东经E]", "")
|
||||
.replaceAll("[东经N]", "")
|
||||
.replace(":", "").trim();
|
||||
String cleanBw = bw.replace(":", ":")
|
||||
.replace("′", "'")
|
||||
.replace("″", "\"")
|
||||
.replaceAll("[北纬N]", "")
|
||||
.replaceAll("[北纬E]", "")
|
||||
.replace(":", "").trim();
|
||||
String dms = cleanDj + "," + cleanBw;
|
||||
return convertToDecimal(dms, 0, false, false);
|
||||
}
|
||||
|
||||
|
||||
public static Gps GPS84ToGCJ02(double lon, double lat) {
|
||||
if (outOfChina(lon, lat)) {
|
||||
return null;
|
||||
}
|
||||
double dLat = transformLat(lon - 105.0, lat - 35.0);
|
||||
double dLon = transformLon(lon - 105.0, lat - 35.0);
|
||||
double radLat = lat / 180.0 * pi;
|
||||
double magic = Math.sin(radLat);
|
||||
magic = 1 - ee * magic * magic;
|
||||
double sqrtMagic = Math.sqrt(magic);
|
||||
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
|
||||
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
|
||||
double mgLat = lat + dLat;
|
||||
double mgLon = lon + dLon;
|
||||
return new Gps(mgLon, mgLat);
|
||||
}
|
||||
|
||||
private static boolean outOfChina(double lon, double lat) {
|
||||
if (lon < 72.004 || lon > 137.8347)
|
||||
return true;
|
||||
return lat < 0.8293 || lat > 55.8271;
|
||||
}
|
||||
|
||||
private static double transformLat(double x, double y) {
|
||||
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
|
||||
+ 0.2 * Math.sqrt(Math.abs(x));
|
||||
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
|
||||
ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static double transformLon(double x, double y) {
|
||||
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
|
||||
* Math.sqrt(Math.abs(x));
|
||||
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
|
||||
ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
|
||||
ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0
|
||||
* pi)) * 2.0 / 3.0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static class Gps {
|
||||
private String id;
|
||||
private double longitude;
|
||||
private double latitude;
|
||||
|
||||
public Gps(double lon, double lat) {
|
||||
this.longitude = lon;
|
||||
this.latitude = lat;
|
||||
}
|
||||
|
||||
public Gps() {
|
||||
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -913,4 +913,8 @@ public class SysDepartController {
|
||||
return sysDepartService.queryDepartNameByOrgCodes(orgCodeSet);
|
||||
}
|
||||
|
||||
@GetMapping("/departDataInit")
|
||||
public void departDataInit(){
|
||||
sysDepartService.departDataInit();
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -264,4 +264,6 @@ public interface ISysDepartService extends IService<SysDepart> {
|
||||
List<BaseUser> queryUserByOrgCode(String orgCode);
|
||||
|
||||
Map<String, String> queryDepartNameByOrgCodes(Set<String> orgCodeSet);
|
||||
|
||||
void departDataInit();
|
||||
}
|
||||
|
||||
+141
@@ -15,6 +15,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@@ -38,11 +43,14 @@ import org.jeecg.modules.system.manager.UserCacheManager;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.untils.CoordinateConverter;
|
||||
import org.jeecg.modules.system.util.FindsDepartsChildrenUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -82,6 +90,8 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
private SysUserRoleMapper sysUserRoleMapper;
|
||||
@Autowired
|
||||
private UserCacheManager userCacheManager;
|
||||
@Autowired
|
||||
private CoordinateConverter converter;
|
||||
|
||||
@Override
|
||||
//todo departids字段做了调整,这里功能需要的话,后面再改
|
||||
@@ -1520,4 +1530,135 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
return departMapper.selectDepartGpsByDepartId(departId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void departDataInit() {
|
||||
String filePath = "D:\\Project\\Java\\rk\\文档\\新疆油田-24\\各二级单位坐标位置更正统计9.15.xlsx";
|
||||
// 获取目前的二级单位数据
|
||||
List<SysDepart> secondDeparts = departMapper
|
||||
.selectList(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getParentId, "1683768826307096578"));
|
||||
// 二级单位名称分组
|
||||
Map<String, SysDepart> secondMap = secondDeparts.stream()
|
||||
.collect(Collectors.toMap(SysDepart::getDepartName, depart -> depart, (existing, replacement) -> existing));
|
||||
|
||||
// 获取目前的三级部门数据
|
||||
List<SysDepart> threeDeparts = departMapper
|
||||
.selectList(new LambdaQueryWrapper<SysDepart>()
|
||||
.in(SysDepart::getParentId, secondDeparts.stream().map(SysDepart::getId).collect(Collectors.toList())));
|
||||
// 三级部门名称分组
|
||||
Map<String, SysDepart> threeMap = threeDeparts.stream()
|
||||
.collect(Collectors.toMap(SysDepart::getDepartName, depart -> depart, (existing, replacement) -> existing));
|
||||
|
||||
// 获取目前的四级部门数据
|
||||
List<SysDepart> fourDeparts = departMapper
|
||||
.selectList(new LambdaQueryWrapper<SysDepart>()
|
||||
.in(SysDepart::getParentId, threeDeparts.stream().map(SysDepart::getId).collect(Collectors.toList())));
|
||||
// 三级部门名称分组
|
||||
Map<String, SysDepart> fourMap = fourDeparts.stream()
|
||||
.collect(Collectors.toMap(SysDepart::getDepartName, depart -> depart, (existing, replacement) -> existing));
|
||||
|
||||
List<SysDepart> secondDepartList = new ArrayList<>();
|
||||
|
||||
List<SysDepart> threeDepartList = new ArrayList<>();
|
||||
|
||||
List<SysDepart> fourDepartList = new ArrayList<>();
|
||||
|
||||
try (FileInputStream file = new FileInputStream(filePath);
|
||||
XSSFWorkbook workbook = new XSSFWorkbook(file)) {
|
||||
|
||||
// 获取第一个工作表
|
||||
XSSFSheet sheet = workbook.getSheetAt(0);
|
||||
|
||||
// 从第二行开始(索引为1)
|
||||
for (int i = 2; i <= sheet.getLastRowNum(); i++) {
|
||||
XSSFRow row = sheet.getRow(i);
|
||||
if (row != null) {
|
||||
// 获取第一个单元格(索引0)的数据 二级单位名称
|
||||
XSSFCell firstCell = row.getCell(0);
|
||||
String firstCellValue = firstCell != null ? getCellValue(firstCell) : "[空]";
|
||||
|
||||
// 获取第二个单元格(索引1)的数据 三级部门名称
|
||||
XSSFCell secondCell = row.getCell(1);
|
||||
String secondCellValue = secondCell != null ? getCellValue(secondCell) : "[空]";
|
||||
|
||||
// 获取第三个单元格(索引1)的数据 经度
|
||||
XSSFCell threeCell = row.getCell(2);
|
||||
String threeCellValue = secondCell != null ? getCellValue(threeCell) : "[空]";
|
||||
|
||||
// 获取第四个单元格(索引1)的数据 经度
|
||||
XSSFCell fourCell = row.getCell(3);
|
||||
String fourCellValue = secondCell != null ? getCellValue(fourCell) : "[空]";
|
||||
|
||||
if (StrUtil.isNotBlank(firstCellValue)) {
|
||||
SysDepart depart = secondMap.get(firstCellValue);
|
||||
if (depart == null) {
|
||||
// 现有不存在 需添加
|
||||
SysDepart newDepart = new SysDepart();
|
||||
newDepart.setDepartName(firstCellValue);
|
||||
newDepart.setParentId("1683768826307096578");
|
||||
newDepart.setOrgCategory("2");
|
||||
newDepart.setOrgType("2");
|
||||
this.saveDepartData(newDepart,GlobalUtils.getLoginUser().getUsername());
|
||||
if (null != newDepart.getId()){
|
||||
SysDepartGps departGps = new SysDepartGps();
|
||||
departGps.setDepartId(newDepart.getId());
|
||||
String run = converter.run(threeCellValue + "-" + fourCellValue);
|
||||
System.out.println(run);
|
||||
// // 经度
|
||||
// departGps.setLng();
|
||||
// // 纬度
|
||||
// departGps.setLat();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("读取Excel文件失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单元格的值
|
||||
*/
|
||||
private String getCellValue(XSSFCell cell) {
|
||||
if (cell == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
return cell.getStringCellValue().trim();
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
return cell.getDateCellValue().toString();
|
||||
} else {
|
||||
// 处理数字格式,避免科学计数法
|
||||
double numericValue = cell.getNumericCellValue();
|
||||
if (numericValue == Math.floor(numericValue)) {
|
||||
// 如果是整数
|
||||
return String.valueOf((long) numericValue);
|
||||
} else {
|
||||
// 如果是小数
|
||||
return String.valueOf(numericValue);
|
||||
}
|
||||
}
|
||||
case BOOLEAN:
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
case FORMULA:
|
||||
try {
|
||||
return String.valueOf(cell.getNumericCellValue());
|
||||
} catch (Exception e) {
|
||||
return cell.getStringCellValue().trim();
|
||||
}
|
||||
case BLANK:
|
||||
return "";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user