WarehousingServiceImpl.java 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. package com.tld.service.impl;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.github.pagehelper.PageHelper;
  5. import com.github.pagehelper.PageInfo;
  6. import com.mysql.cj.xdevapi.JsonString;
  7. import com.tld.excel.ExcelUtils;
  8. import com.tld.mapper.*;
  9. import com.tld.model.*;
  10. import com.tld.model.Dictionary;
  11. import com.tld.model.Error;
  12. import com.tld.service.WarehousingService;
  13. import com.tld.util.DateUtil;
  14. import com.tld.util.HttpClientUtil;
  15. import org.apache.http.ParseException;
  16. import org.redisson.api.RLock;
  17. import org.redisson.api.RedissonClient;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.stereotype.Service;
  20. import org.springframework.transaction.annotation.Transactional;
  21. import javax.annotation.Resource;
  22. import javax.servlet.http.HttpServletRequest;
  23. import javax.servlet.http.HttpServletResponse;
  24. import java.text.SimpleDateFormat;
  25. import java.util.*;
  26. @Service
  27. public class WarehousingServiceImpl implements WarehousingService {
  28. //入库
  29. @Autowired
  30. private WarehousingMapper warehousingMapper;
  31. //用户`
  32. @Autowired
  33. private UserMapper userMapper;
  34. //错误日志表
  35. @Autowired
  36. private ErrorMapper errorMapper;
  37. //redis锁
  38. @Autowired
  39. private RedissonClient redissonClient;
  40. //出库
  41. @Autowired
  42. private AskGoodsMapper askGoodsMapper;
  43. //库存
  44. @Autowired
  45. private StorageLocationMapper storageLocationMapper;
  46. //库存
  47. @Autowired
  48. private DictionaryMapper dictionaryMapper;
  49. //质检单
  50. @Autowired
  51. private ReceiveGoodsMapper receiveGoodsMapper;
  52. @Override
  53. public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate, String warehouseWhere) {
  54. Map<String, Object> map = new HashMap<>();
  55. try {
  56. //判断物料是否录入
  57. MaterialClass materialClass = warehousingMapper.getMateriaIsExist(wllbCode);
  58. if (materialClass == null) {
  59. map.put("msg", "500");
  60. map.put("errMsg", "物料信息未录入,请联系管理员");
  61. return map;
  62. }
  63. if (materialClass.getPartType().equals("半成品") || materialClass.getPartType().equals("产成品")) {
  64. map.put("msg", "500");
  65. map.put("errMsg", "此物料是" + materialClass.getPartType());
  66. return map;
  67. }
  68. Map<String, Object> mapVal = warehousingMapper.getScanIsNot(wllbCode, suppId, unique, producDate, warehouseWhere);
  69. if (Integer.parseInt(mapVal.get("inventoryCount").toString()) != 0 || Integer.parseInt(mapVal.get("virtualCount").toString()) != 0) {
  70. map.put("msg", "500");
  71. map.put("errMsg", "已被扫描");
  72. return map;
  73. }
  74. //判断如果是混合则走单独逻辑
  75. String isNotSisable = warehousingMapper.getIsNotSisable(wllbCode);
  76. if (isNotSisable.equals("1")) {
  77. List<StorageLocation> list1 = warehousingMapper.getIsNotSisableLocation("1");
  78. map.put("data", list1);
  79. map.put("msg", "200");
  80. return map;
  81. }
  82. List<MaterialClass> listMaterialClass = warehousingMapper.getMaterialClass(wllbCode);
  83. if (listMaterialClass.size() == 0) {
  84. listMaterialClass = warehousingMapper.getMaterialClassType(wllbCode);
  85. }
  86. if (listMaterialClass.size() == 0) {
  87. map.put("msg", "500");
  88. map.put("errMsg", "该物料未绑定库位");
  89. return map;
  90. }
  91. StringBuffer stringBuffer = new StringBuffer();
  92. Map<String, Object> listMap = new HashMap<>();
  93. for (int i = 0; i < listMaterialClass.size(); i++) {
  94. Map<String, Object> map1 = warehousingMapper.getScanNum(listMaterialClass.get(i).getStorageLocationCode(), num);
  95. if ( Double.doubleToLongBits(Double.parseDouble(String.valueOf(map1.get("scanNum")))) <= Double.doubleToLongBits(Double.parseDouble(String.valueOf(materialClass.getSize()))) ) {
  96. //查询库存是否同物料同批次存在
  97. List<String> countProduc = warehousingMapper.getInventoryProduc(listMaterialClass.get(i).getWllbCode(), producDate, listMaterialClass.get(i).getStorageLocationCode());
  98. if (countProduc.size() == 0) {
  99. stringBuffer.append(listMaterialClass.get(i).getStorageLocationCode() + ",");
  100. int surplusNum = (int) (Double.parseDouble(String.valueOf(materialClass.getSize())) - Double.parseDouble(String.valueOf(map1.get("scanNum"))) + Double.parseDouble(num));
  101. listMap.put(listMaterialClass.get(i).getStorageLocationCode(), surplusNum);
  102. } else {
  103. if (String.valueOf(countProduc.get(0)).equals(producDate)) {
  104. stringBuffer.append(listMaterialClass.get(i).getStorageLocationCode() + ",");
  105. int surplusNum = (int) (Double.parseDouble(String.valueOf(materialClass.getSize())) - Double.parseDouble(String.valueOf(map1.get("scanNum"))) + Double.parseDouble(num));
  106. listMap.put(listMaterialClass.get(i).getStorageLocationCode(), surplusNum);
  107. }
  108. }
  109. }
  110. }
  111. List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
  112. map.put("data", list);
  113. map.put("listString", listMap);//返回库位剩余数量
  114. map.put("msg", "200");
  115. } catch (Exception e) {
  116. e.printStackTrace();
  117. map.put("msg", "500");
  118. map.put("errMsg", "服务器请求异常,请稍后再试");
  119. }
  120. return map;
  121. }
  122. @Override
  123. @Transactional(rollbackFor = Exception.class)
  124. public Map<String, Object> addWarehousingVirtual(WarehousingVirtual warehousingVirtual) {
  125. Map<String, Object> map = new HashMap<>();
  126. try {
  127. warehousingMapper.addWarehousingVirtual(warehousingVirtual);
  128. map.put("msg", "200");
  129. } catch (Exception e) {
  130. e.printStackTrace();
  131. map.put("msg", "500");
  132. map.put("errMsg", "服务器请求异常,请稍后再试");
  133. }
  134. return map;
  135. }
  136. @Override
  137. @Transactional(rollbackFor = Exception.class)
  138. public Map<String, Object> delWarehousingVirtual(WarehousingVirtual warehousingVirtual) {
  139. Map<String, Object> map = new HashMap<>();
  140. try {
  141. warehousingMapper.delWarehousingVirtual(warehousingVirtual);
  142. map.put("msg", "200");
  143. } catch (Exception e) {
  144. e.printStackTrace();
  145. map.put("msg", "500");
  146. map.put("errMsg", "服务器请求异常,请稍后再试");
  147. }
  148. return map;
  149. }
  150. @Override
  151. @Transactional(rollbackFor = Exception.class)
  152. public Map<String, Object> warehousing(String uniqueCode, String type, String warehouseTransferId) {
  153. Map<String, Object> map = new HashMap<>();
  154. try {
  155. //入库信息
  156. List<WarehousingVirtual> list = new LinkedList<>();
  157. //返回采购单id
  158. StringBuilder stringBuilder = new StringBuilder();
  159. //查询入库所需要的信息
  160. for(WarehousingVirtual warehousingVirtual : warehousingMapper.getVirtual(uniqueCode, type, warehouseTransferId)){
  161. //查询采购单信息
  162. ReceiveGoods receiveGoods1 = receiveGoodsMapper.getReceiveGoodsCode(warehousingVirtual.getReceiveGoodsId());
  163. //存入给gs的返回数据
  164. String code = codeGenerateRk();
  165. warehousingVirtual.setStorageCode(code);
  166. //查询部门编号
  167. List<User> listUser = userMapper.getAllUser(new User().setId(warehousingVirtual.getUserId()));
  168. warehousingVirtual.setDepartmentId(listUser.get(0).getDepartmentId());
  169. //查询物料分类
  170. WarehousingVirtual warehousingVirtual1 = warehousingMapper.getWlClass(warehousingVirtual);
  171. warehousingVirtual.setWllbClass(warehousingVirtual1.getWllbClass());
  172. warehousingVirtual.setMaterialId(warehousingVirtual1.getMaterialId());
  173. warehousingVirtual.setPurchaseNum(receiveGoods1.getPurchaseNum());
  174. list.add(warehousingVirtual);
  175. if(Integer.parseInt(warehousingVirtual.getNum()) <= 0){
  176. break;
  177. }
  178. receiveGoods1.setWarehousingNum(warehousingVirtual.getNum());
  179. warehousingMapper.updateReceiveGood(receiveGoods1);
  180. ReturnWarehousing returnWarehousing = new ReturnWarehousing()
  181. .setWarehousingNum(receiveGoods1.getWarehousingNum())
  182. .setGsCk(warehousingVirtual.getGsCk())
  183. .setSourceType(receiveGoods1.getSourceType())
  184. .setMoveType(receiveGoods1.getMoveType())
  185. .setEntryNumber(receiveGoods1.getEntryNumber())
  186. .setWbs(receiveGoods1.getWbs())
  187. .setId(receiveGoods1.getId())
  188. .setMaterialId(receiveGoods1.getMaterialId())
  189. .setStorageCode(warehousingVirtual.getStorageCode())
  190. .setOrderNumber(receiveGoods1.getOrderNumber())
  191. .setUserName(warehousingVirtual.getUserName())
  192. .setStorageLocationCode(warehousingVirtual.getStorageLocationCode());
  193. warehousingMapper.addReturnWarehousing(returnWarehousing);
  194. warehousingMapper.updateStorage(warehousingVirtual1);//增加入库编号
  195. //判断是否有已存在的采购单号
  196. if(!stringBuilder.toString().contains(receiveGoods1.getOrderNumber() + ",")){
  197. stringBuilder.append(receiveGoods1.getOrderNumber() + ",");
  198. }
  199. }
  200. //入库
  201. warehousingMapper.addStorage(list);//入库流水
  202. warehousingMapper.addInventory(list);//库存
  203. warehousingMapper.delVirtual(uniqueCode);//删除临时表数据
  204. map.put("data", stringBuilder.toString());
  205. map.put("msg", "200");
  206. } catch (Exception e) {
  207. e.printStackTrace();
  208. map.put("msg", "500");
  209. map.put("errMsg", "服务器请求异常,请稍后再试");
  210. }
  211. return map;
  212. }
  213. @Override
  214. public void plugOutWarehousing(String orderNumber) {
  215. try {
  216. for (ReturnWarehousing returnWarehousing : warehousingMapper.getPlugOutWarehousing(orderNumber)) {
  217. JSONObject returnData = new JSONObject();
  218. JSONObject BillItems = new JSONObject();
  219. JSONObject strJson = new JSONObject();
  220. strJson.put("PurOrderID", returnWarehousing.getOrderNumber());//采购单id
  221. strJson.put("WMSID", returnWarehousing.getId());//入库单id
  222. strJson.put("WMSCode", returnWarehousing.getStorageCode());//入库单编号
  223. strJson.put("WareHouse", dictionaryMapper.getWarehouse(returnWarehousing.getStorageLocationCode()));//仓库id
  224. strJson.put("SourceBillDate", DateUtil.dateConversion(returnWarehousing.getScrq()));//业务日期
  225. strJson.put("SourceType", returnWarehousing.getSourceType());//来源类型
  226. strJson.put("MoveType", returnWarehousing.getMoveType());//移动类型
  227. strJson.put("Creator", "测试");//制单人姓名
  228. BillItems.put("WMSItemID", returnWarehousing.getReceiveGoodsId());//利道WMS入库单分录ID
  229. BillItems.put("PurOrderID", returnWarehousing.getOrderNumber());//采购单id
  230. BillItems.put("PurOrderItemID", returnWarehousing.getEntryNumber());//采购订单明细ID
  231. BillItems.put("Material", returnWarehousing.getMaterialId());//物料id
  232. BillItems.put("Quantity", returnWarehousing.getWarehousingNum());//入库数量
  233. BillItems.put("FlexField1", returnWarehousing.getWbs());//wbs
  234. BillItems.put("FlexField1Code", returnWarehousing.getWbsCode());//WBS编号
  235. BillItems.put("FlexField1Name", returnWarehousing.getWbsName());//WBS名称
  236. List<JSONObject> list = new LinkedList<>();
  237. list.add(BillItems);
  238. strJson.put("BillItems", list);
  239. returnData.put("strJson", JSON.toJSONString(strJson));
  240. HttpClientUtil httpClientUtil1 = new HttpClientUtil();
  241. Map<String, Object> result = httpClientUtil1.doPost("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateProductiveOutStock", returnData);
  242. Error error = new Error();
  243. int type = 0;
  244. if (Integer.parseInt(result.get("msg").toString()) != 200) {
  245. //如果失败存入报错信息跟数据
  246. error.setErrorInfo(result.get("data").toString());
  247. error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateProductiveOutStock");
  248. error.setDataVal(returnData.toJSONString());
  249. errorMapper.addError(error);
  250. type = 1;
  251. } else {
  252. JSONObject jsonObject = JSONObject.parseObject(JSON.parseObject((String) result.get("data")).get("result").toString());
  253. if (jsonObject.get("State").toString().equals("0")) {
  254. //如果失败存入报错信息跟数据
  255. error.setErrorInfo(jsonObject.get("Msg").toString());
  256. error.setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreateProductiveOutStock");
  257. error.setDataVal(returnData.toJSONString());
  258. errorMapper.addError(error);
  259. type = 1;
  260. }
  261. }
  262. //删除父子表信息
  263. askGoodsMapper.delPlugOutWarehousing(orderNumber);
  264. //添加记录到tld_access
  265. String names = "入库回传";
  266. String accessType = "1";
  267. String returnGsRemoval = returnData.toString();
  268. askGoodsMapper.addAccess(names, returnGsRemoval, accessType);
  269. //增加流水传输状态
  270. warehousingMapper.updateWarehousingType(returnWarehousing.getStorageCode(), type);
  271. }
  272. } catch (Exception e) {
  273. e.printStackTrace();
  274. }
  275. }
  276. @Override
  277. public Map<String, Object> warehousingFlowing(Storage storage) {
  278. Map<String, Object> map = new HashMap<>();
  279. try {
  280. PageHelper.startPage(storage.getPage(), storage.getLimit());
  281. PageInfo<Storage> list = new PageInfo<>(warehousingMapper.warehousingFlowing(storage));
  282. map.put("data", list);
  283. map.put("msg", "200");
  284. } catch (Exception e) {
  285. e.printStackTrace();
  286. map.put("msg", "500");
  287. map.put("errMsg", "服务器请求异常,请稍后再试");
  288. }
  289. return map;
  290. }
  291. @Override
  292. public Map<String, Object> getWarehousingVirtual(String uniqueCode, String type, String warehouseTransferId) {
  293. Map<String, Object> map = new HashMap<>();
  294. try {
  295. List<WarehousingVirtual> list = warehousingMapper.getWarehousingVirtual(uniqueCode, type, warehouseTransferId);
  296. map.put("data", list);
  297. map.put("msg", "200");
  298. } catch (Exception e) {
  299. e.printStackTrace();
  300. map.put("msg", "500");
  301. map.put("errMsg", "服务器请求异常,请稍后再试");
  302. }
  303. return map;
  304. }
  305. @Override
  306. public void export(Storage storage, HttpServletResponse response) {
  307. try {
  308. //导出数据汇总
  309. List<List<Object>> sheetDataList = new ArrayList<>();
  310. //表头数据
  311. List<Object> head = Arrays.asList("物料名称", "物料编号", "供应商名称", "连番号", "生产日期", "生产批次", "容量", "序列号", "类型", "用户名称", "部门", "库位名称", "入库日期", "采购单号", "WBS","真实姓名","采购订单号", "公司名称", "采购数量");
  312. //查询数据
  313. List<Map<String, Object>> list = new ArrayList<>(warehousingMapper.export(storage));
  314. sheetDataList.add(head);
  315. for (Map<String, Object> userMap : list) {
  316. List<Object> listSheet = new ArrayList<>();
  317. for (String key : userMap.keySet()) {
  318. listSheet.add(userMap.get(key));
  319. }
  320. sheetDataList.add(listSheet);
  321. }
  322. //当前时间
  323. Date time = new Date();
  324. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMddHHmmss");
  325. ExcelUtils.export(response, "入库流水数据导出" + sdf.format(time), sheetDataList);
  326. } catch (Exception e) {
  327. e.printStackTrace();
  328. }
  329. }
  330. @Override
  331. public Map<String, Object> getNotice(Notice notice) {
  332. Map<String, Object> map = new HashMap<>();
  333. try {
  334. Map<String, Object> sumScanNum = new HashMap<>();
  335. PageHelper.startPage(notice.getPage(), notice.getLimit());
  336. PageInfo<Notice> list = new PageInfo<>(warehousingMapper.getNotice(notice));
  337. for (Notice notice1 : list.getList()) {
  338. int sumScanNumVal = warehousingMapper.getSumScanNumVal(notice1);
  339. sumScanNum.put(notice1.getNoticeId() + "-" + notice1.getMaterialId(), sumScanNumVal);
  340. }
  341. map.put("data", list);
  342. map.put("msg", "200");
  343. map.put("sumScanNum", sumScanNum);
  344. } catch (Exception e) {
  345. e.printStackTrace();
  346. map.put("msg", "500");
  347. map.put("errMsg", "服务器请求异常,请稍后再试");
  348. }
  349. return map;
  350. }
  351. @Override
  352. @Transactional(rollbackFor = Exception.class)
  353. public Map<String, Object> addInventoryNotice(Notice notice) {
  354. Map<String, Object> map = new HashMap<>();
  355. try {
  356. Notice notice1 = warehousingMapper.getNoticeId(notice);
  357. if (notice1.getType().equals("1")) {
  358. map.put("msg", "500");
  359. map.put("errMsg", "此通知单已入库!");
  360. return map;
  361. }
  362. // if(Double.parseDouble(notice1.getNum()) < Double.parseDouble(notice.getNum())){
  363. // map.put("msg", "500");
  364. // map.put("errMsg", "入库数量大于通知单数量!");
  365. // return map;
  366. // }
  367. if (warehousingMapper.getInventoryNotice(notice) != 0) {
  368. warehousingMapper.updateInventoryNotice(notice);
  369. } else {
  370. warehousingMapper.addInventoryNotice(notice);
  371. }
  372. notice.setType("1");
  373. warehousingMapper.updateNotice(notice);//修改报工单数量
  374. //存入给gs的返回数据
  375. String storageCode = codeGenerateRk();
  376. //入库流水
  377. WarehousingVirtual warehousingVirtual = new WarehousingVirtual()
  378. .setWllbCode(notice1.getMaterialCode())
  379. .setUserId(notice.getUserId())
  380. .setStorageLocationCode(notice.getStorageLocationCode())
  381. .setProducDate(notice1.getNoticeTime())
  382. .setNum(notice.getWarehousingNum())
  383. .setStorageCode(storageCode)
  384. .setWbs(notice.getWbs())
  385. .setProductionCode(notice1.getProductionCode())
  386. .setAccountSleeve(notice.getCompanyNumber());
  387. warehousingMapper.addProduct(warehousingVirtual);//入库流水 半成品
  388. ReturnWarehousing returnWarehousing = new ReturnWarehousing()
  389. .setStorageCode(storageCode)//入库编号
  390. .setSourceType(notice1.getSourceType())//来源类型
  391. .setMoveType(notice1.getMoveType())//移动类型
  392. .setOrderNumber(notice1.getNoticeId())//通知单id
  393. .setWbs(notice1.getWbs())//wbs
  394. .setEntryNumber(notice1.getEntryNumber())//gs分录号
  395. .setMaterialId(notice1.getMaterialId())//物料id
  396. .setId(notice1.getId())//分录单id
  397. .setWarehousingNum(notice.getWarehousingNum())//入库数量
  398. .setStorageLocationCode(notice.getStorageLocationCode())//库位编号
  399. .setUserName(notice.getUserName());//用户名称
  400. warehousingMapper.addReturnWarehousing(returnWarehousing);
  401. map.put("data", storageCode);
  402. map.put("msg", "200");
  403. } catch (Exception e) {
  404. e.printStackTrace();
  405. map.put("msg", "500");
  406. map.put("errMsg", "服务器请求异常,请稍后再试");
  407. }
  408. return map;
  409. }
  410. @Override
  411. @Transactional(rollbackFor = Exception.class)
  412. public Map<String, Object> updateInventoryNotice(Notice notice) {
  413. Map<String, Object> map = new HashMap<>();
  414. //redis并发锁
  415. RLock lock = redissonClient.getLock(notice.getMaterialId());
  416. lock.lock();
  417. try {
  418. Inventory inventory = warehousingMapper.getHalfInventory(notice);//库存信息
  419. AskGoods askGoods = warehousingMapper.getAskGoodsHalf(notice);//要货单信息
  420. if (askGoods.getType().equals("1")) {
  421. map.put("msg", "500");
  422. map.put("errMsg", "订单已出库");
  423. return map;
  424. }
  425. if (Double.doubleToLongBits(Double.parseDouble(askGoods.getNum())) < Double.doubleToLongBits(Double.parseDouble(notice.getWarehousingNum()) + Double.parseDouble(askGoods.getOutNum()))) {
  426. map.put("msg", "500");
  427. map.put("errMsg", "出库数量大于剩余要货单数量");
  428. return map;
  429. }
  430. if (inventory == null) {
  431. map.put("msg", "500");
  432. map.put("errMsg", "没有查询到此半成品物料的库存");
  433. return map;
  434. }
  435. if (Double.doubleToLongBits(Double.parseDouble(notice.getWarehousingNum())) > Double.doubleToLongBits(Double.parseDouble(inventory.getAmount()))) {
  436. map.put("msg", "500");
  437. map.put("errMsg", "库存不足");
  438. return map;
  439. }
  440. if (Double.doubleToLongBits(Double.parseDouble(notice.getWarehousingNum())) == Double.doubleToLongBits(Double.parseDouble(inventory.getAmount()))) {
  441. warehousingMapper.delInventoryNotice(notice);
  442. } else {
  443. warehousingMapper.updateInventoryNoticeNum(notice);
  444. }
  445. //出库数量 + 已经出库的数量 如果相等 则改变单据状态
  446. Double num = Double.parseDouble(notice.getWarehousingNum()) + Double.parseDouble(askGoods.getOutNum());
  447. String type = null;
  448. if(Double.doubleToLongBits(Double.parseDouble(askGoods.getNum())) == Double.doubleToLongBits(num)){
  449. type = "1";
  450. }
  451. warehousingMapper.updateAskGoodsHalf(askGoods.getId(), notice.getWarehousingNum(), type);//修改要货单出库数量
  452. //新增返回gs信息
  453. String removalCode = codeGenerateCk();
  454. //新增半成品出库流水
  455. AskGoods askGoods1 = new AskGoods()
  456. .setWllbCode(notice.getWllbCode())
  457. .setNum(notice.getWarehousingNum())
  458. .setUserId(notice.getUserId())
  459. .setAskGoodsId(askGoods.getAskGoodsId())
  460. .setDepartment(askGoods.getDepartment())
  461. .setStorageCode(removalCode)
  462. .setWbs(notice.getWbs())
  463. .setCompanyNumber(notice.getCompanyNumber());//新增出库流水
  464. warehousingMapper.addRemovalHalfProduct(askGoods1);
  465. ReturRemoval returRemoval = new ReturRemoval()
  466. .setMaterialId(notice.getMaterialId())
  467. .setDocumentId(notice.getAskGoodsId())
  468. .setWbs(askGoods.getWbs())
  469. .setNum(notice.getWarehousingNum())
  470. .setEntryNumber(askGoods.getEntryNumber())
  471. .setDocumentPointsId(askGoods.getId())
  472. .setStorageLocationCode(inventory.getStorageLocationCode())
  473. .setRemovalCode(removalCode)
  474. .setSourceType(askGoods.getSourceType())
  475. .setMoveType(askGoods.getMoveType());
  476. askGoodsMapper.addReturnGsRemovalF(returRemoval);//新增返回gs数据父表信息
  477. askGoodsMapper.addReturnGsRemoval(returRemoval);//新增返回gs数据子表信息
  478. map.put("data", notice.getAskGoodsId());
  479. map.put("msg", "200");
  480. } catch (Exception e) {
  481. e.printStackTrace();
  482. map.put("msg", "500");
  483. map.put("errMsg", "服务器请求异常,请稍后再试");
  484. } finally {
  485. //判断要解锁的key是否已被锁定;判断要解锁的key是否被当前线程持有
  486. if (lock.isLocked() && lock.isHeldByCurrentThread()) {
  487. //释放锁
  488. lock.unlock();
  489. }
  490. }
  491. return map;
  492. }
  493. @Override
  494. public Map<String, Object> getProduct(Notice notice) {
  495. Map<String, Object> map = new HashMap<>();
  496. try {
  497. PageHelper.startPage(notice.getPage(), notice.getLimit());
  498. PageInfo<Notice> list = new PageInfo<>(warehousingMapper.getProduct(notice));
  499. map.put("data", list);
  500. map.put("msg", "200");
  501. } catch (Exception e) {
  502. e.printStackTrace();
  503. map.put("msg", "500");
  504. map.put("errMsg", "服务器请求异常,请稍后再试");
  505. }
  506. return map;
  507. }
  508. @Override
  509. public void productExcel(Notice notice, HttpServletResponse response) {
  510. try {
  511. //导出数据汇总
  512. List<List<Object>> sheetDataList = new ArrayList<>();
  513. //表头数据
  514. List<Object> head = Arrays.asList("物料名称", "物料编号", "生产时间", "数量", "用户名称", "入库时间", "入库单编号", "WBS","真实姓名","生产订单号","公司名称");
  515. //查询数据
  516. List<Map<String, Object>> list = warehousingMapper.productExcel(notice);
  517. sheetDataList.add(head);
  518. for (Map<String, Object> userMap : list) {
  519. List<Object> listSheet = new ArrayList<>();
  520. for (String key : userMap.keySet()) {
  521. listSheet.add(userMap.get(key));
  522. }
  523. sheetDataList.add(listSheet);
  524. }
  525. //当前时间
  526. Date time = new Date();
  527. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMddHHmmss");
  528. ExcelUtils.export(response, "入库流水数据导出" + sdf.format(time), sheetDataList);
  529. } catch (Exception e) {
  530. e.printStackTrace();
  531. }
  532. }
  533. @Override
  534. public Map<String, Object> getProductWarehousing(Notice notice) {
  535. Map<String, Object> map = new HashMap<>();
  536. try {
  537. MaterialClass material = warehousingMapper.getMaterial(notice);
  538. if (material == null) {
  539. map.put("msg", "500");
  540. map.put("errMsg", "物料信息未录入,请联系管理员");
  541. return map;
  542. }
  543. Map<String, Object> mapVal = warehousingMapper.getScanIsNotProduct(notice);
  544. if (Integer.parseInt(mapVal.get("inventoryCount").toString()) != 0 || Integer.parseInt(mapVal.get("virtualCount").toString()) != 0) {
  545. map.put("msg", "500");
  546. map.put("errMsg", "已被扫描");
  547. return map;
  548. }
  549. int num = 0;
  550. if (notice.getType().equals("0")) {
  551. num = warehousingMapper.getNumUtil("产成品库位托盘定义");
  552. } else {
  553. num = Integer.parseInt(material.getSize());
  554. }
  555. int scanNum = Integer.parseInt(mapVal.get("inventoryCount").toString()) + Integer.parseInt(mapVal.get("virtualCount").toString());
  556. if(scanNum == num){
  557. map.put("msg", "500");
  558. map.put("errMsg", "库位已满");
  559. return map;
  560. }
  561. Notice notice1 = warehousingMapper.getNoticeId(new Notice().setNoticeId(notice.getNoticeId()).setMaterialId(notice.getMaterialId()));
  562. Double contrast = Double.parseDouble(notice1.getWarehousingNum()) + Double.parseDouble(notice.getWarehousingNum());
  563. if(Double.doubleToLongBits(contrast) > Double.doubleToLongBits(Double.parseDouble(notice1.getNum()))){
  564. map.put("msg", "500");
  565. map.put("errMsg", "扫描数量超出报工单数量");
  566. return map;
  567. }
  568. notice.setWllbClass(material.getWllbClass());
  569. StringBuffer stringBuffer = new StringBuffer();//库位编号
  570. if (material.getPartType().equals("产成品")) {
  571. if (material.getIsRecommend().equals("1")) {
  572. StorageLocation storageLocation = new StorageLocation().setIsProduct("1");
  573. String[] symbol = {"<", "="};
  574. for(int i = 0; i < symbol.length; i++){
  575. String producBatch = null;
  576. if(symbol[i].equals("=")){
  577. producBatch = notice.getProducBatch();
  578. }
  579. String storageLocationCode = warehousingMapper.getStorageLocationCode(notice.getAttribute(), symbol[i], producBatch, material.getTldId(), notice.getCompanyNumber()); //查询昨天没满的库位
  580. if(!storageLocationCode.equals("0")) {
  581. int countStorage = warehousingMapper.getCountStorage(notice.getAttribute(), storageLocationCode, symbol[i], producBatch, material.getTldId());
  582. if (countStorage < num) {
  583. stringBuffer.append(storageLocationCode + ",");
  584. List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
  585. map.put("data", list);
  586. map.put("msg", "210");
  587. return map;
  588. }
  589. }
  590. }
  591. //查询产成品库位
  592. List<StorageLocation> storageLocations = storageLocationMapper.getStorage(storageLocation);
  593. for(StorageLocation storageLocation1 : storageLocations) {
  594. Inventory inventory = warehousingMapper.getInventoryInfo(storageLocation1);//查询库存信息
  595. if(inventory == null) {
  596. stringBuffer.append(storageLocation1.getStorageLocationCode() + ",");
  597. break;
  598. }
  599. }
  600. List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
  601. map.put("data", list);
  602. map.put("msg", "210");
  603. } else {
  604. map.put("msg", "220");
  605. // if(warehousingMapper.getInventoryNotice(notice) != 0){
  606. // warehousingMapper.updateInventoryNotice(notice);
  607. // } else {
  608. // warehousingMapper.addInventoryNotice(notice);
  609. // }
  610. // warehousingMapper.updateNotice(notice);//修改报工单数量
  611. // String storageCode = codeGenerateRk();
  612. // //入库流水
  613. // Notice notice1 = warehousingMapper.getNoticeId(notice);
  614. // WarehousingVirtual warehousingVirtual = new WarehousingVirtual()
  615. // .setWllbCode(material.getWllbCode())
  616. // .setUserId(notice.getUserId())
  617. // .setStorageLocationCode(notice.getStorageLocationCode())
  618. // .setProducDate(notice.getProducBatch())
  619. // .setNum(notice.getWarehousingNum())
  620. // .setSerial(notice.getSerial())
  621. // .setSeq(notice.getSeq())
  622. // .setAttribute(notice.getAttribute())
  623. // .setStorageCode(storageCode)
  624. // .setWbs(notice.getWbs())
  625. // .setProductionCode(notice1.getProductionCode());
  626. // warehousingMapper.addHalf(warehousingVirtual);//入库流水 产成品
  627. // //存入给gs的返回数据
  628. // ReturnWarehousing returnWarehousing = new ReturnWarehousing()
  629. // .setStorageCode(storageCode)//入库编号
  630. // .setSourceType(notice1.getSourceType())//来源类型
  631. // .setMoveType(notice1.getMoveType())//移动类型
  632. // .setOrderNumber(notice1.getNoticeId())//通知单id
  633. // .setWbs(notice1.getWbs())//wbs
  634. // .setEntryNumber(notice1.getEntryNumber())//gs分录号
  635. // .setMaterialId(notice1.getMaterialId())//物料id
  636. // .setId(notice1.getId())//分录单id
  637. // .setWarehousingNum(notice.getWarehousingNum());//入库数量
  638. // warehousingMapper.addReturnWarehousing(returnWarehousing);
  639. // map.put("msg", "200");
  640. // map.put("data", notice1.getNoticeId() + ",");
  641. }
  642. }
  643. } catch (Exception e) {
  644. e.printStackTrace();
  645. map.put("msg", "500");
  646. map.put("errMsg", "服务器请求异常,请稍后再试");
  647. }
  648. return map;
  649. }
  650. @Override
  651. public Map<String, Object> getProductWarehousingRecommend(String uniqueCode, String type, String noticeId) {
  652. Map<String, Object> map = new HashMap<>();
  653. try {
  654. //返回采购单id
  655. StringBuilder stringBuilder = new StringBuilder();
  656. //查询入库所需要的信息
  657. for (WarehousingVirtual warehousingVirtual : warehousingMapper.getVirtualNotice(uniqueCode, type, noticeId)) {
  658. //查询物料信息
  659. Notice notice = new Notice().setMaterialCode(warehousingVirtual.getWllbCode());
  660. MaterialClass material = warehousingMapper.getMaterial(notice);
  661. Notice notice1 = warehousingMapper.getNoticeId(new Notice().setNoticeId(noticeId).setMaterialId(material.getTldId()));
  662. Notice notice2 = new Notice()
  663. .setMaterialId(material.getTldId())
  664. .setStorageLocationCode(warehousingVirtual.getStorageLocationCode())
  665. .setNoticeId(noticeId)
  666. .setWarehousingNum(warehousingVirtual.getNum())
  667. .setAttribute(warehousingVirtual.getAttribute())
  668. .setProducBatch(warehousingVirtual.getProducDate())
  669. .setWllbClass(material.getWllbClass())
  670. .setWbs(notice1.getWbs())
  671. .setCompanyNumber(notice1.getCompanyNumber())
  672. .setSupplierId(warehousingVirtual.getSuppId())
  673. .setSerial(warehousingVirtual.getSerial())
  674. .setWllbCode(material.getWllbCode())
  675. .setCompanyNumber(notice1.getCompanyNumber());
  676. Double num = Double.parseDouble(notice1.getWarehousingNum()) + Double.parseDouble(warehousingVirtual.getNum());
  677. if(Double.doubleToLongBits(num) == Double.doubleToLongBits(Double.parseDouble(notice1.getNum()))){
  678. notice2.setType("1");
  679. }
  680. warehousingMapper.addInventoryNotice(notice2);//入库存
  681. warehousingMapper.updateNotice(notice2);//修改报工单数量
  682. //入库流水
  683. String storageCode = codeGenerateRk();
  684. WarehousingVirtual warehousingVirtual1 = new WarehousingVirtual()
  685. .setWllbCode(material.getWllbCode())
  686. .setUserId(warehousingVirtual.getUserId())
  687. .setStorageLocationCode(warehousingVirtual.getStorageLocationCode())
  688. .setProducDate(warehousingVirtual.getProducDate())
  689. .setNum(warehousingVirtual.getNum())
  690. .setSerial(warehousingVirtual.getSerial())
  691. .setSeq(warehousingVirtual.getSeq())
  692. .setAttribute(warehousingVirtual.getAttribute())
  693. .setStorageCode(storageCode)
  694. .setWbs(notice1.getWbs())
  695. .setProductionCode(notice1.getProductionCode())
  696. .setAccountSleeve(warehousingVirtual.getAccountSleeve());
  697. warehousingMapper.addHalf(warehousingVirtual1);//入库流水 产成品
  698. //存入给gs的返回数据
  699. ReturnWarehousing returnWarehousing = new ReturnWarehousing()
  700. .setStorageCode(storageCode)//入库编号
  701. .setSourceType(notice1.getSourceType())//来源类型
  702. .setMoveType(notice1.getMoveType())//移动类型
  703. .setOrderNumber(notice1.getNoticeId())//通知单id
  704. .setWbs(notice1.getWbs())//wbs
  705. .setEntryNumber(notice1.getEntryNumber())//gs分录号
  706. .setMaterialId(notice1.getMaterialId())//物料id
  707. .setId(notice1.getId())//分录单id
  708. .setWarehousingNum(warehousingVirtual.getNum());//入库数量
  709. warehousingMapper.addReturnWarehousing(returnWarehousing);
  710. if (!stringBuilder.toString().contains(notice1.getNoticeId() + ",")) {
  711. stringBuilder.append(notice1.getNoticeId() + ",");
  712. }
  713. warehousingMapper.delVirtual(uniqueCode);//删除临时表数据
  714. }
  715. map.put("msg", "200");
  716. map.put("data", stringBuilder.toString());
  717. } catch (Exception e) {
  718. e.printStackTrace();
  719. map.put("msg", "500");
  720. map.put("errMsg", "服务器请求异常,请稍后再试");
  721. }
  722. return map;
  723. }
  724. @Override
  725. public Map<String, Object> getHalf(Notice notice) {
  726. Map<String, Object> map = new HashMap<>();
  727. try {
  728. PageHelper.startPage(notice.getPage(), notice.getLimit());
  729. PageInfo<Notice> list = new PageInfo<>(warehousingMapper.getHalf(notice));
  730. map.put("data", list);
  731. map.put("msg", "200");
  732. } catch (Exception e) {
  733. e.printStackTrace();
  734. map.put("msg", "500");
  735. map.put("errMsg", "服务器请求异常,请稍后再试");
  736. }
  737. return map;
  738. }
  739. @Override
  740. public void getHalfExcel(Notice notice, HttpServletResponse response) {
  741. try {
  742. //导出数据汇总
  743. List<List<Object>> sheetDataList = new ArrayList<>();
  744. //表头数据
  745. List<Object> head = Arrays.asList("物料名称", "物料编号", "生产批次", "数量", "用户名称", "库位编号", "入库时间", "连番号", "序列号", "属性", "入库单编号", "WBS","真实姓名","生产订单号","公司名称");
  746. //查询数据
  747. List<Map<String, Object>> list = warehousingMapper.getHalfExcel(notice);
  748. sheetDataList.add(head);
  749. for (Map<String, Object> userMap : list) {
  750. List<Object> listSheet = new ArrayList<>();
  751. for (String key : userMap.keySet()) {
  752. listSheet.add(userMap.get(key));
  753. }
  754. sheetDataList.add(listSheet);
  755. }
  756. //当前时间
  757. Date time = new Date();
  758. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMddHHmmss");
  759. ExcelUtils.export(response, "入库流水数据导出" + sdf.format(time), sheetDataList);
  760. } catch (Exception e) {
  761. e.printStackTrace();
  762. }
  763. }
  764. /**
  765. * 删除半成品
  766. *
  767. * @return
  768. */
  769. @Override
  770. @Transactional(rollbackFor = Exception.class)
  771. public Map<String, Object> delInventoryNotice(String id, HttpServletRequest request) {
  772. Map<String, Object> map = new HashMap<>();
  773. try {
  774. String userId = request.getHeader("userId");
  775. Map<String, Object> mapVal = askGoodsMapper.getInventoryNotice(id);
  776. if (mapVal.get("type").toString().equals("1")) {
  777. map.put("msg", "500");
  778. map.put("errMsg", "报工单已报工");
  779. return map;
  780. }
  781. LogData logData = new LogData()
  782. .setUserId(userId)
  783. .setData(mapVal.toString())
  784. .setType("0")
  785. .setDocumentType("报工单");
  786. dictionaryMapper.addLogdata(logData);
  787. askGoodsMapper.delInventoryNotice(id);
  788. map.put("msg", "200");
  789. } catch (Exception e) {
  790. e.printStackTrace();
  791. map.put("msg", "500");
  792. map.put("errMsg", "服务器请求异常,请稍后再试");
  793. }
  794. return map;
  795. }
  796. @Override
  797. public Map<String, Object> otherWarehousing(AskGoods askGoods) {
  798. Map<String, Object> map = new HashMap<>();
  799. try {
  800. //判断物料是否录入
  801. MaterialClass materialClass = warehousingMapper.getMateriaIsExist(askGoods.getWllbCode());
  802. askGoods.setMaterialId(materialClass.getTldId());
  803. //查询库存
  804. List<Inventory> inventory = askGoodsMapper.getInventoryInfoOther(askGoods);
  805. map.put("list", inventory);
  806. map.put("data", materialClass);
  807. map.put("msg", "200");
  808. } catch (Exception e) {
  809. e.printStackTrace();
  810. map.put("msg", "500");
  811. map.put("errMsg", "服务器请求异常,请稍后再试");
  812. }
  813. return map;
  814. }
  815. @Override
  816. public Map<String, Object> otherWarehou(Inventory inventory, HttpServletRequest request) {
  817. Map<String, Object> map = new HashMap<>();
  818. try {
  819. //判断物料是否录入
  820. MaterialClass materialClass = warehousingMapper.getMateriaIsExist(inventory.getWllbCode());
  821. String userId = request.getHeader("userId");
  822. inventory.setWllbClass(materialClass.getWllbClass()).setMaterialId(materialClass.getTldId()).setUserId(userId);
  823. if(inventory.getId() != null){
  824. warehousingMapper.updateInventoryOther(inventory);
  825. } else {
  826. warehousingMapper.addInventoryOther(inventory);
  827. }
  828. List<WarehousingVirtual> list = new LinkedList<>();
  829. String storageCode = codeGenerateRk();//入库单
  830. WarehousingVirtual warehousingVirtual = new WarehousingVirtual()
  831. .setStorageCode(storageCode)
  832. .setWllbCode(materialClass.getCode())
  833. .setSuppId(inventory.getSupplierId())
  834. .setSerial(inventory.getSerial())
  835. .setProducDate(inventory.getProducDate())
  836. .setCapacity(inventory.getNum())
  837. .setType("其他入库")
  838. .setUserId(userId)
  839. .setDepartmentId(inventory.getDepartmentId())
  840. .setStorageLocationCode(inventory.getStorageLocationCode())
  841. .setWbs(inventory.getWbs())
  842. .setAccountSleeve(inventory.getAccountSleeve())
  843. .setMaterialId(materialClass.getTldId())
  844. .setNum(inventory.getAmount())
  845. .setAttribute(inventory.getAttribute());
  846. list.add(warehousingVirtual);
  847. if(materialClass.getPartType().equals("原材料")){
  848. warehousingMapper.addStorage(list);//入库流水
  849. } else if(materialClass.getPartType().equals("半成品")){
  850. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  851. warehousingVirtual.setProducDate(simpleDateFormat.format(new Date()).toString());
  852. warehousingMapper.addProduct(warehousingVirtual);//入库流水 半成品
  853. } else {
  854. warehousingMapper.addHalf(warehousingVirtual);//入库流水 产成品
  855. }
  856. warehousingMapper.addReturnWarehousingOther(warehousingVirtual);//其他入库返回信息
  857. map.put("data", storageCode);
  858. map.put("msg", "200");
  859. } catch (Exception e) {
  860. e.printStackTrace();
  861. map.put("msg", "500");
  862. map.put("errMsg", "服务器请求异常,请稍后再试");
  863. }
  864. return map;
  865. }
  866. @Override
  867. public Map<String, Object> getMing(String code) {
  868. Map<String, Object> map = new HashMap<>();
  869. try {
  870. //查询库存
  871. String wllbCode = askGoodsMapper.getMing(code);
  872. //判断物料是否录入
  873. MaterialClass materialClass = warehousingMapper.getMateriaIsExist(wllbCode);
  874. if(materialClass != null){
  875. if(materialClass.getWllbClass().equals("圆柱终端")){
  876. map.put("msg", "500");
  877. map.put("errMsg", "请扫描托码");
  878. return map;
  879. }
  880. }
  881. map.put("data", materialClass);
  882. map.put("msg", "200");
  883. } catch (Exception e) {
  884. e.printStackTrace();
  885. map.put("msg", "500");
  886. map.put("errMsg", "服务器请求异常,请稍后再试");
  887. }
  888. return map;
  889. }
  890. @Override
  891. public Map<String, Object> addWarehousingVirtualTwo(WarehousingVirtual warehousingVirtual) {
  892. Map<String, Object> map = new HashMap<>();
  893. try{
  894. Map<String, Object> mapVal = warehousingMapper.getSumWarehousingVirtual(warehousingVirtual);
  895. Double num = Double.parseDouble(warehousingVirtual.getNum()) + Double.parseDouble(mapVal.get("scanNum").toString());
  896. if(Double.doubleToLongBits(Double.parseDouble(mapVal.get("num").toString())) < Double.doubleToLongBits(num)){
  897. String surplus = String.valueOf(Double.parseDouble(mapVal.get("num").toString()) - Double.parseDouble(mapVal.get("scanNum").toString()));
  898. map.put("msg", "500");
  899. map.put("errMsg", "扫描数量超过单据数量,剩余要扫数量" + surplus);
  900. return map;
  901. }
  902. warehousingMapper.addWarehousingVirtual(warehousingVirtual);
  903. map.put("msg", "200");
  904. } catch (Exception e){
  905. e.printStackTrace();
  906. map.put("msg", "500");
  907. map.put("errMsg", "服务器请求异常,请稍后再试");
  908. }
  909. return map;
  910. }
  911. @Override
  912. public Map<String, Object> addWarehouseTransferVirtual(WarehousingVirtual warehousingVirtual) {
  913. Map<String, Object> map = new HashMap<>();
  914. try{
  915. Map<String, Object> mapVal = warehousingMapper.getWarehouseTransferVirtual(warehousingVirtual);
  916. Double num = Double.parseDouble(warehousingVirtual.getNum()) + Double.parseDouble(mapVal.get("scanNum").toString());
  917. if(Double.doubleToLongBits(Double.parseDouble(mapVal.get("num").toString())) < Double.doubleToLongBits(num)){
  918. String surplus = String.valueOf(Double.parseDouble(mapVal.get("num").toString()) - Double.parseDouble(mapVal.get("scanNum").toString()));
  919. map.put("msg", "500");
  920. map.put("errMsg", "扫描数量超过单据数量,剩余要扫数量" + surplus);
  921. return map;
  922. }
  923. warehousingMapper.addWarehousingVirtual(warehousingVirtual);
  924. map.put("msg", "200");
  925. } catch (Exception e){
  926. e.printStackTrace();
  927. map.put("msg", "500");
  928. map.put("errMsg", "服务器请求异常,请稍后再试");
  929. }
  930. return map;
  931. }
  932. /**
  933. * 入库单生成
  934. *
  935. * @return
  936. */
  937. public String codeGenerateRk() {
  938. StringBuilder stringBuilder = new StringBuilder("RK");
  939. Date date = new Date();
  940. SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
  941. stringBuilder.append(sdf.format(date));
  942. int count = warehousingMapper.getWarehousingCount();
  943. for (int i = 0; i < 4 - (count + "").length(); i++) {
  944. stringBuilder.append("0");
  945. }
  946. return (stringBuilder.append(count + 1)).toString();
  947. }
  948. /**
  949. * 出库单id
  950. *
  951. * @return
  952. */
  953. public String codeGenerateCk() {
  954. StringBuilder stringBuilder = new StringBuilder("CK");
  955. Date date = new Date();
  956. SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
  957. stringBuilder.append(sdf.format(date));
  958. int count = askGoodsMapper.getReturnRemovalCount();
  959. for (int i = 0; i < 4 - (count + "").length(); i++) {
  960. stringBuilder.append("0");
  961. }
  962. return (stringBuilder.append(count + 1)).toString();
  963. }
  964. }