瀏覽代碼

添加合规子节点

chengqiang 4 年之前
父節點
當前提交
093a36539c

+ 34 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/entity/AddSubData.java

@@ -0,0 +1,34 @@
+package com.jeeplus.modules.sg.overheadline.entity;
+
+/**
+ * 添加合规下级子节点数据
+ */
+public class AddSubData {
+    private String id;   //项目ID
+    private String code;   //分摊费用类型,即根据什么进行分摊
+    private String tableData; //表格数据
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getTableData() {
+        return tableData;
+    }
+
+    public void setTableData(String tableData) {
+        this.tableData = tableData;
+    }
+}

+ 34 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/entity/SubElementData.java

@@ -0,0 +1,34 @@
+package com.jeeplus.modules.sg.overheadline.entity;
+
+/**
+ * 添加合规下级子节点 子节点数据
+ */
+public class SubElementData {
+    private String wbsCode;  //WBS码
+    private String fee;  //费用
+    private String bl;   //比例
+
+    public String getWbsCode() {
+        return wbsCode;
+    }
+
+    public void setWbsCode(String wbsCode) {
+        this.wbsCode = wbsCode;
+    }
+
+    public String getFee() {
+        return fee;
+    }
+
+    public void setFee(String fee) {
+        this.fee = fee;
+    }
+
+    public String getBl() {
+        return bl;
+    }
+
+    public void setBl(String bl) {
+        this.bl = bl;
+    }
+}

+ 7 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/mapper/OverheadLineMapper.java

