Explorar o código

update:绩效百分制

zoie hai 1 ano
pai
achega
9a182375f9
Modificáronse 8 ficheiros con 225 adicións e 89 borrados
  1. 1 1
      .gitignore
  2. 13 12
      conf/app.conf
  3. 164 52
      controllers/Salary.go
  4. 1 0
      go.mod
  5. 2 0
      go.sum
  6. 5 2
      models/Account/Menu.go
  7. 2 2
      models/Account/User.go
  8. 37 20
      models/Salary/Salary.go

+ 1 - 1
.gitignore

@@ -34,6 +34,6 @@ _testmain.go
 lastupdate.tmp
 main
 nohup.out
-ERP_salary8220
+ERP_salary6702
 Makefile
 ofile

+ 13 - 12
conf/app.conf

@@ -1,5 +1,5 @@
 appname = ERP_salary
-HTTPPort = 8220
+HTTPPort = 6702
 runmode = dev
 Graceful = true
 EnableDocs = true
@@ -7,18 +7,19 @@ copyrequestbody = true
 
 Sys_Name = "ERP_SALARY"
 # Nats
-NatsServer_Url = "127.0.0.1:4222"
+# NatsServer_Url = "192.168.192.251:4222"
+NatsServer_Url = "175.178.229.79:4222"
 
-# Mysql
-MysqlServer_UrlPort = "47.111.15.17:3306"
-MysqlServer_Database = "erp_salary"
-MysqlServer_Username = "erp_salary"
-MysqlServer_Password = "DxwTJra8k5rrMdRG"
+# Mysql 线上
+MysqlServer_UrlPort = "192.168.192.251:3306"
+MysqlServer_Database = "erp_salary_test"
+MysqlServer_Username = "erp_salary_test"
+MysqlServer_Password = "784HzbWpj5LbzBHN"
 MysqlServer_MaxIdleConnections = 100
 MysqlServer_MaxOpenConnections = 200
 
 # Redis
-Redis_address = "47.111.15.17:6379"
+Redis_address = "192.168.192.251:6379"
 Redis_password = ""
 Redis_dbNum = "1"
 
@@ -27,7 +28,7 @@ FilterExcludeURL =
 FilterOnlyLoginCheckURL =
 
 # 静态资源
-Qiniu_AccessKey = "-8ezB_d-8-eUFTMvhOGbGzgeQRPeKQnaQ3DBcUxo"
-Qiniu_SecretKey = "KFhkYxTAJ2ZPN3ZS3euTsfWk8-C92rKgkhAMkDRN"
-Qiniu_BUCKET = "coldoss"
-OssQiniu = "https://coldoss.coldbaozhida.com"
+Qiniu_AccessKey = -8ezB_d-8-eUFTMvhOGbGzgeQRPeKQnaQ3DBcUxo
+Qiniu_SecretKey = KFhkYxTAJ2ZPN3ZS3euTsfWk8-C92rKgkhAMkDRN
+Qiniu_BUCKET = baozhida-erp
+Qiniu_Url = https://erposs.baozhida.cn/

+ 164 - 52
controllers/Salary.go

@@ -29,19 +29,10 @@ func (c *SalaryController) Prepare() {
 	c.User = *Account.User_r
 }
 
