arrangeService.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. /**
  2. * @Author $
  3. * @Date $ $
  4. * @Note
  5. **/
  6. package arrangeService
  7. import (
  8. "encoding/json"
  9. "fmt"
  10. "strconv"
  11. "strings"
  12. "github.com/gogf/gf/os/glog"
  13. "xorm.io/xorm"
  14. "dashoo.cn/base_common/utils"
  15. . "dashoo.cn/base_common/utils/db"
  16. "dashoo.cn/genepoint_srv/business/common"
  17. )
  18. type ArrangeService struct {
  19. ServiceBase
  20. }
  21. const TABLE_ARRANGE_MAIN = "bank_arrange_main"
  22. const TABLE_ARRANGE_DETAIL = "bank_arrange_detail"
  23. const TABLE_TAST = "sample_storage_task"
  24. const TABLE_BOX = "bank_box"
  25. func GetArrangeService(xormEngine *xorm.Engine) *ArrangeService {
  26. s := new(ArrangeService)
  27. s.DBE = xormEngine
  28. return s
  29. }
  30. /**
  31. * @Author 徐春林
  32. * @Description // 查询库内整理申请人
  33. * @Date 15:41 2021/3/30
  34. * @Param
  35. * @return
  36. **/
  37. // 获取申请单创建人
  38. func (this *ArrangeService) GetOperUser(EntryNo string) (user string) {
  39. // 获取当前任务的操作人
  40. sql := " select a.UserName from base_user a left join bank_arrange_main b on a.id = b.CreateUserId where b.EntryNo ='" + EntryNo + "' "
  41. this.DBE.SQL(sql).Get(&user)
  42. return user
  43. }
  44. /**
  45. * @Author 徐春林
  46. * @Description // 修改 整理单主表信息
  47. * @Date 15:45 2021/3/30
  48. * @Param
  49. * @return
  50. **/
  51. // 修改出入库单状态
  52. func (this *ArrangeService) ArrangeMainStatusModify(statusCode int, entryNo,msg string) error {
  53. set := ""
  54. if statusCode == 1 || statusCode == 2 || statusCode == 3 || statusCode == 5 {
  55. set = " ,exception='' "
  56. }else{
  57. if msg!=""{
  58. set = " ,exception='"+msg+"' "
  59. }else{
  60. set = " ,exception='' "
  61. }
  62. }
  63. sql := "UPDATE " + TABLE_ARRANGE_MAIN + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' " + set + " WHERE entryno = '" + entryNo + "'"
  64. _, err := this.DBE.Exec(sql)
  65. return err
  66. }
  67. /**
  68. * @Author EDZ
  69. * @Description // 修改整理单详情表信息
  70. * @Date 15:45 2021/3/30
  71. * @Param
  72. * @return
  73. **/
  74. func (this *ArrangeService) ArrangeDetailStatusModify(statusCode int, entryNo string) error {
  75. //获取出入库单Id
  76. getId := "SELECT id FROM " + TABLE_ARRANGE_MAIN+ " WHERE entryno = '" + entryNo + "'"
  77. var idList []Id
  78. err := this.DBE.SQL(getId).Find(&idList)
  79. //批量更新全部成功或失败的任务样本状态
  80. sql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(statusCode) + "' WHERE parentid = '" + strconv.Itoa(idList[0].Id) + "' and taskstatus !=5"
  81. _, err = this.DBE.Exec(sql)
  82. return err
  83. }
  84. /**
  85. * @Author 徐春林
  86. * @Description // 保存整理单异常信息
  87. * @Date 17:08 2021/3/30
  88. * @Param
  89. * @return
  90. **/
  91. //保存异常信息
  92. func (this *ArrangeService) SaveArrangeExcepMsg(msg, entryNo string) error {
  93. sql := "UPDATE " + TABLE_ARRANGE_MAIN + " SET exception = '" + msg + "' WHERE entryno = '" + entryNo + "'"
  94. _, err := this.DBE.Exec(sql)
  95. return err
  96. }
  97. /**
  98. * @Author 徐春林
  99. * @Description // 根据库内整理任务结果, 成功或部分成功更新数据
  100. * @Date 17:23 2021/3/30
  101. * @Param
  102. * @return
  103. **/
  104. func (this *ArrangeService) UpdateArrangeRes (entryNo string, resp string, message []byte) error {
  105. var res ResponseEntity
  106. err := json.Unmarshal(message, &res)
  107. if err != nil {
  108. fmt.Println(err)
  109. }
  110. taskId := strings.Split(res.Data.Task_id, "@")[0]
  111. isEnd := res.Data.Is_end
  112. // 判断是否全部成功, 更新失败的任务状态
  113. this.GetAbnormalDataAndUpdate(taskId,res)
  114. // 先更新盒子的原位置
  115. err = this.UpdateBoxInfoCK(res)
  116. if err != nil {
  117. return err
  118. }
  119. // 获取返回数据中的 盒子信息
  120. err = this.UpdateBoxInfo(res)
  121. if err != nil {
  122. return err
  123. }
  124. // 获取盒子下的 样本信息
  125. for _, value := range res.Data.Actual_data {
  126. //获取报文中的 盒子信息
  127. var Rack_id string = value.Target.Rack_id
  128. fmt.Println("冻存盒盒子编号:", Rack_id)
  129. // 获取报文中的 位置信息和 样本编码
  130. var tubes = value.Tubes
  131. fmt.Println("样本位置信息:", tubes)
  132. //新增方法 更新位置信息
  133. this.UpdatePosition(taskId,Rack_id, tubes, res)
  134. }
  135. if isEnd {
  136. // 根据盒子中样本数量更新样本信息
  137. this.GetAllBox(taskId)
  138. err = this.StatusModifyWithDetail(taskId)
  139. }
  140. return err
  141. }
  142. /**
  143. * @Author 徐春林
  144. * @Description // 获取整理成功的 盒子信息并保存
  145. * @Date 18:36 2021/3/30
  146. * @Param
  147. * @return
  148. **/
  149. func (this *ArrangeService) UpdateBoxInfo(entity ResponseEntity) (err error) {
  150. //1. 获取当前返回的 冻存架信息,
  151. var shelf Shelf
  152. var equipment Bank_Equipment
  153. glog.Info("entity.Data.Actual_data::", entity.Data.Actual_data)
  154. // 循环处理返回的数据,如果出现多盒存入的分批处理
  155. for i := range entity.Data.Actual_data {
  156. glog.Info("操作地 ", i, " 条数据")
  157. boxBarcode := entity.Data.Actual_data[i].RackId // 冻存盒编号
  158. Cu := entity.Data.Actual_data[i].Target.Cu // 设备编号
  159. Ltu := entity.Data.Actual_data[i].Target.Ltu //
  160. Unit := entity.Data.Actual_data[i].Target.Unit
  161. Pos := entity.Data.Actual_data[i].Target.Pos
  162. Group := entity.Data.Actual_data[i].Target.Group
  163. fmt.Println("保存返回的冻存盒位置信息:cu:", Cu, ",Ltu", Ltu, ",Unit", Unit, ",Group", Group, ",Pos", Pos)
  164. // 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 unit
  165. lengSql := " select * from bank_equipment where cu = '" + utils.ToStr(Cu) + "' and Ltu = '" + utils.ToStr(Ltu) + "' "
  166. this.DBE.SQL(lengSql).Get(&equipment)
  167. sql := "select b.id EquipmentId,a.id,b.code,b.name,a.XStation,a.YStation from bank_shelf a left join bank_equipment b on a.EquipmentId = b.id where b.cu = '" + utils.ToStr(Cu) + "' " +
  168. "and a.Ltu = '" + utils.ToStr(Ltu) + "' and a.Group ='" + utils.ToStr(Group) + "'"
  169. // 拼接冻存盒位置信息
  170. position := equipment.Code + "-" + common.Boxlinename(shelf.XStation) + utils.ToStr(shelf.YStation) + "-" +
  171. "" + common.Boxlinename( Pos )
  172. // 冷库设备
  173. YStation:=" "
  174. if equipment.Ltu == 0 {
  175. sql += " and a.Unit ='" + utils.ToStr(Unit) + "' "
  176. YStation = " , YStation =1 "
  177. position += utils.ToStr(1)
  178. fmt.Println("保存返回的冻存盒位置信息:YStation1:1 ", YStation)
  179. }else{
  180. YStation = " , YStation = "+ utils.ToStr(Unit)
  181. position += utils.ToStr(utils.ToStr(Unit))
  182. fmt.Println("保存返回的冻存盒位置信息:cYStation1:2 ", YStation)
  183. }
  184. this.DBE.SQL(sql).Get(&shelf)
  185. fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
  186. position = shelf.Code + position
  187. // 更新盒所在的冻存架的信息 计算位置信息,并更新
  188. // 临时处理逻辑,默认 pos 为 盒子的 XStation
  189. _, err = this.DBE.Exec("update bank_box set XStation ='" + utils.ToStr(Pos) + "' "+YStation+" ,EquipmentId ='" + utils.ToStr(shelf.EquipmentId) + "'," +
  190. " shelfId =" + utils.ToStr(shelf.Id) + ",IsLocked = 0 , position = '"+position+"' where Barcode ='" + boxBarcode + "' ")
  191. // 更新 当前冰箱冻存盒容量 信息
  192. _, err = this.DBE.Exec(" update bank_currboxcapacity set `A" + utils.ToStr(Pos) + "`= -1 where shelfId =" + utils.ToStr(shelf.Id) + "")
  193. }
  194. return err
  195. }
  196. /**
  197. * @Author 徐春林
  198. * @Description // 更新盒子的 位置为空, 架子的容量
  199. * @Date 18:58 2021/3/30
  200. * @Param
  201. * @return
  202. **/
  203. func (this *ArrangeService) UpdateBoxInfoCK(entity ResponseEntity) (err error) {
  204. //1. 获取当前返回的 冻存架信息,
  205. var shelf Shelf
  206. // 循环处理返回的数据,如果出现多盒存入的分批处理
  207. for i := range entity.Data.Actual_data {
  208. boxBarcode := entity.Data.Actual_data[i].RackId // 冻存盒编号
  209. Pos := entity.Data.Actual_data[i].Target.Pos
  210. sql := " select shelfId , EquipmentId from bank_box where code = '" + boxBarcode + "'"
  211. this.DBE.SQL(sql).Get(&shelf)
  212. fmt.Println("冻存架信息:", shelf.Id, shelf.XStation, shelf.YStation)
  213. // 更新盒所在的冻存架的信息 计算位置信息,并更新
  214. // 临时处理逻辑,默认 pos 为 盒子的 XStation
  215. _, err = this.DBE.Exec("update bank_box set EquipmentId=null,shelfId=null,XStation =null,YStation =null,IsLocked = 0 where Barcode ='" + boxBarcode + "' ")
  216. // 更新 当前冰箱冻存盒容量 信息
  217. _, err = this.DBE.Exec(" update bank_currboxcapacity set `A" + utils.ToStr(Pos) + "`= -2 where shelfId =" + utils.ToStr(shelf.Id) + "")
  218. }
  219. return err
  220. }
  221. /**
  222. * @Author 徐春林
  223. * @Description // 获取返回结果中的样本信息
  224. * @Date 19:10 2021/3/30
  225. * @Param
  226. * @return
  227. **/
  228. func (this *ArrangeService) UpdatePosition(taskId,rack_id string, tubes []Tube, entity ResponseEntity) {
  229. // 根据返回的报文中的盒子标识,获取盒子类型
  230. sql := "select Id,RowNum,ColumnNum,EquipmentId,ShelfId,XStation,YStation from bank_box where Barcode ='" + rack_id + "'"
  231. var box Box
  232. this.DBE.SQL(sql).Get(&box)
  233. RowNum := box.RowNum
  234. ColumnNum := box.ColumnNum
  235. // 获取容器信息
  236. equipmentsql := " select Id,Code,Name from bank_equipment where id = '"+ box.EquipmentId+"' "
  237. var equipmentInfo EquipmentInfo
  238. this.DBE.SQL(equipmentsql).Get(&equipmentInfo)
  239. // 获取架子信息
  240. shelfsql := " select Id,XStation,YStation from bank_shelf where id = '"+ box.ShelfId+"' "
  241. var shelf Shelf
  242. this.DBE.SQL(shelfsql).Get(&shelf)
  243. glog.Info("冻存盒的行数:", RowNum, ";冻存盒的列数:", ColumnNum) //
  244. glog.Info("冻存盒内管数量len(tubes) : " ,len(tubes) ) //
  245. if len(tubes) >0{
  246. for i := 0; i < len(tubes); i++ {
  247. no := tubes[i].No
  248. id := tubes[i].Id
  249. glog.Info("样本在盒子中的位置:", no, ";样本条码: ", id)
  250. //计算管子在盒子中的坐标
  251. var box_x, box_y int
  252. if no%ColumnNum == 0 { // 如果 取余数为0 则 证明该数是能被 10 整除的数 为该行 最后一个孔位
  253. box_y = ColumnNum
  254. box_x = no / ColumnNum
  255. } else {
  256. box_y = no % ColumnNum
  257. box_x = (no / ColumnNum) + 1
  258. }
  259. glog.Info("管子在盒子中的位置坐标为:", box_y, ";", box_x)
  260. position := equipmentInfo.Code + "-" + common.Boxlinename(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
  261. "" + common.Boxlinename(box.YStation) + utils.ToStr(box.XStation)+"-"+common.Boxlinename(box_x) + utils.ToStr(box_y)
  262. sql = "update bank_sample set BoxId = '" + utils.ToStr(box.Id) + "',Position = '" + utils.ToStr(box_y) + ";" + utils.ToStr(box_x) + "' , " +
  263. "PositionInfo = '" + position + "' where barcode ='" + id + "' "
  264. //执行sql 更新位置和坐标信息
  265. this.DBE.Exec(sql)
  266. this.UpdateDetail(id, entity, rack_id,taskId)
  267. }
  268. }else{
  269. this.UpdateDetail("", entity, rack_id,taskId)
  270. }
  271. }
  272. /**
  273. * @Author 徐春林
  274. * @Description // 更新样本的容器, 架信息
  275. * @Date 19:32 2021/3/30
  276. * @Param
  277. * @return
  278. **/
  279. func (this *ArrangeService) UpdateDetail(BarCode string, entity ResponseEntity, rack_id,taskId string) {
  280. glog.Info("修改detail:", entity)
  281. arrangeMain := this.GetArrangeMain(taskId)
  282. var shelf Shelf
  283. var equipment Bank_Equipment
  284. var equipmentid string
  285. var ShelfId string
  286. for i := range entity.Data.Actual_data {
  287. Cu := entity.Data.Actual_data[i].Target.Cu // 设备编号
  288. Ltu := entity.Data.Actual_data[i].Target.Ltu //
  289. Unit := entity.Data.Actual_data[i].Target.Unit
  290. Group := entity.Data.Actual_data[i].Target.Group
  291. // 判断是否是冷库,如果是冷库的话,查询容器架子信息时不需要组装 unit
  292. lengSql := " select * from bank_equipment where cu = '" + utils.ToStr(Cu) + "' and Ltu = '" + utils.ToStr(Ltu) + "' "
  293. this.DBE.SQL(lengSql).Get(&equipment)
  294. if entity.Response == "moving"{
  295. // 更内库内整理 冻存盒信息 整理结果
  296. updatesql := "UPDATE bank_arrange_detail SET IsLocked = '0', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "'" + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
  297. this.DBE.Exec(updatesql)
  298. // 更内库内整理 冻存盒信息 整理结果
  299. updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE boxbarcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "' and task_id = '"+taskId+"'"
  300. this.DBE.Exec(updTaskSql)
  301. }
  302. //当 检测到数据 与当前操作盒子的数据一直时,更新 detail 和sample 信息
  303. if entity.Data.Actual_data[i].Target.Rack_id == rack_id {
  304. sql := "select b.id EquipmentId,a.id,a.XStation,a.YStation from bank_shelf a left join bank_equipment b on a.EquipmentId = b.id where b.cu = '" + utils.ToStr(Cu) + "' " +
  305. "and a.Ltu = '" + utils.ToStr(Ltu) + "' and a.Group ='" + utils.ToStr(Group) + "'"
  306. if equipment.Ltu == 0 {
  307. sql += " and a.Unit ='" + utils.ToStr(Unit) + "' "
  308. }
  309. this.DBE.SQL(sql).Get(&shelf)
  310. equipmentid = strconv.Itoa(shelf.EquipmentId)
  311. ShelfId = strconv.Itoa(shelf.Id)
  312. //pos := equipment.Code + "-" + utils.NumberToLetter(shelf.YStation) + utils.ToStr(shelf.XStation) + "-" +
  313. // "" + utils.NumberToLetter(shelf.YStation) + utils.ToStr(shelf.XStation)
  314. //sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " , PositionInfo = CONCAT('"+pos+"-', PositionInfo) where barcode ='" + BarCode + "' "
  315. sql = "update bank_sample set EquipmentId=" + equipmentid + ",ShelfId=" + ShelfId + " where barcode ='" + BarCode + "' "
  316. this.DBE.Exec(sql)
  317. if entity.Response == "moving"{
  318. // 更内库内整理 冻存盒信息 整理结果
  319. updatesql := "UPDATE bank_arrange_detail SET IsLocked = '0', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "'" + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
  320. this.DBE.Exec(updatesql)
  321. // 更内库内整理 冻存盒信息 整理结果
  322. updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE boxbarcode = '" + entity.Data.Actual_data[i].Target.Rack_id + "' and task_id = '"+taskId+"'"
  323. this.DBE.Exec(updTaskSql)
  324. }else{
  325. // 更新库内整理 样本整理结果
  326. updatesql := "UPDATE bank_arrange_detail SET IsLocked = '0', taskstatus = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + BarCode + "'" + " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
  327. this.DBE.Exec(updatesql)
  328. updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(SUCCESS) + "' WHERE barcode = '" + BarCode + "' and task_id = '"+taskId+"'"
  329. this.DBE.Exec(updTaskSql)
  330. }
  331. }
  332. }
  333. }
  334. /**
  335. * @Author 徐春林
  336. * @Description // end 时更新
  337. * @Date 19:36 2021/3/30
  338. * @Param
  339. * @return
  340. **/
  341. func (this *ArrangeService) StatusModifyWithDetail(task_id string) error {
  342. status := SUCCESS
  343. // 关联查询申请详情表,申请主表中指定申请单下执行状态不为success的申请详情数量
  344. sql := "SELECT count(*) FROM `" + TABLE_ARRANGE_DETAIL + "` a JOIN `" + TABLE_ARRANGE_MAIN + "` b ON a.parentid = b.Id WHERE (b.entryno = '" + task_id + "' and a.taskstatus <> " + strconv.Itoa(SUCCESS) + ")"
  345. var total int
  346. //_, err := this.DBE.Exec(sql)
  347. this.DBE.SQL(sql).Get(&total)
  348. //total ,_ := result.RowsAffected()
  349. fmt.Println("数量:", total)
  350. // 存在未执行成功的子任务
  351. if total > 0 {
  352. status = FAILED
  353. }
  354. // 更新申请主表状态
  355. updApplySql := "UPDATE " + TABLE_ARRANGE_MAIN + " SET taskstatus = '" + strconv.Itoa(status) + "' WHERE entryno = '" + task_id + "'"
  356. _, err := this.DBE.Exec(updApplySql)
  357. return err
  358. }
  359. /**
  360. * @Author 徐春林
  361. * @Description // 获取异常信息, 更新任务状态
  362. * @Date 20:08 2021/3/30
  363. * @Param
  364. * @return
  365. **/
  366. func (this *ArrangeService) GetAbnormalDataAndUpdate(taskId string, entity ResponseEntity) {
  367. //获取反馈报文中的所有异常样本Id列表
  368. racks := entity.Data.Abnormal_data.Racks
  369. arrangeMain := this.GetArrangeMain(taskId)
  370. var shelf Shelf
  371. if len(racks) > 0 {
  372. for _, v := range racks {
  373. // 根据盒编码,任务编码查询 任务信息,任务存在更新状态
  374. sql := "SELECT count(*) FROM `" + TABLE_TAST + " WHERE task_id = '" + taskId + "' and BoxBarCode = '" + v.RackId + "'"
  375. var total int
  376. this.DBE.SQL(sql).Get(&total)
  377. fmt.Println("盒任务数量:", total)
  378. // 存在未执行成功的子任务
  379. if total > 0 {
  380. // 更新任务明细信息
  381. updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE BoxBarCode = '" + v.RackId + "' AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
  382. this.DBE.Exec(updatesql)
  383. updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE BoxBarCode = '" + v.RackId + "' and task_id = '" + taskId + "'"
  384. this.DBE.Exec(updTaskSql)
  385. continue
  386. }
  387. // 不存在根据盒编码查询盒当前的架编码
  388. shelfIdsql := "SELECT ShelfId as Id FROM `" + TABLE_BOX + " WHERE Barcode = '" + v.RackId + "'"
  389. this.DBE.SQL(shelfIdsql).Get(&shelf)
  390. fmt.Println("盒的冻存架Id:", shelf.Id)
  391. // 根据架编码,任务Id 查询 任务信息, 任务存在更新状态
  392. // 更新任务明细信息
  393. updatesql := "UPDATE " + TABLE_ARRANGE_DETAIL + " SET taskstatus = '" + strconv.Itoa(FAILED) + "' WHERE ShelfId = " +strconv.Itoa( shelf.Id)+ " AND parentid = '" + strconv.Itoa(arrangeMain.Id) + "'"
  394. this.DBE.Exec(updatesql)
  395. // 更新任务状态
  396. updTaskSql := "UPDATE " + TABLE_TAST + " SET statuscode = '" + strconv.Itoa(FAILED) + "' WHERE ShelfId = " +strconv.Itoa( shelf.Id)+ "and task_id = '" + taskId + "'"
  397. this.DBE.Exec(updTaskSql)
  398. }
  399. }
  400. }
  401. /**
  402. * @Author 徐春林
  403. * @Description // 获取整理主单信息
  404. * @Date 9:42 2021/3/31
  405. * @Param
  406. * @return
  407. **/
  408. func (this *ArrangeService) GetArrangeMain(entryNo string) Bank_Arrange_Main {
  409. where := "entryNo = '" + entryNo + "'"
  410. var entity Bank_Arrange_Main
  411. sql := "SELECT * FROM bank_arrange_main WHERE " + where
  412. //results, err := this.DBE.Query(sql)
  413. //fmt.Println(results)
  414. _,err := this.DBE.SQL(sql).Get(&entity)
  415. fmt.Println("执行错误:", err)
  416. return entity
  417. }
  418. /**
  419. * @Author 徐春林
  420. * @Description // 获取整理范围的所有盒子, 根据盒子中样本数 更新空盒状态
  421. * @Date 9:42 2021/3/31
  422. * @Param
  423. * @return
  424. **/
  425. func (this *ArrangeService) GetAllBox(taskId string) {
  426. arrangeMain := this.GetArrangeMain(taskId)
  427. sql := "update bank_box a set a.IsEmpty = (case when (select count(b.Id) from bank_sample b where a.Id = b.BoxId) > 0 then 0 else 1 end) where a.EquipmentId = '"+utils.ToStr(arrangeMain.EquipmentId)+"'"
  428. this.DBE.Exec(sql)
  429. }