Project.go 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. package controllers
  2. import (
  3. "ERP_project/Nats"
  4. "ERP_project/Nats/NatsServer"
  5. "ERP_project/conf"
  6. "ERP_project/logs"
  7. "ERP_project/models/Account"
  8. "ERP_project/models/Project"
  9. "baliance.com/gooxml/color"
  10. "baliance.com/gooxml/document"
  11. "baliance.com/gooxml/measurement"
  12. "baliance.com/gooxml/schema/soo/wml"
  13. "fmt"
  14. natslibs "git.baozhida.cn/ERP_libs/Nats"
  15. userlibs "git.baozhida.cn/ERP_libs/User"
  16. "git.baozhida.cn/ERP_libs/lib"
  17. "github.com/beego/beego/v2/adapter/orm"
  18. beego "github.com/beego/beego/v2/server/web"
  19. "math"
  20. "os"
  21. "strings"
  22. )
  23. type ProjectController struct {
  24. beego.Controller
  25. User userlibs.User
  26. }
  27. func (c *ProjectController) Prepare() {
  28. c.User = *Account.User_r
  29. }
  30. func (c *ProjectController) Project_Finance_List() {
  31. // 分页参数 初始化
  32. page, _ := c.GetInt("page")
  33. if page < 1 {
  34. page = 1
  35. }
  36. page_z, _ := c.GetInt("page_z")
  37. if page_z < 1 {
  38. page_z = conf.Page_size
  39. }
  40. T_uuid := c.GetString("T_uuid")
  41. userList, _ := NatsServer.Read_User_List_All()
  42. Account.Read_User_All_Map(userList)
  43. ProjectDao := Project.NewProject(orm.NewOrm())
  44. R_List, R_cnt := ProjectDao.Read_Project_Finance_List(T_uuid, page, page_z)
  45. var r_jsons lib.R_JSONS
  46. r_jsons.Num = R_cnt
  47. r_jsons.Data = R_List
  48. r_jsons.Page = page
  49. r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
  50. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  51. c.ServeJSON()
  52. return
  53. }
  54. // 部门负责人查看的权限列表
  55. func (c *ProjectController) Project_List() {
  56. // 分页参数 初始化
  57. page, _ := c.GetInt("page")
  58. if page < 1 {
  59. page = 1
  60. }
  61. page_z, _ := c.GetInt("page_z")
  62. if page_z < 1 {
  63. page_z = conf.Page_size
  64. }
  65. T_uuid := c.GetString("T_uuid")
  66. userList, _ := NatsServer.Read_User_List_All()
  67. Account.Read_User_All_Map(userList)
  68. ProjectDao := Project.NewProject(orm.NewOrm())
  69. R_List, R_cnt := ProjectDao.Read_Project_List(T_uuid, c.User.T_uuid, page, page_z)
  70. var r_jsons lib.R_JSONS
  71. r_jsons.Num = R_cnt
  72. r_jsons.Data = R_List
  73. r_jsons.Page = page
  74. r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
  75. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  76. c.ServeJSON()
  77. return
  78. }
  79. // 用户项目列表
  80. func (c *ProjectController) Project_User_List() {
  81. // 分页参数 初始化
  82. page, _ := c.GetInt("page")
  83. if page < 1 {
  84. page = 1
  85. }
  86. page_z, _ := c.GetInt("page_z")
  87. if page_z < 1 {
  88. page_z = conf.Page_size
  89. }
  90. userList, _ := NatsServer.Read_User_List_All()
  91. Account.Read_User_All_Map(userList)
  92. ProjectDao := Project.NewProject(orm.NewOrm())
  93. R_List, R_cnt := ProjectDao.Read_Project_List(c.User.T_uuid, "", page, page_z)
  94. var r_jsons lib.R_JSONS
  95. r_jsons.Num = R_cnt
  96. r_jsons.Data = R_List
  97. r_jsons.Page = page
  98. r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
  99. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  100. c.ServeJSON()
  101. return
  102. }
  103. func (c *ProjectController) Project_Get() {
  104. // 查询
  105. T_id, _ := c.GetInt("T_id")
  106. o := orm.NewOrm()
  107. ProjectDao := Project.NewProject(o)
  108. //ProjectDetailDao := Project.NewProjectDetail(o)
  109. project, err := ProjectDao.Read_Project_ById(T_id)
  110. if err != nil {
  111. c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
  112. c.ServeJSON()
  113. return
  114. }
  115. //detailList := ProjectDetailDao.Read_ProjectDetail_List(project.Id)
  116. userList, _ := NatsServer.Read_User_List_All()
  117. Account.Read_User_All_Map(userList)
  118. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Project.ProjectToProject_Detail(project)}
  119. c.ServeJSON()
  120. return
  121. }
  122. // 导出单个项目
  123. func (c *ProjectController) Project_Word() {
  124. os.Remove("/Users/zoie/work/bzd_project/ERP/ERP_project/ofile/simple.docx")
  125. // 查询
  126. T_id, _ := c.GetInt("T_id")
  127. o := orm.NewOrm()
  128. ProjectDao := Project.NewProject(o)
  129. project, err := ProjectDao.Read_Project_ById(T_id)
  130. if err != nil {
  131. c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
  132. c.ServeJSON()
  133. return
  134. }
  135. userList, _ := NatsServer.Read_User_List_All()
  136. Account.Read_User_All_Map(userList)
  137. detail := Project.ProjectToProject_Detail(project)
  138. doc := document.New()
  139. para := doc.AddParagraph()
  140. run := para.AddRun()
  141. run.Properties().SetSize(18)
  142. run.AddText("")
  143. para = doc.AddParagraph()
  144. run = para.AddRun()
  145. run.Properties().SetSize(18)
  146. run.AddText("")
  147. // Construct our header
  148. para = doc.AddParagraph()
  149. para.Properties().SetAlignment(wml.ST_JcCenter)
  150. run = para.AddRun()
  151. run.Properties().SetBold(true)
  152. run.Properties().SetFontFamily("宋体")
  153. run.Properties().SetSize(18)
  154. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  155. run.AddText("贵州宝智达网络科技有限公司")
  156. para = doc.AddParagraph()
  157. run = para.AddRun()
  158. run.Properties().SetBold(true)
  159. run.Properties().SetFontFamily("宋体")
  160. run.Properties().SetSize(18)
  161. para.Properties().SetAlignment(wml.ST_JcCenter)
  162. run.AddText("研发立项申请书")
  163. for i := 0; i < 5; i++ {
  164. para = doc.AddParagraph()
  165. run = para.AddRun()
  166. run.Properties().SetSize(18)
  167. run.AddText("")
  168. }
  169. // --------------------项目名称
  170. para = doc.AddParagraph()
  171. para.Properties().SetFirstLineIndent(1 * measurement.Inch)
  172. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  173. run = para.AddRun()
  174. run.Properties().SetFontFamily("宋体")
  175. run.Properties().SetSize(14)
  176. run.AddText("项目名称:")
  177. run = para.AddRun()
  178. run.Properties().SetFontFamily("宋体")
  179. run.Properties().SetSize(14)
  180. run.AddText(detail.T_name)
  181. run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black)
  182. para = doc.AddParagraph()
  183. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  184. para.Properties().SetFirstLineIndent(1 * measurement.Inch)
  185. run = para.AddRun()
  186. run.Properties().SetFontFamily("宋体")
  187. run.Properties().SetSize(14)
  188. run.AddText("项目负责人:")
  189. run = para.AddRun()
  190. run.Properties().SetFontFamily("宋体")
  191. run.Properties().SetSize(14)
  192. run.AddText(detail.T_user_name)
  193. run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black)
  194. para = doc.AddParagraph()
  195. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  196. para.Properties().SetFirstLineIndent(1 * measurement.Inch)
  197. run = para.AddRun()
  198. run.Properties().SetFontFamily("宋体")
  199. run.Properties().SetSize(14)
  200. run.AddText("项目立项日期:")
  201. run = para.AddRun()
  202. run.Properties().SetFontFamily("宋体")
  203. run.Properties().SetSize(14)
  204. date := strings.Split(detail.T_set_up_date, "-")
  205. if len(date) == 3 {
  206. run.AddText(fmt.Sprintf("%s年%s月%s日", date[0], date[1], date[2]))
  207. run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black)
  208. }
  209. para = doc.AddParagraph()
  210. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  211. para.Properties().SetFirstLineIndent(1 * measurement.Inch)
  212. run = para.AddRun()
  213. run.Properties().SetFontFamily("宋体")
  214. run.Properties().SetSize(14)
  215. run.AddText("项目结束日期:")
  216. run = para.AddRun()
  217. run.Properties().SetFontFamily("宋体")
  218. run.Properties().SetSize(14)
  219. date = strings.Split(detail.T_end_date, "-")
  220. if len(date) == 3 {
  221. run.AddText(fmt.Sprintf("%s年%s月%s日", date[0], date[1], date[2]))
  222. run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black)
  223. }
  224. // 分页
  225. para = doc.AddParagraph()
  226. para.Properties().AddSection(wml.ST_SectionMarkNextPage)
  227. table := doc.AddTable()
  228. table.Properties().SetLayout(wml.ST_TblLayoutTypeFixed)
  229. table.Properties().SetWidthPercent(100)
  230. look := table.Properties().TableLook()
  231. look.SetFirstColumn(true)
  232. look.SetFirstRow(true)
  233. look.SetHorizontalBanding(true)
  234. // width of the page
  235. // with thick borers
  236. borders := table.Properties().Borders()
  237. borders.SetBottom(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  238. borders.SetLeft(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  239. borders.SetRight(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  240. borders.SetTop(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  241. borders.SetInsideHorizontal(wml.ST_BorderSingle, color.Auto, measurement.Zero)
  242. borders.SetInsideVertical(wml.ST_BorderSingle, color.Auto, measurement.Zero)
  243. row := table.AddRow()
  244. row.Properties().SetHeight(0.4*measurement.Inch, wml.ST_HeightRuleExact)
  245. cell := row.AddCell()
  246. cell.Properties().SetWidth(0.4 * measurement.Inch)
  247. para = cell.AddParagraph()
  248. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  249. para.Properties().SetAlignment(wml.ST_JcCenter)
  250. run = para.AddRun()
  251. run.Properties().SetFontFamily("宋体")
  252. run.Properties().SetSize(11)
  253. run.AddText("序号")
  254. cell = row.AddCell()
  255. cell.Properties().SetWidth(1.25 * measurement.Inch)
  256. para = cell.AddParagraph()
  257. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  258. para.Properties().SetAlignment(wml.ST_JcCenter)
  259. run = para.AddRun()
  260. run.Properties().SetFontFamily("宋体")
  261. run.Properties().SetSize(11)
  262. run.AddText("功能与指标")
  263. cell = row.AddCell()
  264. cell.Properties().SetWidth(1.25 * measurement.Inch)
  265. para = cell.AddParagraph()
  266. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  267. para.Properties().SetAlignment(wml.ST_JcCenter)
  268. run = para.AddRun()
  269. run.Properties().SetFontFamily("宋体")
  270. run.Properties().SetSize(11)
  271. run.AddText("计划时间(工作日)")
  272. cell = row.AddCell()
  273. cell.Properties().SetWidth(1.25 * measurement.Inch)
  274. para = cell.AddParagraph()
  275. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  276. para.Properties().SetAlignment(wml.ST_JcCenter)
  277. run = para.AddRun()
  278. run.Properties().SetFontFamily("宋体")
  279. run.Properties().SetSize(11)
  280. run.AddText("是否完成(原因)")
  281. for i, r := range detail.T_Detail {
  282. row = table.AddRow()
  283. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  284. cell = row.AddCell()
  285. cell.Properties().SetWidth(0.4 * measurement.Inch)
  286. para = cell.AddParagraph()
  287. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  288. para.Properties().SetAlignment(wml.ST_JcCenter)
  289. run = para.AddRun()
  290. run.Properties().SetFontFamily("宋体")
  291. run.Properties().SetSize(11)
  292. run.AddText(fmt.Sprintf("%d", i+1))
  293. cell = row.AddCell()
  294. cell.Properties().SetWidth(1.25 * measurement.Inch)
  295. para = cell.AddParagraph()
  296. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  297. para.Properties().SetAlignment(wml.ST_JcLeft)
  298. run = para.AddRun()
  299. run.Properties().SetFontFamily("宋体")
  300. run.Properties().SetSize(11)
  301. run.AddText(r.T_function)
  302. cell = row.AddCell()
  303. cell.Properties().SetWidth(1.25 * measurement.Inch)
  304. para = cell.AddParagraph()
  305. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  306. para.Properties().SetAlignment(wml.ST_JcCenter)
  307. run = para.AddRun()
  308. run.Properties().SetFontFamily("宋体")
  309. run.Properties().SetSize(11)
  310. run.AddText(fmt.Sprintf("%g", r.T_planned_time))
  311. cell = row.AddCell()
  312. cell.Properties().SetWidth(1.25 * measurement.Inch)
  313. para = cell.AddParagraph()
  314. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  315. para.Properties().SetAlignment(wml.ST_JcLeft)
  316. run = para.AddRun()
  317. run.Properties().SetFontFamily("宋体")
  318. run.Properties().SetSize(11)
  319. run.AddText(r.T_finish)
  320. }
  321. // 分页
  322. para = doc.AddParagraph()
  323. para.Properties().AddSection(wml.ST_SectionMarkNextPage)
  324. table = doc.AddTable()
  325. table.Properties().SetWidthPercent(110)
  326. table.Properties().SetAlignment(wml.ST_JcTableCenter)
  327. table.Properties().SetLayout(wml.ST_TblLayoutTypeAutofit)
  328. look = table.Properties().TableLook()
  329. look.SetFirstColumn(true)
  330. look.SetFirstRow(true)
  331. look.SetHorizontalBanding(true)
  332. borders = table.Properties().Borders()
  333. borders.SetBottom(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  334. borders.SetLeft(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  335. borders.SetRight(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  336. borders.SetTop(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  337. borders.SetInsideHorizontal(wml.ST_BorderSingle, color.Auto, measurement.Zero)
  338. borders.SetInsideVertical(wml.ST_BorderSingle, color.Auto, measurement.Zero)
  339. //-----------------项目名称
  340. row = table.AddRow()
  341. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  342. cell = row.AddCell()
  343. cell.Properties().SetWidthPercent(25)
  344. para = cell.AddParagraph()
  345. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  346. para.Properties().SetAlignment(wml.ST_JcCenter)
  347. run = para.AddRun()
  348. run.Properties().SetFontFamily("宋体")
  349. run.Properties().SetSize(11)
  350. run.AddText("项目名称")
  351. cell = row.AddCell()
  352. cell.Properties().SetWidthPercent(75)
  353. para = cell.AddParagraph()
  354. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  355. para.Properties().SetAlignment(wml.ST_JcLeft)
  356. run = para.AddRun()
  357. run.Properties().SetFontFamily("宋体")
  358. run.Properties().SetSize(11)
  359. run.AddText(detail.T_name)
  360. //------------------项目简介
  361. row = table.AddRow()
  362. row.Properties().SetHeight(5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  363. cell = row.AddCell()
  364. cell.Properties().SetWidthPercent(25)
  365. para = cell.AddParagraph()
  366. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  367. para.Properties().SetAlignment(wml.ST_JcCenter)
  368. run = para.AddRun()
  369. run.Properties().SetFontFamily("宋体")
  370. run.Properties().SetSize(11)
  371. run.AddText("项目简介")
  372. cell = row.AddCell()
  373. cell.Properties().SetWidthPercent(75)
  374. para = cell.AddParagraph()
  375. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  376. para.Properties().SetAlignment(wml.ST_JcLeft)
  377. run = para.AddRun()
  378. run.Properties().SetFontFamily("宋体")
  379. run.Properties().SetSize(11)
  380. run.AddText(detail.T_description)
  381. // -----------------绩效统计
  382. row = table.AddRow()
  383. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  384. cell = row.AddCell()
  385. cell.Properties().SetVerticalMerge(wml.ST_MergeRestart)
  386. cell.Properties().SetWidthPercent(25)
  387. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  388. //row.Properties().SetHeight(0.3*measurement.Inch, wml.ST_HeightRuleExact)
  389. para = cell.AddParagraph()
  390. para.Properties().SetAlignment(wml.ST_JcCenter)
  391. run = para.AddRun()
  392. run.Properties().SetFontFamily("宋体")
  393. run.Properties().SetSize(11)
  394. run.AddText("绩效统计")
  395. cell = row.AddCell()
  396. cell.Properties().SetWidthPercent(40)
  397. para = cell.AddParagraph()
  398. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  399. para.Properties().SetAlignment(wml.ST_JcCenter)
  400. run = para.AddRun()
  401. run.Properties().SetFontFamily("宋体")
  402. run.Properties().SetSize(11)
  403. run.AddText("计划完成周期(工作日)")
  404. cell = row.AddCell()
  405. cell.Properties().SetWidthPercent(35)
  406. para = cell.AddParagraph()
  407. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  408. para.Properties().SetAlignment(wml.ST_JcCenter)
  409. run = para.AddRun()
  410. run.Properties().SetFontFamily("宋体")
  411. run.Properties().SetSize(11)
  412. run.AddText(fmt.Sprintf("%g", detail.T_planning_cycle))
  413. row = table.AddRow()
  414. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  415. cell = row.AddCell()
  416. cell.Properties().SetVerticalMerge(wml.ST_MergeContinue)
  417. cell.AddParagraph().AddRun().AddText("")
  418. cell = row.AddCell()
  419. cell.Properties().SetWidthPercent(40)
  420. para = cell.AddParagraph()
  421. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  422. para.Properties().SetAlignment(wml.ST_JcCenter)
  423. run = para.AddRun()
  424. run.Properties().SetFontFamily("宋体")
  425. run.Properties().SetSize(11)
  426. run.AddText("实际完成周期(工作日)")
  427. cell = row.AddCell()
  428. cell.Properties().SetWidthPercent(35)
  429. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  430. para = cell.AddParagraph()
  431. para.Properties().SetAlignment(wml.ST_JcCenter)
  432. run = para.AddRun()
  433. run.Properties().SetFontFamily("宋体")
  434. run.Properties().SetSize(11)
  435. run.AddText(fmt.Sprintf("%g", detail.T_reality_cycle))
  436. row = table.AddRow()
  437. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  438. cell = row.AddCell()
  439. cell.Properties().SetVerticalMerge(wml.ST_MergeContinue)
  440. cell.AddParagraph().AddRun().AddText("")
  441. cell = row.AddCell()
  442. cell.Properties().SetWidthPercent(40)
  443. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  444. para = cell.AddParagraph()
  445. para.Properties().SetAlignment(wml.ST_JcCenter)
  446. run = para.AddRun()
  447. run.Properties().SetFontFamily("宋体")
  448. run.Properties().SetSize(11)
  449. run.AddText("提前完成天数(工作日)")
  450. cell = row.AddCell()
  451. cell.Properties().SetWidthPercent(35)
  452. para = cell.AddParagraph()
  453. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  454. para.Properties().SetAlignment(wml.ST_JcCenter)
  455. run = para.AddRun()
  456. run.Properties().SetFontFamily("宋体")
  457. run.Properties().SetSize(11)
  458. run.AddText(fmt.Sprintf("%g", detail.T_advance_day))
  459. row = table.AddRow()
  460. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  461. cell = row.AddCell()
  462. cell.Properties().SetVerticalMerge(wml.ST_MergeContinue)
  463. cell.AddParagraph().AddRun().AddText("")
  464. cell = row.AddCell()
  465. cell.Properties().SetWidthPercent(23)
  466. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  467. para = cell.AddParagraph()
  468. para.Properties().SetAlignment(wml.ST_JcCenter)
  469. run = para.AddRun()
  470. run.Properties().SetFontFamily("宋体")
  471. run.Properties().SetSize(11)
  472. run.AddText("奖励金额(元)")
  473. cell = row.AddCell()
  474. cell.Properties().SetWidthPercent(15)
  475. para = cell.AddParagraph()
  476. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  477. para.Properties().SetAlignment(wml.ST_JcCenter)
  478. run = para.AddRun()
  479. run.Properties().SetFontFamily("宋体")
  480. run.Properties().SetSize(11)
  481. run.AddText(fmt.Sprintf("%g", detail.T_bonus))
  482. cell = row.AddCell()
  483. cell.Properties().SetWidthPercent(22)
  484. para = cell.AddParagraph()
  485. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  486. para.Properties().SetAlignment(wml.ST_JcCenter)
  487. run = para.AddRun()
  488. run.Properties().SetFontFamily("宋体")
  489. run.Properties().SetSize(11)
  490. run.AddText("绩效总金额(元)")
  491. cell = row.AddCell()
  492. cell.Properties().SetWidthPercent(15)
  493. para = cell.AddParagraph()
  494. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  495. para.Properties().SetAlignment(wml.ST_JcCenter)
  496. run = para.AddRun()
  497. run.Properties().SetFontFamily("宋体")
  498. run.Properties().SetSize(11)
  499. run.AddText(fmt.Sprintf("%g", detail.T_Perf))
  500. // -----------------绩效统计
  501. row = table.AddRow()
  502. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  503. cell = row.AddCell()
  504. cell.Properties().SetVerticalMerge(wml.ST_MergeRestart)
  505. cell.Properties().SetWidthPercent(25)
  506. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  507. //row.Properties().SetHeight(0.3*measurement.Inch, wml.ST_HeightRuleExact)
  508. para = cell.AddParagraph()
  509. para.Properties().SetAlignment(wml.ST_JcCenter)
  510. run = para.AddRun()
  511. run.Properties().SetFontFamily("宋体")
  512. run.Properties().SetSize(11)
  513. run.AddText("项目验收")
  514. cell = row.AddCell()
  515. cell.Properties().SetWidthPercent(25)
  516. para = cell.AddParagraph()
  517. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  518. para.Properties().SetAlignment(wml.ST_JcCenter)
  519. run = para.AddRun()
  520. run.Properties().SetFontFamily("宋体")
  521. run.Properties().SetSize(11)
  522. run.AddText("验收时间")
  523. cell = row.AddCell()
  524. cell.Properties().SetWidthPercent(25)
  525. para = cell.AddParagraph()
  526. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  527. para.Properties().SetAlignment(wml.ST_JcCenter)
  528. run = para.AddRun()
  529. run.Properties().SetFontFamily("宋体")
  530. run.Properties().SetSize(11)
  531. run.AddText(fmt.Sprintf("测试人"))
  532. cell = row.AddCell()
  533. cell.Properties().SetWidthPercent(25)
  534. para = cell.AddParagraph()
  535. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  536. para.Properties().SetAlignment(wml.ST_JcCenter)
  537. run = para.AddRun()
  538. run.Properties().SetFontFamily("宋体")
  539. run.Properties().SetSize(11)
  540. run.AddText(fmt.Sprintf("验收人"))
  541. row = table.AddRow()
  542. row.Properties().SetHeight(0.5*measurement.Inch, wml.ST_HeightRuleAtLeast)
  543. cell = row.AddCell()
  544. cell.Properties().SetVerticalMerge(wml.ST_MergeContinue)
  545. cell.AddParagraph().AddRun().AddText("")
  546. cell = row.AddCell()
  547. cell.Properties().SetWidthPercent(25)
  548. cell.AddParagraph().AddRun().AddText("")
  549. cell = row.AddCell()
  550. cell.Properties().SetWidthPercent(25)
  551. cell.AddParagraph().AddRun().AddText("")
  552. cell = row.AddCell()
  553. cell.Properties().SetWidthPercent(25)
  554. cell.AddParagraph().AddRun().AddText("")
  555. // 分页
  556. para = doc.AddParagraph()
  557. para.Properties().AddSection(wml.ST_SectionMarkNextPage)
  558. table = doc.AddTable()
  559. table.Properties().SetWidthPercent(110)
  560. table.Properties().SetAlignment(wml.ST_JcTableCenter)
  561. table.Properties().SetLayout(wml.ST_TblLayoutTypeAutofit)
  562. look = table.Properties().TableLook()
  563. look.SetFirstColumn(true)
  564. look.SetFirstRow(true)
  565. look.SetHorizontalBanding(true)
  566. borders = table.Properties().Borders()
  567. borders.SetBottom(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  568. borders.SetLeft(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  569. borders.SetRight(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  570. borders.SetTop(wml.ST_BorderSingle, color.Auto, 1.5*measurement.Point)
  571. borders.SetInsideHorizontal(wml.ST_BorderSingle, color.Auto, measurement.Zero)
  572. borders.SetInsideVertical(wml.ST_BorderSingle, color.Auto, measurement.Zero)
  573. row = table.AddRow()
  574. row.Properties().SetHeight(1.8*measurement.Inch, wml.ST_HeightRuleExact)
  575. cell = row.AddCell()
  576. cell.Properties().SetWidthPercent(30)
  577. para = cell.AddParagraph()
  578. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  579. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  580. para.Properties().SetAlignment(wml.ST_JcCenter)
  581. run = para.AddRun()
  582. run.Properties().SetFontFamily("宋体")
  583. run.Properties().SetSize(11)
  584. run.AddText("部门负责人")
  585. para = cell.AddParagraph()
  586. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  587. para.Properties().SetAlignment(wml.ST_JcCenter)
  588. run = para.AddRun()
  589. run.Properties().SetFontFamily("宋体")
  590. run.Properties().SetSize(11)
  591. run.AddText("审核意见")
  592. cell = row.AddCell()
  593. cell.Properties().SetWidthPercent(70)
  594. para = cell.AddParagraph()
  595. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  596. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  597. para.Properties().SetAlignment(wml.ST_JcLeft)
  598. run = para.AddRun()
  599. run.Properties().SetFontFamily("宋体")
  600. run.Properties().SetSize(11)
  601. run.AddText("推荐项目经理为:")
  602. para = cell.AddParagraph()
  603. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  604. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  605. para.Properties().SetAlignment(wml.ST_JcLeft)
  606. run = para.AddRun()
  607. run.Properties().SetFontFamily("宋体")
  608. run.Properties().SetSize(11)
  609. run.AddText("其他意见或建议:")
  610. para = cell.AddParagraph()
  611. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  612. para = cell.AddParagraph()
  613. para.Properties().SetAlignment(wml.ST_JcLeft)
  614. run = para.AddRun()
  615. run.Properties().SetFontFamily("宋体")
  616. run.Properties().SetSize(11)
  617. run.AddText("部门负责人(签字/日期):")
  618. row = table.AddRow()
  619. row.Properties().SetHeight(2.5*measurement.Inch, wml.ST_HeightRuleExact)
  620. cell = row.AddCell()
  621. cell.Properties().SetWidthPercent(30)
  622. para = cell.AddParagraph()
  623. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  624. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  625. para.Properties().SetAlignment(wml.ST_JcCenter)
  626. run = para.AddRun()
  627. run.Properties().SetFontFamily("宋体")
  628. run.Properties().SetSize(11)
  629. run.AddText("技术总监")
  630. para = cell.AddParagraph()
  631. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  632. para.Properties().SetAlignment(wml.ST_JcCenter)
  633. run = para.AddRun()
  634. run.Properties().SetFontFamily("宋体")
  635. run.Properties().SetSize(11)
  636. run.AddText("审核意见")
  637. cell = row.AddCell()
  638. cell.Properties().SetWidthPercent(70)
  639. para = cell.AddParagraph()
  640. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  641. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  642. para.Properties().SetAlignment(wml.ST_JcLeft)
  643. run = para.AddRun()
  644. run.Properties().SetFontFamily("宋体")
  645. run.Properties().SetSize(11)
  646. run.AddText("是否同意立项:□同意 □不同意")
  647. para = cell.AddParagraph()
  648. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  649. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  650. para.Properties().SetAlignment(wml.ST_JcLeft)
  651. run = para.AddRun()
  652. run.Properties().SetFontFamily("宋体")
  653. run.Properties().SetSize(11)
  654. run.AddText("是否同意推荐的项目经理:□同意 □不同意")
  655. para = cell.AddParagraph()
  656. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  657. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  658. para.Properties().SetAlignment(wml.ST_JcLeft)
  659. run = para.AddRun()
  660. run.Properties().SetFontFamily("宋体")
  661. run.Properties().SetSize(11)
  662. run.AddText("其他意见或建议:")
  663. para = cell.AddParagraph()
  664. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  665. para = cell.AddParagraph()
  666. para.Properties().SetAlignment(wml.ST_JcLeft)
  667. run = para.AddRun()
  668. run.Properties().SetFontFamily("宋体")
  669. run.Properties().SetSize(11)
  670. run.AddText("技术总监(签字/日期):")
  671. row = table.AddRow()
  672. row.Properties().SetHeight(2.5*measurement.Inch, wml.ST_HeightRuleExact)
  673. cell = row.AddCell()
  674. cell.Properties().SetWidthPercent(30)
  675. para = cell.AddParagraph()
  676. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  677. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  678. para.Properties().SetAlignment(wml.ST_JcCenter)
  679. run = para.AddRun()
  680. run.Properties().SetFontFamily("宋体")
  681. run.Properties().SetSize(11)
  682. run.AddText("总经理")
  683. para = cell.AddParagraph()
  684. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  685. para.Properties().SetAlignment(wml.ST_JcCenter)
  686. run = para.AddRun()
  687. run.Properties().SetFontFamily("宋体")
  688. run.Properties().SetSize(11)
  689. run.AddText("审核意见")
  690. cell = row.AddCell()
  691. cell.Properties().SetWidthPercent(70)
  692. para = cell.AddParagraph()
  693. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  694. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  695. para.Properties().SetAlignment(wml.ST_JcLeft)
  696. run = para.AddRun()
  697. run.Properties().SetFontFamily("宋体")
  698. run.Properties().SetSize(11)
  699. run.AddText("是否同意立项:□同意 □不同意")
  700. para = cell.AddParagraph()
  701. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  702. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  703. para.Properties().SetAlignment(wml.ST_JcLeft)
  704. run = para.AddRun()
  705. run.Properties().SetFontFamily("宋体")
  706. run.Properties().SetSize(11)
  707. run.AddText("是否同意推荐的项目经理:□同意 □不同意")
  708. para = cell.AddParagraph()
  709. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  710. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  711. para.Properties().SetAlignment(wml.ST_JcLeft)
  712. run = para.AddRun()
  713. run.Properties().SetFontFamily("宋体")
  714. run.Properties().SetSize(11)
  715. run.AddText("其他意见或建议:")
  716. para = cell.AddParagraph()
  717. para.Properties().Spacing().SetLineSpacing(18*measurement.Point, wml.ST_LineSpacingRuleAuto)
  718. para = cell.AddParagraph()
  719. para.Properties().SetAlignment(wml.ST_JcLeft)
  720. run = para.AddRun()
  721. run.Properties().SetFontFamily("宋体")
  722. run.Properties().SetSize(11)
  723. run.AddText("总经理(签字/日期):")
  724. row = table.AddRow()
  725. row.Properties().SetHeight(2*measurement.Inch, wml.ST_HeightRuleExact)
  726. cell = row.AddCell()
  727. cell.Properties().SetWidthPercent(100)
  728. para = cell.AddParagraph()
  729. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  730. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  731. para.Properties().SetAlignment(wml.ST_JcCenter)
  732. run = para.AddRun()
  733. run.Properties().SetFontFamily("宋体")
  734. run.Properties().SetSize(11)
  735. run.AddText("最终审批意见为")
  736. run = para.AddRun()
  737. run.AddText(" ")
  738. run.Properties().SetUnderline(wml.ST_UnderlineSingle, color.Black)
  739. run = para.AddRun()
  740. run.Properties().SetFontFamily("宋体")
  741. run.Properties().SetSize(11)
  742. run.AddText("(同意/不同意)立项,研发项目正式启动。")
  743. para = cell.AddParagraph()
  744. para.Properties().Spacing().SetLineSpacing(20*measurement.Point, wml.ST_LineSpacingRuleAuto)
  745. cell.Properties().SetVerticalAlignment(wml.ST_VerticalJcCenter)
  746. para.Properties().SetAlignment(wml.ST_JcCenter)
  747. run = para.AddRun()
  748. run.Properties().SetFontFamily("宋体")
  749. run.Properties().SetSize(11)
  750. run.AddText("日期:")
  751. filename := fmt.Sprintf("研发立项书-%s-%s(%s)", detail.T_name, detail.T_user_name, lib.GetRandstring(6, "0123456789", 0))
  752. // 保存文件
  753. if err = doc.SaveToFile("ofile/" + filename + ".docx"); err != nil {
  754. fmt.Println(err)
  755. }
  756. // 上传 OSS
  757. nats := natslibs.NewNats(Nats.Nats)
  758. url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+filename+".docx", "ofile/"+filename+".docx")
  759. if !is {
  760. c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}
  761. c.ServeJSON()
  762. return
  763. }
  764. //删除目录
  765. err = os.Remove("ofile/" + filename + ".docx")
  766. if err != nil {
  767. logs.Error(lib.FuncName(), err)
  768. }
  769. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: url}
  770. c.ServeJSON()
  771. return
  772. }
  773. func createParaRun(doc *document.Document, s string) document.Run {
  774. para := doc.AddParagraph()
  775. run := para.AddRun()
  776. run.AddText(s)
  777. return run
  778. }
  779. func (c *ProjectController) Project_Add() {
  780. T_name := c.GetString("T_name")
  781. T_start_date := c.GetString("T_start_date")
  782. T_end_date := c.GetString("T_end_date")
  783. T_set_up_date := c.GetString("T_set_up_date")
  784. T_description := c.GetString("T_description")
  785. T_planning_cycle, _ := c.GetFloat("T_planning_cycle")
  786. T_reality_cycle, _ := c.GetFloat("T_reality_cycle")
  787. T_bonus, _ := c.GetFloat("T_bonus")
  788. T_Perf, _ := c.GetFloat("T_Perf")
  789. T_remark := c.GetString("T_remark")
  790. T_detail := c.GetString("T_detail")
  791. T_approver := c.GetString("T_approver")
  792. if len(T_name) == 0 {
  793. c.Data["json"] = lib.JSONS{Code: 202, Msg: "项目名称不能为空!"}
  794. c.ServeJSON()
  795. return
  796. }
  797. var_ := Project.Project{
  798. T_uid: c.User.T_uuid,
  799. T_name: T_name,
  800. T_start_date: T_start_date,
  801. T_end_date: T_end_date,
  802. T_set_up_date: T_set_up_date,
  803. T_description: T_description,
  804. T_planning_cycle: float32(T_planning_cycle),
  805. T_reality_cycle: float32(T_reality_cycle),
  806. T_bonus: float32(T_bonus),
  807. T_Perf: float32(T_Perf),
  808. T_remark: T_remark,
  809. T_detail: T_detail,
  810. T_approver: T_approver,
  811. T_State: Project.WaitAudit,
  812. }
  813. o := orm.NewOrm()
  814. //o.Begin()
  815. ProjectDao := Project.NewProject(o)
  816. //ProjectDetailDao := Project.NewProjectDetail(o)
  817. id, err := ProjectDao.Add_Project(var_)
  818. if err != nil {
  819. //o.Rollback()
  820. c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
  821. c.ServeJSON()
  822. return
  823. }
  824. //detailList := lib.SplitString(T_detail, "|")
  825. //for _, v := range detailList {
  826. // T_function := strings.Split(v, ",")[0]
  827. // T_planned_time := strings.Split(v, ",")[1]
  828. // T_finish := strings.Split(v, ",")[2]
  829. // temp, _ := strconv.ParseFloat(T_planned_time, 64)
  830. // T_planned_time64, _ := decimal.NewFromFloat(temp).Round(2).Float64()
  831. //
  832. // detail := Project.ProjectDetail{
  833. // T_project_id: int(id),
  834. // T_function: T_function,
  835. // T_planned_time: float32(T_planned_time64),
  836. // T_finish: T_finish,
  837. // }
  838. // _, err = ProjectDetailDao.Add_ProjectDetail(detail)
  839. // if err != nil {
  840. // o.Rollback()
  841. // c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
  842. // c.ServeJSON()
  843. // return
  844. // }
  845. //
  846. //}
  847. //o.Commit()
  848. NatsServer.AddNews(T_approver, fmt.Sprintf("【立项申请】您有一条%s的立项申请待审批", c.User.T_name), conf.ProjectApprovalNewsUrl)
  849. NatsServer.AddUserLogs(c.User.T_uuid, "项目", "添加", var_)
  850. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id}
  851. c.ServeJSON()
  852. return
  853. }
  854. func (c *ProjectController) Project_Approval() {
  855. T_id, _ := c.GetInt("T_id")
  856. T_State, _ := c.GetInt("T_State")
  857. o := orm.NewOrm()
  858. ProjectDao := Project.NewProject(o)
  859. project, err := ProjectDao.Read_Project_ById(T_id)
  860. if err != nil {
  861. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
  862. c.ServeJSON()
  863. return
  864. }
  865. if project.T_State == T_State {
  866. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
  867. c.ServeJSON()
  868. return
  869. }
  870. // 1 待审核 2 进行中 3 已完成 4 已发绩效
  871. project.T_State = T_State
  872. _, err = ProjectDao.Update_Project(project, "T_State")
  873. if err != nil {
  874. c.Data["json"] = lib.JSONS{Code: 203, Msg: "添加失败"}
  875. c.ServeJSON()
  876. return
  877. }
  878. if T_State == Project.HaveInHand {
  879. NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)正在进行中", project.T_name), conf.MyProjectNewsUrl)
  880. }
  881. if T_State == Project.Completed {
  882. NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)已完成", project.T_name), conf.MyProjectNewsUrl)
  883. }
  884. if T_State == Project.PayPerf {
  885. NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)已发绩效", project.T_name), conf.MyProjectNewsUrl)
  886. }
  887. NatsServer.AddUserLogs(c.User.T_uuid, "项目", "审核", project)
  888. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
  889. c.ServeJSON()
  890. return
  891. }
  892. func (c *ProjectController) Project_Edit() {
  893. T_id, _ := c.GetInt("T_id")
  894. T_name := c.GetString("T_name")
  895. T_end_date := c.GetString("T_end_date")
  896. T_set_up_date := c.GetString("T_set_up_date")
  897. T_description := c.GetString("T_description")
  898. T_planning_cycle, _ := c.GetFloat("T_planning_cycle")
  899. T_reality_cycle, _ := c.GetFloat("T_reality_cycle")
  900. T_advance_day, _ := c.GetFloat("T_advance_day")
  901. T_bonus, _ := c.GetFloat("T_bonus")
  902. T_Perf, _ := c.GetFloat("T_Perf")
  903. T_remark := c.GetString("T_remark")
  904. T_detail := c.GetString("T_detail")
  905. T_approver := c.GetString("T_approver")
  906. o := orm.NewOrm()
  907. //o.Begin()
  908. ProjectDao := Project.NewProject(o)
  909. //ProjectDetailDao := Project.NewProjectDetail(o)
  910. project, err := ProjectDao.Read_Project_ById(T_id)
  911. if err != nil {
  912. //o.Rollback()
  913. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
  914. c.ServeJSON()
  915. return
  916. }
  917. clos := []string{}
  918. if len(T_name) > 0 {
  919. project.T_name = T_name
  920. clos = append(clos, "T_name")
  921. }
  922. if len(T_end_date) > 0 {
  923. project.T_end_date = T_end_date
  924. clos = append(clos, "T_end_date")
  925. }
  926. if len(T_set_up_date) > 0 {
  927. project.T_set_up_date = T_set_up_date
  928. clos = append(clos, "T_set_up_date")
  929. }
  930. if len(T_description) > 0 {
  931. project.T_description = T_description
  932. clos = append(clos, "T_description")
  933. }
  934. if T_planning_cycle > 0 {
  935. project.T_planning_cycle = float32(T_planning_cycle)
  936. clos = append(clos, "T_planning_cycle")
  937. }
  938. if T_reality_cycle > 0 {
  939. project.T_reality_cycle = float32(T_reality_cycle)
  940. clos = append(clos, "T_reality_cycle")
  941. }
  942. if T_advance_day > 0 {
  943. project.T_advance_day = float32(T_advance_day)
  944. clos = append(clos, "T_advance_day")
  945. }
  946. if T_bonus > 0 {
  947. project.T_bonus = float32(T_bonus)
  948. clos = append(clos, "T_bonus")
  949. }
  950. if T_Perf > 0 {
  951. project.T_Perf = float32(T_Perf)
  952. clos = append(clos, "T_Perf")
  953. }
  954. if len(T_remark) > 0 {
  955. project.T_remark = T_remark
  956. clos = append(clos, "T_remark")
  957. }
  958. if len(T_detail) > 0 {
  959. project.T_detail = T_detail
  960. clos = append(clos, "T_detail")
  961. }
  962. if len(T_approver) > 0 {
  963. project.T_approver = T_approver
  964. clos = append(clos, "T_approver")
  965. }
  966. // 1 待审核 2 进行中 3 已完成 4 已发绩效
  967. // 用户自己修改 项目状态为未通过,修改之后将状态更改待提交
  968. // 部门负责人修改 项目状态不变,修改之后将状态更改待提交
  969. if project.T_State == 3 && c.User.T_uuid == project.T_uid {
  970. project.T_State = 2
  971. NatsServer.AddNews(project.T_uid, fmt.Sprintf("【项目审核】您提交的项目(%s)正在进行中", project.T_name), conf.ProjectApprovalNewsUrl)
  972. }
  973. _, err = ProjectDao.Update_Project(project, clos...)
  974. if err != nil {
  975. //o.Rollback()
  976. c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
  977. c.ServeJSON()
  978. return
  979. }
  980. NatsServer.AddUserLogs(c.User.T_uuid, "项目", "修改", project)
  981. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: project.Id}
  982. c.ServeJSON()
  983. return
  984. }
  985. func (c *ProjectController) Project_Del() {
  986. T_id, _ := c.GetInt("T_id")
  987. o := orm.NewOrm()
  988. //o.Begin()
  989. ProjectDao := Project.NewProject(o)
  990. //ProjectDetailDao := Project.NewProjectDetail(o)
  991. project, err := ProjectDao.Read_Project_ById(T_id)
  992. if err != nil {
  993. //o.Rollback()
  994. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_id Err!"}
  995. c.ServeJSON()
  996. return
  997. }
  998. // 1 待审核 2 进行中 3 已完成 4 已发绩效
  999. if project.T_State > 1 {
  1000. //o.Rollback()
  1001. c.Data["json"] = lib.JSONS{Code: 202, Msg: "项目进行中,禁止删除!"}
  1002. c.ServeJSON()
  1003. return
  1004. }
  1005. //err = ProjectDetailDao.Delete_ProjectDetail_ByT_project_id(project.Id)
  1006. //if err != nil {
  1007. // o.Rollback()
  1008. // c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改失败"}
  1009. // c.ServeJSON()
  1010. // return
  1011. //}
  1012. _, err = ProjectDao.Delete_Project(project)
  1013. if err != nil {
  1014. //o.Rollback()
  1015. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  1016. c.ServeJSON()
  1017. return
  1018. }
  1019. //o.Commit()
  1020. NatsServer.AddUserLogs(c.User.T_uuid, "项目", "删除", project.Id)
  1021. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: project.Id}
  1022. c.ServeJSON()
  1023. return
  1024. }
  1025. func (c *ProjectController) User_List() {
  1026. var r_jsons lib.R_JSONS
  1027. T_Finance, _ := c.GetInt("T_Finance")
  1028. // 分页参数 初始化
  1029. page, _ := c.GetInt("page")
  1030. if page < 1 {
  1031. page = 1
  1032. }
  1033. page_z, _ := c.GetInt("page_z")
  1034. if page_z < 1 {
  1035. page_z = conf.Page_size
  1036. }
  1037. T_name := c.GetString("T_name")
  1038. ProjectDao := Project.NewProject(orm.NewOrm())
  1039. t_uuid := c.User.T_uuid
  1040. if T_Finance == 1 {
  1041. t_uuid = ""
  1042. }
  1043. uuidList := ProjectDao.Read_T_uuid_List(t_uuid)
  1044. if len(uuidList) == 0 {
  1045. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1046. c.ServeJSON()
  1047. return
  1048. }
  1049. R_List, R_cnt, err := NatsServer.Read_User_List_T_uuid(T_name, uuidList, page, page_z)
  1050. if err != nil {
  1051. c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败"}
  1052. c.ServeJSON()
  1053. return
  1054. }
  1055. r_jsons.Num = R_cnt
  1056. r_jsons.Data = R_List
  1057. r_jsons.Page = page
  1058. r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
  1059. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  1060. c.ServeJSON()
  1061. return
  1062. }