-// 管理员请假审批列表 只显示待审核
+// 管理员工资列表 默认显示上月工资
 func (c *SalaryController) Salary_List() {
 	var r_jsons lib.R_JSONS
 
-	page, _ := c.GetInt("page")
-
-	if page < 1 {
-		page = 1
-	}
-	page_z, _ := c.GetInt("page_z")
-	if page_z < 1 {
-		page_z = conf.Page_size
-	}
 	T_date := c.GetString("T_date")
 	var err error
 	// 年月 2023-01
@@ -58,9 +49,33 @@ func (c *SalaryController) Salary_List() {
 
 	userList, _ := NatsServer.Read_User_List_All()
 	Account.Read_User_All_Map(userList)
-	r_jsons.Data, r_jsons.Num = Salary.Read_Salary_List("", T_date, 0, page, page_z)
-	r_jsons.Page = page
-	r_jsons.Page_size = int(math.Ceil(float64(r_jsons.Num) / float64(page_z)))
+	var salary_r Salary.Salary_R
+	salary_List, num := Salary.Read_Salary_List("", T_date, 0, 0, 9999)
+	for _, salary := range salary_List {
+		salary_r.T_base += salary.T_base
+		salary_r.T_post += salary.T_post
+		salary_r.T_seniority += salary.T_seniority
+		salary_r.T_actual_Perf += salary.T_actual_Perf
+		salary_r.T_back_payment += salary.T_back_payment
+		salary_r.T_attendance += salary.T_attendance
+		salary_r.T_cut_payment += salary.T_cut_payment
+		salary_r.T_laballot += salary.T_laballot
+		salary_r.T_pension_insurance += salary.T_pension_insurance
+		salary_r.T_unemployment_insurance += salary.T_unemployment_insurance
+		salary_r.T_medical_insurance += salary.T_medical_insurance
+		salary_r.T_large_medical_insurance += salary.T_large_medical_insurance
+		salary_r.T_housing_fund += salary.T_housing_fund
+		salary_r.T_tax += salary.T_tax
+		salary_r.T_laborage += salary.T_laborage
+		salary_r.T_total += salary.T_total
+	}
+	salary_r.T_user_name = "合计"
+	salary_r.T_user_dept = "合计"
+	salary_r.T_user_post = "合计"
+	salary_List = append(salary_List, salary_r)
+
+	r_jsons.Data = salary_List
+	r_jsons.Num = num
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
 	c.ServeJSON()
@@ -69,14 +84,29 @@ func (c *SalaryController) Salary_List() {
 
 func (c *SalaryController) Salary_Get() {
 	T_uuid := c.GetString("T_uuid")
+	T_date := c.GetString("T_date")
 
-	salary, err := Salary.Read_Latest_Salary_ByT_uid(T_uuid)
+	salary, err := Salary.Read_Salary_ByT_uuid_T_date(T_uuid, T_date)
 	if err != nil {
+		if err.Error() == orm.ErrNoRows.Error() {
+			salary_new, err := Salary.Read_Latest_Salary_ByT_uid(T_uuid)
+
+			if err != nil {
+				c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
+				c.ServeJSON()
+				return
+			}
+			salary_new.T_State = 1
+			c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: salary_new}
+			c.ServeJSON()
+			return
+		}
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
 		c.ServeJSON()
 		return
 	}
-	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: salary}
+
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Salary.SalaryToSalary_R(salary)}
 	c.ServeJSON()
 	return
 }
