浏览代码

+ 项目层级变更

chen.cheng 3 月之前
父节点
当前提交
7afa218a70

+ 3 - 3
bd-park/park-backend/park-application/src/main/java/com/huashe/park/application/web/controller/cons/ProjectInfoController.java

@@ -98,8 +98,8 @@ public class ProjectInfoController extends BaseController {
      */
 
     @Log(title = "工程信息", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids) {
-        return toAjax(projectInfoService.deleteProjectInfoByIds(ids));
+    @DeleteMapping("/{id}")
+    public AjaxResult remove(@PathVariable Long id) {
+        return toAjax(projectInfoService.deleteProjectInfoById(id));
     }
 }

+ 4 - 0
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/IConsUnitInfoService.java

@@ -41,6 +41,8 @@ public interface IConsUnitInfoService {
      */
     int insertConsUnitInfo(ConsUnitMachine consUnitInfo);
 
+    int insertConsUnitInfo(ConsUnitInfo consUnitInfo);
+
     /**
      * 修改施工单元
      * 
@@ -69,6 +71,8 @@ public interface IConsUnitInfoService {
      */
     int deleteConsUnitInfoById(Long id);
 
+    int deleteConsUnitInfoByProjectId(Long projId);
+
     void importConsUnitHole(ConsUnitInfo consUnitHole);
 
     void exportConsUnitHole(ConsUnitInfo consUnitHole, HttpServletResponse response);

+ 35 - 6
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ConsUnitInfoServiceImpl.java

@@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.http.MediaType;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -111,9 +112,13 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
     @Autowired
     private CADForestCfg cadForestCfg;
 
-    @Autowired
     private IProjectInfoService projectInfoService;
 
+    @Autowired
+    public void setProjectInfoService(@Lazy IProjectInfoService projectInfoService) {
+        this.projectInfoService = projectInfoService;
+    }
+
     /**
      * 查询施工单元
      * 
@@ -153,19 +158,25 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
      * @param consUnitInfo 施工单元
      * @return 结果
      */
-    @Override
+
     @Transactional(rollbackFor = Exception.class)
     public int insertConsUnitInfo(ConsUnitMachine consUnitInfo) {
         // 处理施工单元信息
         ConsUnitInfo parentConsUnit = consUnitInfoMapper.selectConsUnitInfoById(consUnitInfo.getParentId());
         consUnitInfo.setAncestors(parentConsUnit.getAncestors() + "," + parentConsUnit.getId());
         consUnitInfo.setByteId(byte8Id.generate());
+        consUnitInfo.setProjectId(parentConsUnit.getProjectId());
         int cnt = consUnitInfoMapper.insertConsUnitInfo(consUnitInfo);
         // 处理施工单元关联信息
         handleMachine(consUnitInfo);
         return cnt;
     }
 
+    @Override
+    public int insertConsUnitInfo(ConsUnitInfo consUnitInfo) {
+        return consUnitInfoMapper.insertConsUnitInfo(consUnitInfo);
+    }
+
     /**
      * 修改施工单元
      * 
@@ -185,7 +196,9 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
                 String newAncestors = newParentConsUnit.getAncestors() + "," + newParentConsUnit.getId();
                 String oldAncestors = oldConsUnit.getAncestors();
                 consUnitInfo.setAncestors(newAncestors);
-                updateConsUnitChildren(consUnitInfo.getId(), newAncestors, oldAncestors);
+                consUnitInfo.setProjectId(newParentConsUnit.getProjectId());
+                updateConsUnitChildren(consUnitInfo.getId(), newParentConsUnit.getParentId(), newAncestors,
+                    oldAncestors);
             }
         }
         return consUnitInfoMapper.updateConsUnitInfo(consUnitInfo);
@@ -219,6 +232,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteConsUnitInfoById(Long id) {
         if (hasChildById(id)) {
             throw new ServiceException(MessageUtils.message("cons.unit.delete.no.child"));
@@ -229,8 +243,23 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deleteConsUnitInfoByProjectId(Long projId) {
+        List<ConsUnitInfo> consUnitInfos = consUnitInfoMapper.selectConsUnitInfoList(new ConsUnitInfo() {
+            {
+                setProjectId(projId);
+                setParentId(0L);
+            }
+        });
+        if (CollectionUtils.isEmpty(consUnitInfos)) {
+            return 0;
+        }
+        ConsUnitInfo consUnitInfo = consUnitInfos.get(0);
+8        return deleteConsUnitInfoById(consUnitInfo.getId());
+    }
+
+    @Override
     public void importConsUnitHole(ConsUnitInfo consUnitInfo) {
-        // TODO 要做多项目切换
         int lastIndex = RuoYiConfig.getUploadPath().lastIndexOf("/");
         String filePath = consUnitInfo.getFileId().replaceFirst(PROFILE,
             RuoYiConfig.getUploadPath().substring(0, lastIndex));
@@ -242,7 +271,6 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         CustSysConfig custSysConfig = sysCustConfigService.selectConfigObjByKey(cadForestCfg.getCadBizParam());
         HttpRequest form = HttpRequest.post(cadForestCfg.getCadServer() + "/upload").form("dwg_file", file)
             .form("param", custSysConfig.getCfgJson());
-        log.info(">>>>>>>>>>>>{}", form.toString());
         String json = form.execute().body();
         List<CADJson> cadJsons = JSONArray.parseArray(json, CADJson.class);
         pileHoleInfoService.deleteConsPileHoleInfoByConsUnitId(consUnitInfo.getId());
@@ -339,13 +367,14 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         return consUnitInfoMapper.qryConsUnitInfoByIds(unitIds);
     }
 
-    private void updateConsUnitChildren(Long id, String newAncestors, String oldAncestors) {
+    private void updateConsUnitChildren(Long id, Long projectId, String newAncestors, String oldAncestors) {
         List<ConsUnitInfo> children = consUnitInfoMapper.selectChildrenById(id);
         if (CollectionUtils.isEmpty(children)) {
             return;
         }
         for (ConsUnitInfo child : children) {
             child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
+            child.setProjectId(projectId);
         }
         consUnitInfoMapper.updateConstUnitChildren(children);
     }

+ 11 - 4
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/PileMachineInfoServiceImpl.java

@@ -180,9 +180,7 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
     public List<ConstUnitNode> qryMachineAssignedUnit(String machineId) {
         PileMachineInfo pileMachineInfo = selectPileMachineInfoByByteId(machineId);
         List<ConsUnitInfo> consUnitInfos = consUnitInfoService.machineAssignedUnit(pileMachineInfo.getId());
-        List<ProjectCoordinateInfo> projectCoordinateInfos = projectCoordinateInfoService
-            .selectProjectCoordinateInfoList(new ProjectCoordinateInfo());
-        ProjectCoordinateInfo projectCoordinateInfo = projectCoordinateInfos.get(0);
+
         // 将 consUnitInfos 使用BeanUtils将子类转换成ConstUnitNode
         List<ConstUnitNode> constUnitNodes = new ArrayList<>();
         consUnitInfos.forEach((item) -> {
@@ -191,7 +189,16 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
             constUnitNodes.add(constUnitNode);
         });
         List<ConstUnitNode> tree = buildConsUnitTree(constUnitNodes);
-        tree.forEach(item -> item.setCoordinateModel(projectCoordinateInfo));
+        tree.forEach(item -> {
+            List<ProjectCoordinateInfo> projectCoordinateInfos = projectCoordinateInfoService
+                .selectProjectCoordinateInfoList(new ProjectCoordinateInfo() {
+                    {
+                        setProjectId(item.getProjectId());
+                    }
+                });
+            ProjectCoordinateInfo projectCoordinateInfo = projectCoordinateInfos.get(0);
+            item.setCoordinateModel(projectCoordinateInfo);
+        });
         return tree;
     }
 

+ 30 - 4
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ProjectInfoServiceImpl.java

@@ -2,11 +2,17 @@ package com.huashe.park.core.service.impl;
 
 import java.util.List;
 
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.huashe.park.common.consts.enums.ConsUnitType;
 import com.huashe.park.core.mapper.ProjectInfoMapper;
+import com.huashe.park.core.service.IConsUnitInfoService;
 import com.huashe.park.core.service.IProjectInfoService;
+import com.huashe.park.domain.entity.ConsUnitInfo;
 import com.huashe.park.domain.entity.ProjectInfo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
 
 /**
  * 工程信息Service业务层处理
@@ -19,6 +25,14 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
     @Autowired
     private ProjectInfoMapper projectInfoMapper;
 
+    private IConsUnitInfoService consUnitInfoService;
+
+
+    @Autowired
+    public void setConsUnitInfoService(@Lazy IConsUnitInfoService consUnitInfoService) {
+        this.consUnitInfoService = consUnitInfoService;
+    }
+
     /**
      * 查询工程信息
      * 
@@ -48,8 +62,17 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int insertProjectInfo(ProjectInfo projectInfo) {
-        return projectInfoMapper.insertProjectInfo(projectInfo);
+        int i = projectInfoMapper.insertProjectInfo(projectInfo);
+        ConsUnitInfo consUnitInfo = new ConsUnitInfo();
+        consUnitInfo.setProjectId(projectInfo.getId());
+        consUnitInfo.setName(projectInfo.getName());
+        consUnitInfo.setParentId(0L);
+        consUnitInfo.setType(ConsUnitType.DIRECTORY.getCode());
+        consUnitInfo.setAncestors("0");
+        consUnitInfoService.insertConsUnitInfo(consUnitInfo);
+        return i;
     }
 
     /**
@@ -81,7 +104,10 @@ public class ProjectInfoServiceImpl implements IProjectInfoService {
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteProjectInfoById(Long id) {
-        return projectInfoMapper.deleteProjectInfoById(id);
+        int i = projectInfoMapper.deleteProjectInfoById(id);
+        consUnitInfoService.deleteConsUnitInfoByProjectId(id);
+        return i;
     }
 }

+ 5 - 3
bd-park/park-backend/park-core/src/main/resources/mapper/cons/ConsUnitInfoMapper.xml

@@ -45,6 +45,8 @@
         <include refid="selectConsUnitInfoVo"/>
         <where>
             <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="parentId != null">and parent_id = #{parentId}</if>
+            <if test="projectId != null">and project_id = #{projectId}</if>
         </where>
     </select>
 
@@ -63,13 +65,13 @@
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="byteId !=null ">byte_id,</if>
             <if test="penningType != null">penning_type,</if>
-            <if test="type != null">type,</if>
+            <if test="type != null">`type`,</if>
             <if test="parentId != null">parent_id,</if>
             <if test="createType != null">create_type,</if>
             <if test="classifyType != null">classify_type,</if>
-            <if test="name != null and name != ''">name,</if>
+            <if test="name != null and name != ''">`name`,</if>
             <if test="ancestors != null and ancestors!=''">ancestors,</if>
-            <if test="projectId != null">update_time,</if>
+            <if test="projectId != null">project_id,</if>
             <if test="fileId != null">file_id,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="createTime != null">create_time,</if>