@@ -42,6 +42,13 @@ public interface OverheadLineMapper {
     JkxlDetailFee getElement(@Param("shortId")String shortId);
 
     /**
+     * 查找element表 parentNode节点的所有子节点信息
+     * @param parentNode 节点编码
+     * @return
+     */
+    List<JkxlDetailFee> getSubElements(@Param("shortId")String parentNode);
+
+    /**
      * 插入detail数据
      * @param jkxlDetailFee
      */

+ 11 - 50
src/main/java/com/jeeplus/modules/sg/overheadline/mapper/xml/OverheadLineMapper.xml

@@ -56,18 +56,6 @@
 		order by a.short_id
 	</select>
 
-<!--	<select id="getList"  resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
-         SELECT
-			<include refid="detailColumns"/>
-         FROM sg_wbs_elements a LEFT JOIN sg_fee_detail b on a.short_id = b.wbs_code
-         and b.id = #{id}
-         <where>
-			 a.state = '1' and project_type = #{type}
-		 </where>
-		 order by a.short_id
-	</select>
-	-->
-
 	<select id="getData"  resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
          SELECT
 			<include refid="detailColumns"/>
@@ -98,46 +86,19 @@
 		where a.short_id = #{shortId}
 	</select>
 
-	<!--<select id="findList"  resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
-		 SELECT
-		 a.id as wbsId,
-         a.project_id as projectId,
-         a.describe,
-		 a.parent_node as parentNode,
-         a.level as hierarchy,
-         a.short_id as wbsCode,
-         a.subject_allocate as subjectAllocate,
-         a.mount_matter as mountMatter,
-         a.mount_server as mountServer,
-		 a.fee_type as feeType,
-         b.original_total_cost as originalTotalCost,
-		b.original_rg_cost as originalRgCost,
-		b.original_cbr_cost as originalCbrCost,
-		b.original_fbr_cost as originalFbrCost,
-		b.original_jx_cost as originalJxCost,
-		b.measures_fee1 as measuresFee1,
-		b.measures_fee2 as measuresFee2,
-		b.measures_fee3 as measuresFee3,
-		b.other_cost as otherCost,
-		b.tex as tex,
-		b.fees as fees,
-		b.zjgc_fee as zjgcFee,
-         b.total_fee as totalFee
-         FROM sg_wbs_elements a LEFT JOIN sg_fee_detail b on a.short_id = b.wbs_code
-         and b.id = #{id}
-         order by a.id
-	</select>  -->
-<!--	<select id="getAdjust" parameterType="String" resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
-		select
-		a.simple_describe as 'describe',
+	<select id="getSubElements" resultType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
+		SELECT
+		a.describe,
+		a.simple_describe as simpleDescribe,
+		a.short_id as wbsCode,
 		a.parent_node as parentNode,
-		a.short_id as wbsCode
-		FROM sg_wbs_elements a LEFT JOIN sg_fee_detail b on a.short_id = b.wbs_code
-		<where>
-			b.id = #{id} and b.original_total_cost is not null
-		</where>
+		a.fee_type as feeType,
+		a.project_type as projectType,
+		a.level as hierarchy
+		FROM sg_wbs_elements a
+		where a.parent_node = #{parentNode}
 	</select>
--->
+
 
 	<insert id="save" parameterType="com.jeeplus.modules.sg.overheadline.entity.JkxlDetailFee">
 		insert into sg_fee_detail

+ 12 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/service/OverheadLineService.java

@@ -213,6 +213,18 @@ public class OverheadLineService {
     }
 
     /**
+     * 处理单独调整
+     * @param ftData
+     */
+    @Transactional(readOnly = false)
+    public void addSubNodes(AddSubData subData){
+        String id = subData.getId();
+        String data = subData.getTableData();   //表格数据JOSN字符串
+        String row = data.replaceAll("&quot;","\\\"");
+        List<SubElementData> subList = (List<SubElementData>) JSONArray.parseArray(row, SubElementData.class);
+    }
+
+    /**
      * 找到费用类型为feeType的节点,以及同样类型的所有父节点,逐层调整totalFee
      * @param id        结算书id
      * @param wbsCode   某其他费用节点编码

+ 35 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/util/ItemShowUtil.java

@@ -27,6 +27,7 @@ public class ItemShowUtil {
     /**
      * 为本体工程添加上级合计行,用于展示。同时设置最上级的parentNode为-1
      * 为了方便动态调整结算书数据以及展示与导出,我们只在数据库中保存本体工程类型节点(不包括“本体工程”节点)与其他费用类型节点
+     * 并且将所有节点整理成树结构
      * @param list
      * @param type
      */
@@ -36,6 +37,7 @@ public class ItemShowUtil {
             fee.setParentNode("-1");
             DetailFeeUtil.getGatherFee(fee,list);
             list.add(fee);
+            DetailFeeUtil.getTree(list);
             return fee;
         }else if(type.equals("2")){
             JkxlDetailFee body = overheadLineMapper.getElement("49000000");
@@ -58,6 +60,7 @@ public class ItemShowUtil {
             list.add(body);
             list.add(jz);
             list.add(az);
+            DetailFeeUtil.getTree(list);
             return body;
         }else if(type.equals("3")){
             JkxlDetailFee top = overheadLineMapper.getElement("20000000");
@@ -71,6 +74,7 @@ public class ItemShowUtil {
             }
             DetailFeeUtil.getGatherFee(top,topList);
             list.add(top);
+            DetailFeeUtil.getTree(list);
             return top;
         }
         return null;
@@ -133,4 +137,35 @@ public class ItemShowUtil {
     }
 
 
+    /**
+     * 对本体工程进行验证,每个节点是否缺少合规下级子节点
+     * @param fee
+     */
+    public void verifyRequireSubNode(JkxlDetailFee fee){
+        if(fee==null)
+            return;
+        List<JkxlDetailFee> subNodes = fee.getNodes();
+        if(subNodes==null||subNodes.size()==0){
+            List<JkxlDetailFee> subElements = overheadLineMapper.getSubElements(fee.getWbsCode());
+            if(subElements!=null||subElements.size()>0){
+                fee.setRequireSubNode(true);
+            }else{
+                fee.setRequireSubNode(false);
+            }
+        }else{
+            for(JkxlDetailFee subNode:subNodes){
+                verifyRequireSubNode(subNode);
+            }
+        }
+    }
+
+    /**
+     * 获取wbs中wbsCode节点下所有合规子节点
+     * @param wbsCode
+     * @return
+     */
+    public List<JkxlDetailFee> getSubElements(String wbsCode){
+        return overheadLineMapper.getSubElements(wbsCode);
+    }
+
 }

+ 38 - 0
src/main/java/com/jeeplus/modules/sg/overheadline/web/OverheadLineController.java

@@ -69,6 +69,9 @@ public class OverheadLineController extends BaseController {
     // 本体工程节点 totalFee不为空
     List<JkxlDetailFee> bodyList = overheadLineService.getDetails(id,"1","1");
     JkxlDetailFee topBodyFee =  itemShowUtil.addTotalColumn(bodyList,type);
+    if(type.equals("3")){
+      itemShowUtil.verifyRequireSubNode(topBodyFee);
+    }
     //设置其他费用的顶级节点的parentNode为-1
     List<JkxlDetailFee> otherList = overheadLineService.getDetails(id,"0","1");
     JkxlDetailFee topOtherFee = DetailFeeUtil.getTree(otherList);
@@ -159,6 +162,41 @@ public class OverheadLineController extends BaseController {
 
 
   /**
+   * 获取合规子节点列表
+   * @param request
+   * @param model
+   * @return
+   */
+  @RequestMapping("/getSubElements")
+  public String getSubElements(HttpServletRequest request,Model model){
+    String wbsCode = request.getParameter("wbsCode");
+    List<JkxlDetailFee> subElements = itemShowUtil.getSubElements(wbsCode);
+    model.addAttribute("list",subElements);
+    return "";
+  }
+
+  /**
+   * 保存子节点数据
+   * @param subData
+   * @param model
+   * @param redirectAttributes
+   * @return
+   */
+  @RequestMapping("/saveSubNodes")
+  public String saveSubNodes(AddSubData subData, Model model, RedirectAttributes redirectAttributes){
+    String id = subData.getId();
+    String itemType = itemService.get(id).getType();
+    try {
+      overheadLineService.addSubNodes(subData);
+      addMessage(redirectAttributes, "添加成功");
+    }catch (Exception e){
+      addMessage(redirectAttributes, "添加失败");
+    }
+    return "redirect:/a/jkxl/list?id="+id+"&type="+itemType;
+  }
+
+
+  /**
    *结算书数据展示页面导出单个项目成果文件
    */
   @RequestMapping("/export")

+ 5 - 3
src/main/java/com/jeeplus/modules/sg/substation/util/SubstationUtil.java

@@ -309,7 +309,8 @@ public class SubstationUtil {
                 }
             }
             if(map.isEmpty()){
-                throw new RuntimeException(getWrongMessage(qd,mainNode+"节点无法找到合规下级节点!"));
+                return;
+//                throw new RuntimeException(getWrongMessage(qd,mainNode+"节点无法找到合规下级节点!"));
             }
             List<JkxlDetailFee> subFees = new ArrayList<>();
             for(JkxlDetailFee fee:map.values()){
@@ -354,9 +355,10 @@ public class SubstationUtil {
             }
 //            mainFee.setNodes(subFees);
             mainFee.addSubNodes(subFees);
-        }else{
-            throw new RuntimeException(getWrongMessage(qd,mainNode+"节点不存在下级节点!"));
         }
+//        else{
+//            throw new RuntimeException(getWrongMessage(qd,mainNode+"节点不存在下级节点!"));
+//        }
     }
 
     public static void getSubBaseInfos(ImportExcel qd, JkxlDetailFee mainFee, String mainNode, String[] wbs, String[] nodes, Integer type){