StirringTankClientService.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. package com.ruoyi.ams.xuankuang.service;
  2. import cn.hutool.core.util.NumberUtil;
  3. import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
  4. import com.ruoyi.ams.order.mapper.WmsDocOrderHeaderMapper;
  5. import com.ruoyi.ams.task.domain.WcsTask;
  6. import com.ruoyi.ams.task.service.IWcsTaskService;
  7. import com.ruoyi.ams.xuankuang.domain.dto.SkuAgitatedTankAttrDTO;
  8. import com.ruoyi.base.constant.Constant;
  9. import com.ruoyi.common.core.domain.AjaxResult;
  10. import com.ruoyi.hard.xuankang.StirringTankClient;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import java.math.BigDecimal;
  15. import java.util.Date;
  16. import java.util.HashMap;
  17. import java.util.List;
  18. import java.util.Map;
  19. import java.util.stream.Collectors;
  20. import static com.ruoyi.hard.xuankang.StirringTankClient.STIR_TANK_COMMAND.*;
  21. /**
  22. * @author Jwk
  23. * @version 1.0
  24. * @date 2023/4/24 15:31
  25. */
  26. @Slf4j
  27. @Service
  28. public class StirringTankClientService {
  29. @Autowired
  30. private IWcsTaskService wcsTaskService;
  31. @Autowired
  32. StirringTankClient stirringTankClient;
  33. @Autowired
  34. BaseLocationInfoSubService baseLocationInfoSubService;
  35. @Autowired
  36. WmsDocOrderSubService wmsDocOrderSubService;
  37. @Autowired
  38. WmsDocOrderHeaderMapper wmsDocOrderHeaderMapper;
  39. //物料的换算比率映射 PS: 换算比例 Rate=20 代表一份物料20kg
  40. private static final Map<String, SkuAgitatedTankAttrDTO> skuToAgitatedTankAttrMapper = new HashMap<String, SkuAgitatedTankAttrDTO>(){
  41. {
  42. put("Na2CO3", new SkuAgitatedTankAttrDTO().setReadDosageCommand(READ_THE_STIRRING_TANK_07)
  43. .setReadLiquidLevel(READ_THE_STIRRING_TANK_01).setAutomatic(Boolean.FALSE)
  44. .setRate(25).setUnableBitIndex(5).setAbleBitIndex(5).setStartBitIndex(5)
  45. .setRunBitIndex(5).setErrorBitIndex(5).setEndBitIndex(5).setConfirmBitIndex(5));//碳酸钠
  46. put("C5H10OS2", new SkuAgitatedTankAttrDTO().setReadDosageCommand(READ_THE_STIRRING_TANK_08)
  47. .setReadLiquidLevel(READ_THE_STIRRING_TANK_02).setAutomatic(Boolean.TRUE)
  48. .setRate(25).setUnableBitIndex(1).setAbleBitIndex(1).setStartBitIndex(1)
  49. .setRunBitIndex(1).setErrorBitIndex(1).setEndBitIndex(1).setConfirmBitIndex(1));//丁黄药
  50. put("C4H9O2PSSNH4", new SkuAgitatedTankAttrDTO().setReadDosageCommand(READ_THE_STIRRING_TANK_09)
  51. .setReadLiquidLevel(READ_THE_STIRRING_TANK_03).setAutomatic(Boolean.FALSE)
  52. .setRate(5).setUnableBitIndex(5).setAbleBitIndex(5).setStartBitIndex(5)
  53. .setRunBitIndex(5).setErrorBitIndex(5).setEndBitIndex(5).setConfirmBitIndex(5));//丁铵黑药
  54. put("(NaPO3)6", new SkuAgitatedTankAttrDTO().setReadDosageCommand(READ_THE_STIRRING_TANK_10)
  55. .setReadLiquidLevel(READ_THE_STIRRING_TANK_04).setAutomatic(Boolean.TRUE)
  56. .setRate(20).setUnableBitIndex(3).setAbleBitIndex(3).setStartBitIndex(3)
  57. .setRunBitIndex(3).setErrorBitIndex(3).setEndBitIndex(3).setConfirmBitIndex(3));//六偏磷酸钠
  58. put("(NH4)2SO4", new SkuAgitatedTankAttrDTO().setReadDosageCommand(READ_THE_STIRRING_TANK_11)
  59. .setReadLiquidLevel(READ_THE_STIRRING_TANK_05).setAutomatic(Boolean.TRUE)
  60. .setRate(20).setUnableBitIndex(4).setAbleBitIndex(4).setStartBitIndex(4)
  61. .setRunBitIndex(4).setErrorBitIndex(4).setEndBitIndex(4).setConfirmBitIndex(4));//硫酸铵
  62. // put("CH3CH2OCS2Na", new SkuAgitatedTankAttrDTO().setReadDosageCommand(READ_THE_STIRRING_TANK_12)
  63. // .setReadLiquidLevel(READ_THE_STIRRING_TANK_06).setAutomatic(Boolean.TRUE)
  64. // .setRate(25).setUnableBitIndex(5).setAbleBitIndex(5).setStartBitIndex(5)
  65. // .setRunBitIndex(5).setErrorBitIndex(5).setEndBitIndex(5).setConfirmBitIndex(5));//乙黄药
  66. put("CH3CH2OCS2Na", new SkuAgitatedTankAttrDTO().setReadDosageCommand(READ_THE_STIRRING_TANK_08)
  67. .setReadLiquidLevel(READ_THE_STIRRING_TANK_02).setAutomatic(Boolean.TRUE)
  68. .setRate(25).setUnableBitIndex(1).setAbleBitIndex(1).setStartBitIndex(1)
  69. .setRunBitIndex(1).setErrorBitIndex(1).setEndBitIndex(1).setConfirmBitIndex(1));//乙黄药 暂用丁黄药搅拌槽
  70. }
  71. };
  72. public static final List<String> getSkuList(){
  73. return skuToAgitatedTankAttrMapper.entrySet().stream().filter(item -> item.getValue().getAutomatic()).map(Map.Entry::getKey).collect(Collectors.toList());
  74. }
  75. public Boolean setTaskEnd(String skuChemicalName) {
  76. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  77. return stirringTankClient.writeTaskEnd(skuAgitatedTankAttrDTO.getEndBitIndex());
  78. }
  79. public Boolean setTaskError(String skuChemicalName) {
  80. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  81. return stirringTankClient.writeTaskError(skuAgitatedTankAttrDTO.getErrorBitIndex());
  82. }
  83. public Boolean setTaskRun(String skuChemicalName) {
  84. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  85. return stirringTankClient.writeTaskRun(skuAgitatedTankAttrDTO.getRunBitIndex());
  86. }
  87. /**
  88. * 写无法注入
  89. */
  90. public Boolean setUnableInject(String skuChemicalName){
  91. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  92. return stirringTankClient.writeUnableInject(skuAgitatedTankAttrDTO.getUnableBitIndex());
  93. }
  94. /**
  95. * 写可以注入
  96. * @param skuChemicalName
  97. * @return
  98. */
  99. public Boolean setAbleInject(String skuChemicalName){
  100. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  101. return stirringTankClient.writeAbleInject(skuAgitatedTankAttrDTO.getAbleBitIndex());
  102. }
  103. /**
  104. * 确认是否现在就需要生成任务
  105. * @param skuChemicalName
  106. * @return
  107. */
  108. public Boolean confirmNeedNow(String skuChemicalName) {
  109. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  110. return stirringTankClient.readConfirmNeedMark(skuAgitatedTankAttrDTO.getConfirmBitIndex());
  111. }
  112. /**
  113. * 确认是否可以执行出库任务
  114. * @param skuChemicalName
  115. * @return
  116. */
  117. public Boolean enableExcuteTask(String skuChemicalName) {
  118. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  119. return stirringTankClient.readExcuteTaskMark(skuAgitatedTankAttrDTO.getStartBitIndex());
  120. }
  121. /**
  122. * 读取并计算物料的使用剂量转换为物料袋数
  123. * @param skuChemicalName 物料化学名称
  124. * @return
  125. */
  126. public BigDecimal getNeededInvQuantity(String skuChemicalName){
  127. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  128. Number neededWeightCount = stirringTankClient.readNeedDosage(skuAgitatedTankAttrDTO.getReadDosageCommand());
  129. return NumberUtil.div(neededWeightCount, skuAgitatedTankAttrDTO.getRate(), 0);
  130. }
  131. /**
  132. * 读取物料搅拌槽液位值
  133. * @param skuChemicalName 物料化学名称
  134. * @return
  135. */
  136. public BigDecimal getSkuLiquidLevel(String skuChemicalName){
  137. SkuAgitatedTankAttrDTO skuAgitatedTankAttrDTO = skuToAgitatedTankAttrMapper.get(skuChemicalName);
  138. Number neededWeightCount = stirringTankClient.readLiquidLevel(skuAgitatedTankAttrDTO.getReadDosageCommand());
  139. return NumberUtil.div(neededWeightCount, BigDecimal.ONE);
  140. }
  141. /**
  142. * 对比碳酸钠库存
  143. *
  144. * @return
  145. */
  146. public boolean matchInventory_1() {
  147. String sku = "Na2CO3";
  148. BigDecimal b = new BigDecimal(0);
  149. //读注入标志位
  150. boolean[] booleans = stirringTankClient.readTank13();
  151. if (booleans[15] = true) {
  152. //读到的碳酸钠所需剂量
  153. Number number = stirringTankClient.readTank07();
  154. int i = number.intValue();
  155. int i1 = ConvertUtils.convertToInt(i);
  156. int qty = ConvertUtils.convertToQty(i1);
  157. int remainder = ConvertUtils.convertToRemainder(i1);
  158. if (remainder >= 25) {
  159. qty = qty + 1;
  160. }
  161. List<BigDecimal> bigDecimals = baseLocationInfoSubService.checkInventory(sku);
  162. for (BigDecimal bigDecimal : bigDecimals) {
  163. b = b.add(bigDecimal);
  164. }
  165. if (qty <= b.intValue()) {
  166. WmsDocOrderHeader wmsDocOrderHeader = new WmsDocOrderHeader();
  167. wmsDocOrderHeader.setSoReference3("1");
  168. List<WmsDocOrderHeader> wmsDocOrderHeaders = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderList1(wmsDocOrderHeader);
  169. String orderNo = wmsDocOrderHeaders.get(0).getOrderNo();
  170. if (wmsDocOrderHeaders != null && wmsDocOrderHeaders.size() > 0) {
  171. boolean[] booleans1 = stirringTankClient.readTank14();
  172. if (booleans1[15] = true) {
  173. AjaxResult ajaxResult = wmsDocOrderSubService.initOrderDetails(orderNo);
  174. if (ajaxResult.isSuccess()) {
  175. stirringTankClient.writeTank03();
  176. }
  177. return true;
  178. }
  179. return false;
  180. }
  181. stirringTankClient.writeTank02();
  182. stirringTankClient.writeTank01f();
  183. outbound_1(qty);
  184. return true;
  185. } else {
  186. stirringTankClient.writeTank01();
  187. stirringTankClient.writeTank02f();
  188. return false;
  189. }
  190. }
  191. return false;
  192. }
  193. /**
  194. * 生成碳酸钠出库单
  195. *
  196. * @return
  197. */
  198. public AjaxResult outbound_1(int qty) {
  199. String sku = "Na2CO3";
  200. BigDecimal qty1 = new BigDecimal(qty);
  201. String orderNo = wmsDocOrderSubService.generateAnOutboundOrder(sku, qty1);
  202. return AjaxResult.success();
  203. }
  204. /**
  205. * 对比丁黄药库存
  206. *
  207. * @return
  208. */
  209. public boolean matchInventory_2() {
  210. String sku = "C5H10OS2";
  211. BigDecimal b = new BigDecimal(0);
  212. //读注入标志位
  213. boolean[] booleans = stirringTankClient.readTank13();
  214. if (booleans[14] = true) {
  215. //读到的丁黄药所需剂量
  216. Number number = stirringTankClient.readTank08();
  217. int i = number.intValue();
  218. int i1 = ConvertUtils.convertToInt1(i);
  219. int qty = ConvertUtils.convertToQty1(i1);
  220. int remainder = ConvertUtils.convertToRemainder1(i1);
  221. if (remainder >= 20) {
  222. qty = qty + 1;
  223. }
  224. List<BigDecimal> bigDecimals = baseLocationInfoSubService.checkInventory(sku);
  225. for (BigDecimal bigDecimal : bigDecimals) {
  226. b = b.add(bigDecimal);
  227. }
  228. if (qty <= b.intValue()) {
  229. WmsDocOrderHeader wmsDocOrderHeader = new WmsDocOrderHeader();
  230. wmsDocOrderHeader.setSoReference3("2");
  231. List<WmsDocOrderHeader> wmsDocOrderHeaders = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderList1(wmsDocOrderHeader);
  232. String orderNo = wmsDocOrderHeaders.get(0).getOrderNo();
  233. if (wmsDocOrderHeaders != null && wmsDocOrderHeaders.size() > 0) {
  234. boolean[] booleans1 = stirringTankClient.readTank14();
  235. if (booleans1[14] = true) {
  236. AjaxResult ajaxResult = wmsDocOrderSubService.initOrderDetails(orderNo);
  237. if (ajaxResult.isSuccess()) {
  238. stirringTankClient.writeTank03_1();
  239. }
  240. return true;
  241. }
  242. return false;
  243. }
  244. stirringTankClient.writeTank02_1();
  245. stirringTankClient.writeTank01_1f();
  246. outbound_2(qty);
  247. return true;
  248. } else {
  249. stirringTankClient.writeTank01_1();
  250. stirringTankClient.writeTank02_1f();
  251. return false;
  252. }
  253. }
  254. return false;
  255. }
  256. /**
  257. * 生成丁黄药出库单
  258. *
  259. * @return
  260. */
  261. public AjaxResult outbound_2(int qty) {
  262. String sku = "C5H10OS2";
  263. Number number = stirringTankClient.readTank08();
  264. BigDecimal qty1 = new BigDecimal(qty);
  265. String order = wmsDocOrderSubService.generateAnOutboundOrder(sku, qty1);
  266. return AjaxResult.success();
  267. }
  268. /**
  269. * 对比丁铵黑药库存
  270. *
  271. * @return
  272. */
  273. public boolean matchInventory_3() {
  274. String sku = "C4H9O2PSSNH4";
  275. BigDecimal b = new BigDecimal(0);
  276. //读注入标志位
  277. boolean[] booleans = stirringTankClient.readTank13();
  278. if (booleans[13] = true) {
  279. //读到的丁铵黑药所需剂量
  280. Number number = stirringTankClient.readTank09();
  281. int i = number.intValue();
  282. int i1 = ConvertUtils.convertToInt2(i);
  283. int qty = ConvertUtils.convertToQty2(i1);
  284. int remainder = ConvertUtils.convertToRemainder2(i1);
  285. if (remainder >= 100) {
  286. qty = qty + 1;
  287. }
  288. List<BigDecimal> bigDecimals = baseLocationInfoSubService.checkInventory(sku);
  289. for (BigDecimal bigDecimal : bigDecimals) {
  290. b = b.add(bigDecimal);
  291. }
  292. if (qty <= b.intValue()) {
  293. WmsDocOrderHeader wmsDocOrderHeader = new WmsDocOrderHeader();
  294. wmsDocOrderHeader.setSoReference3(null);
  295. List<WmsDocOrderHeader> wmsDocOrderHeaders = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderList1(wmsDocOrderHeader);
  296. if (wmsDocOrderHeaders != null && wmsDocOrderHeaders.size() > 0) {
  297. String orderNo = wmsDocOrderHeaders.get(0).getOrderNo();
  298. boolean[] booleans1 = stirringTankClient.readTank14();
  299. if (booleans1[13] = true) {
  300. AjaxResult ajaxResult = wmsDocOrderSubService.initOrderDetails(orderNo);
  301. if (ajaxResult.isSuccess()) {
  302. stirringTankClient.writeTank03_2();
  303. }
  304. return true;
  305. }
  306. return false;
  307. }
  308. stirringTankClient.writeTank02_2();
  309. stirringTankClient.writeTank01_2f();
  310. outbound_3(qty);
  311. return true;
  312. } else {
  313. stirringTankClient.writeTank01_2();
  314. stirringTankClient.writeTank02_2f();
  315. return false;
  316. }
  317. }
  318. return false;
  319. }
  320. /**
  321. * 生成丁铵黑药出库单
  322. *
  323. * @return
  324. */
  325. public AjaxResult outbound_3(int qty) {
  326. String sku = "C4H9O2PSSNH4";
  327. Number number = stirringTankClient.readTank09();
  328. BigDecimal qty1 = new BigDecimal(qty);
  329. String order = wmsDocOrderSubService.generateAnOutboundOrder(sku, qty1);
  330. return AjaxResult.success();
  331. }
  332. /**
  333. * 对比六偏磷酸钠库存
  334. *
  335. * @return
  336. */
  337. public boolean matchInventory_4() {
  338. String sku = "(NaPO3)6";
  339. BigDecimal b = new BigDecimal(0);
  340. //读注入标志位
  341. boolean[] booleans = stirringTankClient.readTank13();
  342. if (booleans[12] = true) {
  343. //读到的六偏磷酸钠所需剂量
  344. Number number = stirringTankClient.readTank10();
  345. int i = number.intValue();
  346. int i1 = ConvertUtils.convertToInt3(i);
  347. int qty = ConvertUtils.convertToQty3(i1);
  348. int remainder = ConvertUtils.convertToRemainder3(i1);
  349. if (remainder >= 25) {
  350. qty = qty + 1;
  351. }
  352. List<BigDecimal> bigDecimals = baseLocationInfoSubService.checkInventory(sku);
  353. for (BigDecimal bigDecimal : bigDecimals) {
  354. b = b.add(bigDecimal);
  355. }
  356. if (qty <= b.intValue()) {
  357. WmsDocOrderHeader wmsDocOrderHeader = new WmsDocOrderHeader();
  358. wmsDocOrderHeader.setSoReference3("3");
  359. List<WmsDocOrderHeader> wmsDocOrderHeaders = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderList1(wmsDocOrderHeader);
  360. if (wmsDocOrderHeaders != null && wmsDocOrderHeaders.size() > 0) {
  361. String orderNo = wmsDocOrderHeaders.get(0).getOrderNo();
  362. boolean[] booleans1 = stirringTankClient.readTank14();
  363. if (booleans1[12] = true) {
  364. AjaxResult ajaxResult = wmsDocOrderSubService.initOrderDetails(orderNo);
  365. if (ajaxResult.isSuccess()) {
  366. stirringTankClient.writeTank03_3();
  367. }
  368. return true;
  369. }
  370. return false;
  371. }
  372. stirringTankClient.writeTank02_3();
  373. stirringTankClient.writeTank01_3f();
  374. outbound_4(qty);
  375. return true;
  376. } else {
  377. stirringTankClient.writeTank01_3();
  378. stirringTankClient.writeTank02_3f();
  379. return false;
  380. }
  381. }
  382. return false;
  383. }
  384. /**
  385. * 生成六偏磷酸钠出库单
  386. *
  387. * @return
  388. */
  389. public AjaxResult outbound_4(int qty) {
  390. String sku = "(NaPO3)6";
  391. Number number = stirringTankClient.readTank10();
  392. BigDecimal qty1 = new BigDecimal(qty);
  393. String order = wmsDocOrderSubService.generateAnOutboundOrder(sku, qty1);
  394. return AjaxResult.success();
  395. }
  396. /**
  397. * 对比硫酸铵库存
  398. *
  399. * @return
  400. */
  401. public boolean matchInventory_5() {
  402. String sku = "(NH4)2SO4";
  403. BigDecimal b = new BigDecimal(0);
  404. //读注入标志位
  405. boolean[] booleans = stirringTankClient.readTank13();
  406. if (booleans[11] = true) {
  407. //读到的硫酸铵所需剂量
  408. Number number = stirringTankClient.readTank11();
  409. int i = number.intValue();
  410. int i1 = ConvertUtils.convertToInt4(i);
  411. int qty = ConvertUtils.convertToQty4(i1);
  412. int remainder = ConvertUtils.convertToRemainder4(i1);
  413. if (remainder >= 25) {
  414. qty = qty + 1;
  415. }
  416. List<BigDecimal> bigDecimals = baseLocationInfoSubService.checkInventory(sku);
  417. for (BigDecimal bigDecimal : bigDecimals) {
  418. b = b.add(bigDecimal);
  419. }
  420. if (qty <= b.intValue()) {
  421. WmsDocOrderHeader wmsDocOrderHeader = new WmsDocOrderHeader();
  422. wmsDocOrderHeader.setSoReference3("4");
  423. List<WmsDocOrderHeader> wmsDocOrderHeaders = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderList1(wmsDocOrderHeader);
  424. if (wmsDocOrderHeaders != null && wmsDocOrderHeaders.size() > 0) {
  425. String orderNo = wmsDocOrderHeaders.get(0).getOrderNo();
  426. boolean[] booleans1 = stirringTankClient.readTank14();
  427. if (booleans1[11] = true) {
  428. AjaxResult ajaxResult = wmsDocOrderSubService.initOrderDetails(orderNo);
  429. if (ajaxResult.isSuccess()) {
  430. stirringTankClient.writeTank03_4();
  431. return true;
  432. }
  433. }
  434. return false;
  435. }
  436. stirringTankClient.writeTank02_4();
  437. stirringTankClient.writeTank01_4f();
  438. outbound_5(qty);
  439. return true;
  440. } else {
  441. stirringTankClient.writeTank01_4();
  442. stirringTankClient.writeTank02_4f();
  443. return false;
  444. }
  445. }
  446. return false;
  447. }
  448. /**
  449. * 生成硫酸铵出库单
  450. *
  451. * @return
  452. */
  453. public AjaxResult outbound_5(int qty) {
  454. String sku = "(NH4)2SO4";
  455. Number number = stirringTankClient.readTank11();
  456. BigDecimal qty1 = new BigDecimal(qty);
  457. String order = wmsDocOrderSubService.generateAnOutboundOrder(sku, qty1);
  458. return AjaxResult.success();
  459. }
  460. /**
  461. * 对比乙黄药库存
  462. *
  463. * @return
  464. */
  465. public boolean
  466. matchInventory_6() {
  467. String sku = "CH3CH2OCS2Na";
  468. BigDecimal b = new BigDecimal(0);
  469. //读注入标志位
  470. boolean[] booleans = stirringTankClient.readTank13();
  471. if (booleans[10] = true) {
  472. //读到的乙黄药所需剂量
  473. Number number = stirringTankClient.readTank12();
  474. int i = number.intValue();
  475. int i1 = ConvertUtils.convertToInt5(i);
  476. int qty = ConvertUtils.convertToQty5(i1);
  477. int remainder = ConvertUtils.convertToRemainder5(i1);
  478. if (remainder >= 20) {
  479. qty = qty + 1;
  480. }
  481. List<BigDecimal> bigDecimals = baseLocationInfoSubService.checkInventory(sku);
  482. for (BigDecimal bigDecimal : bigDecimals) {
  483. b = b.add(bigDecimal);
  484. }
  485. if (qty <= b.intValue()) {
  486. WmsDocOrderHeader wmsDocOrderHeader = new WmsDocOrderHeader();
  487. wmsDocOrderHeader.setSoReference3("5");
  488. List<WmsDocOrderHeader> wmsDocOrderHeaders = wmsDocOrderHeaderMapper.selectWmsDocOrderHeaderList1(wmsDocOrderHeader);
  489. if (wmsDocOrderHeaders != null && wmsDocOrderHeaders.size() > 0) {
  490. String orderNo = wmsDocOrderHeaders.get(0).getOrderNo();
  491. boolean[] booleans1 = stirringTankClient.readTank14();
  492. if (booleans1[10] = true) {
  493. AjaxResult ajaxResult = wmsDocOrderSubService.initOrderDetails(orderNo);
  494. if (ajaxResult.isSuccess()) {
  495. stirringTankClient.writeTank03_5();
  496. return true;
  497. }
  498. }
  499. return false;
  500. }
  501. stirringTankClient.writeTank02_5();
  502. stirringTankClient.writeTank01_5f();
  503. outbound_6(qty);
  504. return true;
  505. } else {
  506. stirringTankClient.writeTank01_5();
  507. stirringTankClient.writeTank02_5f();
  508. return false;
  509. }
  510. }
  511. return false;
  512. }
  513. /**
  514. * 生成乙黄药出库单
  515. *
  516. * @return
  517. */
  518. public AjaxResult outbound_6(int qty) {
  519. String sku = "CH3CH2OCS2Na";
  520. Number number = stirringTankClient.readTank12();
  521. BigDecimal qty1 = new BigDecimal(qty);
  522. String order = wmsDocOrderSubService.generateAnOutboundOrder(sku, qty1);
  523. return AjaxResult.success();
  524. }
  525. /**
  526. * 清除所有写的数据
  527. *
  528. * @return
  529. */
  530. public AjaxResult clear() {
  531. boolean[] booleans = stirringTankClient.writeTank03_Read();
  532. if (booleans[15] = true) {
  533. stirringTankClient.writeTank01f();
  534. stirringTankClient.writeTank02f();
  535. stirringTankClient.writeTank03f();
  536. stirringTankClient.writeTank04f();
  537. stirringTankClient.writeTank05f();
  538. }
  539. if (booleans[14] = true) {
  540. stirringTankClient.writeTank01_1f();
  541. stirringTankClient.writeTank02_1f();
  542. stirringTankClient.writeTank03_1f();
  543. stirringTankClient.writeTank04_1f();
  544. stirringTankClient.writeTank05_1f();
  545. }
  546. if (booleans[13] = true) {
  547. stirringTankClient.writeTank01_2f();
  548. stirringTankClient.writeTank02_2f();
  549. stirringTankClient.writeTank03_2f();
  550. stirringTankClient.writeTank04_2f();
  551. stirringTankClient.writeTank05_2f();
  552. }
  553. if (booleans[12] = true) {
  554. stirringTankClient.writeTank01_3f();
  555. stirringTankClient.writeTank02_3f();
  556. stirringTankClient.writeTank03_3f();
  557. stirringTankClient.writeTank04_3f();
  558. stirringTankClient.writeTank05_3f();
  559. }
  560. if (booleans[11] = true) {
  561. stirringTankClient.writeTank01_4f();
  562. stirringTankClient.writeTank02_4f();
  563. stirringTankClient.writeTank03_4f();
  564. stirringTankClient.writeTank04_4f();
  565. stirringTankClient.writeTank05_4f();
  566. }
  567. if (booleans[10] = true) {
  568. stirringTankClient.writeTank01_5f();
  569. stirringTankClient.writeTank02_5f();
  570. stirringTankClient.writeTank03_5f();
  571. stirringTankClient.writeTank04_5f();
  572. stirringTankClient.writeTank05_5f();
  573. }
  574. return AjaxResult.success();
  575. }
  576. /**
  577. * 清除未完成和未下发成功的任务
  578. * @return
  579. */
  580. public void delTask() {
  581. List<WcsTask> wcsTaskList = wcsTaskService.selectWcsByState(Constant.WAREHOUSE_ID);
  582. if (wcsTaskList == null || wcsTaskList.size() < 1) { log.info("当前暂无需要处理的任务!"+ new Date());}
  583. for (WcsTask wcsTask : wcsTaskList) {
  584. wcsTaskService.callBack(wcsTask.getTaskNo(), 7, null);
  585. }
  586. }
  587. }