caipin 4 년 전
부모
커밋
2f228e2992
6개의 변경된 파일435개의 추가작업 그리고 0개의 파일을 삭제
  1. 37 0
      dao/contract_dao.go
  2. 11 0
      lib/bidsection_ids.go
  3. 145 0
      lib/item_section.go
  4. 106 0
      lib/section_template1.json
  5. 122 0
      lib/section_template2.json
  6. 14 0
      lib/tree.go

+ 37 - 0
dao/contract_dao.go

@@ -0,0 +1,37 @@
+/*
+ * @description: 合同相关数据库操作
+ * @Author: CP
+ * @Date: 2020-11-17 10:41:05
+ * @FilePath: \construction_management\dao\contract_dao.go
+ */
+package dao
+
+import (
+	"github.com/go-xorm/xorm"
+	"go.mod/models"
+)
+
+//数据库操作引擎
+type ContractDao struct {
+	engine *xorm.Engine
+}
+
+//获得一个DAO对象
+func NewContractDao(engine *xorm.Engine) *ContractDao {
+	return &ContractDao{
+		engine: engine,
+	}
+}
+
+// 获得本项目的合同项目节
+func (d *ContractDao) Get(id int) *models.CmContracts {
+	data := &models.CmContracts{}
+	_, err := d.engine.
+		Where("id=? ", id).
+		Get(data)
+	if err != nil {
+		data.Id = 0
+		return data
+	}
+	return data
+}

+ 11 - 0
lib/bidsection_ids.go

@@ -0,0 +1,11 @@
+/*
+ * @description: 标段ID合集
+ * @Author: CP
+ * @Date: 2020-10-23 12:03:14
+ * @FilePath: \construction_management\lib\bidsection_ids.go
+ */
+package lib
+
+type BidsectionIds struct {
+	Id int `json:"id"`
+}

+ 145 - 0
lib/item_section.go

@@ -0,0 +1,145 @@
+/*
+ * @description: 项目节模板
+ * @Author: CP
+ * @Date: 2020-10-29 09:44:20
+ * @FilePath: \construction_management\lib\item_section.go
+ */
+package lib
+
+import (
+	"encoding/json"
+	"io/ioutil"
+	"log"
+)
+
+type ItemSection struct {
+	TemplateTree1 *ItemSectionTemplateTree
+	TemplateList1 []*ItemSectionTemplateTree
+	TemplateRule1 string
+	TemplateTree2 *ItemSectionTemplateTree
+	TemplateList2 []*ItemSectionTemplateTree
+	TemplateRule2 string
+}
+
+// 初始化项目节-树结构
+func NewItemSection() *ItemSection {
+	return &ItemSection{
+		TemplateTree1: makeItemSectionTemplateTree("1"),
+		TemplateRule1: "-",
+		TemplateTree2: makeItemSectionTemplateTree("2"),
+		TemplateRule2: "-",
+	}
+}
+
+func NewItemSectionData() *ItemSection {
+	return &ItemSection{
+		TemplateList1: makeTemplateData("1"),
+		TemplateRule1: "-",
+		TemplateList2: makeTemplateData("2"),
+		TemplateRule2: "-",
+	}
+}
+
+// 项目节模板
+type ItemSectionTemplateTree struct {
+	Id          int                        `form:"id" json:"id" `
+	ParentId    int                        `form:"parentId" json:"parentId"`
+	Name        string                     `form:"name" json:"name"`
+	Depth       int                        `form:"depth" json:"depth"`
+	Serial      int                        `form:"serial" json:"serial"`
+	Attribution string                     `form:"attribution" json:"attribution"`
+	Leaf        bool                       `json:"leaf" `
+	Children    []*ItemSectionTemplateTree `json:"children"`
+
+	IsEnd bool `json:"isEnd"`
+}
+
+// 获得项目节模板数据
+func makeTemplateData(templateNumber string) []*ItemSectionTemplateTree {
+	templateList := make([]*ItemSectionTemplateTree, 0)
+	// 读取模板文件
+	data, err := ioutil.ReadFile("../lib/section_template" + templateNumber + ".json")
+	if err != nil {
+		log.Println("项目节模板文件读取出错:err=", err)
+		return nil
+	}
+
+	err = json.Unmarshal(data, &templateList)
+	if err != nil {
+		log.Println("项目节模板Json转换出错:err=", err)
+		return nil
+	}
+	return templateList
+}
+
+// 初始化项目节模板
+// func NewTemplate() Template {
+// 	return nil
+// }
+// 生成树
+func makeItemSectionTemplateTree(templateNumber string) *ItemSectionTemplateTree {
+	// templateList := make([]*ItemSectionTemplateTree, 0)
+	// // 读取模板文件
+	// data, err := ioutil.ReadFile("../lib/" + fileName)
+	// if err != nil {
+	// 	log.Println("项目节模板文件读取出错:err=", err)
+	// 	return nil
+	// }
+
+	// err = json.Unmarshal(data, &templateList)
+	// if err != nil {
+	// 	log.Println("项目节模板Json转换出错:err=", err)
+	// 	return nil
+	// }
+	templateList := makeTemplateData(templateNumber)
+
+	// 生成根
+	template := &ItemSectionTemplateTree{}
+	template.Id = 0
+	template.Name = "root"
+	template.ParentId = -1
+	templateList = append(templateList, template)
+
+	node := template             //父节点
+	maketree(templateList, node) //调用生成tree
+	return node
+}
+
+// 创建一颗树...interface{}
+func maketree(Data []*ItemSectionTemplateTree, node *ItemSectionTemplateTree) { //参数为父节点,添加父节点的子节点指针切片
+	childs, _ := havechild(Data, node) //判断节点是否有子节点并返回
+	if childs != nil {
+		// 子节点总数
+		Total := len(childs)
+		// 标记最后一个元素
+		end := Total - 1
+		childs[end].IsEnd = true
+		// 往父节点添加子节点
+		node.Children = append(node.Children, childs[0:]...) //添加子节点
+		for _, v := range childs {                           //查询子节点的子节点,并添加到子节点
+			_, has := havechild(Data, v)
+			if has {
+				// 递归添加节点
+				maketree(Data, v)
+			}
+			// else {
+			// 	// 叶子节点
+			// 	node.Leaf = false
+			// }
+
+		}
+	}
+}
+
+// 是否有子树
+func havechild(Data []*ItemSectionTemplateTree, node *ItemSectionTemplateTree) (child []*ItemSectionTemplateTree, yes bool) {
+	for _, v := range Data {
+		if v.ParentId == node.Id {
+			child = append(child, v)
+		}
+	}
+	if child != nil {
+		yes = true
+	}
+	return
+}

