소스 검색

更新用地规划许可方法

DESKTOP-2K9OVK9\siwei 1 개월 전
부모
커밋
01adbbdc9e

+ 1 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/zrzysite/IZrzysiteCommonService.java

@@ -20,6 +20,6 @@ public interface IZrzysiteCommonService {
     void syncCurrentNodeInfo(String projectId,String nodeTableName);
 
 
-
+    String getNodeAttachment(String projectId, String nodeId, String sourceId, String nodeName);
 
 }

+ 17 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/zrzysite/IZrzysiteGhhsService.java

@@ -0,0 +1,17 @@
+package com.siwei.apply.service.zrzysite;
+
+
+
+public interface IZrzysiteGhhsService {
+
+
+
+    void syncConstructInfo();
+
+
+    void syncCurrentNodeInfo(String projectId,String nodeTableName);
+
+
+
+
+}

+ 17 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/zrzysite/IZrzysiteLandService.java

@@ -0,0 +1,17 @@
+package com.siwei.apply.service.zrzysite;
+
+
+
+public interface IZrzysiteLandService {
+
+
+
+    void syncConstructInfo();
+
+
+    void syncCurrentNodeInfo(String projectId,String nodeTableName);
+
+
+
+
+}

+ 4 - 2
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/zrzysite/impl/ZrzysiteCommonServiceImpl.java