@@ -144,17 +174,18 @@ func (c *SalaryController) Salary_Post() {
 	T_base, _ := c.GetFloat("T_base")
 	T_post, _ := c.GetFloat("T_post")
 	T_seniority, _ := c.GetFloat("T_seniority")
-	T_Perf, _ := c.GetFloat("T_Perf")
-	T_Perf_score, _ := c.GetFloat("T_Perf_score")
+	T_perf, _ := c.GetFloat("T_perf")
+	T_perf_score, _ := c.GetInt("T_perf_score")
 	T_back_payment, _ := c.GetFloat("T_back_payment")
 	T_attendance, _ := c.GetFloat("T_attendance")
 	T_cut_payment, _ := c.GetFloat("T_cut_payment")
 	T_pension_insurance, _ := c.GetFloat("T_pension_insurance")
 	T_unemployment_insurance, _ := c.GetFloat("T_unemployment_insurance")
 	T_medical_insurance, _ := c.GetFloat("T_medical_insurance")
-	T_Large_medical_insurance, _ := c.GetFloat("T_Large_medical_insurance")
+	T_Large_medical_insurance, _ := c.GetFloat("T_large_medical_insurance")
 	T_housing_fund, _ := c.GetFloat("T_housing_fund")
 	T_tax, _ := c.GetFloat("T_tax")
+	T_remark := c.GetString("T_remark")
 
 	salary, err := Salary.Read_Salary_ByT_uuid_T_date(T_uuid, T_date)
 
@@ -171,21 +202,23 @@ func (c *SalaryController) Salary_Post() {
 		T_base:                    float32(T_base),
 		T_post:                    float32(T_post),
 		T_seniority:               float32(T_seniority),
-		T_Perf:                    float32(T_Perf),
-		T_Perf_score:              float32(T_Perf_score),
+		T_perf:                    float32(T_perf),
+		T_perf_score:              T_perf_score,
 		T_back_payment:            float32(T_back_payment),
 		T_attendance:              float32(T_attendance),
 		T_cut_payment:             float32(T_cut_payment),
 		T_pension_insurance:       float32(T_pension_insurance),
 		T_unemployment_insurance:  float32(T_unemployment_insurance),
 		T_medical_insurance:       float32(T_medical_insurance),
-		T_Large_medical_insurance: float32(T_Large_medical_insurance),
+		T_large_medical_insurance: float32(T_Large_medical_insurance),
 		T_housing_fund:            float32(T_housing_fund),
 		T_tax:                     float32(T_tax),
+		T_remark:                  T_remark,
+		T_State:                   1,
 	}
 
 	if salary.Id == 0 {
-		_, err = Salary.Add_Salary(var_)
+		var_.Id, err = Salary.Add_Salary(var_)
 		if err != nil {
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败"}
 			c.ServeJSON()
@@ -193,8 +226,9 @@ func (c *SalaryController) Salary_Post() {
 		}
 	} else {
 		var_.Id = salary.Id
-		cols := []string{"T_base", "T_post", "T_seniority", "T_Perf", "T_Perf_score", "T_back_payment", "T_attendance", "T_cut_payment",
-			"T_pension_insurance", "T_unemployment_insurance", "T_medical_insurance", "T_Large_medical_insurance", "T_housing_fund", "T_tax"}
+		cols := []string{"T_base", "T_post", "T_seniority", "T_perf", "T_perf_score", "T_back_payment", "T_attendance", "T_cut_payment",
+			"T_pension_insurance", "T_unemployment_insurance", "T_medical_insurance", "T_large_medical_insurance", "T_housing_fund", "T_tax",
+			"T_remark"}
 		_, err = Salary.Update_Salary(var_, cols...)
 		if err != nil {
 			c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
@@ -216,6 +250,7 @@ func (c *SalaryController) Send_Salary() {
 
 	salary, err := Salary.Read_Salary_ById(T_id)
 	id, err := Salary.Send_Salary(salary)
+	year, month := strings.Split(salary.T_date, "-")[0], strings.Split(salary.T_date, "-")[1]
 	if err != nil {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
 		c.ServeJSON()
@@ -223,6 +258,9 @@ func (c *SalaryController) Send_Salary() {
 	}
 
 	NatsServer.AddUserLogs(c.User.T_uuid, "薪资管理", "发送工资条", id)
+	if salary.T_State == 1 {
+		NatsServer.AddNews(salary.T_uid, fmt.Sprintf("您的%s年%s月工资条已送达,请查收!", year, month), "/salaryMy")
+	}
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
 	c.ServeJSON()
@@ -260,12 +298,12 @@ func (c *SalaryController) Salary_Excel() {
 			Font:      &excelize.Font{Bold: true, Size: 11, Family: "宋体"},
 			Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
 		})
-	f.MergeCell("Sheet1", "A1", "V1")
+	f.MergeCell("Sheet1", "A1", "W1")
 	f.SetRowStyle("Sheet1", 1, 1, Style1)
 	f.SetRowHeight("Sheet1", 1, 50)
 	f.SetCellValue("Sheet1", "A1", fmt.Sprintf("贵州宝智达网络科技有限公司%s年%s月工资表", year, month))
 
-	f.MergeCell("Sheet1", "A2", "V2")
+	f.MergeCell("Sheet1", "A2", "W2")
 	f.SetRowHeight("Sheet1", 2, 30)
 	f.SetRowStyle("Sheet1", 2, 2, Style2)
 	day := da.AddDate(0, 1, -1).Day()
@@ -283,7 +321,7 @@ func (c *SalaryController) Salary_Excel() {
 			},
 		})
 
-	f.SetCellStyle("Sheet1", "A3", "V3", Style3)
+	f.SetCellStyle("Sheet1", "A3", "W3", Style3)
 	f.SetRowHeight("Sheet1", 3, 60)
 
 	// 这里设置表头
@@ -309,6 +347,7 @@ func (c *SalaryController) Salary_Excel() {
 	f.SetCellValue("Sheet1", "T3", "个税扣款")
 	f.SetCellValue("Sheet1", "U3", "扣款合计")
 	f.SetCellValue("Sheet1", "V3", "实发合计")
+	f.SetCellValue("Sheet1", "W3", "备注")
 	// 设置列宽
 	f.SetColWidth("Sheet1", "A", "D", 10)
 	f.SetColWidth("Sheet1", "E", "I", 5)
@@ -318,10 +357,31 @@ func (c *SalaryController) Salary_Excel() {
 	f.SetColWidth("Sheet1", "Q", "R", 6)
 	f.SetColWidth("Sheet1", "S", "T", 5)
 	f.SetColWidth("Sheet1", "U", "V", 12)
+	f.SetColWidth("Sheet1", "W", "W", 20)
+
+	// 冻结1-3行
+	f.SetPanes("Sheet1", &excelize.Panes{
+		Freeze:      true,
+		Split:       false,
+		XSplit:      2,
+		YSplit:      3,
+		TopLeftCell: "A1",
+		ActivePane:  "topRight",
+	})
+
+	// 过滤器
+	f.AutoFilter("Sheet1", "A3:V3", nil)
 
 	userList, _ := NatsServer.Read_User_List_All()
 	Account.Read_User_All_Map(userList)
 	salary_List, _ := Salary.Read_Salary_List("", T_date, 0, 0, 9999)
+
+	if len(salary_List) == 0 {
+		c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("暂无%s年%s月工资数据", year, month)}
+		c.ServeJSON()
+		return
+	}
+
 	// 循环写入数据
 	line := 4
 	var base, post, seniority, actual_Perf, back_payment, attendance, cut_payment, laballot float32
@@ -337,8 +397,8 @@ func (c *SalaryController) Salary_Excel() {
 		f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), salary.T_base)
 		f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), salary.T_post)
 		f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), salary.T_seniority)
