CcbServiceImpl.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. package com.ruoyi.ccb.service.impl;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import com.alibaba.fastjson.JSON;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.github.pagehelper.PageInfo;
  6. import com.ruoyi.ccb.domain.*;
  7. import com.ruoyi.ccb.domain.basic.CargoDetail;
  8. import com.ruoyi.ccb.domain.basic.CargoLockInfo;
  9. import com.ruoyi.ccb.domain.basic.Page;
  10. import com.ruoyi.ccb.domain.basic.SyncedOrg;
  11. import com.ruoyi.ccb.service.CcbService;
  12. import com.ruoyi.common.core.domain.AjaxResult;
  13. import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitems;
  14. import com.ruoyi.warehouseBusiness.service.IWarehouseBillsCcbService;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Service;
  17. import org.springframework.transaction.annotation.Transactional;
  18. import javax.jws.WebService;
  19. import java.math.BigDecimal;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.stream.Collectors;
  24. /**
  25. * CCB-SOAP接口实现
  26. *
  27. * @author s
  28. */
  29. @WebService(serviceName = "CcbService",
  30. targetNamespace = "http://service.ccb.ruoyi.com/",
  31. endpointInterface = "com.ruoyi.ccb.service.CcbService"
  32. )
  33. @Service
  34. public class CcbServiceImpl implements CcbService {
  35. @Autowired
  36. private IWarehouseBillsCcbService ccbService;
  37. @Override
  38. public String takeVoucherIsExist(String json) {
  39. Voucher voucher = JSON.parseObject(json, Voucher.class);
  40. // 库存帐查询
  41. List<Map<String, Object>> stockList = ccbService.getStockList(voucher.getTakeVoucher(), voucher.getUserName());
  42. VoucherR voucherR = new VoucherR();
  43. if (stockList.size() > 0) {
  44. voucherR.setIsExist("Y");
  45. } else {
  46. voucherR.setIsExist("N");
  47. }
  48. voucherR.setBeLongUser(voucher.getUserName());
  49. voucherR.setUscc(voucher.getUscc());
  50. return JSON.toJSONString(voucherR);
  51. }
  52. @Override
  53. public String takeVoucherDetail(String json) {
  54. Voucher voucher = JSON.parseObject(json, Voucher.class);
  55. // 库存帐查询
  56. List<CargoDetail> cargos = new ArrayList<>();
  57. List<Map<String, Object>> stockList = ccbService.getStockList(voucher.getTakeVoucher(), voucher.getUserName());
  58. stockList.forEach(map -> {
  59. String temp = JSON.toJSONString(map);
  60. CargoDetail detail = JSON.parseObject(temp, CargoDetail.class);
  61. detail.setNumberUnit("件");
  62. detail.setWeightUnit("千克");
  63. detail.setCargoBelong(voucher.getUserName());
  64. detail.setInStorageNumber(detail.getTakeVoucher());
  65. detail.setRemainNumber(detail.getNumberLeft());
  66. detail.setRemainWeight(detail.getWeightLeft());
  67. detail.setElectronicTags(ccbService.getLabel(detail.getTakeVoucher()));
  68. JSONObject object = JSON.parseObject(temp);
  69. if (!"0".equals(object.getString("lockStatus"))) {
  70. CargoLockInfo lockInfo = new CargoLockInfo();
  71. lockInfo.setCargoNo(detail.getCargoNo());
  72. lockInfo.setBlNumber(detail.getBlNumber());
  73. lockInfo.setCargoBelong(detail.getCargoBelong());
  74. lockInfo.setTakeVoucher(detail.getTakeVoucher());
  75. lockInfo.setNumber(detail.getNumberLeft());
  76. lockInfo.setNumberUnit(detail.getNumberUnit());
  77. lockInfo.setWeight(detail.getWeightLeft());
  78. lockInfo.setWeightUnit(detail.getWeightUnit());
  79. lockInfo.setSpeci(detail.getSpeci());
  80. lockInfo.setReasonCode("PLGL");
  81. lockInfo.setLockTime(object.getDate("lockTime"));
  82. lockInfo.setWrNumber(detail.getWrNumber());
  83. lockInfo.setElectronicTags(detail.getElectronicTags());
  84. }
  85. });
  86. VoucherDetailR detailR = new VoucherDetailR();
  87. detailR.setTakeVoucher(voucher.getTakeVoucher());
  88. detailR.setStorageEnterpriseName(voucher.getUserName());
  89. detailR.setBondedStatus(0);
  90. detailR.setUserName(voucher.getUserName());
  91. detailR.setUscc(voucher.getUscc());
  92. detailR.setCargos(cargos);
  93. return JSON.toJSONString(detailR);
  94. }
  95. @Override
  96. public String cargoPledge(String json) {
  97. Pledge pledge = JSON.parseObject(json, Pledge.class);
  98. List<String> billNoList = pledge.getCargos()
  99. .stream()
  100. .map(CargoDetail::getTakeVoucher)
  101. .collect(Collectors.toList());
  102. // 出质处理
  103. AjaxResult result = ccbService.lockStock(pledge.getNewUserName(), billNoList, false);
  104. PledgeR pledgeR = new PledgeR();
  105. pledgeR.setUserName(pledge.getUserName());
  106. pledgeR.setUscc(pledge.getUscc());
  107. pledgeR.setNewUserName(pledge.getNewUserName());
  108. pledgeR.setNewUserNameUscc(pledge.getNewUserNameUscc());
  109. pledgeR.setCargos(pledge.getCargos());
  110. if ((int) result.get("code") != 200) {
  111. pledgeR.setResult("N");
  112. pledgeR.setReason((String) result.get("msg"));
  113. } else {
  114. pledgeR.setResult("Y");
  115. }
  116. return JSON.toJSONString(pledgeR);
  117. }
  118. @Override
  119. public String cargoPledgeOut(String json) {
  120. Pledge pledge = JSON.parseObject(json, Pledge.class);
  121. List<String> billNoList = pledge.getCargos()
  122. .stream()
  123. .map(CargoDetail::getTakeVoucher)
  124. .collect(Collectors.toList());
  125. // 解质处理
  126. AjaxResult result = ccbService.unlockStock(billNoList, false);
  127. PledgeR pledgeR = new PledgeR();
  128. pledgeR.setUserName(pledge.getNewUserName());
  129. pledgeR.setUscc(pledge.getNewUserNameUscc());
  130. pledgeR.setCargos(pledge.getCargos());
  131. if ((int) result.get("code") != 200) {
  132. pledgeR.setResult("N");
  133. pledgeR.setReason((String) result.get("msg"));
  134. } else {
  135. pledgeR.setResult("Y");
  136. }
  137. return JSON.toJSONString(pledgeR);
  138. }
  139. @Override
  140. public String moveCargoReq(String json) {
  141. return null;
  142. }
  143. @Override
  144. @Transactional(rollbackFor = Exception.class)
  145. public String inCargoReq(String json) {
  146. InOutCargo inOutCargo = JSON.parseObject(json, InOutCargo.class);
  147. List<TWarehousebillsitems> items = convert(inOutCargo.getCargos());
  148. AjaxResult result = ccbService.inAndOutStock("SJRK", items);
  149. InOutCargoR inOutCargoR = new InOutCargoR();
  150. inOutCargoR.setUserName(inOutCargo.getUserName());
  151. inOutCargoR.setUscc(inOutCargo.getUscc());
  152. inOutCargoR.setReqUser(inOutCargo.getReqUser());
  153. if ((int) result.get("code") != 200) {
  154. inOutCargoR.setResult("N");
  155. inOutCargoR.setReason((String) result.get("msg"));
  156. } else {
  157. inOutCargoR.setResult("Y");
  158. }
  159. return JSON.toJSONString(inOutCargoR);
  160. }
  161. @Override
  162. public String outCargoReq(String json) {
  163. InOutCargo inOutCargo = JSON.parseObject(json, InOutCargo.class);
  164. List<TWarehousebillsitems> items = convert(inOutCargo.getCargos());
  165. AjaxResult result = ccbService.inAndOutStock("SJCK", items);
  166. InOutCargoR inOutCargoR = new InOutCargoR();
  167. inOutCargoR.setUserName(inOutCargo.getUserName());
  168. inOutCargoR.setUscc(inOutCargo.getUscc());
  169. inOutCargoR.setReqUser(inOutCargo.getReqUser());
  170. if ((int) result.get("code") != 200) {
  171. inOutCargoR.setResult("N");
  172. inOutCargoR.setReason((String) result.get("msg"));
  173. } else {
  174. inOutCargoR.setResult("Y");
  175. inOutCargoR.setReason("");
  176. }
  177. return JSON.toJSONString(inOutCargoR);
  178. }
  179. @Override
  180. public String checkCargoCmd(String json) {
  181. return null;
  182. }
  183. @Override
  184. public String syncOrg(String json) {
  185. SyncOrg syncOrg = JSON.parseObject(json, SyncOrg.class);
  186. Page page = syncOrg.getPage();
  187. if (ObjectUtil.isNull(page)) {
  188. page = new Page();
  189. page.setPageNo(1);
  190. page.setPageSize(10);
  191. }
  192. List<Map<String, Object>> orgList = ccbService.getSyncOrg(page.getPageNo(), page.getPageSize(), syncOrg.getRegisterAfter());
  193. page.setTotalRecords(new PageInfo<>(orgList).getTotal());
  194. List<SyncedOrg> orgListR = orgList.stream()
  195. .map(e -> JSON.parseObject(JSON.toJSONString(e), SyncedOrg.class))
  196. .collect(Collectors.toList());
  197. page.setContent(orgListR);
  198. return JSON.toJSONString(page);
  199. }
  200. @Override
  201. public String generateWrNumber(String json) {
  202. Pledge pledge = JSON.parseObject(json, Pledge.class);
  203. List<CargoDetail> cargos = pledge.getCargos();
  204. List<String> billNoList = cargos.stream()
  205. .map(CargoDetail::getTakeVoucher)
  206. .collect(Collectors.toList());
  207. AjaxResult result = ccbService.unlockStock(billNoList, true);
  208. PledgeR pledgeR = new PledgeR();
  209. pledgeR.setUserName(pledge.getUserName());
  210. pledgeR.setUscc(pledge.getUscc());
  211. pledgeR.setNewUserName(pledge.getNewUserName());
  212. pledgeR.setNewUserNameUscc(pledge.getNewUserNameUscc());
  213. if ((int) result.get("code") != 200) {
  214. pledgeR.setResult("N");
  215. pledgeR.setReason((String) result.get("msg"));
  216. } else {
  217. pledgeR.setResult("Y");
  218. cargos.forEach(cargo -> cargo.setWrNumber(cargo.getTakeVoucher()));
  219. }
  220. pledgeR.setCargos(cargos);
  221. return JSON.toJSONString(pledgeR);
  222. }
  223. @Override
  224. public String cancelWrNumber(String json) {
  225. Pledge pledge = JSON.parseObject(json, Pledge.class);
  226. List<String> billNoList = pledge.getCargos()
  227. .stream()
  228. .map(CargoDetail::getTakeVoucher)
  229. .collect(Collectors.toList());
  230. // 解质处理
  231. AjaxResult result = ccbService.unlockStock(billNoList, true);
  232. PledgeR pledgeR = new PledgeR();
  233. pledgeR.setUserName(pledge.getUserName());
  234. pledgeR.setUscc(pledge.getUscc());
  235. pledgeR.setNewUserName(pledge.getNewUserName());
  236. pledgeR.setNewUserNameUscc(pledge.getNewUserNameUscc());
  237. if ((int) result.get("code") != 200) {
  238. pledgeR.setResult("N");
  239. pledgeR.setReason((String) result.get("msg"));
  240. } else {
  241. pledgeR.setResult("Y");
  242. }
  243. pledgeR.setCargos(pledge.getCargos());
  244. return JSON.toJSONString(pledgeR);
  245. }
  246. @Override
  247. public String blNumberIsExist(String json) {
  248. return null;
  249. }
  250. @Override
  251. public String blNumberDetail(String json) {
  252. return null;
  253. }
  254. @Override
  255. public String queryAssets(String json) {
  256. return null;
  257. }
  258. /**
  259. * 数据转换
  260. *
  261. * @param cargos 出入库数据
  262. * @return 结果
  263. */
  264. private List<TWarehousebillsitems> convert(List<CargoDetail> cargos) {
  265. List<TWarehousebillsitems> items = new ArrayList<>();
  266. for (CargoDetail cargo : cargos) {
  267. TWarehousebillsitems item = new TWarehousebillsitems();
  268. item.setCargoNo(cargo.getCargoNo());
  269. item.setCargoBelong(cargo.getCargoBelong());
  270. item.setfMblno(cargo.getBlNumber());
  271. item.setfPackagespecs(cargo.getSpeci());
  272. item.setfOriginalbillno(cargo.getBlNumber());
  273. item.setfBillingway(3L);
  274. item.setfCntqty(1L);
  275. item.setWarehouseNo(cargo.getWarehouseNo());
  276. item.setShelvesNo(cargo.getShelvesName());
  277. if (ObjectUtil.isNotNull(cargo.getNumber())) {
  278. item.setfPlanqty(cargo.getNumber());
  279. item.setfQty(cargo.getNumber());
  280. } else {
  281. String[] s = String.valueOf(cargo.getWeight()).split("\\.");
  282. item.setfPlanqty(Long.parseLong(s[0]));
  283. item.setfQty(Long.parseLong(s[0]));
  284. }
  285. if (ObjectUtil.isNotNull(cargo.getWeight())) {
  286. item.setfPlangrossweight(BigDecimal.valueOf(cargo.getWeight()));
  287. item.setfPlannetweight(BigDecimal.valueOf(cargo.getWeight()));
  288. item.setfGrossweight(BigDecimal.valueOf(cargo.getWeight()));
  289. item.setfNetweight(BigDecimal.valueOf(cargo.getWeight()));
  290. } else {
  291. item.setfPlangrossweight(BigDecimal.valueOf(cargo.getNumber()));
  292. item.setfPlannetweight(BigDecimal.valueOf(cargo.getNumber()));
  293. item.setfGrossweight(BigDecimal.valueOf(cargo.getNumber()));
  294. item.setfNetweight(BigDecimal.valueOf(cargo.getNumber()));
  295. }
  296. // fSealno代替保税字段
  297. item.setfSealno(cargo.getBondedStatus());
  298. item.setfPlanvolumn(BigDecimal.ZERO);
  299. item.setfVolumn(BigDecimal.ZERO);
  300. item.setfBillstatus(10L);
  301. item.setElectronicTags(cargo.getElectronicTags());
  302. items.add(item);
  303. }
  304. return items;
  305. }
  306. }