|
|
@@ -0,0 +1,194 @@
|
|
|
+package com.onemap.apply.service.impl.fxpj;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.onemap.apply.domain.fxpj.GhcyjgDto;
|
|
|
+import com.onemap.apply.domain.yzt.ZymlDTO;
|
|
|
+import com.onemap.apply.mapper.fxpj.*;
|
|
|
+
|
|
|
+import com.onemap.apply.service.fxpj.GhcyService;
|
|
|
+import com.onemap.common.core.utils.StringUtils;
|
|
|
+import com.onemap.common.core.web.domain.RequestResult;
|
|
|
+import com.onemap.common.security.utils.SecurityUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+
|
|
|
+@Service("GhcyService")
|
|
|
+public class GhcyServiceImpl implements GhcyService {
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private GhcysjyMapper ghcysjyMapper;
|
|
|
+ @Resource
|
|
|
+ private GhcyjgMapper ghcyjgMapper;
|
|
|
+
|
|
|
+ //简单的配置个字典用作于前端汉化显示,后续再考虑需不需要存到数据库
|
|
|
+ private Map<String, String> fieldAliasMap = new HashMap<String, String>() {{
|
|
|
+ put("OBJECTID", "编号");
|
|
|
+ put("A_YDYHFLDM", "控规_用地用海分类代码");
|
|
|
+ put("A_YDYHFLMC", "控规_用地用海分类名称");
|
|
|
+ put("B_YDYHFLDM", "总规_用地用海分类代码");
|
|
|
+ put("B_YDYHFLMC", "总规_用地用海分类名称");
|
|
|
+ put("TBMJ", "差异面积");
|
|
|
+ put("YDYHFLDM", "用地用海分类代码");
|
|
|
+ put("YDYHFLMC", "用地用海分类名称");
|
|
|
+ put("XXGHBZDYBH", "详细规划编制单元编号");
|
|
|
+ put("XXGHBZDYMC", "详细规划编制单元名称");
|
|
|
+ }};
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RequestResult sjylist(String params) {
|
|
|
+ List<Map<String, Object>> list = ghcysjyMapper.sjylist(params);
|
|
|
+ return RequestResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RequestResult cyfxjg(String plan1, String plan2) {
|
|
|
+ if (StringUtils.isEmpty(plan1) || StringUtils.isEmpty(plan2)) {
|
|
|
+ return RequestResult.error("参数未传递!");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ //根据规划类型查询差异分析结果数据
|
|
|
+ QueryWrapper<GhcyjgDto> wrapper = new QueryWrapper();
|
|
|
+ wrapper.eq("sjy", String.format("%s,%s", plan1, plan2));
|
|
|
+ List<GhcyjgDto> res = ghcyjgMapper.selectList(wrapper);
|
|
|
+ if (res.size() > 0) {
|
|
|
+ //查询规划类型
|
|
|
+ String ghlx1 = ghcyjgMapper.getGhlx(plan1);
|
|
|
+ String ghlx2 = ghcyjgMapper.getGhlx(plan2);
|
|
|
+ //替换分析结论 %s
|
|
|
+ for (GhcyjgDto cur : res) {
|
|
|
+ String tablename = cur.getTablename();
|
|
|
+ Double tbmj = ghcyjgMapper.getTbmj(tablename);
|
|
|
+ if (tbmj == null) {
|
|
|
+ cur.setHasDetail(false);
|
|
|
+ cur.setRemark(String.format(cur.getRemark(), plan1, plan2, "0"));
|
|
|
+ } else {
|
|
|
+ cur.setRemark(String.format(cur.getRemark(), plan1, plan2, "<span style='color: red; font-weight: bold;'>" + String.valueOf(tbmj) + "</span>"));
|
|
|
+ }
|
|
|
+ if ("1".equals(ghlx1) && "1".equals(ghlx2)) {
|
|
|
+ //统计用地用海差异数据
|
|
|
+ List<Map<String, Object>> statics = ghcyjgMapper.getStatics(tablename);
|
|
|
+ cur.setStatics(statics);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //继续查询资源目录
|
|
|
+ List<ZymlDTO> zyml = new ArrayList<>();
|
|
|
+ String[] zy = {plan1, plan2};
|
|
|
+ for (String zymc : zy) {
|
|
|
+ String uuid = StringUtils.getUUID();
|
|
|
+ ZymlDTO dto = new ZymlDTO();
|
|
|
+ dto.setParent(1);
|
|
|
+ dto.setName(zymc);
|
|
|
+ dto.setBsm(uuid);
|
|
|
+ zyml.add(dto);
|
|
|
+ //查询下属资源服务
|
|
|
+ List<ZymlDTO> mls = ghcyjgMapper.getZyml(zymc);
|
|
|
+ for (ZymlDTO c : mls) {
|
|
|
+ c.setPbsm(uuid);
|
|
|
+ zyml.add(c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //返回体结构包装
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("fxjg", res);
|
|
|
+ map.put("zyml", zyml);
|
|
|
+ return RequestResult.success(map);
|
|
|
+ } else {
|
|
|
+ return RequestResult.error("暂未获取到分析结果,请重新选择规划数据!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return RequestResult.error("查询失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RequestResult getGeomById(String id) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ return RequestResult.error("参数未传递!");
|
|
|
+ }
|
|
|
+ //根据规划类型查询差异分析结果数据
|
|
|
+ QueryWrapper<GhcyjgDto> wrapper = new QueryWrapper();
|
|
|
+ wrapper.eq("id", id);
|
|
|
+ GhcyjgDto res = ghcyjgMapper.selectOne(wrapper);
|
|
|
+ if (res != null) {
|
|
|
+ List<String> geoms = ghcyjgMapper.getGeom(res.getTablename());
|
|
|
+ return RequestResult.success(geoms);
|
|
|
+ } else {
|
|
|
+ return RequestResult.error("参数传递错误,没查到数据!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RequestResult getAttributesById(String id) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ return RequestResult.error("参数未传递!");
|
|
|
+ }
|
|
|
+ //根据规划类型查询差异分析结果数据
|
|
|
+ QueryWrapper<GhcyjgDto> wrapper = new QueryWrapper();
|
|
|
+ wrapper.eq("id", id);
|
|
|
+ GhcyjgDto res = ghcyjgMapper.selectOne(wrapper);
|
|
|
+ if (res != null) {
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+ List<Map<String, Object>> attributes = ghcyjgMapper.getAttributes(res.getTablename());
|
|
|
+ List<Map<String, Object>> resultListMap = new ArrayList<>();
|
|
|
+ for (Map<String, Object> attribute : attributes) {
|
|
|
+ attribute.remove("SHAPE");
|
|
|
+ if (attribute.get("TBMJ") != null) {
|
|
|
+ Double tbmj = Double.valueOf(String.valueOf(attribute.get("TBMJ")));
|
|
|
+ attribute.put("TBMJ", df.format(tbmj));
|
|
|
+ }
|
|
|
+ resultListMap.add(convertAttributeKeys(attribute));
|
|
|
+ }
|
|
|
+ return RequestResult.success(resultListMap);
|
|
|
+ } else {
|
|
|
+ return RequestResult.error("参数传递错误,没查到数据!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RequestResult intersects(String id, Double x, Double y, Integer objectid) {
|
|
|
+ if (StringUtils.isEmpty(id)) {
|
|
|
+ return RequestResult.error("参数未传递!");
|
|
|
+ }
|
|
|
+ //根据规划类型查询差异分析结果数据
|
|
|
+ QueryWrapper<GhcyjgDto> wrapper = new QueryWrapper();
|
|
|
+ wrapper.eq("id", id);
|
|
|
+ GhcyjgDto res = ghcyjgMapper.selectOne(wrapper);
|
|
|
+ if (res != null) {
|
|
|
+ Map<String, Object> attributes = new HashMap<>();
|
|
|
+ if (objectid != null) {
|
|
|
+ String geom = ghcyjgMapper.intersectsById(res.getTablename(), objectid);
|
|
|
+ return RequestResult.success("查询成功", geom);
|
|
|
+ } else {
|
|
|
+ attributes = ghcyjgMapper.intersects(res.getTablename(), x, y);
|
|
|
+ if (attributes != null) {
|
|
|
+ attributes.remove("SHAPE");
|
|
|
+ return RequestResult.success(convertAttributeKeys(attributes));
|
|
|
+ } else {
|
|
|
+ return RequestResult.success(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return RequestResult.error("参数传递错误,没查到数据!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转换方法
|
|
|
+ public Map<String, Object> convertAttributeKeys(Map<String, Object> attributes) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ for (Map.Entry<String, Object> entry : attributes.entrySet()) {
|
|
|
+ String originalKey = entry.getKey();
|
|
|
+ Object value = entry.getValue();
|
|
|
+ // 如果字典中有对应的中文名称,就使用中文名称,否则保持原key
|
|
|
+ String newKey = fieldAliasMap.getOrDefault(originalKey, originalKey);
|
|
|
+ result.put(newKey, value);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|