12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196 |
- 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
- }
|