Task.go 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755
  1. package controllers
  2. import (
  3. "ColdVerify_server/Nats/NatsServer"
  4. "ColdVerify_server/conf"
  5. "ColdVerify_server/lib"
  6. "ColdVerify_server/lib/wx"
  7. "ColdVerify_server/logs"
  8. "ColdVerify_server/models/Account"
  9. "ColdVerify_server/models/Device"
  10. "ColdVerify_server/models/InfoCollection"
  11. "ColdVerify_server/models/System"
  12. "ColdVerify_server/models/Task"
  13. "ColdVerify_server/models/VerifyTemplate"
  14. "encoding/json"
  15. "errors"
  16. "fmt"
  17. beego "github.com/beego/beego/v2/server/web"
  18. "github.com/google/uuid"
  19. "github.com/xuri/excelize/v2"
  20. "gonum.org/v1/plot"
  21. "gonum.org/v1/plot/plotter"
  22. "gonum.org/v1/plot/vg"
  23. "gonum.org/v1/plot/vg/draw"
  24. "image/color"
  25. "math"
  26. "os"
  27. "os/exec"
  28. "strings"
  29. "sync"
  30. "time"
  31. )
  32. type TaskController struct {
  33. beego.Controller
  34. }
  35. // 列表 -
  36. func (c *TaskController) List() {
  37. // 验证登录 User_is, User_r
  38. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  39. if !User_is {
  40. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  41. c.ServeJSON()
  42. return
  43. }
  44. var r_jsons lib.R_JSONS
  45. page, _ := c.GetInt("page")
  46. if page < 1 {
  47. page = 1
  48. }
  49. page_z, _ := c.GetInt("page_z")
  50. if page_z < 1 {
  51. page_z = conf.Page_size
  52. }
  53. T_name := c.GetString("T_name")
  54. T_company := c.GetString("T_company") // 公司名称
  55. T_uuid := c.GetString("T_uuid")
  56. T_InfoCollection_id := c.GetString("T_InfoCollection_id")
  57. T_scheme := c.GetString("T_scheme") // 实施方案 负责人UUID
  58. T_collection := c.GetString("T_collection") // 数据采集 负责人UUID
  59. T_reporting := c.GetString("T_reporting") // 报告编写 负责人UUID
  60. T_delivery := c.GetString("T_delivery") // 交付审核 负责人UUID
  61. T_scheme_state := c.GetString("T_scheme_state") // 实施方案 状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  62. T_collection_state := c.GetString("T_collection_state") // 数据采集 状态 0 未完成 1 数据来源已完成 2 处理中 3 已采集-无数据 4-数据编辑已完成(已提交) 5已通过(负责人) 6已退回(负责人)
  63. T_reporting_state := c.GetString("T_reporting_state") // 报告编写 状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  64. T_delivery_state := c.GetString("T_delivery_state") // 交付审核 状态 0 未完成 1 已完成 2 处理中
  65. T_marking_state := c.GetString("T_marking_state") // 验证标识 状态 0 未完成 1 已完成
  66. CreateTime := c.GetString("CreateTime") // 任务添加时间
  67. UserMap := Account.UserListToMap(Account.Read_User_List_ALL_1())
  68. AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  69. var T_company_list []string
  70. if len(T_company) > 0 {
  71. T_company_list = Account.Read_User_T_uuid_ListByT_name(T_company)
  72. }
  73. var T_admin string
  74. if User_r.T_power > 2 {
  75. T_admin = User_r.T_uuid
  76. }
  77. // 经销商下管理员可查看自己经销商下所有的任务
  78. // 经销商下其他角色只能查看分配给自己的任务
  79. if len(User_r.T_Distributor_id) > 0 && User_r.T_power <= 2 {
  80. T_admin = ""
  81. }
  82. var cnt int
  83. List, cnt := Task.Read_Task_List(User_r.T_Distributor_id, T_uuid, T_admin, T_name, T_InfoCollection_id, T_scheme, T_collection, T_reporting, T_delivery,
  84. T_scheme_state, T_collection_state, T_reporting_state, T_delivery_state, T_marking_state,
  85. T_company_list, UserMap, AdminMap, CreateTime, page, page_z)
  86. page_size := math.Ceil(float64(cnt) / float64(page_z))
  87. r_jsons.List = List
  88. r_jsons.Page = page
  89. r_jsons.Page_size = int(page_size)
  90. r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  91. r_jsons.Num = cnt
  92. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  93. c.ServeJSON()
  94. return
  95. }
  96. // 报告统计
  97. func (c *TaskController) Stat() {
  98. // 验证登录 User_is, User_r
  99. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  100. if !User_is {
  101. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  102. c.ServeJSON()
  103. return
  104. }
  105. var r_jsons lib.R_JSONS
  106. page, _ := c.GetInt("page")
  107. if page < 1 {
  108. page = 1
  109. }
  110. page_z, _ := c.GetInt("page_z")
  111. if page_z < 1 {
  112. page_z = conf.Page_size
  113. }
  114. T_name := c.GetString("T_name")
  115. T_company := c.GetString("T_company") // 公司名称
  116. T_uuid := c.GetString("T_uuid")
  117. T_InfoCollection_id := c.GetString("T_InfoCollection_id")
  118. T_project := c.GetString("T_project") // 项目 负责人UUID
  119. T_scheme := c.GetString("T_scheme") // 实施方案 负责人UUID
  120. T_collection := c.GetString("T_collection") // 数据采集 负责人UUID
  121. T_reporting := c.GetString("T_reporting") // 报告编写 负责人UUID
  122. T_delivery := c.GetString("T_delivery") // 交付审核 负责人UUID
  123. T_scheme_state := c.GetString("T_scheme_state") // 实施方案 状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  124. T_collection_state := c.GetString("T_collection_state") // 数据采集 状态 0 未完成 1 数据来源已完成 2 处理中 3 已采集-无数据 4-数据编辑已完成(已提交) 5已通过(负责人) 6已退回(负责人)
  125. T_reporting_state := c.GetString("T_reporting_state") // 报告编写 状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  126. T_delivery_state := c.GetString("T_delivery_state") // 交付审核 状态 0 未完成 1 已完成 2 处理中
  127. T_marking_state := c.GetString("T_marking_state") // 验证标识 状态 0 未完成 1 已完成
  128. CreateTime := c.GetString("CreateTime") // 任务添加时间
  129. UserMap := Account.UserListToMap(Account.Read_User_List_ALL_1())
  130. AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  131. var T_company_list []string
  132. if len(T_company) > 0 {
  133. T_company_list = Account.Read_User_T_uuid_ListByT_name(T_company)
  134. }
  135. var T_admin string
  136. if User_r.T_power > 2 {
  137. T_admin = User_r.T_uuid
  138. }
  139. var cnt int
  140. List, cnt := Task.Read_Task_Stat(User_r.T_Distributor_id, T_uuid, T_admin, T_name, T_InfoCollection_id, T_project, T_scheme, T_collection, T_reporting, T_delivery,
  141. T_scheme_state, T_collection_state, T_reporting_state, T_delivery_state, T_marking_state,
  142. T_company_list, UserMap, AdminMap, CreateTime, page, page_z)
  143. page_size := math.Ceil(float64(cnt) / float64(page_z))
  144. r_jsons.List = List
  145. r_jsons.Page = page
  146. r_jsons.Page_size = int(page_size)
  147. r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  148. r_jsons.Num = cnt
  149. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  150. c.ServeJSON()
  151. return
  152. }
  153. // 报告统计 - 导出excel
  154. func (c *TaskController) Stat_Excel() {
  155. // 验证登录 User_is, User_r
  156. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  157. if !User_is {
  158. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  159. c.ServeJSON()
  160. return
  161. }
  162. T_name := c.GetString("T_name")
  163. T_company := c.GetString("T_company") // 公司名称
  164. T_uuid := c.GetString("T_uuid")
  165. T_InfoCollection_id := c.GetString("T_InfoCollection_id")
  166. T_project := c.GetString("T_project") // 项目 负责人UUID
  167. T_scheme := c.GetString("T_scheme") // 实施方案 负责人UUID
  168. T_collection := c.GetString("T_collection") // 数据采集 负责人UUID
  169. T_reporting := c.GetString("T_reporting") // 报告编写 负责人UUID
  170. T_delivery := c.GetString("T_delivery") // 交付审核 负责人UUID
  171. T_scheme_state := c.GetString("T_scheme_state") // 实施方案 状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  172. T_collection_state := c.GetString("T_collection_state") // 数据采集 状态 0 未完成 1 数据来源已完成 2 处理中 3 已采集-无数据 4-数据编辑已完成(已提交) 5已通过(负责人) 6已退回(负责人)
  173. T_reporting_state := c.GetString("T_reporting_state") // 报告编写 状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  174. T_delivery_state := c.GetString("T_delivery_state") // 交付审核 状态 0 未完成 1 已完成 2 处理中
  175. T_marking_state := c.GetString("T_marking_state") // 验证标识 状态 0 未完成 1 已完成
  176. CreateTime := c.GetString("CreateTime") // 任务添加时间
  177. UserMap := Account.UserListToMap(Account.Read_User_List_ALL_1())
  178. AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  179. var T_company_list []string
  180. if len(T_company) > 0 {
  181. T_company_list = Account.Read_User_T_uuid_ListByT_name(T_company)
  182. }
  183. var T_admin string
  184. if User_r.T_power > 2 {
  185. T_admin = User_r.T_uuid
  186. }
  187. List, _ := Task.Read_Task_Stat(User_r.T_Distributor_id, T_uuid, T_admin, T_name, T_InfoCollection_id, T_project, T_scheme, T_collection, T_reporting, T_delivery,
  188. T_scheme_state, T_collection_state, T_reporting_state, T_delivery_state, T_marking_state,
  189. T_company_list, UserMap, AdminMap, CreateTime, 0, 9999)
  190. f := excelize.NewFile() // 设置单元格的值
  191. line := 1
  192. // 这里设置表头
  193. f.MergeCell("Sheet1", fmt.Sprintf("A%d", line), fmt.Sprintf("A%d", line+1))
  194. f.MergeCell("Sheet1", fmt.Sprintf("B%d", line), fmt.Sprintf("B%d", line+1))
  195. f.MergeCell("Sheet1", fmt.Sprintf("C%d", line), fmt.Sprintf("C%d", line+1))
  196. f.MergeCell("Sheet1", fmt.Sprintf("D%d", line), fmt.Sprintf("D%d", line+1))
  197. f.MergeCell("Sheet1", fmt.Sprintf("E%d", line), fmt.Sprintf("E%d", line+1))
  198. f.MergeCell("Sheet1", fmt.Sprintf("F%d", line), fmt.Sprintf("F%d", line+1))
  199. f.MergeCell("Sheet1", fmt.Sprintf("G%d", line), fmt.Sprintf("G%d", line+1))
  200. f.MergeCell("Sheet1", fmt.Sprintf("H%d", line), fmt.Sprintf("H%d", line+1))
  201. f.MergeCell("Sheet1", fmt.Sprintf("I%d", line), fmt.Sprintf("I%d", line+1))
  202. f.MergeCell("Sheet1", fmt.Sprintf("J%d", line), fmt.Sprintf("J%d", line+1))
  203. f.MergeCell("Sheet1", fmt.Sprintf("K%d", line), fmt.Sprintf("K%d", line+1))
  204. f.MergeCell("Sheet1", fmt.Sprintf("L%d", line), fmt.Sprintf("L%d", line+1))
  205. f.MergeCell("Sheet1", fmt.Sprintf("M%d", line), fmt.Sprintf("M%d", line+1))
  206. f.MergeCell("Sheet1", fmt.Sprintf("N%d", line), fmt.Sprintf("N%d", line+1))
  207. f.MergeCell("Sheet1", fmt.Sprintf("O%d", line), fmt.Sprintf("O%d", line+1))
  208. f.MergeCell("Sheet1", fmt.Sprintf("P%d", line), fmt.Sprintf("P%d", line+1))
  209. f.MergeCell("Sheet1", fmt.Sprintf("Q%d", line), fmt.Sprintf("U%d", line))
  210. f.MergeCell("Sheet1", fmt.Sprintf("V%d", line), fmt.Sprintf("AA%d", line))
  211. f.MergeCell("Sheet1", fmt.Sprintf("AB%d", line), fmt.Sprintf("AG%d", line))
  212. f.MergeCell("Sheet1", fmt.Sprintf("AH%d", line), fmt.Sprintf("AM%d", line))
  213. f.SetCellValue("Sheet1", fmt.Sprintf("Q%d", line), "信息表")
  214. f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line), "方案")
  215. f.SetCellValue("Sheet1", fmt.Sprintf("AB%d", line), "实施")
  216. f.SetCellValue("Sheet1", fmt.Sprintf("AH%d", line), "报告")
  217. f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), "序号")
  218. f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), "公司名称")
  219. f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), "报告名称")
  220. f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), "项目负责人")
  221. f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), "地区")
  222. f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), "类别")
  223. f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), "设备类型")
  224. f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), "规格/容积")
  225. f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), "验证类型")
  226. f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), "标的物名称")
  227. f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), "验证温度范围")
  228. f.SetCellValue("Sheet1", fmt.Sprintf("L%d", line), "报告编号")
  229. f.SetCellValue("Sheet1", fmt.Sprintf("M%d", line), "项目开始时间")
  230. f.SetCellValue("Sheet1", fmt.Sprintf("N%d", line), "项目用时")
  231. f.SetCellValue("Sheet1", fmt.Sprintf("O%d", line), "驳回次数")
  232. f.SetCellValue("Sheet1", fmt.Sprintf("P%d", line), "回款")
  233. f.SetCellValue("Sheet1", fmt.Sprintf("Q%d", line+1), "编写人")
  234. f.SetCellValue("Sheet1", fmt.Sprintf("R%d", line+1), "状态")
  235. f.SetCellValue("Sheet1", fmt.Sprintf("S%d", line+1), "开始时间")
  236. f.SetCellValue("Sheet1", fmt.Sprintf("T%d", line+1), "退回次数")
  237. f.SetCellValue("Sheet1", fmt.Sprintf("U%d", line+1), "所需时间")
  238. f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line+1), "编写人")
  239. f.SetCellValue("Sheet1", fmt.Sprintf("W%d", line+1), "状态")
  240. f.SetCellValue("Sheet1", fmt.Sprintf("X%d", line+1), "开始时间")
  241. f.SetCellValue("Sheet1", fmt.Sprintf("Y%d", line+1), "退回次数")
  242. f.SetCellValue("Sheet1", fmt.Sprintf("Z%d", line+1), "所需时间")
  243. f.SetCellValue("Sheet1", fmt.Sprintf("AA%d", line+1), "超时时间")
  244. f.SetCellValue("Sheet1", fmt.Sprintf("AB%d", line+1), "编写人")
  245. f.SetCellValue("Sheet1", fmt.Sprintf("AC%d", line+1), "状态")
  246. f.SetCellValue("Sheet1", fmt.Sprintf("AD%d", line+1), "开始时间")
  247. f.SetCellValue("Sheet1", fmt.Sprintf("AE%d", line+1), "退回次数")
  248. f.SetCellValue("Sheet1", fmt.Sprintf("AF%d", line+1), "所需时间")
  249. f.SetCellValue("Sheet1", fmt.Sprintf("AG%d", line+1), "超时时间")
  250. f.SetCellValue("Sheet1", fmt.Sprintf("AH%d", line+1), "编写人")
  251. f.SetCellValue("Sheet1", fmt.Sprintf("AI%d", line+1), "状态")
  252. f.SetCellValue("Sheet1", fmt.Sprintf("AJ%d", line+1), "开始时间")
  253. f.SetCellValue("Sheet1", fmt.Sprintf("AK%d", line+1), "退回次数")
  254. f.SetCellValue("Sheet1", fmt.Sprintf("AL%d", line+1), "所需时间")
  255. f.SetCellValue("Sheet1", fmt.Sprintf("AM%d", line+1), "超时时间")
  256. f.SetCellValue("Sheet1", fmt.Sprintf("AN%d", line+1), "领导备注")
  257. // 设置列宽
  258. f.SetColWidth("Sheet1", "A", "A", 7)
  259. f.SetColWidth("Sheet1", "B", "B", 20)
  260. f.SetColWidth("Sheet1", "C", "C", 10)
  261. f.SetColWidth("Sheet1", "D", "D", 10)
  262. f.SetColWidth("Sheet1", "E", "E", 12)
  263. f.SetColWidth("Sheet1", "F", "F", 8)
  264. f.SetColWidth("Sheet1", "G", "G", 12)
  265. f.SetColWidth("Sheet1", "H", "H", 14)
  266. f.SetColWidth("Sheet1", "I", "I", 12)
  267. f.SetColWidth("Sheet1", "J", "J", 12)
  268. f.SetColWidth("Sheet1", "K", "K", 12)
  269. f.SetColWidth("Sheet1", "L", "L", 12)
  270. f.SetColWidth("Sheet1", "M", "M", 12)
  271. f.SetColWidth("Sheet1", "N", "N", 12)
  272. f.SetColWidth("Sheet1", "O", "O", 10)
  273. f.SetColWidth("Sheet1", "P", "P", 8)
  274. f.SetColWidth("Sheet1", "Q", "Q", 8)
  275. f.SetColWidth("Sheet1", "R", "R", 8)
  276. f.SetColWidth("Sheet1", "S", "S", 12)
  277. f.SetColWidth("Sheet1", "T", "T", 10)
  278. f.SetColWidth("Sheet1", "U", "U", 10)
  279. f.SetColWidth("Sheet1", "V", "V", 8)
  280. f.SetColWidth("Sheet1", "W", "W", 8)
  281. f.SetColWidth("Sheet1", "X", "X", 12)
  282. f.SetColWidth("Sheet1", "Y", "Y", 10)
  283. f.SetColWidth("Sheet1", "Z", "Z", 12)
  284. f.SetColWidth("Sheet1", "AA", "AA", 12)
  285. f.SetColWidth("Sheet1", "AB", "AB", 8)
  286. f.SetColWidth("Sheet1", "AC", "AC", 8)
  287. f.SetColWidth("Sheet1", "AD", "AD", 12)
  288. f.SetColWidth("Sheet1", "AE", "AE", 10)
  289. f.SetColWidth("Sheet1", "AF", "AF", 12)
  290. f.SetColWidth("Sheet1", "AG", "AG", 12)
  291. f.SetColWidth("Sheet1", "AG", "AG", 10)
  292. f.SetColWidth("Sheet1", "AH", "AH", 8)
  293. f.SetColWidth("Sheet1", "AI", "AI", 8)
  294. f.SetColWidth("Sheet1", "AJ", "AJ", 10)
  295. f.SetColWidth("Sheet1", "AK", "AK", 12)
  296. f.SetColWidth("Sheet1", "AL", "AL", 12)
  297. f.SetColWidth("Sheet1", "AM", "AM", 12)
  298. Style1, _ := f.NewStyle(
  299. &excelize.Style{
  300. Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
  301. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  302. Border: []excelize.Border{
  303. {Type: "left", Color: "000000", Style: 1},
  304. {Type: "top", Color: "000000", Style: 1},
  305. {Type: "bottom", Color: "000000", Style: 1},
  306. {Type: "right", Color: "000000", Style: 1},
  307. },
  308. })
  309. f.SetCellStyle("Sheet1", "A1", "AM2", Style1)
  310. f.SetRowHeight("Sheet1", 1, 25)
  311. f.SetRowHeight("Sheet1", 2, 25)
  312. line += 1
  313. // 循环写入数据
  314. for i, v := range List {
  315. line++
  316. f.SetCellValue("Sheet1", fmt.Sprintf("A%d", line), i+1)
  317. f.SetCellValue("Sheet1", fmt.Sprintf("B%d", line), v.T_user_name)
  318. f.SetCellValue("Sheet1", fmt.Sprintf("C%d", line), v.T_name)
  319. f.SetCellValue("Sheet1", fmt.Sprintf("D%d", line), v.T_project_name)
  320. f.SetCellValue("Sheet1", fmt.Sprintf("E%d", line), fmt.Sprintf("%s-%s-%s", v.T_province, v.T_city, v.T_district))
  321. f.SetCellValue("Sheet1", fmt.Sprintf("F%d", line), v.T_category)
  322. f.SetCellValue("Sheet1", fmt.Sprintf("G%d", line), v.T_device_type)
  323. f.SetCellValue("Sheet1", fmt.Sprintf("H%d", line), v.T_volume)
  324. f.SetCellValue("Sheet1", fmt.Sprintf("I%d", line), v.T_verify_type)
  325. f.SetCellValue("Sheet1", fmt.Sprintf("J%d", line), v.T_subject_matter)
  326. f.SetCellValue("Sheet1", fmt.Sprintf("K%d", line), v.T_temp_range)
  327. f.SetCellValue("Sheet1", fmt.Sprintf("L%d", line), fmt.Sprintf("%s-%s", v.T_report_type, v.T_report_number))
  328. f.SetCellValue("Sheet1", fmt.Sprintf("M%d", line), v.T_start_time)
  329. f.SetCellValue("Sheet1", fmt.Sprintf("N%d", line), v.T_time_interval)
  330. f.SetCellValue("Sheet1", fmt.Sprintf("O%d", line), v.T_reject_times)
  331. returnedMoney := "否"
  332. if v.InfoCollection.T_status == InfoCollection.InfoCollectionStatusReturnedMoney {
  333. returnedMoney = "是"
  334. }
  335. f.SetCellValue("Sheet1", fmt.Sprintf("P%d", line), returnedMoney)
  336. f.SetCellValue("Sheet1", fmt.Sprintf("Q%d", line), v.InfoCollection.T_submit_uuid_name)
  337. f.SetCellValue("Sheet1", fmt.Sprintf("R%d", line), InfoCollection.InfoCollectionStatusMap[v.InfoCollection.T_State])
  338. f.SetCellValue("Sheet1", fmt.Sprintf("S%d", line), v.InfoCollection.T_start_time)
  339. f.SetCellValue("Sheet1", fmt.Sprintf("T%d", line), v.InfoCollection.T_return_times)
  340. f.SetCellValue("Sheet1", fmt.Sprintf("U%d", line), v.InfoCollection.T_time_interval)
  341. f.SetCellValue("Sheet1", fmt.Sprintf("V%d", line), v.T_scheme_name)
  342. f.SetCellValue("Sheet1", fmt.Sprintf("W%d", line), Task.TaskSchemeStateMap[v.T_scheme_state])
  343. f.SetCellValue("Sheet1", fmt.Sprintf("X%d", line), v.T_scheme_start_time)
  344. f.SetCellValue("Sheet1", fmt.Sprintf("Y%d", line), v.T_scheme_return_times)
  345. f.SetCellValue("Sheet1", fmt.Sprintf("Z%d", line), v.T_scheme_time_interval)
  346. f.SetCellValue("Sheet1", fmt.Sprintf("AA%d", line), v.T_scheme_overtime)
  347. f.SetCellValue("Sheet1", fmt.Sprintf("AB%d", line), v.T_collection_name)
  348. f.SetCellValue("Sheet1", fmt.Sprintf("AC%d", line), Task.TaskCollectionStateMap[v.T_collection_state])
  349. f.SetCellValue("Sheet1", fmt.Sprintf("AD%d", line), v.T_collection_start_time)
  350. f.SetCellValue("Sheet1", fmt.Sprintf("AE%d", line), v.T_collection_return_times)
  351. f.SetCellValue("Sheet1", fmt.Sprintf("AF%d", line), v.T_collection_time_interval)
  352. f.SetCellValue("Sheet1", fmt.Sprintf("AG%d", line), v.T_collection_overtime)
  353. f.SetCellValue("Sheet1", fmt.Sprintf("AH%d", line), v.T_reporting_name)
  354. f.SetCellValue("Sheet1", fmt.Sprintf("AI%d", line), Task.TaskReportingStateMap[v.T_reporting_state])
  355. f.SetCellValue("Sheet1", fmt.Sprintf("AJ%d", line), v.T_reporting_start_time)
  356. f.SetCellValue("Sheet1", fmt.Sprintf("AK%d", line), v.T_reporting_return_times)
  357. f.SetCellValue("Sheet1", fmt.Sprintf("AL%d", line), v.T_reporting_time_interval)
  358. f.SetCellValue("Sheet1", fmt.Sprintf("AM%d", line), v.T_reporting_overtime)
  359. f.SetCellValue("Sheet1", fmt.Sprintf("AN%d", line), v.T_record)
  360. }
  361. Style2, _ := f.NewStyle(
  362. &excelize.Style{
  363. Font: &excelize.Font{Size: 10, Family: "宋体"},
  364. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  365. Border: []excelize.Border{
  366. {Type: "left", Color: "000000", Style: 1},
  367. {Type: "top", Color: "000000", Style: 1},
  368. {Type: "bottom", Color: "000000", Style: 1},
  369. {Type: "right", Color: "000000", Style: 1},
  370. },
  371. })
  372. f.SetCellStyle("Sheet1", "A2", fmt.Sprintf("AM%d", line), Style2)
  373. StyleBlueFill, _ := f.NewStyle(
  374. &excelize.Style{
  375. Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
  376. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  377. Border: []excelize.Border{
  378. {Type: "left", Color: "000000", Style: 1},
  379. {Type: "top", Color: "000000", Style: 1},
  380. {Type: "bottom", Color: "000000", Style: 1},
  381. {Type: "right", Color: "000000", Style: 1},
  382. },
  383. Fill: excelize.Fill{Type: "pattern", Color: []string{"#DEE5F5"}, Pattern: 1},
  384. })
  385. // 粉色填充
  386. StylePinkFill, _ := f.NewStyle(
  387. &excelize.Style{
  388. Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
  389. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  390. Border: []excelize.Border{
  391. {Type: "left", Color: "000000", Style: 1},
  392. {Type: "top", Color: "000000", Style: 1},
  393. {Type: "bottom", Color: "000000", Style: 1},
  394. {Type: "right", Color: "000000", Style: 1},
  395. },
  396. Fill: excelize.Fill{Type: "pattern", Color: []string{"#FBDFE2"}, Pattern: 1},
  397. })
  398. StyleOrangeFill, _ := f.NewStyle(
  399. &excelize.Style{
  400. Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
  401. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  402. Border: []excelize.Border{
  403. {Type: "left", Color: "000000", Style: 1},
  404. {Type: "top", Color: "000000", Style: 1},
  405. {Type: "bottom", Color: "000000", Style: 1},
  406. {Type: "right", Color: "000000", Style: 1},
  407. },
  408. Fill: excelize.Fill{Type: "pattern", Color: []string{"#FCE7D8"}, Pattern: 1},
  409. })
  410. StyleYellowFill, _ := f.NewStyle(
  411. &excelize.Style{
  412. Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
  413. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  414. Border: []excelize.Border{
  415. {Type: "left", Color: "000000", Style: 1},
  416. {Type: "top", Color: "000000", Style: 1},
  417. {Type: "bottom", Color: "000000", Style: 1},
  418. {Type: "right", Color: "000000", Style: 1},
  419. },
  420. Fill: excelize.Fill{Type: "pattern", Color: []string{"#FFF5D0"}, Pattern: 1},
  421. })
  422. StyleGreenFill, _ := f.NewStyle(
  423. &excelize.Style{
  424. Font: &excelize.Font{Bold: true, Size: 12, Family: "宋体"},
  425. Alignment: &excelize.Alignment{Horizontal: "center", Vertical: "center", WrapText: true},
  426. Border: []excelize.Border{
  427. {Type: "left", Color: "000000", Style: 1},
  428. {Type: "top", Color: "000000", Style: 1},
  429. {Type: "bottom", Color: "000000", Style: 1},
  430. {Type: "right", Color: "000000", Style: 1},
  431. },
  432. Fill: excelize.Fill{Type: "pattern", Color: []string{"#E7F4DE"}, Pattern: 1},
  433. })
  434. f.SetCellStyle("Sheet1", "A1", "AM2", StyleBlueFill)
  435. f.SetCellStyle("Sheet1", "Q1", "U1", StylePinkFill)
  436. f.SetCellStyle("Sheet1", "V1", "AA1", StyleOrangeFill)
  437. f.SetCellStyle("Sheet1", "AB1", "AG1", StyleYellowFill)
  438. f.SetCellStyle("Sheet1", "AH1", "AM1", StyleGreenFill)
  439. f.SetCellStyle("Sheet1", "AN1", "AN2", StyleBlueFill)
  440. // 冻结1-2行
  441. f.SetPanes("Sheet1", &excelize.Panes{
  442. Freeze: true,
  443. Split: false,
  444. XSplit: 3,
  445. YSplit: 2,
  446. TopLeftCell: "A1",
  447. ActivePane: "topRight",
  448. })
  449. lib.Create_Dir("./ofile")
  450. timeStr := time.Now().Format("20060102150405")
  451. // 保存文件
  452. if err := f.SaveAs("ofile/" + timeStr + ".xlsx"); err != nil {
  453. logs.Error(lib.FuncName(), err)
  454. }
  455. if !lib.Pload_qiniu("ofile/"+timeStr+".xlsx", "ofile/"+timeStr+".xlsx") {
  456. c.Data["json"] = lib.JSONS{Code: 203, Msg: "oss!"}
  457. c.ServeJSON()
  458. return
  459. }
  460. //删除目录
  461. err := os.Remove("ofile/" + timeStr + ".xlsx")
  462. if err != nil {
  463. logs.Error(lib.FuncName(), err)
  464. }
  465. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: "https://bzdcoldverifyoss.baozhida.cn/" + "ofile/" + timeStr + ".xlsx"}
  466. c.ServeJSON()
  467. return
  468. }
  469. // 获取任务负责人列表
  470. func (c *TaskController) GetTaskUserList() {
  471. // 验证登录 User_is, User_r
  472. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  473. if !User_is {
  474. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  475. c.ServeJSON()
  476. return
  477. }
  478. T_type := c.GetString("T_type") // T_project项目 T_scheme方案 T_collection数据采集 T_reporting报告
  479. list := Task.Get_Task_UserList(T_type)
  480. AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  481. var User_list []Account.Admin_R
  482. for _, v := range list {
  483. if len(v) == 0 {
  484. continue
  485. }
  486. User_list = append(User_list, Account.Admin_R{T_uuid: v, T_name: AdminMap[v]})
  487. }
  488. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: User_list}
  489. c.ServeJSON()
  490. return
  491. }
  492. // 列表 -
  493. func (c *TaskController) UserTaskList() {
  494. // 验证登录 User_is, User_r
  495. User_r, User_is := Account.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  496. if !User_is {
  497. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  498. c.ServeJSON()
  499. return
  500. }
  501. var r_jsons lib.R_JSONS
  502. page, _ := c.GetInt("page")
  503. if page < 1 {
  504. page = 1
  505. }
  506. page_z, _ := c.GetInt("page_z")
  507. if page_z < 1 {
  508. page_z = conf.Page_size
  509. }
  510. T_name := c.GetString("T_name")
  511. UserMap := Account.UserListToMap(Account.Read_User_List_ALL_1())
  512. AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  513. var cnt int
  514. List, cnt := Task.Read_UserTask_List(User_r.T_uuid, T_name, UserMap, AdminMap, page, page_z)
  515. page_size := math.Ceil(float64(cnt) / float64(page_z))
  516. r_jsons.List = List
  517. r_jsons.Page = page
  518. r_jsons.Page_size = int(page_size)
  519. r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  520. r_jsons.Num = cnt
  521. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  522. c.ServeJSON()
  523. return
  524. }
  525. // 获取-
  526. func (c *TaskController) Get() {
  527. // 验证登录 User_is, User_r
  528. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  529. if !User_is {
  530. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  531. c.ServeJSON()
  532. return
  533. }
  534. T_task_id := c.GetString("T_task_id")
  535. r, is := Task.Read_Task(T_task_id)
  536. if !is {
  537. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  538. c.ServeJSON()
  539. return
  540. }
  541. // 添加浏览量
  542. _ = Task.Add_Task_Visit(r)
  543. r.T_Visit += 1
  544. userMap := Account.UserListToMap(Account.Read_User_List_ALL_1())
  545. adminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  546. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: Task.TaskToTask_Stat(r, userMap, adminMap)}
  547. c.ServeJSON()
  548. return
  549. }
  550. // 添加-
  551. func (c *TaskController) Add() {
  552. // 验证登录 User_is, User_r
  553. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  554. if !User_is {
  555. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  556. c.ServeJSON()
  557. return
  558. }
  559. dc := Device.DeviceClass{
  560. T_uuid: User_r.T_uuid,
  561. T_State: 1,
  562. }
  563. T_class_id, is := Device.Add_DeviceClass(dc)
  564. if !is {
  565. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加分类失败!"}
  566. c.ServeJSON()
  567. return
  568. }
  569. System.Add_UserLogs_T(User_r.T_uuid, "分类管理", "添加", dc)
  570. T_InfoCollection_id := c.GetString("T_InfoCollection_id") // 信息采集id
  571. T_name := c.GetString("T_name")
  572. T_uuid := c.GetString("T_uuid") // 用户uuid
  573. T_VerifyTemplate_class := c.GetString("T_VerifyTemplate_class")
  574. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  575. T_deadline := c.GetString("T_deadline")
  576. T_scheme := c.GetString("T_scheme")
  577. T_collection := c.GetString("T_collection")
  578. T_reporting := c.GetString("T_reporting")
  579. T_delivery := c.GetString("T_delivery")
  580. T_project := c.GetString("T_project") // 项目 负责人UUID
  581. T_province := c.GetString("T_province") // 省
  582. T_city := c.GetString("T_city") // 市
  583. T_district := c.GetString("T_district") // 区
  584. T_province_code := c.GetString("T_province_code") // 省 code
  585. T_city_code := c.GetString("T_city_code") // 市 code
  586. T_district_code := c.GetString("T_district_code") // 区 code
  587. T_category := c.GetString("T_category") // 类别
  588. T_device_type := c.GetString("T_device_type") // 设备类型
  589. T_volume := c.GetString("T_volume") // 规格/容积
  590. T_verify_type := c.GetString("T_verify_type") // 验证类型
  591. T_subject_matter := c.GetString("T_subject_matter") // 标的物名称
  592. T_temp_range := c.GetString("T_temp_range") // 验证温度范围
  593. T_report_number := c.GetString("T_report_number") // 报告编号
  594. T_report_type := c.GetString("T_report_type") // 报告类型
  595. T_device_quantity, _ := c.GetInt("T_device_quantity") // 终端数量
  596. // 查询信息采集信息
  597. infoCollection, is := InfoCollection.Read_InfoCollection(T_InfoCollection_id)
  598. if !is {
  599. c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取信息采集失败!"}
  600. c.ServeJSON()
  601. return
  602. }
  603. var_ := Task.Task{
  604. T_Distributor_id: User_r.T_Distributor_id,
  605. T_InfoCollection_id: T_InfoCollection_id,
  606. T_InfoTemplate_id: infoCollection.T_InfoTemplate_id,
  607. T_start_time: infoCollection.T_start_time, // 项目开始时间使用信息采集开始时间
  608. T_class: int(T_class_id),
  609. T_uuid: T_uuid,
  610. T_name: T_name,
  611. T_VerifyTemplate_class: T_VerifyTemplate_class,
  612. T_VerifyTemplate_id: T_VerifyTemplate_id,
  613. T_deadline: T_deadline,
  614. T_scheme: T_scheme,
  615. T_collection: T_collection,
  616. T_reporting: T_reporting,
  617. T_delivery: T_delivery,
  618. T_Show: 1,
  619. T_State: 1,
  620. T_project: T_project,
  621. T_province: T_province,
  622. T_city: T_city,
  623. T_district: T_district,
  624. T_province_code: T_province_code,
  625. T_city_code: T_city_code,
  626. T_district_code: T_district_code,
  627. T_category: T_category,
  628. T_device_type: T_device_type,
  629. T_volume: T_volume,
  630. T_verify_type: T_verify_type,
  631. T_subject_matter: T_subject_matter,
  632. T_temp_range: T_temp_range,
  633. T_report_number: T_report_number,
  634. T_report_type: T_report_type,
  635. T_device_quantity: T_device_quantity,
  636. }
  637. if T_report_number != "/" {
  638. _, exist := Task.Read_TaskbyT_report_number(T_report_number)
  639. if exist {
  640. c.Data["json"] = lib.JSONS{Code: 202, Msg: "报告编号已存在!"}
  641. c.ServeJSON()
  642. return
  643. }
  644. }
  645. T_task_id, is := Task.Add_Task(var_)
  646. if !is {
  647. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  648. c.ServeJSON()
  649. return
  650. }
  651. NatsServer.Create_Local_Table(T_task_id)
  652. Task.Redis_Task_T_report_number_DelK(T_report_number) // 删除redis内的任务编号
  653. // 通知
  654. _, company_r := Account.Read_User_ByT_uuid(var_.T_uuid)
  655. go wx.WxSend(var_.T_scheme, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  656. go wx.WxSend(var_.T_collection, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  657. go wx.WxSend(var_.T_reporting, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  658. go wx.WxSend(var_.T_delivery, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  659. // 添加任务操作日志
  660. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "添加", var_)
  661. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "添加", var_)
  662. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_task_id}
  663. c.ServeJSON()
  664. return
  665. }
  666. // 接收信息采集
  667. func (c *TaskController) ReceiptInfoCollection() {
  668. // 验证登录 User_is, User_r
  669. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  670. if !User_is {
  671. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  672. c.ServeJSON()
  673. return
  674. }
  675. // 修改信息采集状态为已接收
  676. T_InfoCollection_id := c.GetString("T_InfoCollection_id")
  677. //T_status,_ := c.GetInt("T_status")
  678. infoCollection, is := InfoCollection.Read_InfoCollection(T_InfoCollection_id)
  679. if !is {
  680. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  681. c.ServeJSON()
  682. return
  683. }
  684. if infoCollection.T_status != InfoCollection.InfoCollectionStatusSubmitted && infoCollection.T_status != InfoCollection.InfoCollectionStatusReceipt {
  685. c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("当前状态为%s,禁止接收!", InfoCollection.InfoCollectionStatusMap[infoCollection.T_status])}
  686. c.ServeJSON()
  687. return
  688. }
  689. //infoCollection.T_status = InfoCollection.InfoCollectionStatusReceipt
  690. //if len(infoCollection.T_end_time) == 0 {
  691. // infoCollection.T_end_time = time.Now().Format("2006-01-02 15:04:05")
  692. // infoCollection.T_time_interval, _ = lib.MinutesDifference(infoCollection.T_start_time, infoCollection.T_end_time)
  693. //}
  694. //if !InfoCollection.Update_InfoCollection(infoCollection, "T_status", "T_end_time", "T_time_interval") {
  695. infoCollection.T_status = 3 // 已接收
  696. if !InfoCollection.Update_InfoCollection(infoCollection, "T_status") {
  697. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  698. c.ServeJSON()
  699. return
  700. }
  701. System.Add_UserLogs_T(User_r.T_uuid, "信息采集管理", "接收信息采集", infoCollection)
  702. //if T_status == InfoCollection.InfoCollectionStatusReturn{
  703. // // 通知 报告负责人审核
  704. // _, company_r := Account.Read_User_ByT_uuid(infoCollection.T_uuid)
  705. // System.Add_News(conf.VdelUuid, fmt.Sprintf("【%s-%s】信息采集 已退回", company_r.T_name, infoCollection.T_name), "")
  706. // go wx.WxSend(conf.VdelUuid, fmt.Sprintf("【%s-%s】信息采集 已退回", company_r.T_name, infoCollection.T_name))
  707. //
  708. //}
  709. // 修改任务管理实施方案开始时间
  710. //T_task_id := c.GetString("T_task_id")
  711. //task, is := Task.Read_Task(T_task_id)
  712. //if !is {
  713. // c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  714. // c.ServeJSON()
  715. // return
  716. //}
  717. // 添加任务操作日志
  718. //Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "接收信息采集", task)
  719. //System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "接收信息采集", task)
  720. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  721. c.ServeJSON()
  722. return
  723. }
  724. // 添加-
  725. func (c *TaskController) AddData_Tool() {
  726. T_uuid := "3e84dda9-9eec-42b9-9350-0894262fc8a1" // 用户uuid
  727. T_name := c.GetString("T_name")
  728. T_task_id := c.GetString("T_task_id")
  729. T_task_id = strings.ToLower(T_task_id)
  730. r, _ := Task.Read_Task(T_task_id)
  731. if r.T_collection_state == 2 {
  732. c.Data["json"] = lib.JSONS{Code: 200, Msg: "数据采集中..."}
  733. c.ServeJSON()
  734. return
  735. }
  736. if r.Id > 0 {
  737. // 同步1.0数据
  738. NatsServer.Sync1_TaskData(T_task_id)
  739. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_task_id}
  740. c.ServeJSON()
  741. return
  742. }
  743. dc := Device.DeviceClass{
  744. T_uuid: T_uuid,
  745. T_State: 1,
  746. }
  747. T_class_id, is := Device.Add_DeviceClass(dc)
  748. if !is {
  749. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加分类失败!"}
  750. c.ServeJSON()
  751. return
  752. }
  753. var_ := Task.Task{
  754. T_task_id: T_task_id,
  755. T_class: int(T_class_id),
  756. T_uuid: T_uuid,
  757. T_name: T_name,
  758. T_Show: 1,
  759. T_State: 1,
  760. T_collection_state: 2,
  761. }
  762. _, is = Task.Add_Task_Tool(var_)
  763. if !is {
  764. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  765. c.ServeJSON()
  766. return
  767. }
  768. // 创建本地表
  769. NatsServer.Create_Local_Table(T_task_id)
  770. // 同步1.0数据
  771. NatsServer.Sync1_TaskData(T_task_id)
  772. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_task_id}
  773. c.ServeJSON()
  774. return
  775. }
  776. // 修改采集状态-
  777. func (c *TaskController) UpCollectionState() {
  778. // 验证登录 User_is, User_r
  779. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  780. if !User_is {
  781. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  782. c.ServeJSON()
  783. return
  784. }
  785. T_collection_state, _ := c.GetInt("T_collection_state")
  786. T_reason := c.GetString("T_reason") // 退回原因
  787. T_task_id := c.GetString("T_task_id")
  788. r, is := Task.Read_Task(T_task_id)
  789. if !is {
  790. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  791. c.ServeJSON()
  792. return
  793. }
  794. _, company_r := Account.Read_User_ByT_uuid(r.T_uuid)
  795. r.T_collection_state = T_collection_state
  796. clos := make([]string, 0)
  797. clos = append(clos, "T_collection_state")
  798. if T_collection_state == Task.TaskCollectionStateReturn {
  799. r.T_collection_return_times += 1
  800. clos = append(clos, "T_collection_return_times")
  801. }
  802. if T_collection_state == Task.TaskCollectionStateSubmitted ||
  803. T_collection_state == Task.TaskCollectionStateReturn ||
  804. T_collection_state == Task.TaskCollectionStatePass {
  805. // 添加已提交状态验证报告记录
  806. auditRecordJson, err := Task.Add_AuditRecord(r.T_collection_audit_record, "", User_r.T_uuid, T_collection_state, T_reason, "")
  807. if err != nil {
  808. return
  809. }
  810. r.T_collection_audit_record = auditRecordJson
  811. clos = append(clos, "T_collection_audit_record")
  812. }
  813. if T_collection_state == Task.TaskCollectionStatePass {
  814. // 数据编辑审核通过时间为验证报告开始时间
  815. r.T_reporting_start_time = time.Now().Format("2006-01-02 15:04:05")
  816. clos = append(clos, "T_reporting_start_time")
  817. }
  818. if !Task.Update_Task(r, clos...) {
  819. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  820. c.ServeJSON()
  821. return
  822. }
  823. // 已退回(负责人)
  824. if T_collection_state == Task.TaskCollectionStateReturn {
  825. System.Add_News(r.T_collection, fmt.Sprintf("【%s-%s】数据编辑 %s,%s", company_r.T_name, r.T_name, Task.TaskCollectionStateMap[T_collection_state], T_reason), "")
  826. go wx.WxSend(r.T_collection, fmt.Sprintf("【%s-%s】数据编辑 %s,%s", company_r.T_name, r.T_name, Task.TaskCollectionStateMap[T_collection_state], T_reason))
  827. }
  828. // 添加任务操作日志
  829. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "修改采集状态", r)
  830. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "修改采集状态", r)
  831. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  832. c.ServeJSON()
  833. return
  834. }
  835. func (c *TaskController) UpDeliveryState() {
  836. // 验证登录 User_is, User_r
  837. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  838. if !User_is {
  839. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  840. c.ServeJSON()
  841. return
  842. }
  843. T_delivery_state, _ := c.GetInt("T_delivery_state")
  844. T_task_id := c.GetString("T_task_id")
  845. r, is := Task.Read_Task(T_task_id)
  846. if !is {
  847. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  848. c.ServeJSON()
  849. return
  850. }
  851. r.T_delivery_state = T_delivery_state
  852. if !Task.Update_Task(r, "T_delivery_state") {
  853. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  854. c.ServeJSON()
  855. return
  856. }
  857. // 添加任务操作日志
  858. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "修改交付审核状态", r)
  859. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "修改交付审核状态", r)
  860. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  861. c.ServeJSON()
  862. return
  863. }
  864. // 更新线上数据后台执行
  865. func (c *TaskDataController) TaskData_Up_TaskData_Back() {
  866. // 验证登录 User_is, User_r
  867. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  868. if !User_is {
  869. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  870. c.ServeJSON()
  871. return
  872. }
  873. T_task_id := c.GetString("T_task_id")
  874. r, is := Task.Read_Task(T_task_id)
  875. if !is {
  876. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  877. c.ServeJSON()
  878. return
  879. }
  880. // 通知 报告人员
  881. _, company_r := Account.Read_User_ByT_uuid(r.T_uuid)
  882. infoCollection, _ := InfoCollection.Read_InfoCollection(r.T_InfoCollection_id)
  883. System.Add_News(infoCollection.T_submit_uuid, fmt.Sprintf("【%s-%s】报告已完成,请及时通知客户审核", company_r.T_name, r.T_name), "")
  884. go wx.WxSend(infoCollection.T_submit_uuid, fmt.Sprintf("【%s-%s】报告已完成,请及时通知客户审核", company_r.T_name, r.T_name))
  885. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  886. c.ServeJSON()
  887. return
  888. }
  889. // 修改-
  890. func (c *TaskController) Up() {
  891. // 验证登录 User_is, User_r
  892. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  893. if !User_is {
  894. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  895. c.ServeJSON()
  896. return
  897. }
  898. T_name := c.GetString("T_name")
  899. T_Show, T_Show_err := c.GetInt("T_Show")
  900. T_VerifyTemplate_class := c.GetString("T_VerifyTemplate_class")
  901. T_VerifyTemplate_id := c.GetString("T_VerifyTemplate_id")
  902. T_deadline := c.GetString("T_deadline")
  903. T_scheme := c.GetString("T_scheme")
  904. T_collection := c.GetString("T_collection")
  905. T_collection_state, _ := c.GetInt("T_collection_state")
  906. T_collection_signature := c.GetString("T_collection_signature") // 完成编辑签字图片
  907. T_reporting := c.GetString("T_reporting")
  908. T_delivery := c.GetString("T_delivery")
  909. T_record := c.GetString("T_record")
  910. T_doc1 := c.GetString("T_doc1")
  911. T_pdf1 := c.GetString("T_pdf1")
  912. T_doc2 := c.GetString("T_doc2")
  913. T_pdf2 := c.GetString("T_pdf2")
  914. T_doc3 := c.GetString("T_doc3")
  915. T_pdf3 := c.GetString("T_pdf3")
  916. T_pdf4 := c.GetString("T_pdf4") // 验证标识
  917. T_VerifyDeviceDataStartTime := c.GetString("T_VerifyDeviceDataStartTime") // 验证设备数据开始时间
  918. T_VerifyDeviceDataEndTime := c.GetString("T_VerifyDeviceDataEndTime") // 验证设备数据开始时间
  919. T_BindDeviceDataStartTime := c.GetString("T_BindDeviceDataStartTime") // 绑定设备数据开始时间
  920. T_BindDeviceDataEndTime := c.GetString("T_BindDeviceDataEndTime") // 绑定设备数据结束时间
  921. T_sn := c.GetString("T_sn") // T_sn
  922. T_CalibrationExpirationTime := c.GetString("T_CalibrationExpirationTime") // 校准到期时间
  923. T_project := c.GetString("T_project") // 项目 负责人UUID
  924. T_province := c.GetString("T_province") // 省
  925. T_city := c.GetString("T_city") // 市
  926. T_district := c.GetString("T_district") // 区
  927. T_province_code := c.GetString("T_province_code") // 省 code
  928. T_city_code := c.GetString("T_city_code") // 市 code
  929. T_district_code := c.GetString("T_district_code") // 区 code
  930. T_category := c.GetString("T_category") // 类别
  931. T_device_type := c.GetString("T_device_type") // 设备类型
  932. T_volume := c.GetString("T_volume") // 规格/容积
  933. T_verify_type := c.GetString("T_verify_type") // 验证类型
  934. T_subject_matter := c.GetString("T_subject_matter") // 标的物名称
  935. T_temp_range := c.GetString("T_temp_range") // 验证温度范围
  936. T_report_number := c.GetString("T_report_number") // 报告编号
  937. T_report_type := c.GetString("T_report_type") // 报告编号
  938. T_device_quantity, _ := c.GetInt("T_device_quantity") // 报告编号
  939. T_task_id := c.GetString("T_task_id")
  940. r, is := Task.Read_Task(T_task_id)
  941. if !is {
  942. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  943. c.ServeJSON()
  944. return
  945. }
  946. if len(T_report_number) > 0 && T_report_number != "/" {
  947. t, exist := Task.Read_TaskbyT_report_number(T_report_number)
  948. if exist && r.T_task_id != t.T_task_id {
  949. c.Data["json"] = lib.JSONS{Code: 202, Msg: "报告编号已存在!"}
  950. c.ServeJSON()
  951. return
  952. }
  953. }
  954. // .......
  955. clos := make([]string, 0)
  956. if len(T_name) > 0 {
  957. r.T_name = T_name
  958. clos = append(clos, "T_name")
  959. }
  960. if T_Show_err == nil {
  961. r.T_Show = T_Show
  962. clos = append(clos, "T_Show")
  963. }
  964. if len(T_VerifyTemplate_class) > 0 {
  965. r.T_VerifyTemplate_class = T_VerifyTemplate_class
  966. clos = append(clos, "T_VerifyTemplate_class")
  967. }
  968. if len(T_VerifyTemplate_id) > 0 {
  969. r.T_VerifyTemplate_id = T_VerifyTemplate_id
  970. clos = append(clos, "T_VerifyTemplate_id")
  971. }
  972. if len(T_deadline) > 0 {
  973. r.T_deadline = T_deadline
  974. clos = append(clos, "T_deadline")
  975. }
  976. if len(T_scheme) > 0 {
  977. r.T_scheme = T_scheme
  978. clos = append(clos, "T_scheme")
  979. }
  980. if len(T_collection) > 0 {
  981. r.T_collection = T_collection
  982. clos = append(clos, "T_collection")
  983. }
  984. if len(T_reporting) > 0 {
  985. r.T_reporting = T_reporting
  986. clos = append(clos, "T_reporting")
  987. }
  988. if len(T_delivery) > 0 {
  989. r.T_delivery = T_delivery
  990. clos = append(clos, "T_delivery")
  991. }
  992. if len(T_record) > 0 {
  993. r.T_record = T_record
  994. clos = append(clos, "T_record")
  995. }
  996. // 完成编辑后设置实施结束时间
  997. if T_collection_state == 4 {
  998. r.T_collection_state = T_collection_state
  999. clos = append(clos, "T_collection_state")
  1000. r.T_collection_signature = T_collection_signature
  1001. clos = append(clos, "T_collection_signature")
  1002. r.T_collection_end_time = time.Now().Format("2006-01-02 15:04:05")
  1003. clos = append(clos, "T_collection_end_time")
  1004. if len(r.T_collection_start_time) > 0 {
  1005. r.T_collection_time_interval, _ = lib.MinutesDifference(r.T_collection_start_time, r.T_collection_end_time)
  1006. // 扣除暂停时间
  1007. Task_Compute := Task.Read_TaskTime_Compute(r.T_task_id, 1)
  1008. if Task_Compute > 0 {
  1009. r.T_collection_time_interval -= float64(Task_Compute)
  1010. }
  1011. clos = append(clos, "T_collection_time_interval")
  1012. // 所需时间 > 超时时间
  1013. if r.T_collection_time_interval > Task.TaskCollectionTimeLimit && len(r.T_report_type) > 0 {
  1014. r.T_collection_overtime = r.T_collection_time_interval - Task.TaskCollectionTimeLimit // 超时时间
  1015. clos = append(clos, "T_collection_overtime")
  1016. }
  1017. // 通知 报告人员
  1018. _, company_r := Account.Read_User_ByT_uuid(r.T_uuid)
  1019. System.Add_News(r.T_reporting, fmt.Sprintf("【%s-%s】数据采集 已提交", company_r.T_name, r.T_name), "")
  1020. go wx.WxSend(r.T_reporting, fmt.Sprintf("【%s-%s】数据采集 已提交", company_r.T_name, r.T_name))
  1021. }
  1022. // 添加已提交状态数据编辑记录
  1023. auditRecordJson, err := Task.Add_AuditRecord(r.T_collection_audit_record, "", User_r.T_uuid, r.T_collection_state, "", "")
  1024. if err == nil {
  1025. r.T_collection_audit_record = auditRecordJson
  1026. clos = append(clos, "T_collection_audit_record")
  1027. }
  1028. }
  1029. if len(T_doc1) > 0 {
  1030. r.T_doc1 = T_doc1
  1031. clos = append(clos, "T_doc1")
  1032. }
  1033. // 验证报告内容T_pdf1,上传后将 当前任务 验证方案 标志 为 5 (0未完成 1已完成(客户通过) 2已退回(客户) 3已通过(报告负责人) 4已退回(报告负责人) 5已提交)
  1034. // 上传后设置方案结束时间,计算所需时间和超时时间
  1035. if len(T_pdf1) > 0 {
  1036. r.T_pdf1 = T_pdf1
  1037. clos = append(clos, "T_pdf1")
  1038. //r.T_pdf1_watermark = GetWatermarkPdf(r,T_pdf1,"T_pdf1")
  1039. //clos = append(clos, "T_pdf1_watermark")
  1040. go GetWatermarkPdf(r, T_pdf1, "T_pdf1")
  1041. r.T_scheme_state = 5
  1042. clos = append(clos, "T_scheme_state")
  1043. // 添加已提交状态验证方案记录
  1044. auditRecordJson, err := Task.Add_AuditRecord(r.T_scheme_audit_record, "", User_r.T_uuid, r.T_scheme_state, "", "")
  1045. if err != nil {
  1046. return
  1047. }
  1048. r.T_scheme_audit_record = auditRecordJson
  1049. clos = append(clos, "T_scheme_audit_record")
  1050. r.T_scheme_end_time = time.Now().Format("2006-01-02 15:04:05")
  1051. clos = append(clos, "T_scheme_end_time")
  1052. r.T_scheme_time_interval, _ = lib.MinutesDifference(r.T_scheme_start_time, r.T_scheme_end_time)
  1053. Task_Compute := Task.Read_TaskTime_Compute(r.T_task_id, 0)
  1054. if Task_Compute > 0 {
  1055. r.T_scheme_time_interval -= float64(Task_Compute)
  1056. }
  1057. clos = append(clos, "T_scheme_time_interval")
  1058. // 所需时间 > 超时时间
  1059. if r.T_scheme_time_interval > Task.TaskSchemeTimeLimit[r.T_report_type] && len(r.T_report_type) > 0 {
  1060. r.T_scheme_overtime = r.T_scheme_time_interval - Task.TaskSchemeTimeLimit[r.T_report_type] // 超时时间
  1061. if Task.TaskSchemeTimeLimit[r.T_report_type] == 0 {
  1062. r.T_scheme_overtime = 0
  1063. }
  1064. clos = append(clos, "T_scheme_overtime")
  1065. }
  1066. // 通知 实施人员进场
  1067. _, company_r := Account.Read_User_ByT_uuid(r.T_uuid)
  1068. System.Add_News(r.T_collection, fmt.Sprintf("【%s-%s】验证方案 已提交", company_r.T_name, r.T_name), "")
  1069. go wx.WxSend(r.T_collection, fmt.Sprintf("【%s-%s】验证方案 已提交", company_r.T_name, r.T_name))
  1070. }
  1071. if len(T_doc2) > 0 {
  1072. r.T_doc2 = T_doc2
  1073. clos = append(clos, "T_doc2")
  1074. }
  1075. // 验证报告内容T_pdf2 ,上传后将 当前任务 报告编写 标志 为 1
  1076. // 上传后设置报告结束时间,计算所需时间和超时时间
  1077. if len(T_pdf2) > 0 {
  1078. r.T_pdf2 = T_pdf2
  1079. clos = append(clos, "T_pdf2")
  1080. //r.T_pdf2_watermark = GetWatermarkPdf(T_pdf2,"T_pdf1")
  1081. //clos = append(clos, "T_pdf2_watermark")
  1082. go GetWatermarkPdf(r, T_pdf2, "T_pdf2")
  1083. r.T_reporting_state = 5
  1084. clos = append(clos, "T_reporting_state")
  1085. // 添加已提交状态验证报告记录
  1086. auditRecordJson, err := Task.Add_AuditRecord(r.T_reporting_audit_record, "", User_r.T_uuid, r.T_reporting_state, "", "")
  1087. if err == nil {
  1088. r.T_reporting_audit_record = auditRecordJson
  1089. clos = append(clos, "T_reporting_audit_record")
  1090. r.T_reporting_end_time = time.Now().Format("2006-01-02 15:04:05")
  1091. clos = append(clos, "T_reporting_end_time")
  1092. if len(r.T_reporting_start_time) > 0 {
  1093. r.T_reporting_time_interval, _ = lib.MinutesDifference(r.T_reporting_start_time, r.T_reporting_end_time)
  1094. clos = append(clos, "T_reporting_time_interval")
  1095. // 扣除暂停时间
  1096. Task_Compute := Task.Read_TaskTime_Compute(r.T_task_id, 2)
  1097. if Task_Compute > 0 {
  1098. r.T_reporting_time_interval -= float64(Task_Compute)
  1099. }
  1100. clos = append(clos, "T_reporting_time_interval")
  1101. // 所需时间 > 超时时间
  1102. if r.T_reporting_time_interval > Task.TaskReportingTimeLimit[r.T_report_type] && len(r.T_report_type) > 0 {
  1103. r.T_reporting_overtime = r.T_reporting_time_interval - Task.TaskReportingTimeLimit[r.T_report_type] // 超时时间
  1104. if Task.TaskReportingTimeLimit[r.T_report_type] == 0 {
  1105. r.T_reporting_overtime = 0
  1106. }
  1107. clos = append(clos, "T_reporting_overtime")
  1108. }
  1109. }
  1110. }
  1111. // 通知 报告人员
  1112. _, company_r := Account.Read_User_ByT_uuid(r.T_uuid)
  1113. System.Add_News(r.T_delivery, fmt.Sprintf("【%s-%s】验证报告 已提交", company_r.T_name, r.T_name), "")
  1114. go wx.WxSend(r.T_delivery, fmt.Sprintf("【%s-%s】验证报告 已提交", company_r.T_name, r.T_name))
  1115. }
  1116. if len(T_doc3) > 0 {
  1117. r.T_doc3 = T_doc3
  1118. clos = append(clos, "T_doc3")
  1119. }
  1120. if len(T_pdf3) > 0 {
  1121. r.T_pdf3 = T_pdf3
  1122. clos = append(clos, "T_pdf3")
  1123. }
  1124. // 验证标识内容T_pdf4 ,上传后将 当前任务 验证标识 标志 为 1
  1125. if len(T_pdf4) > 0 {
  1126. r.T_pdf4 = T_pdf4
  1127. clos = append(clos, "T_pdf4")
  1128. r.T_marking_state = 1
  1129. clos = append(clos, "T_marking_state")
  1130. }
  1131. if len(T_VerifyDeviceDataStartTime) > 0 {
  1132. r.T_VerifyDeviceDataStartTime = T_VerifyDeviceDataStartTime
  1133. clos = append(clos, "T_VerifyDeviceDataStartTime")
  1134. }
  1135. if len(T_VerifyDeviceDataEndTime) > 0 {
  1136. r.T_VerifyDeviceDataEndTime = T_VerifyDeviceDataEndTime
  1137. clos = append(clos, "T_VerifyDeviceDataEndTime")
  1138. }
  1139. if len(T_BindDeviceDataStartTime) > 0 {
  1140. r.T_BindDeviceDataStartTime = T_BindDeviceDataStartTime
  1141. clos = append(clos, "T_BindDeviceDataStartTime")
  1142. }
  1143. if len(T_BindDeviceDataEndTime) > 0 {
  1144. r.T_BindDeviceDataEndTime = T_BindDeviceDataEndTime
  1145. clos = append(clos, "T_BindDeviceDataEndTime")
  1146. }
  1147. if len(T_sn) > 0 {
  1148. T_sn = strings.TrimSpace(T_sn)
  1149. r.T_sn = T_sn
  1150. clos = append(clos, "T_sn")
  1151. }
  1152. if len(T_CalibrationExpirationTime) > 0 {
  1153. r.T_CalibrationExpirationTime = T_CalibrationExpirationTime
  1154. clos = append(clos, "T_CalibrationExpirationTime")
  1155. }
  1156. // 从3.0获取校准时间
  1157. if len(T_sn) > 0 && len(T_CalibrationExpirationTime) == 0 {
  1158. go func(r Task.Task, T_sn, T_CalibrationExpirationTime string) {
  1159. NatsServer.Cold_UpdateDevice_CalibrationTime(T_sn, T_CalibrationExpirationTime)
  1160. device, err := NatsServer.Cold_ReadDeviceByT_sn(T_sn)
  1161. if err == nil {
  1162. if !device.T_CalibrationTime.IsZero() {
  1163. r.T_CalibrationExpirationTime = device.T_CalibrationTime.Format("2006-01-02")
  1164. clos = append(clos, "T_CalibrationExpirationTime")
  1165. Task.Update_Task(r, "T_CalibrationExpirationTime")
  1166. }
  1167. }
  1168. }(r, T_sn, T_CalibrationExpirationTime)
  1169. }
  1170. if len(T_project) > 0 {
  1171. r.T_project = T_project
  1172. clos = append(clos, "T_project")
  1173. }
  1174. if len(T_province) > 0 {
  1175. r.T_province = T_province
  1176. clos = append(clos, "T_province")
  1177. }
  1178. if len(T_city) > 0 {
  1179. r.T_city = T_city
  1180. clos = append(clos, "T_city")
  1181. }
  1182. if len(T_district) > 0 {
  1183. r.T_district = T_district
  1184. clos = append(clos, "T_district")
  1185. }
  1186. if len(T_province_code) > 0 {
  1187. r.T_province_code = T_province_code
  1188. clos = append(clos, "T_province_code")
  1189. }
  1190. if len(T_city_code) > 0 {
  1191. r.T_city_code = T_city_code
  1192. clos = append(clos, "T_city_code")
  1193. }
  1194. if len(T_district_code) > 0 {
  1195. r.T_district_code = T_district_code
  1196. clos = append(clos, "T_district_code")
  1197. }
  1198. if len(T_category) > 0 {
  1199. r.T_category = T_category
  1200. clos = append(clos, "T_category")
  1201. }
  1202. if len(T_device_type) > 0 {
  1203. r.T_device_type = T_device_type
  1204. clos = append(clos, "T_device_type")
  1205. }
  1206. if len(T_volume) > 0 {
  1207. r.T_volume = T_volume
  1208. clos = append(clos, "T_volume")
  1209. }
  1210. if len(T_verify_type) > 0 {
  1211. r.T_verify_type = T_verify_type
  1212. clos = append(clos, "T_verify_type")
  1213. }
  1214. if len(T_subject_matter) > 0 {
  1215. r.T_subject_matter = T_subject_matter
  1216. clos = append(clos, "T_subject_matter")
  1217. }
  1218. if len(T_temp_range) > 0 {
  1219. r.T_temp_range = T_temp_range
  1220. clos = append(clos, "T_temp_range")
  1221. }
  1222. if len(T_report_number) > 0 {
  1223. r.T_report_number = T_report_number
  1224. clos = append(clos, "T_report_number")
  1225. }
  1226. if len(T_report_type) > 0 {
  1227. r.T_report_type = T_report_type
  1228. clos = append(clos, "T_report_type")
  1229. }
  1230. if T_device_quantity > 0 {
  1231. r.T_device_quantity = T_device_quantity
  1232. clos = append(clos, "T_device_quantity")
  1233. }
  1234. if !Task.Update_Task(r, clos...) {
  1235. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  1236. c.ServeJSON()
  1237. return
  1238. }
  1239. // 添加任务操作日志
  1240. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "修改", r)
  1241. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "修改", r)
  1242. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1243. c.ServeJSON()
  1244. return
  1245. }
  1246. // 修改验证方案状态
  1247. func (c *TaskController) UpSchemeState() {
  1248. Admin_r, Admin_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1249. User_r, User_is := Account.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1250. if !Admin_is && !User_is {
  1251. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  1252. c.ServeJSON()
  1253. return
  1254. }
  1255. operate_uuid := ""
  1256. if Admin_is {
  1257. operate_uuid = Admin_r.T_uuid
  1258. }
  1259. if User_is {
  1260. operate_uuid = User_r.T_uuid
  1261. }
  1262. T_scheme_state, _ := c.GetInt("T_scheme_state") // 1 已完成(客户通过) 5已退回(客户) 3已通过(报告负责人) 4已退回(报告负责人)
  1263. T_reason := c.GetString("T_reason") // 退回原因
  1264. T_signature := c.GetString("T_signature") // 通过后客户签名图片链接
  1265. T_task_id := c.GetString("T_task_id")
  1266. r, is := Task.Read_Task(T_task_id)
  1267. if !is {
  1268. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  1269. c.ServeJSON()
  1270. return
  1271. }
  1272. _, company_r := Account.Read_User_ByT_uuid(r.T_uuid)
  1273. clos := make([]string, 0)
  1274. if T_scheme_state > 0 {
  1275. r.T_scheme_state = T_scheme_state
  1276. clos = append(clos, "T_scheme_state")
  1277. }
  1278. if len(T_signature) > 0 {
  1279. r.T_scheme_signature = T_signature
  1280. clos = append(clos, "T_scheme_signature")
  1281. }
  1282. if T_scheme_state == Task.TaskSchemeStateClientReturn || T_scheme_state == Task.TaskSchemeStateReturn {
  1283. r.T_scheme_return_times += 1
  1284. clos = append(clos, "T_scheme_return_times")
  1285. // 客户退回时新增驳回次数和驳回记录
  1286. if T_scheme_state == Task.TaskSchemeStateClientReturn {
  1287. r.T_reject_times += 1
  1288. var rejectRecordList []Task.AuditRecord
  1289. if len(r.T_reject_record) > 0 {
  1290. err := json.Unmarshal([]byte(r.T_reject_record), &rejectRecordList)
  1291. if err != nil {
  1292. logs.Error("JSON 反序列化失败:", err)
  1293. return
  1294. }
  1295. }
  1296. rejectRecordList = append(rejectRecordList, Task.AuditRecord{
  1297. T_uuid: User_r.T_uuid,
  1298. T_state: T_scheme_state,
  1299. T_reason: T_reason,
  1300. T_time: time.Now().Format("2006-01-02 15:04:05"),
  1301. T_type: "scheme",
  1302. })
  1303. rejectRecordJson, err := json.Marshal(rejectRecordList)
  1304. if err != nil {
  1305. logs.Error("JSON 反序列化失败:", err)
  1306. return
  1307. }
  1308. r.T_reject_record = string(rejectRecordJson)
  1309. clos = append(clos, "T_reject_times")
  1310. clos = append(clos, "T_reject_record")
  1311. }
  1312. }
  1313. auditRecordJson, err := Task.Add_AuditRecord(r.T_scheme_audit_record, User_r.T_uuid, Admin_r.T_uuid, T_scheme_state, T_reason, "")
  1314. if err != nil {
  1315. return
  1316. }
  1317. r.T_scheme_audit_record = auditRecordJson
  1318. clos = append(clos, "T_scheme_audit_record")
  1319. if !Task.Update_Task(r, clos...) {
  1320. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  1321. c.ServeJSON()
  1322. return
  1323. }
  1324. //AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  1325. // 已提交
  1326. if T_scheme_state == Task.TaskSchemeStateSubmitted {
  1327. System.Add_News(r.T_collection, fmt.Sprintf("【%s-%s】验证方案 %s,请尽快与客户沟通确定", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state]), "")
  1328. go wx.WxSend(r.T_collection, fmt.Sprintf("【%s-%s】验证方案 %s,请尽快与客户沟通确定", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state]))
  1329. }
  1330. // 已通过
  1331. if T_scheme_state == Task.TaskSchemeStatePass {
  1332. infoCollection, _ := InfoCollection.Read_InfoCollection(r.T_InfoCollection_id)
  1333. System.Add_News(infoCollection.T_submit_uuid, fmt.Sprintf("【%s-%s】验证方案 %s,请尽快与客户沟通确定", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state]), "")
  1334. go wx.WxSend(infoCollection.T_submit_uuid, fmt.Sprintf("【%s-%s】验证方案 %s,请尽快与客户沟通确定", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state]))
  1335. }
  1336. // 已退回(负责人)
  1337. if T_scheme_state == Task.TaskSchemeStateReturn {
  1338. System.Add_News(r.T_scheme, fmt.Sprintf("【%s-%s】验证方案 %s,%s", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state], T_reason), "")
  1339. go wx.WxSend(r.T_scheme, fmt.Sprintf("【%s-%s】验证方案 %s,%s", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state], T_reason))
  1340. }
  1341. // 已退回(客户)
  1342. if T_scheme_state == Task.TaskSchemeStateClientReturn {
  1343. System.Add_News(r.T_scheme, fmt.Sprintf("!!!【%s-%s】验证方案 %s,%s", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state], T_reason), "")
  1344. go wx.WxSend(r.T_scheme, fmt.Sprintf("!!!【%s-%s】验证方案 %s,%s", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state], T_reason))
  1345. System.Add_News(conf.VdelUuid, fmt.Sprintf("!!!【%s-%s】验证方案 %s,%s", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state], T_reason), "")
  1346. go wx.WxSend(conf.VdelUuid, fmt.Sprintf("!!!【%s-%s】验证方案 %s,%s", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state], T_reason))
  1347. go wx.WxSend(conf.BoosUuid, fmt.Sprintf("!!!【%s-%s】验证方案 %s,%s", company_r.T_name, r.T_name, Task.TaskSchemeStateMap[T_scheme_state], T_reason))
  1348. }
  1349. // 添加任务操作日志
  1350. Task.Add_TaskLogs_T(operate_uuid, T_task_id, "任务管理", "修改验证方案状态", r)
  1351. System.Add_UserLogs_T(operate_uuid, "任务管理", "修改验证方案状态", r)
  1352. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1353. c.ServeJSON()
  1354. return
  1355. }
  1356. // 修改验证报告状态
  1357. func (c *TaskController) UpReportingState() {
  1358. Admin_r, Admin_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1359. User_r, User_is := Account.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1360. if !Admin_is && !User_is {
  1361. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  1362. c.ServeJSON()
  1363. return
  1364. }
  1365. operate_uuid := ""
  1366. if Admin_is {
  1367. operate_uuid = Admin_r.T_uuid
  1368. }
  1369. if User_is {
  1370. operate_uuid = User_r.T_uuid
  1371. }
  1372. T_reporting_state, _ := c.GetInt("T_reporting_state") // 1 已完成(客户通过) 5已退回(客户) 3已通过(报告负责人) 4已退回(报告负责人)
  1373. T_reason := c.GetString("T_reason") // 退回原因
  1374. T_signature := c.GetString("T_signature") // 通过后客户签名图片链接
  1375. T_task_id := c.GetString("T_task_id")
  1376. r, is := Task.Read_Task(T_task_id)
  1377. if !is {
  1378. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  1379. c.ServeJSON()
  1380. return
  1381. }
  1382. //_, user_r := Account.Read_User_ByT_uuid(r.T_uuid)
  1383. clos := make([]string, 0)
  1384. if T_reporting_state > 0 {
  1385. r.T_reporting_state = T_reporting_state
  1386. clos = append(clos, "T_reporting_state")
  1387. }
  1388. if T_reporting_state == Task.TaskReportingStatePass {
  1389. r.T_reporting_pass_time = time.Now().Format("2006-01-02 15:04:05")
  1390. clos = append(clos, "T_reporting_pass_time")
  1391. }
  1392. if len(T_signature) > 0 {
  1393. r.T_reporting_signature = T_signature
  1394. clos = append(clos, "T_reporting_signature")
  1395. }
  1396. if T_reporting_state == Task.TaskReportingStateClientReturn || T_reporting_state == Task.TaskReportingStateReturn {
  1397. r.T_reporting_return_times += 1
  1398. clos = append(clos, "T_reporting_return_times")
  1399. // 客户退回时新增驳回次数和驳回记录
  1400. if T_reporting_state == Task.TaskReportingStateClientReturn {
  1401. r.T_reject_times += 1
  1402. var rejectRecordList []Task.AuditRecord
  1403. if len(r.T_reject_record) > 0 {
  1404. err := json.Unmarshal([]byte(r.T_reject_record), &rejectRecordList)
  1405. if err != nil {
  1406. logs.Error("JSON 反序列化失败:", err)
  1407. return
  1408. }
  1409. }
  1410. rejectRecordList = append(rejectRecordList, Task.AuditRecord{
  1411. T_uuid: User_r.T_uuid,
  1412. T_state: T_reporting_state,
  1413. T_reason: T_reason,
  1414. T_time: time.Now().Format("2006-01-02 15:04:05"),
  1415. T_type: "reporting",
  1416. })
  1417. rejectRecordJson, err := json.Marshal(rejectRecordList)
  1418. if err != nil {
  1419. logs.Error("JSON 反序列化失败:", err)
  1420. return
  1421. }
  1422. r.T_reject_record = string(rejectRecordJson)
  1423. clos = append(clos, "T_reject_times")
  1424. clos = append(clos, "T_reject_record")
  1425. }
  1426. }
  1427. auditRecordJson, err := Task.Add_AuditRecord(r.T_reporting_audit_record, User_r.T_uuid, Admin_r.T_uuid, T_reporting_state, T_reason, "")
  1428. if err != nil {
  1429. return
  1430. }
  1431. r.T_reporting_audit_record = auditRecordJson
  1432. clos = append(clos, "T_reporting_audit_record")
  1433. // 查询信息采集信息
  1434. infoCollection, is := InfoCollection.Read_InfoCollection(r.T_InfoCollection_id)
  1435. if !is {
  1436. c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取信息采集失败!"}
  1437. c.ServeJSON()
  1438. return
  1439. }
  1440. // 验证报告客户审核通过后设置结束时间
  1441. if T_reporting_state == Task.TaskReportingStateClientPass {
  1442. r.T_end_time = time.Now().Format("2006-01-02 15:04:05")
  1443. r.T_time_interval, err = lib.MinutesDifference(infoCollection.T_start_time, r.T_end_time)
  1444. if err != nil {
  1445. logs.Error("UpReportingState:", err.Error())
  1446. }
  1447. clos = append(clos, "T_end_time")
  1448. clos = append(clos, "T_time_interval")
  1449. }
  1450. if !Task.Update_Task(r, clos...) {
  1451. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  1452. c.ServeJSON()
  1453. return
  1454. }
  1455. // 已通过
  1456. if T_reporting_state == Task.TaskReportingStatePass {
  1457. System.Add_News(infoCollection.T_submit_uuid, fmt.Sprintf("【%s-%s】验证报告 %s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state]), "")
  1458. go wx.WxSend(infoCollection.T_submit_uuid, fmt.Sprintf("【%s-%s】验证报告 %s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state]))
  1459. System.Add_News(r.T_reporting, fmt.Sprintf("【%s-%s】验证报告 %s,请及时 打印报告", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state]), "")
  1460. go wx.WxSend(r.T_reporting, fmt.Sprintf("【%s-%s】验证报告 %s,请及时 打印报告", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state]))
  1461. }
  1462. // 已退回
  1463. if T_reporting_state == Task.TaskReportingStateReturn {
  1464. System.Add_News(r.T_reporting, fmt.Sprintf("【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason), "")
  1465. go wx.WxSend(r.T_reporting, fmt.Sprintf("【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason))
  1466. }
  1467. // 已通过(客户) 通知销售
  1468. if T_reporting_state == Task.TaskReportingStateClientPass {
  1469. go wx.WxSend(infoCollection.T_submit_uuid, fmt.Sprintf("【%s-%s】 %s,请尽快安排客户回款", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state]))
  1470. }
  1471. if T_reporting_state == Task.TaskReportingStateClientReturn {
  1472. System.Add_News(r.T_scheme, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason), "")
  1473. go wx.WxSend(r.T_scheme, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason))
  1474. System.Add_News(r.T_collection, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason), "")
  1475. go wx.WxSend(r.T_collection, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason))
  1476. System.Add_News(r.T_reporting, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason), "")
  1477. go wx.WxSend(r.T_reporting, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason))
  1478. //System.Add_News(r.T_delivery, fmt.Sprintf("!!!【%s-%s】验证报告 %s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state]), "")
  1479. //go wx.WxSend(r.T_delivery, fmt.Sprintf("!!!【%s-%s】验证报告 %s", infoCollection.T_name, r.T_name,Task.TaskReportingStateMap[T_reporting_state]))
  1480. System.Add_News(conf.VdelUuid, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason), "")
  1481. go wx.WxSend(conf.VdelUuid, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason))
  1482. go wx.WxSend(conf.BoosUuid, fmt.Sprintf("!!!【%s-%s】验证报告 %s,%s", infoCollection.T_name, r.T_name, Task.TaskReportingStateMap[T_reporting_state], T_reason))
  1483. }
  1484. // 添加任务操作日志
  1485. Task.Add_TaskLogs_T(operate_uuid, T_task_id, "任务管理", "修改验证报告状态", r)
  1486. System.Add_UserLogs_T(operate_uuid, "任务管理", "修改验证报告状态", r)
  1487. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1488. c.ServeJSON()
  1489. return
  1490. }
  1491. // 进场 改成 方案开始
  1492. func (c *TaskController) EnterArea() {
  1493. // 验证登录 User_is, User_r
  1494. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1495. if !User_is {
  1496. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  1497. c.ServeJSON()
  1498. return
  1499. }
  1500. T_task_id := c.GetString("T_task_id")
  1501. r, is := Task.Read_Task(T_task_id)
  1502. if !is {
  1503. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  1504. c.ServeJSON()
  1505. return
  1506. }
  1507. // 方案开始
  1508. if len(r.T_scheme_start_time) == 0 {
  1509. r.T_scheme_start_time = time.Now().Format("2006-01-02 15:04:05")
  1510. Task.Update_Task(r, "T_scheme_start_time")
  1511. }
  1512. // 添加任务操作日志
  1513. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "方案开始", r)
  1514. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "方案开始", r)
  1515. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1516. c.ServeJSON()
  1517. return
  1518. }
  1519. // 开始验证
  1520. func (c *TaskController) StartVerify() {
  1521. // 验证登录 User_is, User_r
  1522. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1523. if !User_is {
  1524. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  1525. c.ServeJSON()
  1526. return
  1527. }
  1528. T_task_id := c.GetString("T_task_id")
  1529. T_time := c.GetString("T_time") // 进场时间
  1530. r, is := Task.Read_Task(T_task_id)
  1531. if !is {
  1532. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  1533. c.ServeJSON()
  1534. return
  1535. }
  1536. if len(r.T_collection_start_time) == 0 {
  1537. r.T_collection_start_time = T_time
  1538. if !Task.Update_Task(r, "T_collection_start_time") {
  1539. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改实施开始时间失败!"}
  1540. c.ServeJSON()
  1541. return
  1542. }
  1543. // 添加任务操作日志
  1544. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "开始验证", r)
  1545. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "开始验证", r)
  1546. }
  1547. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1548. c.ServeJSON()
  1549. return
  1550. }
  1551. // 删除-
  1552. func (c *TaskController) Del() {
  1553. // 验证登录 User_is, User_r
  1554. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1555. if !User_is {
  1556. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  1557. c.ServeJSON()
  1558. return
  1559. }
  1560. T_task_id := c.GetString("T_task_id")
  1561. if r, is := Task.Read_Task(T_task_id); is {
  1562. if !Task.Delete_Task(r) {
  1563. c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除失败!"}
  1564. c.ServeJSON()
  1565. return
  1566. }
  1567. // 添加任务操作日志
  1568. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务管理", "删除", r)
  1569. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "删除", r)
  1570. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1571. c.ServeJSON()
  1572. return
  1573. }
  1574. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  1575. c.ServeJSON()
  1576. return
  1577. }
  1578. // 列表 -
  1579. func (c *TaskController) Logs_List() {
  1580. // 验证登录 User_is, User_r
  1581. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1582. if !User_is {
  1583. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  1584. c.ServeJSON()
  1585. return
  1586. }
  1587. var r_jsons lib.R_JSONS
  1588. page, _ := c.GetInt("page")
  1589. if page < 1 {
  1590. page = 1
  1591. }
  1592. page_z, _ := c.GetInt("page_z")
  1593. if page_z < 1 {
  1594. page_z = conf.Page_size
  1595. }
  1596. T_task_id := c.GetString("T_task_id")
  1597. AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  1598. var cnt int
  1599. List, cnt := Task.Read_TaskLogs_List(T_task_id, AdminMap, page, page_z)
  1600. page_size := math.Ceil(float64(cnt) / float64(page_z))
  1601. r_jsons.List = List
  1602. r_jsons.Page = page
  1603. r_jsons.Page_size = int(page_size)
  1604. r_jsons.Pages = lib.Func_page(int64(page), int64(page_size))
  1605. r_jsons.Num = cnt
  1606. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  1607. c.ServeJSON()
  1608. return
  1609. }
  1610. // 查询图片生成状态
  1611. func (c *TaskController) DeviceData_JPGState() {
  1612. T_task_id := c.GetString("T_task_id")
  1613. T_remark := c.GetString("T_remark")
  1614. jpg, is := Device.Redis_DeviceDataJPG_Get(T_task_id + T_remark)
  1615. if !is {
  1616. c.Data["json"] = lib.JSONS{Code: 1202, Msg: "暂无图片正在生成"}
  1617. c.ServeJSON()
  1618. return
  1619. }
  1620. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: jpg}
  1621. c.ServeJSON()
  1622. return
  1623. }
  1624. // 生成温度图片
  1625. func (c *TaskController) DeviceData_JPG() {
  1626. StartTime := c.GetString("StartTime")
  1627. if len(StartTime) > 0 {
  1628. _, ok := lib.TimeStrToTime(StartTime)
  1629. if !ok {
  1630. c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误!"}
  1631. c.ServeJSON()
  1632. return
  1633. }
  1634. }
  1635. EndTime := c.GetString("EndTime")
  1636. if len(EndTime) > 0 {
  1637. _, ok := lib.TimeStrToTime(EndTime)
  1638. if !ok {
  1639. c.Data["json"] = lib.JSONS{Code: 202, Msg: "时间格式错误!"}
  1640. c.ServeJSON()
  1641. return
  1642. }
  1643. } else {
  1644. EndTime = time.Now().Format("2006-01-02 15:04:05")
  1645. }
  1646. T_remark := c.GetString("T_remark")
  1647. TemperatureMin, _ := c.GetFloat("TemperatureMin") // 最低温度
  1648. TemperatureMax, _ := c.GetFloat("TemperatureMax") // 最高温度
  1649. if TemperatureMin == 0 {
  1650. TemperatureMin = 2
  1651. }
  1652. if TemperatureMax == 0 {
  1653. TemperatureMax = 8
  1654. }
  1655. T_task_id := c.GetString("T_task_id")
  1656. Task_r, is := Task.Read_Task(T_task_id)
  1657. if !is {
  1658. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_task_id 错误!"}
  1659. c.ServeJSON()
  1660. return
  1661. }
  1662. if Task_r.T_collection_state == 2 {
  1663. c.Data["json"] = lib.JSONS{Code: 202, Msg: "数据采集中,请稍后!"}
  1664. c.ServeJSON()
  1665. return
  1666. }
  1667. deviceClassList, _ := Device.Read_DeviceClassList_OrderList(Task_r.T_class, "", "", T_remark, 0, 9999)
  1668. if !is {
  1669. c.Data["json"] = lib.JSONS{Code: 202, Msg: "T_class 错误!"}
  1670. c.ServeJSON()
  1671. return
  1672. }
  1673. Device.Redis_DeviceDataJPG_Del(T_task_id + T_remark)
  1674. // 生成图片
  1675. go DeviceDataJPG(StartTime, EndTime, T_task_id, T_remark, deviceClassList, TemperatureMin, TemperatureMax)
  1676. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!"}
  1677. c.ServeJSON()
  1678. return
  1679. }
  1680. // SyncInfoCollection 同步信息采集表
  1681. func (c *TaskController) SyncInfoCollection() {
  1682. T_task_id := c.GetString("T_task_id")
  1683. T_source, _ := c.GetInt("T_source")
  1684. task, is := Task.Read_Task(T_task_id)
  1685. if !is {
  1686. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  1687. c.ServeJSON()
  1688. return
  1689. }
  1690. // 获取信息采集表模版信息
  1691. InfoCollection_Map_List := InfoCollection.Read_InfoTemplateMap_List_For_Data(task.T_InfoTemplate_id)
  1692. InfoCollection_Data := InfoCollection.Read_InfoTemplateMapData_List(task.T_InfoCollection_id, task.T_InfoTemplate_id, InfoCollection_Map_List)
  1693. Map_List := VerifyTemplate.Read_VerifyTemplateMap_List_For_Data(task.T_VerifyTemplate_id, T_source, 0)
  1694. Data := VerifyTemplate.Read_VerifyTemplateMapData_List(T_source, T_task_id, task.T_VerifyTemplate_id, Map_List)
  1695. InfoCollectionDataMap := make(map[string]string)
  1696. for _, data := range InfoCollection_Data {
  1697. InfoCollectionDataMap[data.T_name] = data.T_value
  1698. }
  1699. MapDataList := make([]VerifyTemplate.VerifyTemplateMapData, 0)
  1700. for _, v := range Data {
  1701. if len(v.T_value) > 0 {
  1702. continue
  1703. }
  1704. if InfoCollectionDataMap[v.T_name] == "" {
  1705. continue
  1706. }
  1707. val := VerifyTemplate.VerifyTemplateMapData{
  1708. T_source: T_source,
  1709. T_task_id: task.T_task_id,
  1710. T_VerifyTemplate_id: task.T_VerifyTemplate_id,
  1711. T_VerifyTemplateMap_id: v.T_VerifyTemplateMap_id,
  1712. T_flow_sort: v.T_flow_sort,
  1713. T_max_time: v.T_max_time,
  1714. T_min_time: v.T_min_time,
  1715. T_value: InfoCollectionDataMap[v.T_name],
  1716. }
  1717. MapDataList = append(MapDataList, val)
  1718. }
  1719. var ids []int64
  1720. ids, is = VerifyTemplate.AddOrUpdate_VerifyTemplateMapData(MapDataList)
  1721. if !is {
  1722. c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
  1723. c.ServeJSON()
  1724. return
  1725. }
  1726. c.Data["json"] = lib.JSONS{Data: ids, Code: 200, Msg: "ok!"}
  1727. c.ServeJSON()
  1728. return
  1729. }
  1730. // 退回记录列表
  1731. func (c *TaskController) AuditRecordList() {
  1732. // 验证登录 User_is, User_r
  1733. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  1734. if !User_is {
  1735. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  1736. c.ServeJSON()
  1737. return
  1738. }
  1739. T_task_id := c.GetString("T_task_id")
  1740. T_type := c.GetString("T_type") // T_task任务 T_scheme方案 T_collection数据采集 T_reporting报告
  1741. //T_task 驳回记录
  1742. //T_scheme 实施方案状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  1743. //T_collection 数据采集状态 0 未完成 1 数据来源已完成 2 处理中 3 已采集-无数据 4-数据编辑已完成(已提交) 5已通过(负责人) 6已退回(负责人)
  1744. //T_reporting 报告编写状态 0 未完成 1 已完成(客户通过) 2已退回(客户) 3已通过(负责人) 4已退回(负责人) 5已提交
  1745. T_state, _ := c.GetInt("T_state") // -1 获取全部
  1746. r, is := Task.Read_Task(T_task_id)
  1747. if !is {
  1748. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  1749. c.ServeJSON()
  1750. return
  1751. }
  1752. var auditRecordList []Task.AuditRecord
  1753. switch T_type {
  1754. case "T_task":
  1755. T_state = -1
  1756. if len(r.T_reject_record) > 0 {
  1757. err := json.Unmarshal([]byte(r.T_reject_record), &auditRecordList)
  1758. if err != nil {
  1759. logs.Error("JSON 反序列化失败:", err)
  1760. return
  1761. }
  1762. }
  1763. case "T_scheme":
  1764. if len(r.T_scheme_audit_record) > 0 {
  1765. err := json.Unmarshal([]byte(r.T_scheme_audit_record), &auditRecordList)
  1766. if err != nil {
  1767. logs.Error("JSON 反序列化失败:", err)
  1768. return
  1769. }
  1770. }
  1771. case "T_collection":
  1772. if len(r.T_collection_audit_record) > 0 {
  1773. err := json.Unmarshal([]byte(r.T_collection_audit_record), &auditRecordList)
  1774. if err != nil {
  1775. logs.Error("JSON 反序列化失败:", err)
  1776. return
  1777. }
  1778. }
  1779. case "T_reporting":
  1780. if len(r.T_reporting_audit_record) > 0 {
  1781. err := json.Unmarshal([]byte(r.T_reporting_audit_record), &auditRecordList)
  1782. if err != nil {
  1783. logs.Error("JSON 反序列化失败:", err)
  1784. return
  1785. }
  1786. }
  1787. }
  1788. AdminMap := Account.AdminListToMap(Account.Read_Admin_List_ALL_1())
  1789. UserMap := Account.UserListToMap(Account.Read_User_List_ALL_1())
  1790. var auditRecordList2 []Task.AuditRecord
  1791. // 返回全部
  1792. if T_state == -1 {
  1793. for i := 0; i < len(auditRecordList); i++ {
  1794. auditRecordList[i].T_admin_name = AdminMap[auditRecordList[i].T_admin]
  1795. auditRecordList[i].T_uuid_name = UserMap[auditRecordList[i].T_uuid]
  1796. auditRecordList2 = append(auditRecordList2, auditRecordList[i])
  1797. }
  1798. c.Data["json"] = lib.JSONS{Data: auditRecordList2, Code: 200, Msg: "ok!"}
  1799. c.ServeJSON()
  1800. return
  1801. }
  1802. if T_state == -2 {
  1803. for i := 0; i < len(auditRecordList); i++ {
  1804. if auditRecordList[i].T_state == 2 || auditRecordList[i].T_state == 4 {
  1805. auditRecordList[i].T_admin_name = AdminMap[auditRecordList[i].T_admin]
  1806. auditRecordList[i].T_uuid_name = UserMap[auditRecordList[i].T_uuid]
  1807. auditRecordList2 = append(auditRecordList2, auditRecordList[i])
  1808. }
  1809. }
  1810. c.Data["json"] = lib.JSONS{Data: auditRecordList2, Code: 200, Msg: "ok!"}
  1811. c.ServeJSON()
  1812. return
  1813. }
  1814. for i := 0; i < len(auditRecordList); i++ {
  1815. if auditRecordList[i].T_state == T_state {
  1816. auditRecordList[i].T_admin_name = AdminMap[auditRecordList[i].T_admin]
  1817. auditRecordList[i].T_uuid_name = UserMap[auditRecordList[i].T_uuid]
  1818. auditRecordList2 = append(auditRecordList2, auditRecordList[i])
  1819. }
  1820. }
  1821. c.Data["json"] = lib.JSONS{Data: auditRecordList2, Code: 200, Msg: "ok!"}
  1822. c.ServeJSON()
  1823. return
  1824. }
  1825. // 存档生成图片
  1826. func DeviceDataJPG(StartTime, EndTime, T_task_id, T_remark string, deviceList []Device.DeviceClassList, TemperatureMin, TemperatureMax float64) {
  1827. Device.Redis_DeviceDataJPG_Set(T_task_id+T_remark, Device.DeviceDataJPG{
  1828. State: 1,
  1829. Msg: "图片生成中",
  1830. Url: "",
  1831. })
  1832. msg := ""
  1833. state := 2
  1834. url := ""
  1835. if TemperatureMin == 0 {
  1836. TemperatureMin = 2
  1837. }
  1838. if TemperatureMax == 0 {
  1839. TemperatureMax = 8
  1840. }
  1841. var ymin, ymax float64
  1842. var xminT, xmaxT time.Time
  1843. if len(deviceList) > 0 {
  1844. ymin, ymax, xminT, xmaxT = Device.Read_DeviceData_T_Min_Max_Time_Min_Max(deviceList[0].T_sn, StartTime, EndTime)
  1845. }
  1846. // 创建一个新的绘图
  1847. p := plot.New()
  1848. // 设置绘图标题和标签
  1849. p.Title.Text = "温度折线图"
  1850. //p.Legend.ThumbnailWidth = 5 * vg.Inch
  1851. p.X.Label.Text = "时间"
  1852. p.Y.Label.Text = "温度"
  1853. var chData = make(chan int, 10)
  1854. var jobGroup sync.WaitGroup
  1855. var device = make([]Device.DeviceCount, len(deviceList))
  1856. // 创建温度线
  1857. for i := 0; i < len(deviceList); i++ {
  1858. chData <- 1
  1859. jobGroup.Add(1)
  1860. go func(index int) {
  1861. //go func(index int, wg *sync.WaitGroup, p *plot.Plot) {
  1862. defer func() {
  1863. <-chData // 完成时chan取出1个
  1864. jobGroup.Done() // 完成时将等待组值减1
  1865. }()
  1866. sn, id := deviceList[index].T_sn, deviceList[index].T_id
  1867. ymin_, ymax_, minTime_, maxTime_ := Device.Read_DeviceData_T_Min_Max_Time_Min_Max(sn, StartTime, EndTime)
  1868. if ymin > ymin_ {
  1869. ymin = ymin_
  1870. }
  1871. if ymax < ymax_ {
  1872. ymax = ymax_
  1873. }
  1874. if xminT.After(minTime_) && !minTime_.IsZero() {
  1875. xminT = minTime_
  1876. }
  1877. if xmaxT.Before(maxTime_) && !maxTime_.IsZero() {
  1878. xmaxT = maxTime_
  1879. }
  1880. r_maps, r_maps_num := Device.Read_DeviceSensorData_ById_List(sn, StartTime, EndTime, 0, 9999)
  1881. device[index] = Device.DeviceCount{
  1882. T_id: id,
  1883. Num: r_maps_num,
  1884. }
  1885. if r_maps_num == 0 {
  1886. return
  1887. }
  1888. pts := make(plotter.XYs, len(r_maps))
  1889. for j, d := range r_maps {
  1890. t, _ := lib.TimeStrToTime(d.T_time)
  1891. pts[j].X = float64(t.Unix())
  1892. pts[j].Y = float64(d.T_t)
  1893. }
  1894. line, err := plotter.NewLine(pts)
  1895. if err != nil {
  1896. return
  1897. }
  1898. line.Color = randomColor(index)
  1899. p.Add(line)
  1900. }(i)
  1901. }
  1902. jobGroup.Wait()
  1903. xmin, xmax := float64(xminT.Unix()), float64(xmaxT.Unix())
  1904. // 添加最高,最低标准线 用红色虚线标识
  1905. p.Add(horizontalLine(xmin, xmax, TemperatureMin))
  1906. p.Add(horizontalLine(xmin, xmax, TemperatureMax))
  1907. if ymax < 8 {
  1908. ymax = 8
  1909. }
  1910. if ymin > 0 {
  1911. ymin = 0
  1912. }
  1913. p.Y.Min, p.Y.Max = ymin, ymax
  1914. p.X.Min, p.X.Max = xmin, xmax
  1915. p.Y.Tick.Marker = commaTicks{}
  1916. //p.X.Tick.Marker = plot.TimeTicks{Format: "2006-01-02 15:04:05"}
  1917. p.X.Tick.Marker = timeTicks{}
  1918. p.X.Tick.Label.Rotation = math.Pi / 5
  1919. p.X.Tick.Label.YAlign = draw.YCenter
  1920. p.X.Tick.Label.XAlign = draw.XRight
  1921. filename := "jpg" + time.Now().Format("20060102150405")
  1922. // 保存文件
  1923. if err := p.Save(10*vg.Inch, 4*vg.Inch, "ofile/"+filename+".jpg"); err != nil {
  1924. Device.Redis_DeviceDataJPG_Set(T_task_id+T_remark, Device.DeviceDataJPG{
  1925. State: 3,
  1926. Msg: "图片生成失败",
  1927. Url: url,
  1928. })
  1929. logs.Error(lib.FuncName(), "生成图片失败", err)
  1930. return
  1931. }
  1932. if !lib.Pload_qiniu("ofile/"+filename+".jpg", "ofile/"+filename+".jpg") {
  1933. Device.Redis_DeviceDataJPG_Set(T_task_id+T_remark, Device.DeviceDataJPG{
  1934. State: 3,
  1935. Msg: "图片上传七牛云失败",
  1936. Url: url,
  1937. })
  1938. logs.Error(lib.FuncName(), "上传七牛云失败")
  1939. return
  1940. }
  1941. //删除目录
  1942. os.Remove("ofile/" + filename + ".jpg")
  1943. msg = "图片生成成功"
  1944. url = "https://bzdcoldverifyoss.baozhida.cn/" + "ofile/" + filename + ".jpg"
  1945. Device.Redis_DeviceDataJPG_Set(T_task_id+T_remark, Device.DeviceDataJPG{
  1946. State: state,
  1947. Msg: msg,
  1948. Url: url,
  1949. Device: device,
  1950. })
  1951. return
  1952. }
  1953. func horizontalLine(xmin, xmax, y float64) *plotter.Line {
  1954. pts := make(plotter.XYs, 2)
  1955. pts[0].X = xmin
  1956. pts[0].Y = y
  1957. pts[1].X = xmax
  1958. pts[1].Y = y
  1959. line, err := plotter.NewLine(pts)
  1960. if err != nil {
  1961. panic(any(err))
  1962. }
  1963. line.LineStyle.Dashes = []vg.Length{vg.Points(8), vg.Points(5), vg.Points(1), vg.Points(5)}
  1964. line.Color = color.RGBA{R: 255, A: 255}
  1965. return line
  1966. }
  1967. type timeTicks struct{}
  1968. func (timeTicks) Ticks(min, max float64) []plot.Tick {
  1969. tks := plot.TimeTicks{}.Ticks(min, max)
  1970. for i, t := range tks {
  1971. //if t.Label == "" { // Skip minor ticks, they are fine.
  1972. // continue
  1973. //}
  1974. tks[i].Label = time.Unix(int64(t.Value), 0).Format("2006-01-02 15:04:05")
  1975. }
  1976. return tks
  1977. }
  1978. type commaTicks struct{}
  1979. // Ticks computes the default tick marks, but inserts commas
  1980. // into the labels for the major tick marks.
  1981. func (commaTicks) Ticks(min, max float64) []plot.Tick {
  1982. tks := plot.DefaultTicks{}.Ticks(min, max)
  1983. for i, t := range tks {
  1984. //if t.Label == "" { // Skip minor ticks, they are fine.
  1985. // continue
  1986. //}
  1987. tks[i].Label = fmt.Sprintf("%.0f", t.Value)
  1988. }
  1989. return tks
  1990. }
  1991. // 生成随机颜色的辅助函数
  1992. func randomColor(i int) color.RGBA {
  1993. var colors []color.RGBA
  1994. colors = append(colors,
  1995. color.RGBA{R: 52, G: 152, B: 219, A: 255},
  1996. color.RGBA{R: 230, G: 126, B: 34, A: 255},
  1997. color.RGBA{R: 142, G: 68, B: 173, A: 255},
  1998. color.RGBA{R: 211, G: 84, B: 0, A: 255},
  1999. color.RGBA{R: 231, G: 76, B: 60, A: 255},
  2000. color.RGBA{R: 26, G: 188, B: 156, A: 255},
  2001. color.RGBA{R: 243, G: 156, B: 18, A: 255},
  2002. color.RGBA{R: 22, G: 160, B: 133, A: 255},
  2003. color.RGBA{R: 46, G: 204, B: 113, A: 255},
  2004. color.RGBA{R: 39, G: 174, B: 96, A: 255},
  2005. color.RGBA{R: 41, G: 128, B: 185, A: 255},
  2006. color.RGBA{R: 155, G: 89, B: 182, A: 255},
  2007. color.RGBA{R: 192, G: 57, B: 43, A: 255},
  2008. color.RGBA{R: 241, G: 196, B: 15, A: 255},
  2009. )
  2010. return colors[i%len(colors)]
  2011. }
  2012. // 获取加完水印的pdf
  2013. func GetWatermarkPdf(task Task.Task, pdfURL string, flag string) (pdf string) {
  2014. if len(pdfURL) == 0 {
  2015. return
  2016. }
  2017. currentDirectory := lib.GetCurrentDirectory()
  2018. scriptPath := currentDirectory + "/script"
  2019. pdf_file_out_name := uuid.New().String() + ".pdf"
  2020. pdfFilename := currentDirectory + "/ofile/" + uuid.New().String() + ".pdf"
  2021. pdf_file_out := currentDirectory + "/ofile/watermark" + pdf_file_out_name
  2022. watermark_pdf := currentDirectory + "/script/watermark.pdf"
  2023. // 执行Python脚本
  2024. cmd := exec.Command("python3", "add_watermark.py", pdfURL, pdfFilename, pdf_file_out, watermark_pdf)
  2025. cmd.Dir = scriptPath
  2026. // 获取命令输出
  2027. _, err := cmd.CombinedOutput()
  2028. if err != nil {
  2029. logs.Error("执行python脚本添加水印错误:", err)
  2030. return
  2031. }
  2032. lib.Pload_qiniu(pdf_file_out, pdf_file_out_name)
  2033. if !lib.Pload_qiniu(pdf_file_out, pdf_file_out) {
  2034. err = errors.New("上传水印pdf失败")
  2035. return
  2036. }
  2037. defer func() {
  2038. os.Remove(pdfFilename)
  2039. os.Remove(pdf_file_out)
  2040. }()
  2041. pdf = "https://bzdcoldverifyoss.baozhida.cn/" + pdf_file_out_name
  2042. switch flag {
  2043. case "T_pdf1":
  2044. task.T_pdf1_watermark = pdf
  2045. Task.Update_Task(task, "T_pdf1_watermark")
  2046. case "T_pdf2":
  2047. task.T_pdf2_watermark = pdf
  2048. Task.Update_Task(task, "T_pdf2_watermark")
  2049. }
  2050. return
  2051. }
  2052. // 暂停申请
  2053. // 列表 -
  2054. func (c *TaskController) TaskTimeList() {
  2055. // 验证登录 User_is, User_r
  2056. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  2057. if !User_is {
  2058. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  2059. c.ServeJSON()
  2060. return
  2061. }
  2062. var r_jsons lib.R_JSONS
  2063. T_task_id := c.GetString("T_task_id")
  2064. T_task_type, _ := c.GetInt("T_task_type", 0) // 公司名称
  2065. var cnt int64
  2066. List, cnt := Task.Read_TaskTime_List(T_task_id, T_task_type)
  2067. r_jsons.List = List
  2068. r_jsons.Num = int(cnt)
  2069. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  2070. c.ServeJSON()
  2071. return
  2072. }
  2073. // 添加-
  2074. func (c *TaskController) TaskTimeAdd() {
  2075. // 验证登录 User_is, User_r
  2076. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  2077. if !User_is {
  2078. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  2079. c.ServeJSON()
  2080. return
  2081. }
  2082. dc := Device.DeviceClass{
  2083. T_uuid: User_r.T_uuid,
  2084. T_State: 1,
  2085. }
  2086. System.Add_UserLogs_T(User_r.T_uuid, "任务暂停", "暂停申请", dc)
  2087. T_task_id := c.GetString("T_task_id")
  2088. T_task_type, _ := c.GetInt("T_task_type", 0) // 公司名称
  2089. T_aaa := c.GetString("T_aaa")
  2090. var_ := Task.TaskTime{
  2091. T_task_id: T_task_id,
  2092. T_task_type: T_task_type,
  2093. T_uuid: User_r.T_uuid,
  2094. T_remarks: T_aaa,
  2095. T_start_time: time.Now().Format("2006-01-02 15:04:05"),
  2096. }
  2097. List, _ := Task.Read_TaskTime_List(T_task_id, T_task_type)
  2098. if len(List) > 0 {
  2099. if len(List[len(List)-1].T_end_time) == 0 {
  2100. c.Data["json"] = lib.JSONS{Code: 202, Msg: "上一个任务还没结束!"}
  2101. c.ServeJSON()
  2102. return
  2103. }
  2104. }
  2105. is := Task.Add_TaskTime(var_)
  2106. if !is {
  2107. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  2108. c.ServeJSON()
  2109. return
  2110. }
  2111. // 添加任务操作日志
  2112. Task.Add_TaskLogs_T(User_r.T_uuid, T_task_id, "任务暂停", "暂停申请", var_)
  2113. System.Add_UserLogs_T(User_r.T_uuid, "任务暂停", "暂停申请", var_)
  2114. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_task_id}
  2115. c.ServeJSON()
  2116. return
  2117. }
  2118. // 添加-
  2119. func (c *TaskController) TaskTimeEnd() {
  2120. // 验证登录 User_is, User_r
  2121. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  2122. if !User_is {
  2123. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  2124. c.ServeJSON()
  2125. return
  2126. }
  2127. dc := Device.DeviceClass{
  2128. T_uuid: User_r.T_uuid,
  2129. T_State: 1,
  2130. }
  2131. System.Add_UserLogs_T(User_r.T_uuid, "任务暂停", "暂停结束", dc)
  2132. Id, _ := c.GetInt("Id", 0)
  2133. TaskTime_r, is := Task.Read_TaskTime_ById(Id)
  2134. if !is {
  2135. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  2136. c.ServeJSON()
  2137. return
  2138. }
  2139. TaskTime_r.T_end_time = time.Now().Format("2006-01-02 15:04:05")
  2140. is = Task.Update_TaskTime(TaskTime_r, "T_end_time")
  2141. if !is {
  2142. c.Data["json"] = lib.JSONS{Code: 202, Msg: "修改失败!"}
  2143. c.ServeJSON()
  2144. return
  2145. }
  2146. // 添加任务操作日志
  2147. Task.Add_TaskLogs_T(User_r.T_uuid, TaskTime_r.T_task_id, "任务暂停", "暂停结束", TaskTime_r)
  2148. System.Add_UserLogs_T(User_r.T_uuid, "任务暂停", "暂停结束", TaskTime_r)
  2149. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: TaskTime_r.T_task_id}
  2150. c.ServeJSON()
  2151. return
  2152. }
  2153. // 列表 - 统计排名
  2154. func (c *TaskController) StatisticalRanking() {
  2155. // 验证登录 User_is, User_r
  2156. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  2157. if !User_is {
  2158. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  2159. c.ServeJSON()
  2160. return
  2161. }
  2162. T_power, _ := c.GetInt("T_power", 0) // 5 数据采集工程师 6 验证报告工程师
  2163. type Admin_T struct {
  2164. T_name string
  2165. T_scheme int // 实施方案
  2166. T_scheme_returnnum int // 退回
  2167. T_scheme_overnum int // 超时
  2168. T_scheme_log string // 日志
  2169. T_collection int // 数据采集
  2170. T_collection_returnnum int // 退回
  2171. T_collection_overnum int // 超时
  2172. T_collection_log string // 日志
  2173. T_reporting int // 报告编写
  2174. T_reporting_returnnum int // 退回
  2175. T_reporting_overnum int // 超时
  2176. T_reporting_log string // 日志
  2177. T_rejectdnum int // 驳回数量
  2178. }
  2179. var Admin_T_List []Admin_T
  2180. Admin_List := Account.Read_Admin_List_ALL_T_power(T_power)
  2181. for _, A := range Admin_List {
  2182. Admin_t := Admin_T{T_name: A.T_name}
  2183. // 方案
  2184. Task_List := Task.Read_UserTask_StatisticalRanking(A.T_uuid, "T_scheme") //T_scheme T_collection T_reporting
  2185. for _, T := range Task_List {
  2186. if len(T.T_scheme_end_time) > 0 {
  2187. if is, _ := lib.IsInCurrentMonth(T.T_scheme_end_time); !is {
  2188. continue // 不是本月
  2189. }
  2190. Admin_t.T_scheme += 1
  2191. Admin_t.T_scheme_log += T.T_name
  2192. // 退回
  2193. if T.T_scheme_return_times > 0 {
  2194. Admin_t.T_scheme_returnnum += T.T_scheme_return_times
  2195. Admin_t.T_scheme_log += " | 退回" + lib.To_string(int(T.T_scheme_return_times))
  2196. }
  2197. // 超时
  2198. if T.T_scheme_overtime > 0 {
  2199. Admin_t.T_scheme_overnum += 1
  2200. Admin_t.T_scheme_log += " | 超时" + lib.ConvertMinutesToDHM(int(T.T_scheme_overtime))
  2201. }
  2202. // 驳回
  2203. if T.T_reject_times > 0 {
  2204. Admin_t.T_rejectdnum += T.T_reject_times
  2205. Admin_t.T_scheme_log += " | 驳回" + lib.To_string(int(T.T_reject_times))
  2206. }
  2207. Admin_t.T_scheme_log += "\n"
  2208. }
  2209. }
  2210. // 实施
  2211. Task_List = Task.Read_UserTask_StatisticalRanking(A.T_uuid, "T_collection") //T_scheme T_collection T_reporting
  2212. for _, T := range Task_List {
  2213. if len(T.T_collection_end_time) > 0 {
  2214. if is, _ := lib.IsInCurrentMonth(T.T_collection_end_time); !is {
  2215. continue // 不是本月
  2216. }
  2217. Admin_t.T_collection += 1
  2218. Admin_t.T_collection_log += T.T_name
  2219. // 退回
  2220. if T.T_collection_return_times > 0 {
  2221. Admin_t.T_collection_returnnum += T.T_collection_return_times
  2222. Admin_t.T_collection_log += " | 退回" + lib.To_string(int(T.T_collection_return_times))
  2223. }
  2224. // 超时
  2225. if T.T_collection_overtime > 0 {
  2226. Admin_t.T_collection_overnum += 1
  2227. Admin_t.T_collection_log += " | 超时" + lib.ConvertMinutesToDHM(int(T.T_collection_overtime))
  2228. }
  2229. // 驳回
  2230. if T.T_reject_times > 0 {
  2231. Admin_t.T_rejectdnum += T.T_reject_times
  2232. Admin_t.T_collection_log += " | 驳回" + lib.To_string(int(T.T_reject_times))
  2233. }
  2234. Admin_t.T_collection_log += "\n"
  2235. }
  2236. }
  2237. // 报告
  2238. Task_List = Task.Read_UserTask_StatisticalRanking(A.T_uuid, "T_reporting") //T_scheme T_collection T_reporting
  2239. for _, T := range Task_List {
  2240. if len(T.T_reporting_end_time) > 0 {
  2241. if is, _ := lib.IsInCurrentMonth(T.T_reporting_end_time); !is {
  2242. continue // 不是本月
  2243. }
  2244. Admin_t.T_reporting += 1
  2245. Admin_t.T_reporting_log += T.T_name
  2246. // 退回
  2247. if T.T_reporting_return_times > 0 {
  2248. Admin_t.T_reporting_returnnum += T.T_reporting_return_times
  2249. Admin_t.T_reporting_log += " | 退回" + lib.To_string(int(T.T_reporting_return_times))
  2250. }
  2251. // 超时
  2252. if T.T_reporting_overtime > 0 {
  2253. Admin_t.T_reporting_overnum += 1
  2254. Admin_t.T_reporting_log += " | 超时" + lib.ConvertMinutesToDHM(int(T.T_reporting_overtime))
  2255. }
  2256. // 驳回
  2257. if T.T_reject_times > 0 {
  2258. Admin_t.T_rejectdnum += T.T_reject_times
  2259. Admin_t.T_reporting_log += " | 驳回" + lib.To_string(int(T.T_reject_times))
  2260. }
  2261. Admin_t.T_reporting_log += "\n"
  2262. }
  2263. }
  2264. Admin_T_List = append(Admin_T_List, Admin_t)
  2265. }
  2266. var r_jsons lib.R_JSONS
  2267. r_jsons.List = Admin_T_List
  2268. r_jsons.Page = 0
  2269. r_jsons.Page_size = 0
  2270. r_jsons.Pages = lib.Func_page(int64(0), int64(0))
  2271. r_jsons.Num = 0
  2272. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  2273. c.ServeJSON()
  2274. return
  2275. }
  2276. // 复制-
  2277. func (c *TaskController) Copy() {
  2278. // 验证登录 User_is, User_r
  2279. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  2280. if !User_is {
  2281. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  2282. c.ServeJSON()
  2283. return
  2284. }
  2285. T_name := c.GetString("T_name")
  2286. T_task_id := c.GetString("T_task_id")
  2287. r, is := Task.Read_Task(T_task_id)
  2288. if !is {
  2289. c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取信息采集失败!"}
  2290. c.ServeJSON()
  2291. return
  2292. }
  2293. dc := Device.DeviceClass{
  2294. T_uuid: User_r.T_uuid,
  2295. T_State: 1,
  2296. }
  2297. T_class_id, is := Device.Add_DeviceClass(dc)
  2298. if !is {
  2299. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加分类失败!"}
  2300. c.ServeJSON()
  2301. return
  2302. }
  2303. System.Add_UserLogs_T(User_r.T_uuid, "分类管理", "添加", dc)
  2304. // 查询信息采集信息
  2305. infoCollection, is := InfoCollection.Read_InfoCollection(r.T_InfoCollection_id)
  2306. if !is {
  2307. c.Data["json"] = lib.JSONS{Code: 202, Msg: "获取信息采集失败!"}
  2308. c.ServeJSON()
  2309. return
  2310. }
  2311. var_ := Task.Task{
  2312. T_Distributor_id: User_r.T_Distributor_id,
  2313. T_InfoCollection_id: r.T_InfoCollection_id,
  2314. T_InfoTemplate_id: infoCollection.T_InfoTemplate_id,
  2315. T_start_time: infoCollection.T_start_time, // 项目开始时间使用信息采集开始时间
  2316. T_class: int(T_class_id),
  2317. T_uuid: r.T_uuid,
  2318. T_name: T_name,
  2319. T_VerifyTemplate_class: r.T_VerifyTemplate_class,
  2320. T_VerifyTemplate_id: r.T_VerifyTemplate_id,
  2321. T_deadline: r.T_deadline,
  2322. T_scheme: r.T_scheme,
  2323. T_collection: r.T_collection,
  2324. T_reporting: r.T_reporting,
  2325. T_delivery: r.T_delivery,
  2326. T_Show: 1,
  2327. T_State: 1,
  2328. T_project: r.T_project,
  2329. T_province: r.T_province,
  2330. T_city: r.T_city,
  2331. T_district: r.T_district,
  2332. T_province_code: r.T_province_code,
  2333. T_city_code: r.T_city_code,
  2334. T_district_code: r.T_district_code,
  2335. T_category: r.T_category,
  2336. T_device_type: r.T_device_type,
  2337. T_volume: r.T_volume,
  2338. T_verify_type: r.T_verify_type,
  2339. T_subject_matter: r.T_subject_matter,
  2340. T_temp_range: r.T_temp_range,
  2341. T_report_type: r.T_report_type,
  2342. T_device_quantity: r.T_device_quantity,
  2343. }
  2344. var_.T_report_number, _ = Task.GenerateNextT_report_number(var_.T_device_type)
  2345. id, is := Task.Add_Task(var_)
  2346. if !is {
  2347. c.Data["json"] = lib.JSONS{Code: 202, Msg: "添加失败!"}
  2348. c.ServeJSON()
  2349. return
  2350. }
  2351. NatsServer.Create_Local_Table(T_task_id)
  2352. Task.Redis_Task_T_report_number_DelK(var_.T_report_number) // 删除redis内的任务编号
  2353. // 通知
  2354. _, company_r := Account.Read_User_ByT_uuid(var_.T_uuid)
  2355. go wx.WxSend(var_.T_scheme, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  2356. go wx.WxSend(var_.T_collection, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  2357. go wx.WxSend(var_.T_reporting, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  2358. go wx.WxSend(var_.T_delivery, fmt.Sprintf("【%s-%s】任务派发", company_r.T_name, var_.T_name))
  2359. // 添加任务操作日志
  2360. Task.Add_TaskLogs_T(User_r.T_uuid, id, "任务管理", "添加", var_)
  2361. System.Add_UserLogs_T(User_r.T_uuid, "任务管理", "添加", var_)
  2362. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: id}
  2363. c.ServeJSON()
  2364. return
  2365. }
  2366. // 生成报告编号 设备类型+年+季度+递增编号
  2367. func (c *TaskController) GenT_report_number() {
  2368. // 验证登录 User_is, User_r
  2369. _, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  2370. if !User_is {
  2371. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  2372. c.ServeJSON()
  2373. return
  2374. }
  2375. T_device_type := c.GetString("T_device_type")
  2376. number, err := Task.GenerateNextT_report_number(T_device_type)
  2377. if err != nil {
  2378. c.Data["json"] = lib.JSONS{Code: 202, Msg: err.Error()}
  2379. c.ServeJSON()
  2380. return
  2381. }
  2382. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: number}
  2383. c.ServeJSON()
  2384. return
  2385. }
  2386. // 自动填写布点
  2387. func (c *TaskController) Auto_fill_deploy() {
  2388. // 验证登录 User_is, User_r
  2389. User_r, User_is := Account.Verification_Admin(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
  2390. if !User_is {
  2391. c.Data["json"] = lib.JSONS{Code: 201, Msg: "请重新登录!"}
  2392. c.ServeJSON()
  2393. return
  2394. }
  2395. T_task_id := c.GetString("T_task_id")
  2396. T_source, _ := c.GetInt("T_source")
  2397. task, is := Task.Read_Task(T_task_id)
  2398. if !is {
  2399. c.Data["json"] = lib.JSONS{Code: 202, Msg: "Id 错误!"}
  2400. c.ServeJSON()
  2401. return
  2402. }
  2403. verifyTemplate, is := VerifyTemplate.Read_VerifyTemplate(task.T_VerifyTemplate_id)
  2404. verifyTemplate_R := VerifyTemplate.VerifyTemplateToVerifyTemplate_R(verifyTemplate)
  2405. Map_List := VerifyTemplate.Read_VerifyTemplateMap_List_For_Data(task.T_VerifyTemplate_id, T_source, 0)
  2406. MapData := VerifyTemplate.Read_VerifyTemplateMapData_List(T_source, T_task_id, task.T_VerifyTemplate_id, Map_List)
  2407. T_deploy_list := verifyTemplate_R.T_deploy_list
  2408. //if len(T_deploy_list) == 0 {
  2409. // // 解析设备列表备注的布点
  2410. // deviceClassList := Device.Read_DeviceClassList_List_ByT_remark(task.T_class, "")
  2411. // for _, v := range deviceClassList {
  2412. // splitList := lib.SplitStringSeparator(v.T_remark, "|")
  2413. // for _, T_name := range splitList {
  2414. // T_deploy_list = append(T_deploy_list, VerifyTemplate.VerifyTemplateDeploy{T_name: T_name})
  2415. // }
  2416. // }
  2417. //}
  2418. // 循环查询布点
  2419. deployMap := make(map[string]string)
  2420. for _, deploy := range T_deploy_list {
  2421. deviceClassList := Device.Read_DeviceClassList_List_ByT_remark(task.T_class, deploy.T_name)
  2422. var snList []string
  2423. for _, v := range deviceClassList {
  2424. snList = append(snList, v.T_sn)
  2425. }
  2426. deployMap[deploy.T_name] = strings.Join(snList, "|")
  2427. }
  2428. MapDataList := make([]VerifyTemplate.VerifyTemplateMapData, 0)
  2429. for _, v := range MapData {
  2430. if snList, ok := deployMap[v.T_name]; ok {
  2431. val := VerifyTemplate.VerifyTemplateMapData{
  2432. T_source: v.T_source,
  2433. T_task_id: task.T_task_id,
  2434. T_VerifyTemplate_id: task.T_VerifyTemplate_id,
  2435. T_VerifyTemplateMap_id: v.T_VerifyTemplateMap_id,
  2436. T_Required: v.T_Required,
  2437. T_Construction: v.T_Construction,
  2438. T_flow_sort: v.T_flow_sort,
  2439. T_max_time: v.T_max_time,
  2440. T_min_time: v.T_min_time,
  2441. T_value: snList,
  2442. T_start_time: v.T_start_time,
  2443. }
  2444. MapDataList = append(MapDataList, val)
  2445. }
  2446. }
  2447. ids, is := VerifyTemplate.AddOrUpdate_VerifyTemplateMapData_ADD_History(MapDataList, T_source, User_r.T_uuid)
  2448. if !is {
  2449. c.Data["json"] = lib.JSONS{Code: 202, Msg: "保存失败"}
  2450. c.ServeJSON()
  2451. return
  2452. }
  2453. System.Add_UserLogs_T(User_r.T_uuid, "验证模版标签数据", "自动填写", ids)
  2454. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: ids}
  2455. c.ServeJSON()
  2456. return
  2457. }