|
@@ -6,27 +6,31 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
|
import com.ruoyi.common.core.page.PagePlus;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.gas.domain.GArea;
|
|
|
+import com.ruoyi.gas.domain.GBuilding;
|
|
|
import com.ruoyi.gas.domain.bo.GAreaBo;
|
|
|
import com.ruoyi.gas.domain.bo.GAreaPhotoBo;
|
|
|
import com.ruoyi.gas.domain.vo.GAreaVo;
|
|
|
+import com.ruoyi.gas.domain.vo.GImportVo;
|
|
|
import com.ruoyi.gas.domain.vo.GUserVo;
|
|
|
import com.ruoyi.gas.mapper.GAreaMapper;
|
|
|
+import com.ruoyi.gas.mapper.GBuildingMapper;
|
|
|
import com.ruoyi.gas.service.IGAreaPhotoService;
|
|
|
import com.ruoyi.gas.service.IGAreaService;
|
|
|
+import com.ruoyi.system.mapper.SysDictDataMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.io.File;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -48,6 +52,90 @@ public class GAreaServiceImpl extends ServicePlusImpl<GAreaMapper, GArea, GAreaV
|
|
|
return baseMapper.getArea(userId, name);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<GImportVo> selectList() {
|
|
|
+ return baseMapper.selectGExportsList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SysDictDataMapper sysDictDataMapper;
|
|
|
+ @Resource
|
|
|
+ private GBuildingMapper gBuildingMapper;
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> importUser(List<GImportVo> list, Boolean isUpdateSupport, String operName, int n, int successNum) {
|
|
|
+ if (ObjectUtils.isEmpty(list) || list.size() == 0) {
|
|
|
+ throw new ServiceException("导入数据不能为空!");
|
|
|
+ }
|
|
|
+ Map<String, Object> ret = new HashMap<>();
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ for (int i = n; i < list.size(); i++) {
|
|
|
+ GImportVo vo = list.get(i);
|
|
|
+
|
|
|
+ String districtValue = sysDictDataMapper.queryValueTextByKey("district", vo.getDistrict());
|
|
|
+ if (StringUtils.isBlank(districtValue)) {
|
|
|
+ throw new ServiceException("" + "第" + (n + 1) + "行行政区填写错误,导入失败!");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ n++;
|
|
|
+ // 验证是否存在这个小区
|
|
|
+ if (StringUtils.isNotEmpty(vo.getAreaName())) {
|
|
|
+ GArea area = baseMapper.getByName(vo.getAreaName());
|
|
|
+ GBuilding building = new GBuilding();
|
|
|
+ if (ObjectUtils.isEmpty(area)) {
|
|
|
+ area = new GArea();
|
|
|
+ //小区zDsZ1a2b3c4d%1234!
|
|
|
+ area.setName(vo.getAreaName());
|
|
|
+ area.setCreateBy(operName);
|
|
|
+ area.setCreateTime(new Date());
|
|
|
+ area.setDistrict(districtValue);
|
|
|
+ baseMapper.insert(area);
|
|
|
+ if (StringUtils.isNotEmpty(vo.getBuildName())) {
|
|
|
+ //楼宇
|
|
|
+ building.setName(vo.getBuildName());
|
|
|
+ building.setAreaId(area.getId());
|
|
|
+ building.setCreateBy(operName);
|
|
|
+ building.setCreateTime(new Date());
|
|
|
+ gBuildingMapper.insert(building);
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("" + "第" + (n + 1) + "行格式错误,导入失败!");
|
|
|
+ }
|
|
|
+ } else if (isUpdateSupport) {
|
|
|
+ if (StringUtils.isNotEmpty(vo.getBuildName())) {
|
|
|
+ building = gBuildingMapper.getByName(vo.getBuildName(), area.getId());
|
|
|
+ if (ObjectUtils.isEmpty(building)) {
|
|
|
+ building = new GBuilding();
|
|
|
+ //楼宇
|
|
|
+ building.setName(vo.getBuildName());
|
|
|
+ building.setAreaId(area.getId());
|
|
|
+ building.setCreateBy(operName);
|
|
|
+ building.setCreateTime(new Date());
|
|
|
+ gBuildingMapper.insert(building);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("" + "第" + (n + 1) + "行格式错误,导入失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("" + "第" + (n + 1) + "行格式错误,导入失败!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("" + "第" + (n + 1) + "行格式错误,导入失败!");
|
|
|
+ }
|
|
|
+ ret.put("bfb", String.format("%.2f", (Double.valueOf((n + 1)) / Double.valueOf(list.size())) * 100));
|
|
|
+ ret.put("n", n);
|
|
|
+ ret.put("is_success", true);
|
|
|
+ ret.put("successMsg", "");
|
|
|
+ ret.put("successNum", successNum);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
|
|
+ ret.put("bfb", String.format("%.2f", (Double.valueOf((n + 1)) / Double.valueOf(list.size())) * 100));
|
|
|
+ ret.put("n", n);
|
|
|
+ ret.put("is_success", false);
|
|
|
+ ret.put("successMsg", successMsg.toString());
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Boolean releaseIs(Long id) {
|