+ 106 - 0
lib/section_template1.json

@@ -0,0 +1,106 @@
+[
+    {
+        "id": 1,
+        "name": "第一部分 建筑安装工程费",
+        "depth": 0,
+        "serial": 1,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 2,
+        "name": "第二部分 土地使用及拆迁补偿费",
+        "depth": 0,
+        "serial": 2,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 3,
+        "name": "第三部分 工程建设其他费",
+        "depth": 0,
+        "serial": 3,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 4,
+        "name": "建设项目管理费",
+        "depth": 1,
+        "serial": 1,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 5,
+        "name": "研究试验费",
+        "depth": 1,
+        "serial": 2,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 6,
+        "name": "建设项目前期工作费",
+        "depth": 1,
+        "serial": 3,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 7,
+        "name": "专项评价(估)费",
+        "depth": 1,
+        "serial": 4,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 8,
+        "name": "联合诗运转费",
+        "depth": 1,
+        "serial": 5,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 9,
+        "name": "工程保通管理费",
+        "depth": 1,
+        "serial": 6,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 10,
+        "name": "工程保险费",
+        "depth": 1,
+        "serial": 7,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 11,
+        "name": "其他相关费用",
+        "depth": 1,
+        "serial": 8,
+        "attribution": "3-",
+        "parentId": 3
+    },
+    {
+        "id": 12,
+        "name": "第四部分 预备费",
+        "depth": 0,
+        "serial": 4,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 13,
+        "name": "第五部分 建设期贷款利息",
+        "depth": 0,
+        "serial": 5,
+        "attribution": "",
+        "parentId": 0
+    }
+]

+ 122 - 0
lib/section_template2.json

@@ -0,0 +1,122 @@
+[
+    {
+        "id": 1,
+        "name": "第一部分 建筑安装工程费",
+        "depth": 0,
+        "serial": 1,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 2,
+        "name": "劳务",
+        "depth": 1,
+        "serial": 1,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 3,
+        "name": "材料",
+        "depth": 1,
+        "serial": 2,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 4,
+        "name": "机械",
+        "depth": 1,
+        "serial": 3,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 5,
+        "name": "设备购置",
+        "depth": 1,
+        "serial": 4,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 6,
+        "name": "临时工程",
+        "depth": 1,
+        "serial": 5,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 7,
+        "name": "施工测量、检测及试验",
+        "depth": 1,
+        "serial": 6,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 8,
+        "name": "其他直接费",
+        "depth": 1,
+        "serial": 7,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 9,
+        "name": "专项费用",
+        "depth": 1,
+        "serial": 8,
+        "attribution": "1-",
+        "parentId": 1
+    },
+    {
+        "id": 10,
+        "name": "施工场地建设",
+        "depth": 2,
+        "serial": 1,
+        "attribution": "1-8-",
+        "parentId": 9
+    },
+    {
+        "id": 11,
+        "name": "安全生产",
+        "depth": 2,
+        "serial": 2,
+        "attribution": "1-8-",
+        "parentId": 9
+    },
+    {
+        "id": 12,
+        "name": "第二部分 土地使用及拆迁补偿费",
+        "depth": 0,
+        "serial": 2,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 13,
+        "name": "第三部分 工程建设其他费",
+        "depth": 0,
+        "serial": 3,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 14,
+        "name": "第四部分 预备费",
+        "depth": 0,
+        "serial": 4,
+        "attribution": "",
+        "parentId": 0
+    },
+    {
+        "id": 15,
+        "name": "第五部分 建设期贷款利息",
+        "depth": 0,
+        "serial": 5,
+        "attribution": "",
+        "parentId": 0
+    }
+]

+ 14 - 0
lib/tree.go

@@ -0,0 +1,14 @@
+/*
+ * @description:废弃
+ * @Author: CP
+ * @Date: 2020-09-16 14:15:41
+ * @FilePath: \construction_management\lib\tree.go
+ */
+package lib
+
+type Tree struct {
+	Id       int     `json:"id"`
+	ParentId int     `json:"pid"`
+	Name     string  `json:"name"`
+	Child    []*Tree `json:"child"`
+}