| | |
| | | package com.lf.server.service.data; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.lf.server.entity.all.BaseEntity; |
| | | import com.lf.server.entity.ctrl.TabMapperEntity; |
| | | import com.lf.server.entity.data.MetaEntity; |
| | | import com.lf.server.entity.data.MetaFileEntity; |
| | | import com.lf.server.entity.md.MdZxcgEntity; |
| | | import com.lf.server.helper.ClassHelper; |
| | | import com.lf.server.helper.ExcelHelper; |
| | | import com.lf.server.helper.FileHelper; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import com.lf.server.service.all.BaseQueryService; |
| | | import com.lf.server.service.all.BaseUploadService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.File; |
| | | import java.lang.reflect.Field; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return 0; |
| | | } |
| | | |
| | | return 0; |
| | | setCreateInfo(list, mfe); |
| | | |
| | | int rows = 0; |
| | | for (int i = 0, c = list.size(); i < c; i++) { |
| | | rows += baseMapper.insert(list.get(i)); |
| | | } |
| | | |
| | | if (baseMapper instanceof GeomBaseMapper) { |
| | | GeomBaseMapper geomBaseMapper = (GeomBaseMapper) baseMapper; |
| | | updateGeom(geomBaseMapper, list); |
| | | } |
| | | |
| | | return rows; |
| | | } |
| | | |
| | | /** |
| | | * 设置创建信息 |
| | | */ |
| | | @SuppressWarnings("AlibabaRemoveCommentedCode") |
| | | private <T> void setCreateInfo(List<T> list, MetaFileEntity mfe) { |
| | | try { |
| | | for (T t : list) { |
| | | Field cuField = t.getClass().getDeclaredField("createuser"); |
| | | cuField.setAccessible(true); |
| | | cuField.set(t, mfe.getCreateUser()); |
| | | |
| | | Field ctField = t.getClass().getDeclaredField("createtime"); |
| | | ctField.setAccessible(true); |
| | | ctField.set(t, mfe.getCreateTime()); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 设置空间信息 |
| | | */ |
| | | private <T> void updateGeom(GeomBaseMapper geomBaseMapper, List<T> list) { |
| | | try { |
| | | String tabName = BaseQueryService.getTabName(geomBaseMapper); |
| | | for (T t : list) { |
| | | Field xField = t.getClass().getDeclaredField("x"); |
| | | xField.setAccessible(true); |
| | | double x = (double) xField.get(t); |
| | | |
| | | Field yField = t.getClass().getDeclaredField("y"); |
| | | yField.setAccessible(true); |
| | | double y = (double) yField.get(t); |
| | | |
| | | BaseEntity baseEntity = (BaseEntity) t; |
| | | Integer gid = baseEntity.getGid(); |
| | | |
| | | String wkt = String.format("POINT(%f %f)", x, y); |
| | | geomBaseMapper.updateGeom(tabName, gid, wkt); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | } |
| | | } |
| | | |
| | | /** |