123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200 |
- 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() {
- os.Remove("/Users/zoie/work/bzd_project/ERP/ERP_project/ofile/simple.docx")
- // 查询
- 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)
- 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")
- }
- if T_advance_day > 0 {
- project.T_advance_day = float32(T_advance_day)
- clos = append(clos, "T_advance_day")
- }
- if T_bonus > 0 {
- 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
- }
|