synceas.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. package util
  2. import (
  3. "fmt"
  4. "log"
  5. "strconv"
  6. "github.com/pkg/errors"
  7. "kpt.xdmy/apiserver/routers/restful"
  8. "kpt.xdmy/pkg/logging"
  9. "kpt.xdmy/pkg/setting"
  10. )
  11. // @Summary 现代牧业EAS对接 备件,出入库
  12. type BillLaid struct { // 销售出库&其它出库 &采购入库 & 其他入库
  13. BizType BillNumber `json:"bizType"` //业务类型
  14. BizDate string `json:"bizDate"` //业务日期
  15. Description string `json:"description"` //摘要
  16. PaymentType BillNumber `json:"paymentType"` // 付款方式
  17. TransactionType BillNumber `json:"transactionType"` // 事务类型
  18. Number string `json:"number"` // 单据编号
  19. Entry []BillEntry `json:"entry"` //
  20. StorageOrgUnit BillNumber `json:"storageOrgUnit"` //库存组织
  21. Supplier BillNumber `json:"supplier"` //供应商
  22. Currency BillNumber `json:"currency"` // 币别
  23. Creator BillNumber `json:"creator"` //创建者
  24. }
  25. type BillNumber struct {
  26. Number string `json:"number"`
  27. }
  28. type BillEntry struct {
  29. ActualPrice string `json:"actualPrice"` //实际单价
  30. ActualTaxPrice string `json:"actualTaxPrice"` //实际含税单价
  31. UnitActualCost string `json:"unitActualCost"` //单位实际成本
  32. UnitPurchaseCost string `json:"unitPurchaseCost"` //单位采购成本
  33. TaxPrice string `json:"taxPrice"` //含税单价
  34. BalanceSupplier BillNumber `json:"balanceSupplier"` //结算供应商
  35. Price string `json:"price"` //单价
  36. ActualCost string `json:"actualCost"` //实际成本
  37. PurchaseCost string `json:"purchaseCost"` //采购成本
  38. Amount string `json:"amount"` // 金额
  39. TaxAmount string `json:"taxAmount"` // 价税合计
  40. ContractNumber string `json:"contractNumber"` // 合同号
  41. Warehouse BillNumber `json:"warehouse"` // 仓库
  42. Unit BillNumber `json:"unit"` // 单位
  43. Material BillNumber `json:"material"` //物料
  44. Qty string `json:"qty"` //数量
  45. StoreType BillNumber `json:"storeType"` //库存类型
  46. StoreStatus BillNumber `json:"storeStatus"` //库存状态
  47. }
  48. type BillUse struct { //领料出库&生产入库
  49. Head BillUseHead `json:"head"`
  50. Entrys []BillUseEntrys `json:"entrys"`
  51. }
  52. type BillUseHead struct {
  53. BillNumber string `json:"billNumber"` //单据编号
  54. BizDate string `json:"bizDate"` //业务日期
  55. BizTypeNumber string `json:"bizTypeNumber"` //业务类型
  56. TransactionType string `json:"transactionType"` //事务类型
  57. Department string `json:"department"` //部门
  58. SupplyStorageOrg string `json:"supplyStorageOrg"` //供方库存组织
  59. StorageOrg string `json:"storageOrg"` //需方库存组织
  60. CostCenter string `json:"costCenter"` //成本中心
  61. Remark string `json:"remark"` //摘要
  62. Creator string `json:"creator"` //创建者
  63. }
  64. type BillUseEntrys struct {
  65. MaterielNumber string `json:"materielNumber"` // 物料
  66. Lot string `json:"lot"` //批次
  67. Amount string `json:"amount"` //数量
  68. MeteredUnit string `json:"meteredUnit"` //单位
  69. WareHouse string `json:"wareHouse"` //需方仓库
  70. Location string `json:"location"` //需方库位
  71. Picker string `json:"picker"` // 领料员
  72. EntryRemark string `json:"entryRemark"` //备注
  73. MasterDepartment string `json:"masterDepartment"` //主制部门
  74. EntryCostCenter string `json:"entryCostCenter"` //成本中心
  75. }
  76. type Parts struct { // 备件
  77. MaterialNumber string `json:"materialNumber"`
  78. MaterialName string `json:"materialName"`
  79. MaterialGroup string `json:"materialGroup"`
  80. Model string `json:"model"`
  81. BaseUnit string `json:"baseUnit"`
  82. Status int `json:"status"`
  83. KaClass string `json:"kaClass"`
  84. //kaClass int32 `json:"kaClass"`
  85. //planningMode int32 `json:"planningMode"`
  86. }
  87. func EASBillSync(typeIN int, billCode interface{}, statue string) error {
  88. defer func() {
  89. if err := recover(); err != nil {
  90. logging.Error("EASBillSync recover err :", err)
  91. }
  92. }()
  93. fmt.Println("++++++++++++++++", typeIN, billCode)
  94. var err error
  95. schema := ""
  96. id := ""
  97. switch typeIN {
  98. case 1: // 入库
  99. schema = "bigpartlaid"
  100. id, err = BigpartLaid(billCode, "syncEASPpartlaid", "006")
  101. case 2: // 出库
  102. schema = "bigpartUse"
  103. id, err = BigpartUse(billCode, "syncEASPpartuse", "100")
  104. case 3, 10: //退库
  105. schema = "bigpartquit"
  106. if typeIN == 3 {
  107. sqlstr := fmt.Sprintf("select id from bigpartquit where useForm='%s' and issync = 0 order by id limit 1", billCode)
  108. restful.BasicList(sqlstr, nil, &billCode)
  109. if err != nil {
  110. log.Default().Printf("EASBillSync:%v", err)
  111. }
  112. }
  113. id, err = BigpartUse(billCode, "syncEASPpartquit", "100")
  114. case 4: //退货
  115. schema = "bigPartRefund"
  116. id, err = BigpartLaid(billCode, "syncEASPPartRefund", "006")
  117. case 5: //备件
  118. schema = "parts"
  119. id = billCode.(string)
  120. // sql = "SELECT id billCode FROM parts WHERE issync = 0 and statue = 1"
  121. err = CheckEASWebServiceParts(statue, "syncEASParts", billCode.(string))
  122. case 6: //调拨入库&出库
  123. schema = "bigparttransfer"
  124. id, err = BigpartLaid(billCode, "syncEASPpartlaid", "008")
  125. case 7: //仅调拨出库
  126. schema = "bigpartUse"
  127. id, err = BigpartUseTransfer(billCode, "syncEASPpartuse", "009")
  128. default:
  129. return errors.New("未知处理类型")
  130. }
  131. tx, err := restful.Dbs.Beginx()
  132. if err != nil {
  133. logging.Error("tx.Begin 事务启动失败__error:", err)
  134. }
  135. defer func() {
  136. switch {
  137. case err != nil:
  138. if tx != nil {
  139. tx.Rollback()
  140. }
  141. default:
  142. if tx != nil {
  143. err = tx.Commit()
  144. }
  145. }
  146. }()
  147. if err != nil {
  148. logging.Info("EASBillSync err", err)
  149. fmt.Println("EASBillSync err", err)
  150. sql := "update " + schema + " set msg = ? where id =?"
  151. _, err = tx.Exec(sql, err.Error(), id)
  152. return err
  153. }
  154. if id == "" {
  155. return nil
  156. }
  157. sql := "update " + schema + " set issync = 1 where id =?"
  158. _, err = tx.Exec(sql, id)
  159. return err
  160. }
  161. func CheckEASWebServiceParts(statue, sqlname, id string) error {
  162. if statue == "1" {
  163. var sqls, params string
  164. sqlstr := fmt.Sprintf("SELECT sqlstr,params FROM apisql WHERE sqlname = '%s' limit 1", sqlname)
  165. err := restful.BasicList(sqlstr, nil, &sqls, &params)
  166. if err != nil {
  167. log.Default().Printf("CheckEASWebServiceParts query error: %v", err)
  168. }
  169. m, err := restful.MapStr(sqls, &id)
  170. if err != nil {
  171. logging.Error("CheckEASWebServiceParts select err", err)
  172. return err
  173. }
  174. if len(m) == 0 {
  175. logging.Error("CheckEASWebServiceParts select len is 0")
  176. return errors.New("CheckEASWebServiceParts 查询结果为空")
  177. }
  178. var parts = Parts{}
  179. parts.BaseUnit = m["baseUnit"]
  180. parts.MaterialGroup = m["materialGroup"]
  181. parts.MaterialName = m["materialName"]
  182. parts.MaterialNumber = m["materialNumber"]
  183. parts.KaClass = m["kaClass"]
  184. parts.Model = m["model"]
  185. parts.Status = 0
  186. sessionid := ""
  187. // 先判断备件与单据是否要分两个地址同步(一个正式线一个测试线)
  188. if setting.ServerSetting.EasUrlTem != "" {
  189. sessionid, err = EASWebServiceLogin(setting.ServerSetting.EasUrlTem)
  190. if err != nil || len(sessionid) < 7 {
  191. log.Default().Printf("EASWebServiceLogin :%s,%v", sessionid, err)
  192. return errors.New("EASWebServiceLogin faild")
  193. }
  194. } else {
  195. singelChan <- struct{}{}
  196. sessionid = <-sessionidChan
  197. if len(sessionid) < 7 || sessionid[:6] == "error:" {
  198. return errors.New(fmt.Sprintf("eas登录失败,sessionid:%s", sessionid))
  199. }
  200. }
  201. err = EASWebServicInsertParts(sessionid, parts, setting.ServerSetting.EasUrlTem)
  202. if err != nil {
  203. logging.Error("EASWebServicInsertParts", err)
  204. return err
  205. }
  206. }
  207. return nil
  208. }
  209. func BigpartUse(billCode interface{}, sqlname, billType string) (string, error) {
  210. var sqls string
  211. pu := BillUse{}
  212. sqlstr := fmt.Sprintf("SELECT sqlstr FROM apisql WHERE sqlname = '%s' limit 1", sqlname)
  213. err := restful.BasicList(sqlstr, nil, &sqls)
  214. if err != nil {
  215. log.Default().Printf("BigpartUse :%v", err)
  216. return "", err
  217. }
  218. ress, _ := restful.MapStrList(sqls, billCode)
  219. if len(ress) == 0 {
  220. logging.Error("BigpartUse select len is 0")
  221. return "", errors.New("查询结果为空")
  222. }
  223. id := ress[0]["id"]
  224. pu.Head.BillNumber = ress[0]["BillNumber"]
  225. pu.Head.BizDate = ress[0]["BizDate"]
  226. pu.Head.BizTypeNumber = ress[0]["BizTypeNumber"]
  227. pu.Head.TransactionType = ress[0]["TransactionType"]
  228. pu.Head.Department = ress[0]["Department"]
  229. pu.Head.SupplyStorageOrg = ress[0]["SupplyStorageOrg"]
  230. pu.Head.StorageOrg = ress[0]["StorageOrg"]
  231. pu.Head.Creator = ress[0]["Creator"]
  232. pu.Head.Remark = ress[0]["Remark"]
  233. pu.Head.CostCenter = ress[0]["Department"]
  234. isZeroStock := false //是否零库存
  235. en := make([]BillUseEntrys, len(ress))
  236. count := 0
  237. for key, res := range ress {
  238. if res["isZeroStock"] == "1" {
  239. isZeroStock = true
  240. count++
  241. }
  242. en[key].Amount = res["Amount"]
  243. en[key].EntryRemark = res["EntryRemark"]
  244. en[key].Lot = res["Lot"]
  245. en[key].MaterielNumber = res["MaterielNumber"]
  246. en[key].MeteredUnit = res["MeteredUnit"]
  247. en[key].Picker = res["Picker"]
  248. en[key].WareHouse = res["WareHouse"]
  249. en[key].Location = res["Location"]
  250. en[key].MasterDepartment = ress[0]["Department"]
  251. en[key].EntryCostCenter = ress[0]["Department"]
  252. }
  253. pu.Entrys = en
  254. pujson, _ := json.Marshal(pu)
  255. singelChan <- struct{}{}
  256. sessionid := <-sessionidChan
  257. if len(sessionid) < 7 || sessionid[:6] == "error:" {
  258. return id, errors.New("eas登录失败")
  259. }
  260. //零库存出库,先进行入库,每个供应商一个入库单
  261. if isZeroStock {
  262. pls := make([]BillLaid, 0)
  263. pl := BillLaid{}
  264. pl.Number = ress[0]["BillNumber"] + "-RK"
  265. pl.TransactionType = BillNumber{
  266. Number: "001",
  267. }
  268. pl.BizDate = ress[0]["BizDate1"]
  269. pl.BizType = BillNumber{
  270. Number: "110",
  271. }
  272. pl.Currency = BillNumber{
  273. Number: "BB01",
  274. }
  275. pl.PaymentType = BillNumber{
  276. Number: "004",
  277. }
  278. pl.StorageOrgUnit = BillNumber{
  279. Number: ress[0]["SupplyStorageOrg"],
  280. }
  281. pl.Supplier = BillNumber{
  282. Number: ress[0]["BalanceSupplier"],
  283. }
  284. pl.Creator = BillNumber{
  285. Number: ress[0]["Creator"],
  286. }
  287. en := make([]BillEntry, 0)
  288. count = 0
  289. temp := ""
  290. cou := 1
  291. code := pl.Number
  292. for _, res := range ress {
  293. if res["isZeroStock"] == "0" {
  294. continue
  295. }
  296. if temp == "" {
  297. temp = res["BalanceSupplier"]
  298. }
  299. if temp != res["BalanceSupplier"] {
  300. pl.Entry = en
  301. pls = append(pls, pl)
  302. pl.Number = code + "-" + strconv.Itoa(cou)
  303. pl.Supplier = BillNumber{
  304. Number: res["BalanceSupplier"],
  305. }
  306. cou++
  307. temp = res["BalanceSupplier"]
  308. en = make([]BillEntry, 0)
  309. }
  310. pl.Supplier = BillNumber{
  311. Number: res["BalanceSupplier"],
  312. }
  313. ent := BillEntry{}
  314. ent.Amount = res["SumPrice"]
  315. ent.Qty = res["Amount"]
  316. ent.ActualCost = res["SumPrice"]
  317. ent.ActualPrice = res["Price"]
  318. ent.ActualTaxPrice = res["Price"]
  319. ent.BalanceSupplier = BillNumber{
  320. Number: res["BalanceSupplier"],
  321. }
  322. ent.ContractNumber = res["ContractNumber"]
  323. ent.Material = BillNumber{
  324. Number: res["MaterielNumber"],
  325. }
  326. ent.Price = res["Price"]
  327. ent.PurchaseCost = res["SumPrice"]
  328. ent.TaxAmount = res["SumPrice"]
  329. ent.TaxPrice = res["Price"]
  330. ent.Unit = BillNumber{
  331. Number: res["MeteredUnit"],
  332. }
  333. ent.UnitActualCost = res["SumPrice"]
  334. ent.UnitPurchaseCost = res["Price"]
  335. ent.Warehouse = BillNumber{
  336. Number: res["WareHouse"],
  337. }
  338. en = append(en, ent)
  339. }
  340. pl.Entry = en
  341. pls = append(pls, pl)
  342. pljson, _ := json.Marshal(pls)
  343. //println(string(pljson))
  344. err = EASWebServicInsertPartsuselaid(sessionid, string(pljson), "006")
  345. if err != nil {
  346. logging.Error("EASWebServicInsertPartsuselaid", err)
  347. return id, err
  348. }
  349. }
  350. err = EASWebServicInsertPartsuselaid(sessionid, string(pujson), billType)
  351. if err != nil {
  352. logging.Error("EASWebServicInsertPartsuselaid", err)
  353. return id, err
  354. }
  355. //EASWebServiceLogout()
  356. return id, nil
  357. }
  358. //
  359. func BigpartUseTransfer(billCode interface{}, sqlname, billType string) (string, error) {
  360. var sqls, params string
  361. sqlstr := fmt.Sprintf("SELECT sqlstr,params FROM apisql WHERE sqlname = '%s' limit 1", sqlname)
  362. err := restful.BasicList(sqlstr, nil, &sqls, &params)
  363. if err != nil {
  364. log.Default().Printf("BigpartUseTransfer basiclist: %v", err)
  365. }
  366. ress, _ := restful.MapStrList(sqls, billCode)
  367. if len(ress) == 0 {
  368. logging.Error("BigpartUse select len is 0", len(ress))
  369. return "", errors.New("查询结果为空")
  370. }
  371. id := ress[0]["id"]
  372. pus := make([]BillLaid, 0)
  373. pu := BillLaid{}
  374. pu.Number = ress[0]["BillNumber"]
  375. pu.TransactionType = BillNumber{
  376. Number: ress[0]["TransactionType"],
  377. }
  378. pu.BizDate = ress[0]["BizDate1"]
  379. pu.BizType = BillNumber{
  380. Number: ress[0]["BizTypeNumber"],
  381. }
  382. pu.Currency = BillNumber{
  383. Number: "BB01",
  384. }
  385. pu.PaymentType = BillNumber{
  386. Number: ress[0]["PaymentType"],
  387. }
  388. pu.StorageOrgUnit = BillNumber{
  389. Number: ress[0]["SupplyStorageOrg"],
  390. }
  391. pu.Supplier = BillNumber{
  392. Number: ress[0]["BalanceSupplier"],
  393. }
  394. pu.Description = ress[0]["Description"]
  395. pu.Creator = BillNumber{
  396. Number: ress[0]["Creator"],
  397. }
  398. en := make([]BillEntry, len(ress))
  399. isZeroStock := false
  400. for key, res := range ress {
  401. isZeroStock = true
  402. en[key].Amount = res["SumPrice"]
  403. en[key].Qty = res["Amount"]
  404. en[key].ActualCost = res["SumPrice"]
  405. en[key].ActualPrice = res["Price"]
  406. en[key].ActualTaxPrice = res["Price"]
  407. en[key].BalanceSupplier = BillNumber{
  408. Number: res["BalanceSupplier"],
  409. }
  410. en[key].ContractNumber = res["ContractNumber"]
  411. en[key].Material = BillNumber{
  412. Number: res["MaterielNumber"],
  413. }
  414. en[key].Price = res["Price"]
  415. en[key].PurchaseCost = res["SumPrice"]
  416. en[key].TaxAmount = res["SumPrice"]
  417. en[key].TaxPrice = res["Price"]
  418. en[key].Unit = BillNumber{
  419. Number: res["MeteredUnit"],
  420. }
  421. en[key].UnitActualCost = res["SumPrice"]
  422. en[key].UnitPurchaseCost = res["Price"]
  423. en[key].Warehouse = BillNumber{
  424. Number: res["WareHouse"],
  425. }
  426. en[key].StoreType = BillNumber{
  427. Number: "G",
  428. }
  429. en[key].StoreStatus = BillNumber{
  430. Number: "1",
  431. }
  432. }
  433. if isZeroStock {
  434. pu.Entry = en
  435. pus = append(pus, pu)
  436. pujson, _ := json.Marshal(pus)
  437. singelChan <- struct{}{}
  438. sessionid := <-sessionidChan
  439. if len(sessionid) < 7 || sessionid[:6] == "error:" {
  440. return id, errors.New("eas登录失败")
  441. }
  442. err = EASWebServicInsertPartsuselaid(sessionid, string(pujson), billType)
  443. if err != nil {
  444. logging.Error("EASWebServicInsertPartsuselaid", err)
  445. return id, err
  446. }
  447. }
  448. tx, err := restful.Dbs.Beginx()
  449. if err != nil {
  450. logging.Error("tx.Begin 事务启动失败__error:", err)
  451. }
  452. defer func() {
  453. switch {
  454. case err != nil:
  455. fmt.Println("__error:", err)
  456. if tx != nil {
  457. tx.Rollback()
  458. }
  459. default:
  460. if tx != nil {
  461. err = tx.Commit()
  462. }
  463. }
  464. }()
  465. sql := "update bigpartUse set issync = 1 where id =?"
  466. _, err = tx.Exec(sql, id)
  467. return id, err
  468. }
  469. func BigpartLaid(billCode interface{}, sqlname, billtype string) (string, error) {
  470. var sqls, params string
  471. sqlstr := fmt.Sprintf("SELECT sqlstr,params FROM apisql WHERE sqlname = '%s' limit 1", sqlname)
  472. err := restful.BasicList(sqlstr, nil, &sqls, &params)
  473. if err != nil {
  474. log.Default().Printf("BigpartLaid basiclist: %v", err)
  475. }
  476. ress, _ := restful.MapStrList(sqls, billCode)
  477. if len(ress) == 0 {
  478. logging.Error("BigpartLaid select len is 0", len(ress))
  479. return "", errors.New("查询结果为空")
  480. }
  481. id := ress[0]["id"]
  482. pls := make([]BillLaid, 0)
  483. pl := BillLaid{}
  484. pl.Number = ress[0]["BillNumber"]
  485. pl.TransactionType = BillNumber{
  486. Number: ress[0]["TransactionType"],
  487. }
  488. pl.BizDate = ress[0]["BizDate"]
  489. pl.BizType = BillNumber{
  490. Number: ress[0]["BizType"],
  491. }
  492. pl.Currency = BillNumber{
  493. Number: ress[0]["Currency"],
  494. }
  495. pl.PaymentType = BillNumber{
  496. Number: ress[0]["PaymentType"],
  497. }
  498. pl.StorageOrgUnit = BillNumber{
  499. Number: ress[0]["StorageOrgUnit"],
  500. }
  501. pl.Supplier = BillNumber{
  502. Number: ress[0]["BalanceSupplier"],
  503. }
  504. pl.Description = ress[0]["Description"]
  505. pl.Creator = BillNumber{
  506. Number: ress[0]["Creator"],
  507. }
  508. en := make([]BillEntry, len(ress))
  509. isZeroStock := false
  510. for key, res := range ress { // 零库存入库跳过
  511. if res["isZeroStock"] == "1" {
  512. continue
  513. } else {
  514. isZeroStock = true
  515. }
  516. pl.Supplier = BillNumber{
  517. Number: res["BalanceSupplier"],
  518. }
  519. en[key].Amount = res["Amount"]
  520. en[key].Qty = res["Qty"]
  521. en[key].ActualCost = res["ActualCost"]
  522. en[key].ActualPrice = res["ActualPrice"]
  523. en[key].ActualTaxPrice = res["ActualTaxPrice"]
  524. en[key].BalanceSupplier = BillNumber{
  525. Number: res["BalanceSupplier"],
  526. }
  527. en[key].ContractNumber = res["ContractNumber"]
  528. en[key].Material = BillNumber{
  529. Number: res["Material"],
  530. }
  531. en[key].Price = res["Price"]
  532. en[key].PurchaseCost = res["PurchaseCost"]
  533. en[key].TaxAmount = res["TaxAmount"]
  534. en[key].TaxPrice = res["TaxPrice"]
  535. en[key].Unit = BillNumber{
  536. Number: res["Unit"],
  537. }
  538. en[key].UnitActualCost = res["UnitActualCost"]
  539. en[key].UnitPurchaseCost = res["UnitPurchaseCost"]
  540. en[key].Warehouse = BillNumber{
  541. Number: res["Warehouse"],
  542. }
  543. }
  544. if isZeroStock {
  545. pl.Entry = en
  546. pls = append(pls, pl)
  547. pujson, _ := json.Marshal(pls)
  548. singelChan <- struct{}{}
  549. sessionid := <-sessionidChan
  550. if len(sessionid) < 7 || sessionid[:6] == "error:" {
  551. return id, errors.New("eas登录失败")
  552. }
  553. err = EASWebServicInsertPartsuselaid(sessionid, string(pujson), billtype)
  554. if err != nil {
  555. logging.Error("EASWebServicInsertPartsuselaid", err)
  556. return id, err
  557. }
  558. if billtype == "008" { // 为调拨入库时
  559. _, err = BigpartUseTransfer(ress[0]["useCode"], "syncEASPpartuse", "009")
  560. }
  561. }
  562. return id, nil
  563. }