@@ -222,12 +222,15 @@ public class ZrzysiteCommonServiceImpl implements IZrzysiteCommonService {
             JsgcghxkUpdateVo jsgcghxkUpdateVo = new JsgcghxkUpdateVo();
             jsgcghxkUpdateVo.setId(needUpdateNodeId);
             jsgcghxkUpdateVo.setProjectId(projectId);
-            jsgcghxkUpdateVo.setYddw(construct.getYdwz());
+            jsgcghxkUpdateVo.setYdwz(construct.getYdwz());
             jsgcghxkUpdateVo.setYddw(construct.getXddw());
             jsgcghxkUpdateVo.setJsgm(construct.getJsgm());
             jsgcghxkUpdateVo.setZsbh(construct.getZsbh());
             jsgcghxkUpdateVo.setFzjg(construct.getFadw());
             jsgcghxkUpdateVo.setSourceId(construct.getSqbh());
+            if (construct.getFzrq() != null) {
+                jsgcghxkUpdateVo.setFzDate(sdf.format(construct.getFzrq()));
+            }
             jsgcghxkService.update(jsgcghxkUpdateVo);
             addNodeId = needUpdateNodeId;
         }else {
@@ -248,7 +251,6 @@ public class ZrzysiteCommonServiceImpl implements IZrzysiteCommonService {
     }
 
 
-
     /*
     1.先拿到示例id
     2.根据实例id,获取所有的附件材料条数。

+ 190 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/zrzysite/impl/ZrzysiteGhhsServiceImpl.java

@@ -0,0 +1,190 @@
+package com.siwei.apply.service.zrzysite.impl;
+
+import com.siwei.apply.domain.Project;
+import com.siwei.apply.domain.Tdhyhs;
+import com.siwei.apply.domain.vo.TdhyhsUpdateVo;
+import com.siwei.apply.domain.vo.TdhyhsVo;
+import com.siwei.apply.domain.zrzysite.ZrzysiteGhhs;
+import com.siwei.apply.mapper.ProjectMapper;
+import com.siwei.apply.mapper.TdhyhsMapper;
+import com.siwei.apply.mapper.zrzysite.ZrzysiteGhhsMapper;
+import com.siwei.apply.service.TdhyhsService;
+import com.siwei.apply.service.zrzysite.IZrzysiteCommonService;
+import com.siwei.apply.service.zrzysite.IZrzysiteGhhsService;
+import com.siwei.apply.enums.AloneWorkFlowEnum;
+import com.siwei.common.core.exception.ServiceException;
+import com.siwei.common.core.utils.DateUtils;
+import com.siwei.common.core.utils.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class ZrzysiteGhhsServiceImpl implements IZrzysiteGhhsService {
+
+    @Autowired
+    private ZrzysiteGhhsMapper zrzysiteGhhsMapper;
+
+    @Autowired
+    private ProjectMapper projectMapper;
+
+    @Autowired
+    private TdhyhsMapper tdhyhsMapper;
+
+    @Autowired
+    private TdhyhsService tdhyhsService;
+
+    @Autowired
+    private IZrzysiteCommonService zrzysiteCommonService;
+
+    private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.YYYY_MM_DD);
+
+    @Override
+    public void syncConstructInfo() {
+        List<Project> ghhsProjectList = projectMapper.getZrzysiteProjectList("t_tdhyhs");
+        if (!ghhsProjectList.isEmpty()) {
+            List<String> projectCodes = ghhsProjectList.stream()
+                    .map(Project::getCode)
+                    .filter(StringUtils::isNotBlank)
+                    .collect(Collectors.toList());
+
+            List<ZrzysiteGhhs> ghhsList = zrzysiteGhhsMapper.selectByXmdmList(projectCodes);
+
+            Map<String, List<ZrzysiteGhhs>> codeToGhhsMap = ghhsList.stream()
+                    .collect(Collectors.groupingBy(ZrzysiteGhhs::getXmdm));
+
+            LinkedHashMap<Project, List<ZrzysiteGhhs>> zrzysiteGhhsMap = new LinkedHashMap<>();
+            for (Project project : ghhsProjectList) {
+                List<ZrzysiteGhhs> items = codeToGhhsMap.getOrDefault(project.getCode(), new ArrayList<>());
+                zrzysiteGhhsMap.put(project, items);
+            }
+            addGhhsInfoToDataBase(zrzysiteGhhsMap);
+        }
+        log.info("当前批次执行完毕");
+    }
+
+    @Override
+    public void syncCurrentNodeInfo(String projectId, String nodeTableName) {
+        Project project = projectMapper.get(projectId);
+        if (Objects.isNull(project) || StringUtils.isBlank(project.getCode())) {
+            throw new ServiceException("当前项目不具备同步条件,请检查项目代码是否存在");
+        }
+
+        List<ZrzysiteGhhs> ghhsList = zrzysiteGhhsMapper.selectByXmdmList(new ArrayList<>(Collections.singleton(project.getCode())));
+        if (CollectionUtils.isEmpty(ghhsList)) {
+            return;
+        }
+        List<Tdhyhs> tdhyhsList = tdhyhsMapper.get(projectId);
+        Map<String, String> resSourceIdMap = tdhyhsList.stream()
+                .filter(obj -> StringUtils.isNotBlank(obj.getSourceId()))
+                .collect(Collectors.toMap(Tdhyhs::getSourceId, Tdhyhs::getId));
+        List<String> needUpdateNodeIdList = tdhyhsList.stream()
+                .filter(s -> StringUtils.isBlank(s.getSourceId()))
+                .map(Tdhyhs::getId)
+                .collect(Collectors.toList());
+
+        String addNodeId = "";
+        for (ZrzysiteGhhs ghhs : ghhsList) {
+            String needUpdateNodeId = "";
+            if (resSourceIdMap.containsKey(ghhs.getApplyinstId())) {
+                needUpdateNodeId = resSourceIdMap.get(ghhs.getApplyinstId());
+            } else if (!needUpdateNodeIdList.isEmpty()) {
+                needUpdateNodeId = needUpdateNodeIdList.remove(0);
+            }
+            addNodeId = addOrUpdatToTable(ghhs, projectId, needUpdateNodeId);
+            zrzysiteCommonService.getNodeAttachment(projectId, addNodeId, ghhs.getApplyinstId(), AloneWorkFlowEnum.NODE_6.getName());
+        }
+    }
+
+    public void addGhhsInfoToDataBase(Map<Project, List<ZrzysiteGhhs>> zrzysiteGhhsMap) {
+        for (Map.Entry<Project, List<ZrzysiteGhhs>> entry : zrzysiteGhhsMap.entrySet()) {
+            Project project = entry.getKey();
+            List<ZrzysiteGhhs> ghhsList = entry.getValue();
+            if (CollectionUtils.isEmpty(ghhsList)) {
+                continue;
+            }
+            String projectId = project.getId();
+            String sourceType = project.getCreatorId();
+
+            String addNodeId = "";
+            if ("2".equals(sourceType)) {
+                List<Tdhyhs> tdhyhsList = tdhyhsMapper.get(projectId);
+                Optional<Tdhyhs> hasOnchainRes = tdhyhsList.stream().filter(Tdhyhs::getHasOnchain).findFirst();
+                if (hasOnchainRes.isPresent()) {
+                    continue;
+                }
+
+                if (tdhyhsList.stream().anyMatch(obj ->
+                        StringUtils.isNotBlank(obj.getHgzh())
+                                && StringUtils.isNotBlank(obj.getFzDate()))) {
+                    continue;
+                }
+
+                List<String> resSourceIdList = tdhyhsList.stream()
+                        .map(Tdhyhs::getSourceId)
+                        .filter(StringUtils::isNotBlank)
+                        .collect(Collectors.toList());
+                if (!resSourceIdList.isEmpty()) {
+                    continue;
+                }
+
+                List<String> needUpdateNodeIdList = tdhyhsList.stream()
+                        .filter(s -> StringUtils.isBlank(s.getSourceId()))
+                        .map(Tdhyhs::getId)
+                        .collect(Collectors.toList());
+
+                for (ZrzysiteGhhs ghhs : ghhsList) {
+                    String needUpdateNodeId = "";
+                    if (!needUpdateNodeIdList.isEmpty()) {
+                        needUpdateNodeId = needUpdateNodeIdList.remove(0);
+                    }
+                    addNodeId = addOrUpdatToTable(ghhs, projectId, needUpdateNodeId);
+                    zrzysiteCommonService.getNodeAttachment(projectId, addNodeId, ghhs.getApplyinstId(), AloneWorkFlowEnum.NODE_6.getName());
+                }
+            } else if ("1".equals(sourceType)) {
+                for (ZrzysiteGhhs ghhs : ghhsList) {
+                    addNodeId = addOrUpdatToTable(ghhs, projectId, "");
+                    zrzysiteCommonService.getNodeAttachment(projectId, addNodeId, ghhs.getApplyinstId(), AloneWorkFlowEnum.NODE_6.getName());
+                }
+            }
+        }
+    }
+
+    public String addOrUpdatToTable(ZrzysiteGhhs ghhs, String projectId, String needUpdateNodeId) {
+        String addNodeId = "";
+        if (StringUtils.isNotBlank(needUpdateNodeId)) {
+            TdhyhsUpdateVo updateVo = new TdhyhsUpdateVo();
+            updateVo.setId(needUpdateNodeId);
+            updateVo.setProjectId(projectId);
+            updateVo.setHgzh(ghhs.getHgzh());
+            updateVo.setFzjg(ghhs.getFzjg());
+            updateVo.setJsdw(ghhs.getYddw());
+            updateVo.setHyyj(ghhs.getHyyj());
+            updateVo.setSourceId(ghhs.getApplyinstId());
+            if (ghhs.getFzrq() != null) {
+                updateVo.setFzDate(sdf.format(ghhs.getFzrq()));
+            }
+            tdhyhsService.update(updateVo);
+            addNodeId = needUpdateNodeId;
+        } else {
+            TdhyhsVo vo = new TdhyhsVo();
+            vo.setProjectId(projectId);
+            vo.setHgzh(ghhs.getHgzh());
+            vo.setFzjg(ghhs.getFzjg());
+            vo.setJsdw(ghhs.getYddw());
+            vo.setHyyj(ghhs.getHyyj());
+            vo.setSourceId(ghhs.getApplyinstId());
+            if (ghhs.getFzrq() != null) {
+                vo.setFzDate(sdf.format(ghhs.getFzrq()));
+            }
+            addNodeId = tdhyhsService.add(vo);
+        }
+        return addNodeId;
+    }
+}

+ 214 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/zrzysite/impl/ZrzysiteLandServiceImpl.java

@@ -0,0 +1,214 @@
+package com.siwei.apply.service.zrzysite.impl;
+
+import com.siwei.apply.domain.Jsydghxk;
+import com.siwei.apply.domain.Project;
+import com.siwei.apply.domain.vo.JsydghxkUpdateVo;
+import com.siwei.apply.domain.vo.JsydghxkVo;
+import com.siwei.apply.domain.zrzysite.ZrzysiteLand;
+import com.siwei.apply.mapper.JsydghxkMapper;
+import com.siwei.apply.mapper.ProjectMapper;
+import com.siwei.apply.mapper.zrzysite.ZrzysiteLandMapper;
+import com.siwei.apply.service.JsydghxkService;
+import com.siwei.apply.service.zrzysite.IZrzysiteCommonService;
+import com.siwei.apply.service.zrzysite.IZrzysiteLandService;
+import com.siwei.apply.enums.AloneWorkFlowEnum;
+import com.siwei.common.core.exception.ServiceException;
+import com.siwei.common.core.utils.DateUtils;
+import com.siwei.common.core.utils.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@Service
+public class ZrzysiteLandServiceImpl implements IZrzysiteLandService {
+
+    @Autowired
+    private ZrzysiteLandMapper zrzysiteLandMapper;
+
+    @Autowired
+    private ProjectMapper projectMapper;
+
+    @Autowired
+    private JsydghxkMapper jsydghxkMapper;
+
+    @Autowired
+    private JsydghxkService jsydghxkService;
+
+    @Autowired
+    private IZrzysiteCommonService zrzysiteCommonService;
+
+    private final SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.YYYY_MM_DD);
+
+    @Override
+    public void syncConstructInfo() {
+        List<Project> landProjectList = projectMapper.getZrzysiteProjectList("t_jsydghxk");
+        if (!landProjectList.isEmpty()) {
+            List<String> projectCodes = landProjectList.stream()
+                    .map(Project::getCode)
+                    .filter(StringUtils::isNotBlank)
+                    .collect(Collectors.toList());
+
+            List<ZrzysiteLand> landList = zrzysiteLandMapper.selectByXmdmList(projectCodes);
+
+            Map<String, List<ZrzysiteLand>> codeToLandMap = landList.stream()
+                    .collect(Collectors.groupingBy(ZrzysiteLand::getXmdm));
+
+            LinkedHashMap<Project, List<ZrzysiteLand>> zrzysiteLandMap = new LinkedHashMap<>();
+            for (Project project : landProjectList) {
+                List<ZrzysiteLand> items = codeToLandMap.getOrDefault(project.getCode(), new ArrayList<>());
+                zrzysiteLandMap.put(project, items);
+            }
+            addLandInfoToDataBase(zrzysiteLandMap);
+        }
+        log.info("当前批次执行完毕");
+    }
+
+    @Override
+    public void syncCurrentNodeInfo(String projectId, String nodeTableName) {
+        Project project = projectMapper.get(projectId);
+        if (Objects.isNull(project) || StringUtils.isBlank(project.getCode())) {
+            throw new ServiceException("当前项目不具备同步条件,请检查项目代码是否存在");
+        }
+
+        List<ZrzysiteLand> landList = zrzysiteLandMapper.selectByXmdmList(new ArrayList<>(Collections.singleton(project.getCode())));
+        if (CollectionUtils.isEmpty(landList)) {
+            return;
+        }
+        List<Jsydghxk> jsydghxkList = jsydghxkMapper.getList(projectId);
+        Map<String, String> resSourceIdMap = jsydghxkList.stream()
+                .filter(obj -> StringUtils.isNotBlank(obj.getSourceId()))
+                .collect(Collectors.toMap(Jsydghxk::getSourceId, Jsydghxk::getId));
+        List<String> needUpdateNodeIdList = jsydghxkList.stream()
+                .filter(s -> StringUtils.isBlank(s.getSourceId()))
+                .map(Jsydghxk::getId)
+                .collect(Collectors.toList());
+
+        String addNodeId = "";
+        for (ZrzysiteLand land : landList) {
+            String needUpdateNodeId = "";
+            if (resSourceIdMap.containsKey(land.getSqbh())) {
+                needUpdateNodeId = resSourceIdMap.get(land.getSqbh());
+            } else if (!needUpdateNodeIdList.isEmpty()) {
+                needUpdateNodeId = needUpdateNodeIdList.remove(0);
+            }
+            addNodeId = addOrUpdatToTable(land, projectId, needUpdateNodeId);
+            zrzysiteCommonService.getNodeAttachment(projectId, addNodeId, land.getSqbh(), AloneWorkFlowEnum.NODE_4.getName());
+        }
+    }
+
+    public void addLandInfoToDataBase(Map<Project, List<ZrzysiteLand>> zrzysiteLandMap) {
+        for (Map.Entry<Project, List<ZrzysiteLand>> entry : zrzysiteLandMap.entrySet()) {
+            Project project = entry.getKey();
+            List<ZrzysiteLand> landList = entry.getValue();
+            if (CollectionUtils.isEmpty(landList)) {
+                continue;
+            }
+            String projectId = project.getId();
+            String sourceType = project.getCreatorId();
+
+            String addNodeId = "";
+            if ("2".equals(sourceType)) {
+                List<Jsydghxk> jsydghxkList = jsydghxkMapper.getList(projectId);
+                Optional<Jsydghxk> hasOnchainRes = jsydghxkList.stream().filter(Jsydghxk::getHasOnchain).findFirst();
+                if (hasOnchainRes.isPresent()) {
+                    continue;
+                }
+
+                if (jsydghxkList.stream().anyMatch(obj ->
+                        StringUtils.isNotBlank(obj.getZsbh())
+                                && StringUtils.isNotBlank(obj.getFzDate()))) {
+                    continue;
+                }
+
+                List<String> resSourceIdList = jsydghxkList.stream()
+                        .map(Jsydghxk::getSourceId)
+                        .filter(StringUtils::isNotBlank)
+                        .collect(Collectors.toList());
+                if (!resSourceIdList.isEmpty()) {
+                    continue;
+                }
+
+                List<String> needUpdateNodeIdList = jsydghxkList.stream()
+                        .filter(s -> StringUtils.isBlank(s.getSourceId()))
+                        .map(Jsydghxk::getId)
+                        .collect(Collectors.toList());
+
+                for (ZrzysiteLand land : landList) {
+                    String needUpdateNodeId = "";
+                    if (!needUpdateNodeIdList.isEmpty()) {
+                        needUpdateNodeId = needUpdateNodeIdList.remove(0);
+                    }
+                    addNodeId = addOrUpdatToTable(land, projectId, needUpdateNodeId);
+                    zrzysiteCommonService.getNodeAttachment(projectId, addNodeId, land.getSqbh(), AloneWorkFlowEnum.NODE_4.getName());
+                }
+            } else if ("1".equals(sourceType)) {
+                for (ZrzysiteLand land : landList) {
+                    addNodeId = addOrUpdatToTable(land, projectId, "");
+                    zrzysiteCommonService.getNodeAttachment(projectId, addNodeId, land.getSqbh(), AloneWorkFlowEnum.NODE_4.getName());
+                }
+            }
+        }
+    }
+
+    public String addOrUpdatToTable(ZrzysiteLand land, String projectId, String needUpdateNodeId) {
+        String addNodeId = "";
+        if (StringUtils.isNotBlank(needUpdateNodeId)) {
+            JsydghxkUpdateVo updateVo = new JsydghxkUpdateVo();
+            updateVo.setId(needUpdateNodeId);
+            updateVo.setProjectId(projectId);
+            updateVo.setYddw(land.getXddw());
+            updateVo.setYdwz(land.getYdwz());
+            if (StringUtils.isNotBlank(land.getYdmj())) {
+                try {
+                    updateVo.setYdArea(Float.parseFloat(land.getYdmj()));
+                } catch (NumberFormatException e) {
+                    log.warn("用地面积转换失败: {}", land.getYdmj());
+                }
+            }
+            updateVo.setTdyt(land.getTdyt());
+            updateVo.setTdhqfs(land.getTdhqfs());
+            updateVo.setPzydjg(land.getPzydjg());
+            updateVo.setPzydwh(land.getPzydwh());
+            updateVo.setJsgm(land.getJsgm());
+            updateVo.setZsbh(land.getZsbh());
+            updateVo.setFzjg(land.getFadw());
+            updateVo.setSourceId(land.getSqbh());
+            if (land.getFzrq() != null) {
+                updateVo.setFzDate(sdf.format(land.getFzrq()));
+            }
+            jsydghxkService.update(updateVo);
+            addNodeId = needUpdateNodeId;
+        } else {
+            JsydghxkVo vo = new JsydghxkVo();
+            vo.setProjectId(projectId);
+            vo.setYddw(land.getXddw());
+            vo.setYdwz(land.getYdwz());
+            if (StringUtils.isNotBlank(land.getYdmj())) {
+                try {
+                    vo.setYdArea(Float.parseFloat(land.getYdmj()));
+                } catch (NumberFormatException e) {
+                    log.warn("用地面积转换失败: {}", land.getYdmj());
+                }
+            }
+            vo.setTdyt(land.getTdyt());
+            vo.setTdhqfs(land.getTdhqfs());
+            vo.setPzydjg(land.getPzydjg());
+            vo.setPzydwh(land.getPzydwh());
+            vo.setJsgm(land.getJsgm());
+            vo.setZsbh(land.getZsbh());
+            vo.setFzjg(land.getFadw());
+            vo.setSourceId(land.getSqbh());
+            if (land.getFzrq() != null) {
+                vo.setFzDate(sdf.format(land.getFzrq()));
+            }
+            addNodeId = jsydghxkService.add(vo);
+        }
+        return addNodeId;
+    }
+}

+ 8 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/JsydghxkMapper.xml

@@ -58,6 +58,14 @@
         ORDER BY created_at ASC
     </select>
 
+    <!-- 根据项目ID获取记录列表 -->
+    <select id="getList" resultMap="BaseResultMap" parameterType="String">
+        SELECT *
+        FROM t_jsydghxk
+        WHERE project_id = #{projectId}
+        ORDER BY created_at ASC
+    </select>
+
     <!-- 新增:根据主键ID获取记录 -->
     <select id="getById" resultMap="BaseResultMap" parameterType="String">
         SELECT *