-		f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), salary.T_Perf)
-		f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), salary.T_Perf_score)
+		f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), salary.T_perf)
+		f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), salary.T_perf_score)
 		f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), salary.T_actual_Perf)
 		f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), salary.T_back_payment)
 		f.SetCellValue("Sheet1", fmt.Sprintf("L%d", line), salary.T_attendance)
@@ -347,11 +407,12 @@ func (c *SalaryController) Salary_Excel() {
 		f.SetCellValue("Sheet1", fmt.Sprintf("O%d", line), salary.T_pension_insurance)
 		f.SetCellValue("Sheet1", fmt.Sprintf("P%d", line), salary.T_unemployment_insurance)
 		f.SetCellValue("Sheet1", fmt.Sprintf("Q%d", line), salary.T_medical_insurance)
-		f.SetCellValue("Sheet1", fmt.Sprintf("R%d", line), salary.T_Large_medical_insurance)
+		f.SetCellValue("Sheet1", fmt.Sprintf("R%d", line), salary.T_large_medical_insurance)
 		f.SetCellValue("Sheet1", fmt.Sprintf("S%d", line), salary.T_housing_fund)
 		f.SetCellValue("Sheet1", fmt.Sprintf("T%d", line), salary.T_tax)
 		f.SetCellValue("Sheet1", fmt.Sprintf("U%d", line), salary.T_laborage)
 		f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line), salary.T_total)
+		f.SetCellValue("Sheet1", fmt.Sprintf("W%d", line), salary.T_remark)
 
 		base += salary.T_base
 		post += salary.T_post
@@ -365,7 +426,7 @@ func (c *SalaryController) Salary_Excel() {
 		pension_insurance += salary.T_pension_insurance
 		unemployment_insurance += salary.T_unemployment_insurance
 		medical_insurance += salary.T_medical_insurance
-		Large_medical_insurance += salary.T_Large_medical_insurance
+		Large_medical_insurance += salary.T_large_medical_insurance
 		housing_fund += salary.T_housing_fund
 		tax += salary.T_tax
 		laborage += salary.T_laborage
@@ -373,25 +434,46 @@ func (c *SalaryController) Salary_Excel() {
 		line++
 
 	}
+
+	// ------------- 最后一行 合计 ------------------------
 	f.SetRowHeight("Sheet1", line, 22)
 	f.MergeCell("Sheet1", fmt.Sprintf("B%d", line), fmt.Sprintf("D%d", line))
 	f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), "合计")
