|
@@ -29,19 +29,10 @@ func (c *SalaryController) Prepare() {
|
|
c.User = *Account.User_r
|
|
c.User = *Account.User_r
|
|
}
|
|
}
|
|
|
|
|
|
-// 管理员请假审批列表 只显示待审核
|
|
|
|
|
|
+// 管理员工资列表 默认显示上月工资
|
|
func (c *SalaryController) Salary_List() {
|
|
func (c *SalaryController) Salary_List() {
|
|
var r_jsons lib.R_JSONS
|
|
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")
|
|
T_date := c.GetString("T_date")
|
|
var err error
|
|
var err error
|
|
// 年月 2023-01
|
|
// 年月 2023-01
|
|
@@ -58,9 +49,33 @@ func (c *SalaryController) Salary_List() {
|
|
|
|
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
Account.Read_User_All_Map(userList)
|
|
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.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -69,14 +84,29 @@ func (c *SalaryController) Salary_List() {
|
|
|
|
|
|
func (c *SalaryController) Salary_Get() {
|
|
func (c *SalaryController) Salary_Get() {
|
|
T_uuid := c.GetString("T_uuid")
|
|
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 != 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.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
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()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -144,17 +174,18 @@ func (c *SalaryController) Salary_Post() {
|
|
T_base, _ := c.GetFloat("T_base")
|
|
T_base, _ := c.GetFloat("T_base")
|
|
T_post, _ := c.GetFloat("T_post")
|
|
T_post, _ := c.GetFloat("T_post")
|
|
T_seniority, _ := c.GetFloat("T_seniority")
|
|
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_back_payment, _ := c.GetFloat("T_back_payment")
|
|
T_attendance, _ := c.GetFloat("T_attendance")
|
|
T_attendance, _ := c.GetFloat("T_attendance")
|
|
T_cut_payment, _ := c.GetFloat("T_cut_payment")
|
|
T_cut_payment, _ := c.GetFloat("T_cut_payment")
|
|
T_pension_insurance, _ := c.GetFloat("T_pension_insurance")
|
|
T_pension_insurance, _ := c.GetFloat("T_pension_insurance")
|
|
T_unemployment_insurance, _ := c.GetFloat("T_unemployment_insurance")
|
|
T_unemployment_insurance, _ := c.GetFloat("T_unemployment_insurance")
|
|
T_medical_insurance, _ := c.GetFloat("T_medical_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_housing_fund, _ := c.GetFloat("T_housing_fund")
|
|
T_tax, _ := c.GetFloat("T_tax")
|
|
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)
|
|
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_base: float32(T_base),
|
|
T_post: float32(T_post),
|
|
T_post: float32(T_post),
|
|
T_seniority: float32(T_seniority),
|
|
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_back_payment: float32(T_back_payment),
|
|
T_attendance: float32(T_attendance),
|
|
T_attendance: float32(T_attendance),
|
|
T_cut_payment: float32(T_cut_payment),
|
|
T_cut_payment: float32(T_cut_payment),
|
|
T_pension_insurance: float32(T_pension_insurance),
|
|
T_pension_insurance: float32(T_pension_insurance),
|
|
T_unemployment_insurance: float32(T_unemployment_insurance),
|
|
T_unemployment_insurance: float32(T_unemployment_insurance),
|
|
T_medical_insurance: float32(T_medical_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_housing_fund: float32(T_housing_fund),
|
|
T_tax: float32(T_tax),
|
|
T_tax: float32(T_tax),
|
|
|
|
+ T_remark: T_remark,
|
|
|
|
+ T_State: 1,
|
|
}
|
|
}
|
|
|
|
|
|
if salary.Id == 0 {
|
|
if salary.Id == 0 {
|
|
- _, err = Salary.Add_Salary(var_)
|
|
|
|
|
|
+ var_.Id, err = Salary.Add_Salary(var_)
|
|
if err != nil {
|
|
if err != nil {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -193,8 +226,9 @@ func (c *SalaryController) Salary_Post() {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
var_.Id = salary.Id
|
|
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...)
|
|
_, err = Salary.Update_Salary(var_, cols...)
|
|
if err != nil {
|
|
if err != nil {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
|
|
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)
|
|
salary, err := Salary.Read_Salary_ById(T_id)
|
|
id, err := Salary.Send_Salary(salary)
|
|
id, err := Salary.Send_Salary(salary)
|
|
|
|
+ year, month := strings.Split(salary.T_date, "-")[0], strings.Split(salary.T_date, "-")[1]
|
|
if err != nil {
|
|
if err != nil {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -223,6 +258,9 @@ func (c *SalaryController) Send_Salary() {
|
|
}
|
|
}
|
|
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "薪资管理", "发送工资条", id)
|
|
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.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -260,12 +298,12 @@ func (c *SalaryController) Salary_Excel() {
|
|
Font: &excelize.Font{Bold: true, Size: 11, Family: "宋体"},
|
|
Font: &excelize.Font{Bold: true, Size: 11, Family: "宋体"},
|
|
Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
|
|
Alignment: &excelize.Alignment{Horizontal: "left", Vertical: "center"},
|
|
})
|
|
})
|
|
- f.MergeCell("Sheet1", "A1", "V1")
|
|
|
|
|
|
+ f.MergeCell("Sheet1", "A1", "W1")
|
|
f.SetRowStyle("Sheet1", 1, 1, Style1)
|
|
f.SetRowStyle("Sheet1", 1, 1, Style1)
|
|
f.SetRowHeight("Sheet1", 1, 50)
|
|
f.SetRowHeight("Sheet1", 1, 50)
|
|
f.SetCellValue("Sheet1", "A1", fmt.Sprintf("贵州宝智达网络科技有限公司%s年%s月工资表", year, month))
|
|
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.SetRowHeight("Sheet1", 2, 30)
|
|
f.SetRowStyle("Sheet1", 2, 2, Style2)
|
|
f.SetRowStyle("Sheet1", 2, 2, Style2)
|
|
day := da.AddDate(0, 1, -1).Day()
|
|
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)
|
|
f.SetRowHeight("Sheet1", 3, 60)
|
|
|
|
|
|
// 这里设置表头
|
|
// 这里设置表头
|
|
@@ -309,6 +347,7 @@ func (c *SalaryController) Salary_Excel() {
|
|
f.SetCellValue("Sheet1", "T3", "个税扣款")
|
|
f.SetCellValue("Sheet1", "T3", "个税扣款")
|
|
f.SetCellValue("Sheet1", "U3", "扣款合计")
|
|
f.SetCellValue("Sheet1", "U3", "扣款合计")
|
|
f.SetCellValue("Sheet1", "V3", "实发合计")
|
|
f.SetCellValue("Sheet1", "V3", "实发合计")
|
|
|
|
+ f.SetCellValue("Sheet1", "W3", "备注")
|
|
// 设置列宽
|
|
// 设置列宽
|
|
f.SetColWidth("Sheet1", "A", "D", 10)
|
|
f.SetColWidth("Sheet1", "A", "D", 10)
|
|
f.SetColWidth("Sheet1", "E", "I", 5)
|
|
f.SetColWidth("Sheet1", "E", "I", 5)
|
|
@@ -318,10 +357,31 @@ func (c *SalaryController) Salary_Excel() {
|
|
f.SetColWidth("Sheet1", "Q", "R", 6)
|
|
f.SetColWidth("Sheet1", "Q", "R", 6)
|
|
f.SetColWidth("Sheet1", "S", "T", 5)
|
|
f.SetColWidth("Sheet1", "S", "T", 5)
|
|
f.SetColWidth("Sheet1", "U", "V", 12)
|
|
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()
|
|
userList, _ := NatsServer.Read_User_List_All()
|
|
Account.Read_User_All_Map(userList)
|
|
Account.Read_User_All_Map(userList)
|
|
salary_List, _ := Salary.Read_Salary_List("", T_date, 0, 0, 9999)
|
|
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
|
|
line := 4
|
|
var base, post, seniority, actual_Perf, back_payment, attendance, cut_payment, laballot float32
|
|
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("E%d", line), salary.T_base)
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), salary.T_post)
|
|
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("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("J%d", line), salary.T_actual_Perf)
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), salary.T_back_payment)
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), salary.T_back_payment)
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("L%d", line), salary.T_attendance)
|
|
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("O%d", line), salary.T_pension_insurance)
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("P%d", line), salary.T_unemployment_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("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("S%d", line), salary.T_housing_fund)
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("T%d", line), salary.T_tax)
|
|
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("U%d", line), salary.T_laborage)
|
|
f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line), salary.T_total)
|
|
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
|
|
base += salary.T_base
|
|
post += salary.T_post
|
|
post += salary.T_post
|
|
@@ -365,7 +426,7 @@ func (c *SalaryController) Salary_Excel() {
|
|
pension_insurance += salary.T_pension_insurance
|
|
pension_insurance += salary.T_pension_insurance
|
|
unemployment_insurance += salary.T_unemployment_insurance
|
|
unemployment_insurance += salary.T_unemployment_insurance
|
|
medical_insurance += salary.T_medical_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
|
|
housing_fund += salary.T_housing_fund
|
|
tax += salary.T_tax
|
|
tax += salary.T_tax
|
|
laborage += salary.T_laborage
|
|
laborage += salary.T_laborage
|
|
@@ -373,25 +434,46 @@ func (c *SalaryController) Salary_Excel() {
|
|
line++
|
|
line++
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // ------------- 最后一行 合计 ------------------------
|
|
f.SetRowHeight("Sheet1", line, 22)
|
|
f.SetRowHeight("Sheet1", line, 22)
|
|
f.MergeCell("Sheet1", fmt.Sprintf("B%d", line), fmt.Sprintf("D%d", line))
|
|
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("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(
|
|
Style4, _ := f.NewStyle(
|
|
&excelize.Style{
|
|
&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)
|
|
fmt.Println(err)
|
|
}
|
|
}
|
|
|
|
|
|
// 上传 OSS
|
|
// 上传 OSS
|
|
nats := natslibs.NewNats(Nats.Nats)
|
|
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 {
|
|
if !is {
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
//删除目录
|
|
//删除目录
|
|
- err = os.Remove("ofile/" + timeStr + ".xlsx")
|
|
|
|
|
|
+ err = os.Remove("ofile/" + filename + ".xlsx")
|
|
if err != nil {
|
|
if err != nil {
|
|
logs.Error(lib.FuncName(), err)
|
|
logs.Error(lib.FuncName(), err)
|
|
}
|
|
}
|