Project.go 38 KB

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