-	f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), base)
-	f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), post)
-	f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), seniority)
-	f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), actual_Perf)
-	f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), back_payment)
-	f.SetCellValue("Sheet1", fmt.Sprintf("L%d", line), attendance)
-	f.SetCellValue("Sheet1", fmt.Sprintf("M%d", line), cut_payment)
-	f.SetCellValue("Sheet1", fmt.Sprintf("N%d", line), laballot)
-	f.SetCellValue("Sheet1", fmt.Sprintf("O%d", line), pension_insurance)
-	f.SetCellValue("Sheet1", fmt.Sprintf("P%d", line), unemployment_insurance)
-	f.SetCellValue("Sheet1", fmt.Sprintf("Q%d", line), medical_insurance)
-	f.SetCellValue("Sheet1", fmt.Sprintf("R%d", line), Large_medical_insurance)
-	f.SetCellValue("Sheet1", fmt.Sprintf("S%d", line), housing_fund)
-	f.SetCellValue("Sheet1", fmt.Sprintf("T%d", line), tax)
-	f.SetCellValue("Sheet1", fmt.Sprintf("U%d", line), laborage)
-	f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line), total)
+	// 代码统计
+	//f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), base)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), post)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), seniority)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), actual_Perf)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), back_payment)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("L%d", line), attendance)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("M%d", line), cut_payment)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("N%d", line), laballot)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("O%d", line), pension_insurance)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("P%d", line), unemployment_insurance)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("Q%d", line), medical_insurance)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("R%d", line), Large_medical_insurance)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("S%d", line), housing_fund)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("T%d", line), tax)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("U%d", line), laborage)
+	//f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line), total)
+
+	// 函数统计
+	f.SetCellFormula("Sheet1", fmt.Sprintf("E%d", line), fmt.Sprintf("SUM(E4,E%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("F%d", line), fmt.Sprintf("SUM(F4,F%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("G%d", line), fmt.Sprintf("SUM(G4,G%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("J%d", line), fmt.Sprintf("SUM(J4,J%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("K%d", line), fmt.Sprintf("SUM(K4,K%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("L%d", line), fmt.Sprintf("SUM(L4,L%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("M%d", line), fmt.Sprintf("SUM(M4,M%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("N%d", line), fmt.Sprintf("SUM(N4,N%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("O%d", line), fmt.Sprintf("SUM(O4,O%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("P%d", line), fmt.Sprintf("SUM(P4,P%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("Q%d", line), fmt.Sprintf("SUM(Q4,Q%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("R%d", line), fmt.Sprintf("SUM(R4,R%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("S%d", line), fmt.Sprintf("SUM(S4,S%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("T%d", line), fmt.Sprintf("SUM(T4,T%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("U%d", line), fmt.Sprintf("SUM(U4,U%d)", line-1))
+	f.SetCellFormula("Sheet1", fmt.Sprintf("V%d", line), fmt.Sprintf("SUM(V4,V%d)", line-1))
 
 	Style4, _ := f.NewStyle(
 		&excelize.Style{
@@ -405,24 +487,54 @@ func (c *SalaryController) Salary_Excel() {
 			},
 		})
 
-	f.SetCellStyle("Sheet1", "A4", fmt.Sprintf("V%d", line), Style4)
+	// 黄色填充
+	StyleYullowFill, _ := f.NewStyle(
+		&excelize.Style{
+			Font:      &excelize.Font{Bold: true, Size: 10, Family: "宋体"},
+			Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
+			Border: []excelize.Border{
+				{Type: "left", Color: "000000", Style: 1},
+				{Type: "top", Color: "000000", Style: 1},
+				{Type: "bottom", Color: "000000", Style: 1},
+				{Type: "right", Color: "000000", Style: 1},
+			},
+			Fill: excelize.Fill{Type: "pattern", Color: []string{"#FFFF00"}, Pattern: 1},
+		})
+	// 绿色填充
+	StyleGreenFill, _ := f.NewStyle(
+		&excelize.Style{
+			Font:      &excelize.Font{Bold: true, Size: 10, Family: "宋体"},
+			Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
+			Border: []excelize.Border{
+				{Type: "left", Color: "000000", Style: 1},
+				{Type: "top", Color: "000000", Style: 1},
+				{Type: "bottom", Color: "000000", Style: 1},
+				{Type: "right", Color: "000000", Style: 1},
+			},
+			Fill: excelize.Fill{Type: "pattern", Color: []string{"#92D050"}, Pattern: 1},
+		})
+
+	f.SetCellStyle("Sheet1", "A4", fmt.Sprintf("W%d", line), Style4)
 
-	timeStr := time.Now().Format("20060102150405")
+	f.SetCellStyle("Sheet1", "N3", fmt.Sprintf("N%d", line-1), StyleYullowFill)
+	f.SetCellStyle("Sheet1", "U3", fmt.Sprintf("U%d", line-1), StyleYullowFill)
+	f.SetCellStyle("Sheet1", "V3", fmt.Sprintf("V%d", line-1), StyleGreenFill)
+	filename := fmt.Sprintf("贵州宝智达网络科技有限公司%s年%s月工资表(%s)", year, month, lib.GetRandstring(6, "0123456789", 0))
 	// 保存文件
-	if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
+	if err = f.SaveAs("ofile/" + filename + ".xlsx"); err != nil {
 		fmt.Println(err)
 	}
 
 	// 上传 OSS
 	nats := natslibs.NewNats(Nats.Nats)
-	url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx")
+	url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+filename+".xlsx", "ofile/"+filename+".xlsx")
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
 		c.ServeJSON()
 		return
 	}
 	//删除目录
-	err = os.Remove("ofile/" + timeStr + ".xlsx")
+	err = os.Remove("ofile/" + filename + ".xlsx")
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 	}

+ 1 - 0
go.mod

@@ -40,6 +40,7 @@ require (
 	github.com/richardlehane/mscfb v1.0.4 // indirect
 	github.com/richardlehane/msoleps v1.0.3 // indirect
 	github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
+	github.com/shopspring/decimal v1.3.1 // indirect
 	github.com/signintech/gopdf v0.16.1 // indirect
 	github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
 	github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 // indirect

+ 2 - 0
go.sum

@@ -283,6 +283,8 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh
 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
 github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 h1:DAYUYH5869yV94zvCES9F51oYtN5oGlwjxJJz7ZCnik=
 github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
+github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
+github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
 github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
 github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=

+ 5 - 2
models/Account/Menu.go

@@ -14,8 +14,8 @@ import (
 var RedisCache_API cache.Cache
 
 func init() {
-	//orm.RegisterModel(new(menulibs.Menu))
-	//orm.RegisterModel(new(menulibs.API))
+	orm.RegisterModel(new(menulibs.Menu))
+	orm.RegisterModel(new(menulibs.API))
 
 	var err error
 
@@ -32,6 +32,9 @@ func init() {
 
 // 获取列表
 func Read_API_List_ByPower(T_power_id string, Menu_Bind string) (maps []menulibs.API) {
+	if len(Menu_Bind) == 0 {
+		return
+	}
 	o := orm.NewOrm()
 	APIDao := menulibs.NewAPI(o, RedisCache_API)
 	maps, err := APIDao.Read_API_List_ByPower(T_power_id, Menu_Bind)

+ 2 - 2
models/Account/User.go

@@ -31,7 +31,7 @@ func Read_User_T_name_Get(T_uuid string) string {
 func Read_User_T_dept_Get(T_uuid string) string {
 	v, ok := AdminMap.Load(T_uuid)
 	if ok {
-		return v.(userlibs.User).T_dept
+		return v.(userlibs.User).T_dept_name
 	} else {
 		return ""
 	}
@@ -40,7 +40,7 @@ func Read_User_T_dept_Get(T_uuid string) string {
 func Read_User_T_post_Get(T_uuid string) string {
 	v, ok := AdminMap.Load(T_uuid)
 	if ok {
-		return v.(userlibs.User).T_post
+		return v.(userlibs.User).T_post_name
 	} else {
 		return ""
 	}

+ 37 - 20
models/Salary/Salary.go

@@ -7,6 +7,7 @@ import (
 	"git.baozhida.cn/ERP_libs/lib"
 	"github.com/beego/beego/v2/adapter/orm"
 	orm2 "github.com/beego/beego/v2/client/orm"
+	"github.com/shopspring/decimal"
 	"time"
 )
 
@@ -18,19 +19,19 @@ type Salary struct {
 	T_base                    float32 `orm:"digits(12);decimals(2)"` // 基础工资
 	T_post                    float32 `orm:"digits(12);decimals(2)"` // 岗位工资
 	T_seniority               float32 `orm:"digits(12);decimals(2)"` // 工龄工资
-	T_Perf                    float32 `orm:"digits(12);decimals(2)"` // 绩效金额
-	T_Perf_score              float32 `orm:"digits(12);decimals(2)"` // 绩效得分
+	T_perf                    float32 `orm:"digits(12);decimals(2)"` // 绩效金额
+	T_perf_score              int     `orm:"size(20);default(100)"`  // 绩效得分 百分制
 	T_back_payment            float32 `orm:"digits(12);decimals(2)"` // 其他补款
 	T_attendance              float32 `orm:"digits(12);decimals(2)"` // 考勤扣款
 	T_cut_payment             float32 `orm:"digits(12);decimals(2)"` // 其他扣款
 	T_pension_insurance       float32 `orm:"digits(12);decimals(2)"` // 需缴养老保险
 	T_unemployment_insurance  float32 `orm:"digits(12);decimals(2)"` // 需缴纳失业保险
 	T_medical_insurance       float32 `orm:"digits(12);decimals(2)"` // 需缴医疗保险
-	T_Large_medical_insurance float32 `orm:"digits(12);decimals(2)"` // 需缴大额医疗保险
+	T_large_medical_insurance float32 `orm:"digits(12);decimals(2)"` // 需缴大额医疗保险
 	T_housing_fund            float32 `orm:"digits(12);decimals(2)"` // 需缴住房公积金
 	T_tax                     float32 `orm:"digits(12);decimals(2)"` // 需缴个人所得税
-
-	T_State int `orm:"size(200);default(1)"` //  1 未发送 2 已发送
+	T_remark                  string  `orm:"type(text);null"`
+	T_State                   int     `orm:"size(20);default(1)"` //  1 未发送 2 已发送
 
 	CreateTime time.Time `orm:"column(create_time);type(timestamp);null;auto_now_add"` //auto_now_add 第一次保存时才设置时间
 	UpdateTime time.Time `orm:"column(update_time);type(timestamp);null;auto_now"`     //auto_now 每次 model 保存时都会对时间自动更新
@@ -56,8 +57,8 @@ type Salary_R struct {
 	T_base         float32 // 基础工资
 	T_post         float32 // 岗位工资
 	T_seniority    float32 // 工龄工资
-	T_Perf         float32 // 绩效金额
-	T_Perf_score   float32 // 绩效得分
+	T_perf         float32 // 绩效金额
+	T_perf_score   int     // 绩效得分
 	T_actual_Perf  float32 // 实发绩效
 	T_back_payment float32 // 其他补款
 	T_attendance   float32 // 考勤扣款
@@ -67,11 +68,15 @@ type Salary_R struct {
 	T_pension_insurance       float32 // 需缴养老保险
 	T_unemployment_insurance  float32 // 需缴纳失业保险
 	T_medical_insurance       float32 // 需缴医疗保险
-	T_Large_medical_insurance float32 // 需缴大额医疗保险
+	T_large_medical_insurance float32 // 需缴大额医疗保险
 	T_housing_fund            float32 // 需缴住房公积金
 	T_tax                     float32 // 需缴个人所得税
 	T_laborage                float32 // 扣款合计=养老保险+失业保险+基本医疗保险+大额医疗保险+公积金+个税扣款
 	T_total                   float32 // 实发合计
+
+	T_remark string // 备注
+
+	T_State int
 }
 
 // ---------------- 特殊方法 -------------------
@@ -86,25 +91,34 @@ func SalaryToSalary_R(t Salary) (r Salary_R) {
 	r.T_base = t.T_base
 	r.T_post = t.T_post
 	r.T_seniority = t.T_seniority
-	r.T_Perf = t.T_Perf
-	r.T_Perf_score = t.T_Perf_score
-	r.T_actual_Perf = t.T_Perf * t.T_Perf_score
+	r.T_perf = t.T_perf
+	r.T_perf_score = t.T_perf_score
+	r.T_actual_Perf = t.T_perf * float32(t.T_perf_score/100)
 
 	r.T_back_payment = t.T_back_payment
 	r.T_attendance = t.T_attendance
 	r.T_cut_payment = t.T_cut_payment
 	// 应发合计=基本工资+岗位工资+工龄工资+实发绩效+其他补款-考勤扣款-其他扣款
-	r.T_laballot = t.T_base + t.T_post + t.T_seniority + r.T_actual_Perf + t.T_back_payment - t.T_attendance - t.T_cut_payment
-
+	T_laballot := t.T_base + t.T_post + t.T_seniority + r.T_actual_Perf + t.T_back_payment - t.T_attendance - t.T_cut_payment
+	T_laballot64, _ := decimal.NewFromFloat32(T_laballot).Round(2).Float64()
+	r.T_laballot = float32(T_laballot64)
 	r.T_pension_insurance = t.T_pension_insurance
 	r.T_unemployment_insurance = t.T_unemployment_insurance
 	r.T_medical_insurance = t.T_medical_insurance
-	r.T_Large_medical_insurance = t.T_Large_medical_insurance
+	r.T_large_medical_insurance = t.T_large_medical_insurance
 	r.T_housing_fund = t.T_housing_fund
 	r.T_tax = t.T_tax
 	// 扣款合计=养老保险+失业保险+基本医疗保险+大额医疗保险+公积金+个税扣款
-	r.T_laborage = t.T_pension_insurance + t.T_unemployment_insurance + t.T_medical_insurance + t.T_Large_medical_insurance + t.T_housing_fund + t.T_tax
-	r.T_total = r.T_laballot - r.T_laborage
+	T_laborage := t.T_pension_insurance + t.T_unemployment_insurance + t.T_medical_insurance + t.T_large_medical_insurance + t.T_housing_fund + t.T_tax
+	T_laborage64, _ := decimal.NewFromFloat32(T_laborage).Round(2).Float64()
+	r.T_laborage = float32(T_laborage64)
+
+	T_total := r.T_laballot - r.T_laborage
+	T_total64, _ := decimal.NewFromFloat32(T_total).Round(2).Float64()
+	r.T_total = float32(T_total64)
+
+	r.T_remark = t.T_remark
+	r.T_State = t.T_State
 	return r
 }
 
@@ -122,8 +136,10 @@ func Read_Salary_ById(id int) (r Salary, err error) {
 
 func Read_Salary_ByT_uuid_T_date(T_uuid, T_date string) (r Salary, err error) {
 	o := orm.NewOrm()
-	r = Salary{T_uid: T_uuid, T_date: T_date}
-	err = o.Read(&r, "T_uid", "T_date")
+	qs := o.QueryTable(new(Salary))
+	//r = Salary{T_uid: T_uuid, T_date: T_date}
+	//err = o.Read(&r, "T_uid", "T_date")
+	err = qs.Filter("T_uid", T_uuid).Filter("T_date", T_date).One(&r)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return r, err
@@ -132,13 +148,14 @@ func Read_Salary_ByT_uuid_T_date(T_uuid, T_date string) (r Salary, err error) {
 }
 
 // 添加
-func Add_Salary(m Salary) (id int64, err error) {
+func Add_Salary(m Salary) (id int, err error) {
 	o := orm.NewOrm()
-	id, err = o.Insert(&m)
+	_, err = o.Insert(&m)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
 		return
 	}
+	id = m.Id
 	return
 }