package controllers import ( "ERP_project/Nats" "ERP_project/Nats/NatsServer" "ERP_project/conf" "ERP_project/logs" "ERP_project/models/Account" "ERP_project/models/Project" "baliance.com/gooxml/color" "baliance.com/gooxml/document" "baliance.com/gooxml/measurement" "baliance.com/gooxml/schema/soo/wml" "fmt" natslibs "git.baozhida.cn/ERP_libs/Nats" userlibs "git.baozhida.cn/ERP_libs/User" "git.baozhida.cn/ERP_libs/lib" "github.com/beego/beego/v2/adapter/orm" beego "github.com/beego/beego/v2/server/web" "math" "os" "strings" ) type ProjectController struct { beego.Controller User userlibs.User } func (c *ProjectController) Prepare() { c.User = *Account.User_r } func (c *ProjectController) Project_Finance_List() { // 分页参数 初始化 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_uuid := c.GetString("T_uuid") userList, _ := NatsServer.Read_User_List_All() Account.Read_User_All_Map(userList) ProjectDao := Project.NewProject(orm.NewOrm()) R_List, R_cnt := ProjectDao.Read_Project_Finance_List(T_uuid, page, page_z) var r_jsons lib.R_JSONS r_jsons.Num = R_cnt r_jsons.Data = R_List r_jsons.Page = page r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z))) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} c.ServeJSON() return } // 部门负责人查看的权限列表 func (c *ProjectController) Project_List() { // 分页参数 初始化 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_uuid := c.GetString("T_uuid") userList, _ := NatsServer.Read_User_List_All() Account.Read_User_All_Map(userList) ProjectDao := Project.NewProject(orm.NewOrm()) R_List, R_cnt := ProjectDao.Read_Project_List(T_uuid, c.User.T_uuid, page, page_z) var r_jsons lib.R_JSONS r_jsons.Num = R_cnt r_jsons.Data = R_List r_jsons.Page = page r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z))) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} c.ServeJSON() return } // 用户项目列表 func (c *ProjectController) Project_User_List() { // 分页参数 初始化 page, _ := c.GetInt("page") if page < 1 { page = 1 } page_z, _ := c.GetInt("page_z") if page_z < 1 { page_z = conf.Page_size } userList, _ := NatsServer.Read_User_List_All() Account.Read_User_All_Map(userList) ProjectDao := Project.NewProject(orm.NewOrm()) R_List, R_cnt := ProjectDao.Read_Project_List(c.User.T_uuid, "", page, page_z) var r_jsons lib.R_JSONS r_jsons.Num = R_cnt r_jsons.Data = R_List r_jsons.Page = page r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z))) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} c.ServeJSON() return } func (c *ProjectController) Project_Get() { // 查询 T_id, _ := c.GetInt("T_id") o := orm.NewOrm() ProjectDao := Project.NewProject(o) //ProjectDetailDao := Project.NewProjectDetail(o) project, err := ProjectDao.Read_Project_ById(T_id) if err != nil { c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"} c.ServeJSON() return } //detailList := ProjectDetailDao.Read_ProjectDetail_List(project.Id) userList, _ := NatsServer.Read_User_List_All() Account.Read_User_All_Map(userList) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Project.ProjectToProject_Detail(project)} c.ServeJSON() return } // 导出单个项目 func (c *ProjectController) Project_Word() { // 查询 T_id, _ := c.GetInt("T_id") o := orm.NewOrm() ProjectDao := Project.NewProject(o) project, err := ProjectDao.Read_Project_ById(T_id) if err != nil { c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"} c.ServeJSON() return } userList, _ := NatsServer.Read_User_List_All() Account.Read_User_All_Map(userList) detail := Project.ProjectToProject_Detail(project) doc := document.New() para := doc.AddParagraph() run := para.AddRun() run.Properties().SetSize(18) run.AddText("") para = doc.AddParagraph() run = para.AddRun() run.Properties().SetSize(18) run.AddText("") // Construct our header para = doc.AddParagraph() para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetBold(true) run.Properties().SetFontFamily("宋体") run.Properties().SetSize(18) para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) run.AddText("贵州宝智达网络科技有限公司") para = doc.AddParagraph() run = para.AddRun() run.Properties().SetBold(true) run.Properties().SetFontFamily("宋体") run.Properties().SetSize(18) para.Properties().SetAlignment(wml.ST_JcCenter) run.AddText("研发立项申请书") for i := 0; i < 5; i++ { para = doc.AddParagraph() run = para.AddRun() run.Properties().SetSize(18) run.AddText("") } // --------------------项目名称 para = doc.AddParagraph() para.Properties().SetFirstLineIndent(1 * measurement.Inch) para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) run.AddText("项目名称:") run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) run.AddText(detail.T_name) run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black) para = doc.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) para.Properties().SetFirstLineIndent(1 * measurement.Inch) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) run.AddText("项目负责人:") run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) run.AddText(detail.T_user_name) run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black) para = doc.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) para.Properties().SetFirstLineIndent(1 * measurement.Inch) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) run.AddText("项目立项日期:") run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) date := strings.Split(detail.T_set_up_date, "-") if len(date) == 3 { run.AddText(fmt.Sprintf("%s年%s月%s日", date[0], date[1], date[2])) run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black) } para = doc.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) para.Properties().SetFirstLineIndent(1 * measurement.Inch) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) run.AddText("项目结束日期:") run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(14) date = strings.Split(detail.T_end_date, "-") if len(date) == 3 { run.AddText(fmt.Sprintf("%s年%s月%s日", date[0], date[1], date[2])) run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black) } // 分页 para = doc.AddParagraph() para.Properties().AddSection(wml.ST_SectionMarkNextPage) table := doc.AddTable() table.Properties().SetLayout(wml.ST_TblLayoutTypeFixed) table.Properties().SetWidthPercent(100) look := table.Properties().TableLook() look.SetFirstColumn(true) look.SetFirstRow(true) look.SetHorizontalBanding(true) // width of the page // with thick borers borders := table.Properties().Borders() borders.SetBottom(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetLeft(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetRight(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetTop(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetInsideHorizontal(wml.ST_BorderSingle, color.Auto, measurement.Zero) borders.SetInsideVertical(wml.ST_BorderSingle, color.Auto, measurement.Zero) row := table.AddRow() row.Properties().SetHeight(0.4*measurement.Inch, wml.ST_HeightRuleExact) cell := row.AddCell() cell.Properties().SetWidth(0.4 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("序号") cell = row.AddCell() cell.Properties().SetWidth(1.25 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("功能与指标") cell = row.AddCell() cell.Properties().SetWidth(1.25 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("计划时间(工作日)") cell = row.AddCell() cell.Properties().SetWidth(1.25 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("是否完成(原因)") for i, r := range detail.T_Detail { row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetWidth(0.4 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("%d", i+1)) cell = row.AddCell() cell.Properties().SetWidth(1.25 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(r.T_function) cell = row.AddCell() cell.Properties().SetWidth(1.25 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("%g", r.T_planned_time)) cell = row.AddCell() cell.Properties().SetWidth(1.25 * measurement.Inch) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(r.T_finish) } // 分页 para = doc.AddParagraph() para.Properties().AddSection(wml.ST_SectionMarkNextPage) table = doc.AddTable() table.Properties().SetWidthPercent(110) table.Properties().SetAlignment(wml.ST_JcTableCenter) table.Properties().SetLayout(wml.ST_TblLayoutTypeAutofit) look = table.Properties().TableLook() look.SetFirstColumn(true) look.SetFirstRow(true) look.SetHorizontalBanding(true) borders = table.Properties().Borders() borders.SetBottom(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetLeft(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetRight(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetTop(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetInsideHorizontal(wml.ST_BorderSingle, color.Auto, measurement.Zero) borders.SetInsideVertical(wml.ST_BorderSingle, color.Auto, measurement.Zero) //-----------------项目名称 row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetWidthPercent(25) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("项目名称") cell = row.AddCell() cell.Properties().SetWidthPercent(75) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(detail.T_name) //------------------项目简介 row = table.AddRow() row.Properties().SetHeight(5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetWidthPercent(25) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("项目简介") cell = row.AddCell() cell.Properties().SetWidthPercent(75) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(detail.T_description) // -----------------绩效统计 row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetVerticalMerge(wml.ST_MergeRestart) cell.Properties().SetWidthPercent(25) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) //row.Properties().SetHeight(0.3*measurement.Inch, wml.ST_HeightRuleExact) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("绩效统计") cell = row.AddCell() cell.Properties().SetWidthPercent(40) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("计划完成周期(工作日)") cell = row.AddCell() cell.Properties().SetWidthPercent(35) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("%g", detail.T_planning_cycle)) row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetVerticalMerge(wml.ST_MergeContinue) cell.AddParagraph().AddRun().AddText("") cell = row.AddCell() cell.Properties().SetWidthPercent(40) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("实际完成周期(工作日)") cell = row.AddCell() cell.Properties().SetWidthPercent(35) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("%g", detail.T_reality_cycle)) row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetVerticalMerge(wml.ST_MergeContinue) cell.AddParagraph().AddRun().AddText("") cell = row.AddCell() cell.Properties().SetWidthPercent(40) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("提前完成天数(工作日)") cell = row.AddCell() cell.Properties().SetWidthPercent(35) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("%g", detail.T_advance_day)) row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetVerticalMerge(wml.ST_MergeContinue) cell.AddParagraph().AddRun().AddText("") cell = row.AddCell() cell.Properties().SetWidthPercent(23) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("奖励金额(元)") cell = row.AddCell() cell.Properties().SetWidthPercent(15) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("%g", detail.T_bonus)) cell = row.AddCell() cell.Properties().SetWidthPercent(22) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("绩效总金额(元)") cell = row.AddCell() cell.Properties().SetWidthPercent(15) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("%g", detail.T_Perf)) // -----------------绩效统计 row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetVerticalMerge(wml.ST_MergeRestart) cell.Properties().SetWidthPercent(25) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) //row.Properties().SetHeight(0.3*measurement.Inch, wml.ST_HeightRuleExact) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("项目验收") cell = row.AddCell() cell.Properties().SetWidthPercent(25) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("验收时间") cell = row.AddCell() cell.Properties().SetWidthPercent(25) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("测试人")) cell = row.AddCell() cell.Properties().SetWidthPercent(25) para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText(fmt.Sprintf("验收人")) row = table.AddRow() row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast) cell = row.AddCell() cell.Properties().SetVerticalMerge(wml.ST_MergeContinue) cell.AddParagraph().AddRun().AddText("") cell = row.AddCell() cell.Properties().SetWidthPercent(25) cell.AddParagraph().AddRun().AddText("") cell = row.AddCell() cell.Properties().SetWidthPercent(25) cell.AddParagraph().AddRun().AddText("") cell = row.AddCell() cell.Properties().SetWidthPercent(25) cell.AddParagraph().AddRun().AddText("") // 分页 para = doc.AddParagraph() para.Properties().AddSection(wml.ST_SectionMarkNextPage) table = doc.AddTable() table.Properties().SetWidthPercent(110) table.Properties().SetAlignment(wml.ST_JcTableCenter) table.Properties().SetLayout(wml.ST_TblLayoutTypeAutofit) look = table.Properties().TableLook() look.SetFirstColumn(true) look.SetFirstRow(true) look.SetHorizontalBanding(true) borders = table.Properties().Borders() borders.SetBottom(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetLeft(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetRight(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetTop(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point) borders.SetInsideHorizontal(wml.ST_BorderSingle, color.Auto, measurement.Zero) borders.SetInsideVertical(wml.ST_BorderSingle, color.Auto, measurement.Zero) row = table.AddRow() row.Properties().SetHeight(1.8*measurement.Inch, wml.ST_HeightRuleExact) cell = row.AddCell() cell.Properties().SetWidthPercent(30) para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("部门负责人") para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("审核意见") cell = row.AddCell() cell.Properties().SetWidthPercent(70) para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("推荐项目经理为:") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("其他意见或建议:") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("部门负责人(签字/日期):") row = table.AddRow() row.Properties().SetHeight(2.5*measurement.Inch, wml.ST_HeightRuleExact) cell = row.AddCell() cell.Properties().SetWidthPercent(30) para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("技术总监") para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("审核意见") cell = row.AddCell() cell.Properties().SetWidthPercent(70) para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("是否同意立项:□同意 □不同意") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("是否同意推荐的项目经理:□同意 □不同意") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("其他意见或建议:") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("技术总监(签字/日期):") row = table.AddRow() row.Properties().SetHeight(2.5*measurement.Inch, wml.ST_HeightRuleExact) cell = row.AddCell() cell.Properties().SetWidthPercent(30) para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("总经理") para = cell.AddParagraph() cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("审核意见") cell = row.AddCell() cell.Properties().SetWidthPercent(70) para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("是否同意立项:□同意 □不同意") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("是否同意推荐的项目经理:□同意 □不同意") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("其他意见或建议:") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto) para = cell.AddParagraph() para.Properties().SetAlignment(wml.ST_JcLeft) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("总经理(签字/日期):") row = table.AddRow() row.Properties().SetHeight(2*measurement.Inch, wml.ST_HeightRuleExact) cell = row.AddCell() cell.Properties().SetWidthPercent(100) para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("最终审批意见为") run = para.AddRun() run.AddText(" ") run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("(同意/不同意)立项,研发项目正式启动。") para = cell.AddParagraph() para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto) cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter) para.Properties().SetAlignment(wml.ST_JcCenter) run = para.AddRun() run.Properties().SetFontFamily("宋体") run.Properties().SetSize(11) run.AddText("日期:") filename := fmt.Sprintf("研发立项书-%s-%s(%s)", detail.T_name, detail.T_user_name, lib.GetRandstring(6, "0123456789", 0)) // 保存文件 if err = doc.SaveToFile("ofile/" + filename + ".docx"); err != nil { fmt.Println(err) } // 上传 OSS nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix) url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+filename+".docx", "ofile/"+filename+".docx") if !is { c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"} c.ServeJSON() return } //删除目录 err = os.Remove("ofile/" + filename + ".docx") if err != nil { logs.Error(lib.FuncName(), err) } c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url} c.ServeJSON() return } func createParaRun(doc *document.Document, s string) document.Run { para := doc.AddParagraph() run := para.AddRun() run.AddText(s) return run } func (c *ProjectController) Project_Add() { T_name := c.GetString("T_name") T_start_date := c.GetString("T_start_date") T_end_date := c.GetString("T_end_date") T_set_up_date := c.GetString("T_set_up_date") T_description := c.GetString("T_description") T_planning_cycle, _ := c.GetFloat("T_planning_cycle") T_reality_cycle, _ := c.GetFloat("T_reality_cycle") T_bonus, _ := c.GetFloat("T_bonus") T_Perf, _ := c.GetFloat("T_Perf") T_remark := c.GetString("T_remark") T_detail := c.GetString("T_detail") T_approver := c.GetString("T_approver") if len(T_name) == 0 { c.Data["json"] = lib.JSONS{Code: 202, Msg: "项目名称不能为空!"} c.ServeJSON() return } var_ := Project.Project{ T_uid: c.User.T_uuid, T_name: T_name, T_start_date: T_start_date, T_end_date: T_end_date, T_set_up_date: T_set_up_date, T_description: T_description, T_planning_cycle: float32(T_planning_cycle), T_reality_cycle: float32(T_reality_cycle), T_bonus: float32(T_bonus), T_Perf: float32(T_Perf), T_remark: T_remark, T_detail: T_detail, T_approver: T_approver, T_State: Project.WaitAudit, } o := orm.NewOrm() //o.Begin() ProjectDao := Project.NewProject(o) //ProjectDetailDao := Project.NewProjectDetail(o) id, err := ProjectDao.Add_Project(var_) if err != nil { //o.Rollback() c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"} c.ServeJSON() return } //detailList := lib.SplitString(T_detail, "|") //for _, v := range detailList { // T_function := strings.Split(v, ",")[0] // T_planned_time := strings.Split(v, ",")[1] // T_finish := strings.Split(v, ",")[2] // temp, _ := strconv.ParseFloat(T_planned_time, 64) // T_planned_time64, _ := decimal.NewFromFloat(temp).Round(2).Float64() // // detail := Project.ProjectDetail{ // T_project_id: int(id), // T_function: T_function, // T_planned_time: float32(T_planned_time64), // T_finish: T_finish, // } // _, err = ProjectDetailDao.Add_ProjectDetail(detail) // if err != nil { // o.Rollback() // c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"} // c.ServeJSON() // return // } // //} //o.Commit() NatsServer.AddNews(T_approver, fmt.Sprintf("【立项申请】您有一条%s的立项申请待审批", c.User.T_name), conf.ProjectApprovalNewsUrl) NatsServer.AddUserLogs(c.User.T_uuid, "项目", "添加", var_) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id} c.ServeJSON() return } func (c *ProjectController) Project_Approval() { T_id, _ := c.GetInt("T_id") T_State, _ := c.GetInt("T_State") o := orm.NewOrm() ProjectDao := Project.NewProject(o) project, err := ProjectDao.Read_Project_ById(T_id) if err != nil { c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"} c.ServeJSON() return } if project.T_State == T_State { c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id} c.ServeJSON() return } // 1 待审核 2 进行中 3 已完成 4 已发绩效 project.T_State = T_State _, err = ProjectDao.Update_Project(project, "T_State") if err != nil { c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"} c.ServeJSON() return } if T_State == Project.HaveInHand { NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)正在进行中", project.T_name), conf.MyProjectNewsUrl) } if T_State == Project.Completed { NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)已完成", project.T_name), conf.MyProjectNewsUrl) } if T_State == Project.PayPerf { NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)已发绩效", project.T_name), conf.MyProjectNewsUrl) } NatsServer.AddUserLogs(c.User.T_uuid, "项目", "审核", project) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id} c.ServeJSON() return } func (c *ProjectController) Project_Edit() { T_id, _ := c.GetInt("T_id") T_name := c.GetString("T_name") T_end_date := c.GetString("T_end_date") T_set_up_date := c.GetString("T_set_up_date") T_description := c.GetString("T_description") T_planning_cycle, _ := c.GetFloat("T_planning_cycle") T_reality_cycle, _ := c.GetFloat("T_reality_cycle") T_advance_day, _ := c.GetFloat("T_advance_day") T_bonus, _ := c.GetFloat("T_bonus") T_Perf, _ := c.GetFloat("T_Perf") T_remark := c.GetString("T_remark") T_detail := c.GetString("T_detail") T_approver := c.GetString("T_approver") o := orm.NewOrm() //o.Begin() ProjectDao := Project.NewProject(o) //ProjectDetailDao := Project.NewProjectDetail(o) project, err := ProjectDao.Read_Project_ById(T_id) if err != nil { //o.Rollback() c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"} c.ServeJSON() return } clos := []string{} if len(T_name) > 0 { project.T_name = T_name clos = append(clos, "T_name") } if len(T_end_date) > 0 { project.T_end_date = T_end_date clos = append(clos, "T_end_date") } if len(T_set_up_date) > 0 { project.T_set_up_date = T_set_up_date clos = append(clos, "T_set_up_date") } if len(T_description) > 0 { project.T_description = T_description clos = append(clos, "T_description") } if T_planning_cycle > 0 { project.T_planning_cycle = float32(T_planning_cycle) clos = append(clos, "T_planning_cycle") } if T_reality_cycle > 0 { project.T_reality_cycle = float32(T_reality_cycle) clos = append(clos, "T_reality_cycle") } project.T_advance_day = float32(T_advance_day) clos = append(clos, "T_advance_day") project.T_bonus = float32(T_bonus) clos = append(clos, "T_bonus") if T_Perf > 0 { project.T_Perf = float32(T_Perf) clos = append(clos, "T_Perf") } if len(T_remark) > 0 { project.T_remark = T_remark clos = append(clos, "T_remark") } if len(T_detail) > 0 { project.T_detail = T_detail clos = append(clos, "T_detail") } if len(T_approver) > 0 { project.T_approver = T_approver clos = append(clos, "T_approver") } // 1 待审核 2 进行中 3 已完成 4 已发绩效 // 用户自己修改 项目状态为未通过,修改之后将状态更改待提交 // 部门负责人修改 项目状态不变,修改之后将状态更改待提交 if project.T_State == 3 && c.User.T_uuid == project.T_uid { project.T_State = 2 NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)正在进行中", project.T_name), conf.ProjectApprovalNewsUrl) } _, err = ProjectDao.Update_Project(project, clos...) if err != nil { //o.Rollback() c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"} c.ServeJSON() return } NatsServer.AddUserLogs(c.User.T_uuid, "项目", "修改", project) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: project.Id} c.ServeJSON() return } func (c *ProjectController) Project_Del() { T_id, _ := c.GetInt("T_id") o := orm.NewOrm() //o.Begin() ProjectDao := Project.NewProject(o) //ProjectDetailDao := Project.NewProjectDetail(o) project, err := ProjectDao.Read_Project_ById(T_id) if err != nil { //o.Rollback() c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"} c.ServeJSON() return } // 1 待审核 2 进行中 3 已完成 4 已发绩效 if project.T_State > 1 { //o.Rollback() c.Data["json"] = lib.JSONS{Code: 202, Msg: "项目进行中,禁止删除!"} c.ServeJSON() return } //err = ProjectDetailDao.Delete_ProjectDetail_ByT_project_id(project.Id) //if err != nil { // o.Rollback() // c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"} // c.ServeJSON() // return //} _, err = ProjectDao.Delete_Project(project) if err != nil { //o.Rollback() c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"} c.ServeJSON() return } //o.Commit() NatsServer.AddUserLogs(c.User.T_uuid, "项目", "删除", project.Id) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: project.Id} c.ServeJSON() return } func (c *ProjectController) User_List() { var r_jsons lib.R_JSONS T_Finance, _ := c.GetInt("T_Finance") // 分页参数 初始化 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_name := c.GetString("T_name") ProjectDao := Project.NewProject(orm.NewOrm()) t_uuid := c.User.T_uuid if T_Finance == 1 { t_uuid = "" } uuidList := ProjectDao.Read_T_uuid_List(t_uuid) if len(uuidList) == 0 { c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"} c.ServeJSON() return } R_List, R_cnt, err := NatsServer.Read_User_List_T_uuid(T_name, uuidList, page, page_z) if err != nil { c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败"} c.ServeJSON() return } r_jsons.Num = R_cnt r_jsons.Data = R_List r_jsons.Page = page r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z))) c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons} c.ServeJSON() return }