ColOdrService.java 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. package com.oqpo.api.service.inoutmng;
  2. import com.oqpo.api.entity.inoutmng.*;
  3. import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
  4. import com.oqpo.api.entity.oper.FileEntity;
  5. import com.oqpo.api.entity.oper.UserMngEntity;
  6. import com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity;
  7. import com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity;
  8. import com.oqpo.api.entity.rtnmng.RtnOdrBaseInfoEntity;
  9. import com.oqpo.api.entity.rtnmng.RtnOdrDtlPtclEntity;
  10. import com.oqpo.api.entity.rtnmng.RtnProcInfoPtclEntity;
  11. import com.oqpo.api.entity.stinfo.BrandEntity;
  12. import com.oqpo.api.entity.stinfo.SpplyEntity;
  13. import com.oqpo.api.entity.stinfo.StoreBaseInfoEntity;
  14. import com.oqpo.api.entity.stockmng.StckMgntBaseInfoEntity;
  15. import com.oqpo.api.entity.stockmng.StckMgntDtlHistEntity;
  16. import com.oqpo.api.entity.stockmng.WhsProcInfoPtclEntity;
  17. import com.oqpo.api.enums.ChgDvsn;
  18. import com.oqpo.api.enums.InOutCd;
  19. import com.oqpo.api.enums.SystemMessageCode;
  20. import com.oqpo.api.exception.GlobalException;
  21. import com.oqpo.api.mapper.FileMapper;
  22. import com.oqpo.api.mapper.inoutmng.ColOdrMapper;
  23. import com.oqpo.api.mapper.inoutmng.ShmtOdrMapper;
  24. import com.oqpo.api.mapper.loanmng.LoanStateMapper;
  25. import com.oqpo.api.mapper.oper.UserMngMapper;
  26. import com.oqpo.api.mapper.pomng.PchOrdMapper;
  27. import com.oqpo.api.mapper.rtnmng.RtnOdrMapper;
  28. import com.oqpo.api.mapper.stinfo.BrandMapper;
  29. import com.oqpo.api.mapper.stinfo.StoreBaseInfoMapper;
  30. import com.oqpo.api.mapper.stinfo.SupplyMapper;
  31. import com.oqpo.api.mapper.stockmng.StockMngMapper;
  32. import com.oqpo.api.service.CommonService;
  33. import com.oqpo.api.service.pomng.PchOrdService;
  34. import com.oqpo.api.service.rtnmng.RtnOdrService;
  35. import com.oqpo.api.web.dto.request.GridRequest;
  36. import com.oqpo.api.web.dto.request.inoutmng.*;
  37. import com.oqpo.api.web.dto.response.GridResponse;
  38. import com.oqpo.api.web.dto.response.inoutmng.*;
  39. import lombok.extern.slf4j.Slf4j;
  40. import org.springframework.beans.factory.annotation.Autowired;
  41. import org.springframework.stereotype.Service;
  42. import org.springframework.transaction.annotation.Transactional;
  43. import java.util.ArrayList;
  44. import java.util.List;
  45. import java.util.stream.Collectors;
  46. @Service
  47. @Slf4j
  48. public class ColOdrService extends CommonService {
  49. @Autowired
  50. private ColOdrMapper colOdrMapper;
  51. @Autowired
  52. private RtnOdrMapper rtnOdrMapper;
  53. @Autowired
  54. private RtnOdrService rtnOdrService;
  55. @Autowired
  56. private BrandMapper brandMapper;
  57. @Autowired
  58. private SupplyMapper supplyMapper;
  59. @Autowired
  60. private StoreBaseInfoMapper storeBaseInfoMapper;
  61. @Autowired
  62. private FileMapper fileMapper;
  63. @Autowired
  64. private UserMngMapper userMngMapper;
  65. /*
  66. 수거 대상 그리드 리스트 조회
  67. */
  68. public GridResponse selectColTargetOdrGridList(String sBrandId, String fromDt, String toDt, String sWhsId, String sRtnWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
  69. int gridPage = gridRequest.getGridPage();
  70. int gridSize = gridRequest.getGridSize();
  71. fromDt = fromDt == null ? null : fromDt.replace(".", "");
  72. toDt = toDt == null ? null : toDt.replace(".", "");
  73. int gridRecords = colOdrMapper.selectColTargetRtnGridCnt(sBrandId, fromDt, toDt, sWhsId, sRtnWhsId, sItemNm);
  74. int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
  75. List<RtnOdrBaseInfoEntity> entities = colOdrMapper.selectColTargetRtnGridList(sBrandId, fromDt, toDt, sWhsId,sRtnWhsId, sItemNm, gridRequest);
  76. List<Object> gridRows = entities.stream()
  77. .map(m -> ColTragetOdrSearchListResponse.builder()
  78. .viewCd("R")
  79. .brandId(m.getBrandId() == null ? "" : m.getBrandId())
  80. .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
  81. .rtnPodrUnqNo(m.getRtnPodrUnqNo() == null ? "" : m.getRtnPodrUnqNo())
  82. .rtnPodrDtlNo(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getRtnPodrDtlNo() == null ? "" : m.getRtnOdrDtlInfo().getRtnPodrDtlNo())
  83. .rtnReqUnqNo(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqUnqNo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqUnqNo())
  84. .rtnReqDtlNo(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqDtlNo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqDtlNo())
  85. .itemId(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getItemId() == null ? "" : m.getRtnOdrDtlInfo().getItemId())
  86. .itemNm(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getItemNm() == null ? "" : m.getRtnOdrDtlInfo().getItemNm())
  87. .rtnWhsId(m.getRtnWhsId() == null ? "" : m.getRtnWhsId())
  88. .rtnLocation(m.getRtnLocation() == null ? "" : m.getRtnLocation())
  89. .rntWhsNm(m.getRtnWhsNm() == null ? "" : m.getRtnWhsNm() + " - " + m.getRtnLocationNm())
  90. .whsId(m.getWhsId() == null ? "" : m.getWhsId())
  91. .location(m.getLocation() == null ? "" : m.getLocation())
  92. .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm() + " - " + m.getLocationNm())
  93. .unitAmt(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getUnitAmt() == null ? 0 : m.getRtnOdrDtlInfo().getUnitAmt())
  94. .rtnReqQty(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getRtnReqQty() == null ? 0 : m.getRtnOdrDtlInfo().getRtnReqQty())
  95. .rtnOdrQty(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrQty() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrQty())
  96. .rtnAmt(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getRtnAmt() == null ? 0 : m.getRtnOdrDtlInfo().getRtnAmt())
  97. .colReqDt(m.getColReqDt() == null ? "" : m.getColReqDt())
  98. .storeId(m.getStoreId() == null ? "" : m.getStoreId())
  99. .build())
  100. .collect(Collectors.toList());
  101. return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
  102. }
  103. /*
  104. 수거지시 초기 그리드 리스트 조회
  105. */
  106. public GridResponse selectColInstOdrGridList(String sBrandId, InstInitColOdrRequest instInitColOdrRequest, GridRequest gridRequest) throws Exception {
  107. int gridPage = gridRequest.getGridPage();
  108. int gridSize = gridRequest.getGridSize();
  109. List<RtnOdrBaseInfoEntity> entities = colOdrMapper.selectColInstRtnGridList(sBrandId,instInitColOdrRequest.toCodeEntities(instInitColOdrRequest.getGridUpdateData()), gridRequest);
  110. int gridRecords = entities.size();
  111. int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
  112. List<Object> gridRows = entities.stream()
  113. .map(m -> ColInstInitOdrSearchListResponse.builder()
  114. .viewCd("R")
  115. .brandId(m.getBrandId() == null ? "" : m.getBrandId())
  116. .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
  117. .rtnPodrUnqNo(m.getRtnPodrUnqNo() == null ? "" : m.getRtnPodrUnqNo())
  118. .rtnPodrDtlNo(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getRtnPodrDtlNo() == null ? "" : m.getRtnOdrDtlInfo().getRtnPodrDtlNo())
  119. .rtnReqUnqNo(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqUnqNo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqUnqNo())
  120. .rtnReqDtlNo(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqDtlNo() == null ? "" : m.getRtnOdrDtlInfo().getRtnReqDtlNo())
  121. .itemId(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getItemId() == null ? "" : m.getRtnOdrDtlInfo().getItemId())
  122. .itemNm(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getItemNm() == null ? "" : m.getRtnOdrDtlInfo().getItemNm())
  123. .rtnWhsId(m.getRtnWhsId() == null ? "" : m.getRtnWhsId())
  124. .rtnLocation(m.getRtnLocation() == null ? "" : m.getRtnLocation())
  125. .rntWhsNm(m.getRtnWhsNm() == null ? "" : m.getRtnWhsNm() + " - " + m.getRtnLocationNm())
  126. .whsId(m.getWhsId() == null ? "" : m.getWhsId())
  127. .location(m.getLocation() == null ? "" : m.getLocation())
  128. .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm() + " - " + m.getLocationNm())
  129. .unitAmt(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getUnitAmt() == null ? 0 : m.getRtnOdrDtlInfo().getUnitAmt())
  130. .colQty(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getColQty() == null ? 0 : m.getRtnOdrDtlInfo().getColQty())
  131. .rtnOdrQty(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrQty() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrQty())
  132. .rtnAmt(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getRtnAmt() == null ? 0 : m.getRtnOdrDtlInfo().getRtnAmt())
  133. .colReqDt(m.getColReqDt() == null ? "" : m.getColReqDt())
  134. .storeId(m.getStoreId() == null ? "" : m.getStoreId())
  135. .build())
  136. .collect(Collectors.toList());
  137. return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
  138. }
  139. /*
  140. 수거지시 저장
  141. */
  142. @Transactional
  143. public void instColOdr(String userId, InstColOdrRequest instColOdrRequest) throws Exception {
  144. try {
  145. List<RtnOdrDtlPtclEntity> gridInsertData = instColOdrRequest.toCodeEntities(instColOdrRequest.getGridInsertData());
  146. List<RtnOdrBaseInfoEntity> jobList = colOdrMapper.selectPickJobDataList(instColOdrRequest.getBrandId(), gridInsertData);
  147. String whsId = "";
  148. String location = "";
  149. String rtnWhsId = "";
  150. String rtnLocation = "";
  151. int itemQty = 0;
  152. long colTotalAmt = 0;
  153. int colQty = 0;
  154. String colCmdUnqNo = "";
  155. String colPickUnqNo = "";
  156. ColOdrBaseEntity colOdrBaseEntity = new ColOdrBaseEntity();
  157. List<ColOdrDtlPtclEntity> colDtlList = new ArrayList<ColOdrDtlPtclEntity>();
  158. PickInfoMgntEntity pickInfoMgntEntity = new PickInfoMgntEntity();
  159. List<PickDtlPtclEntity> pickDtlList = new ArrayList<PickDtlPtclEntity>();
  160. for (int i = 0; i < jobList.size(); i++) {
  161. RtnOdrBaseInfoEntity entity = jobList.get(i);
  162. for (int j = 0; j < gridInsertData.size(); j++) {
  163. RtnOdrDtlPtclEntity reqEntity = gridInsertData.get(j);
  164. if (entity.getRtnPodrUnqNo().equals(reqEntity.getRtnPodrUnqNo()) && entity.getRtnOdrDtlInfo().getRtnPodrDtlNo().equals(reqEntity.getRtnPodrDtlNo())) {
  165. if (reqEntity.getColQty() > entity.getRtnOdrDtlInfo().getRtnOdrQty()) {
  166. // 반품발주수량보다 수거수량이 많을수 없습니다.
  167. throw new GlobalException(SystemMessageCode.ERR_POPICKQTY);
  168. }
  169. colQty = reqEntity.getColQty();
  170. break;
  171. }
  172. }
  173. if (rtnWhsId.equals(entity.getRtnWhsId()) && rtnLocation.equals(entity.getRtnLocation()) && whsId.equals(entity.getWhsId()) && location.equals(entity.getLocation())) {
  174. // 추가 작업
  175. itemQty = itemQty + 1;
  176. colTotalAmt = colTotalAmt + (entity.getRtnOdrDtlInfo().getUnitAmt() * colQty);
  177. colOdrBaseEntity.setItemQty(itemQty);
  178. colOdrBaseEntity.setColTotalAmt(colTotalAmt);
  179. pickInfoMgntEntity.setColTotAmt(colTotalAmt);
  180. //수거서 상세 정보
  181. int dtlNo = itemQty * 10;
  182. ColOdrDtlPtclEntity colDtlEntity = new ColOdrDtlPtclEntity();
  183. colDtlEntity.setColCmdUnqNo(colCmdUnqNo);
  184. colDtlEntity.setColCmdDtlNo(Integer.toString(dtlNo));
  185. colDtlEntity.setItemId(entity.getRtnOdrDtlInfo().getItemId());
  186. colDtlEntity.setItemNm(entity.getRtnOdrDtlInfo().getItemNm());
  187. colDtlEntity.setUnitAmt(entity.getRtnOdrDtlInfo().getUnitAmt());
  188. colDtlEntity.setColQty(colQty);
  189. colDtlEntity.setColAmt(colQty * entity.getRtnOdrDtlInfo().getUnitAmt());
  190. colDtlEntity.setRtnQty(entity.getRtnOdrDtlInfo().getRtnOdrQty());
  191. colDtlEntity.setRtnAmt(entity.getRtnOdrDtlInfo().getRtnOdrAmt());
  192. colDtlEntity.setRtnRsnDvsn(entity.getRtnOdrDtlInfo().getRtnRsnDvsn());
  193. colDtlEntity.setRtnRsn(entity.getRtnOdrDtlInfo().getRtnRsn());
  194. colDtlEntity.setRtnPodrUnqNo(entity.getRtnPodrUnqNo());
  195. colDtlEntity.setRtnPodrDtlNo(entity.getRtnOdrDtlInfo().getRtnPodrDtlNo());
  196. colDtlEntity.setRtnReqUnqNo(entity.getRtnOdrDtlInfo().getRtnReqUnqNo());
  197. colDtlEntity.setRtnReqDtlNo(entity.getRtnOdrDtlInfo().getRtnReqDtlNo());
  198. colDtlList.add(colDtlEntity);
  199. PickDtlPtclEntity pickDtlEntity = new PickDtlPtclEntity();
  200. pickDtlEntity.setColPickUnqNo(colPickUnqNo);
  201. pickDtlEntity.setColPickDtlNo(Integer.toString(dtlNo));
  202. pickDtlEntity.setRtnPodrUnqNo(entity.getRtnPodrUnqNo());
  203. pickDtlEntity.setRtnPodrDtlNo(entity.getRtnOdrDtlInfo().getRtnPodrDtlNo());
  204. pickDtlEntity.setRtnReqUnqNo(entity.getRtnOdrDtlInfo().getRtnReqUnqNo());
  205. pickDtlEntity.setRtnReqDtlNo(entity.getRtnOdrDtlInfo().getRtnReqDtlNo());
  206. pickDtlEntity.setColCmdUnqNo(colCmdUnqNo);
  207. pickDtlEntity.setColCmdDtlNo(Integer.toString(dtlNo));
  208. pickDtlEntity.setItemId(entity.getRtnOdrDtlInfo().getItemId());
  209. pickDtlEntity.setItemNm(entity.getRtnOdrDtlInfo().getItemNm());
  210. pickDtlEntity.setUnit(entity.getRtnOdrDtlInfo().getUnit());
  211. pickDtlEntity.setUnitAmt(entity.getRtnOdrDtlInfo().getUnitAmt());
  212. pickDtlEntity.setRodrQty(entity.getRtnOdrDtlInfo().getRtnOdrQty());
  213. pickDtlEntity.setColReqQty(colQty);
  214. pickDtlEntity.setColReqAmt(colQty * entity.getRtnOdrDtlInfo().getUnitAmt());
  215. pickDtlList.add(pickDtlEntity);
  216. } else {
  217. // 신규로 출하건 생성함 //select fn_get_dealno(16, '') as col_cmd_unq_no
  218. if (colDtlList.size() > 0) {
  219. colOdrMapper.insertColOdrBase(userId,colOdrBaseEntity);
  220. colOdrMapper.insertColOdrDtl(userId,colDtlList);
  221. colOdrMapper.insertPickMgntBase(userId,pickInfoMgntEntity);
  222. colOdrMapper.insertPickDtlPtcl(userId,pickDtlList);
  223. itemQty = 0;
  224. colTotalAmt = 0;
  225. }
  226. itemQty = 1;
  227. colTotalAmt = entity.getRtnOdrDtlInfo().getUnitAmt() * colQty;
  228. whsId = entity.getWhsId();
  229. location = entity.getLocation();
  230. rtnWhsId = entity.getRtnWhsId();
  231. rtnLocation = entity.getRtnLocation();
  232. colCmdUnqNo = fnGetDealNo(20, ""); // 출하지시번호
  233. colPickUnqNo = fnGetDealNo(15, ""); // 납품서번호
  234. // 수거지시
  235. colOdrBaseEntity = new ColOdrBaseEntity();
  236. colDtlList = new ArrayList<ColOdrDtlPtclEntity>();
  237. ColOdrDtlPtclEntity colDtlEntity = new ColOdrDtlPtclEntity();
  238. //납품서정보
  239. pickInfoMgntEntity= new PickInfoMgntEntity();
  240. pickDtlList = new ArrayList<PickDtlPtclEntity>();
  241. PickDtlPtclEntity pickDtlEntity = new PickDtlPtclEntity();
  242. colOdrBaseEntity.setColCmdUnqNo(colCmdUnqNo);
  243. colOdrBaseEntity.setBrandId(entity.getBrandId());
  244. colOdrBaseEntity.setWhsId(entity.getWhsId());
  245. colOdrBaseEntity.setLocation(entity.getLocation());
  246. colOdrBaseEntity.setStoreId(entity.getStoreId());
  247. colOdrBaseEntity.setColPickUnqNo(colPickUnqNo);
  248. colOdrBaseEntity.setItemQty(itemQty);
  249. colOdrBaseEntity.setColTotalAmt(colTotalAmt);
  250. colOdrBaseEntity.setColReqDt(instColOdrRequest.getColSchDt().replaceAll("\\.",""));
  251. colOdrBaseEntity.setColDvsn(entity.getColDvsn());
  252. colOdrBaseEntity.setColCmdStCd("COL1");
  253. colOdrBaseEntity.setColReqMgrNm(entity.getRtnMgrNm());
  254. colOdrBaseEntity.setColReqMgrId(entity.getRtnMgrId());
  255. colOdrBaseEntity.setColDt(null);
  256. colOdrBaseEntity.setColCnfmNm(null);
  257. colOdrBaseEntity.setColCnfmId(null);
  258. colOdrBaseEntity.setColMgrNm(instColOdrRequest.getPickMgrNm());
  259. colOdrBaseEntity.setColMgrTelNo(instColOdrRequest.getPickMgrTelNo().replaceAll("-",""));
  260. colOdrBaseEntity.setColMgrEmal(null);
  261. colOdrBaseEntity.setColMgrMblNo(null);
  262. colOdrBaseEntity.setRtnWhsId(entity.getRtnWhsId());
  263. colOdrBaseEntity.setRtnLocation(entity.getRtnLocation());
  264. colOdrBaseEntity.setSpplyId(entity.getSpplyId());
  265. colOdrBaseEntity.setSpplyNm(entity.getSpplyNm());
  266. colDtlEntity.setColCmdUnqNo(colCmdUnqNo);
  267. colDtlEntity.setColCmdDtlNo("10");
  268. colDtlEntity.setItemId(entity.getRtnOdrDtlInfo().getItemId());
  269. colDtlEntity.setItemNm(entity.getRtnOdrDtlInfo().getItemNm());
  270. colDtlEntity.setUnitAmt(entity.getRtnOdrDtlInfo().getUnitAmt());
  271. colDtlEntity.setColQty(colQty);
  272. colDtlEntity.setColAmt(colQty * entity.getRtnOdrDtlInfo().getUnitAmt());
  273. colDtlEntity.setRtnQty(entity.getRtnOdrDtlInfo().getRtnOdrQty());
  274. colDtlEntity.setRtnAmt(entity.getRtnOdrDtlInfo().getRtnOdrAmt());
  275. colDtlEntity.setRtnRsnDvsn(entity.getRtnOdrDtlInfo().getRtnRsnDvsn());
  276. colDtlEntity.setRtnRsn(entity.getRtnOdrDtlInfo().getRtnRsn());
  277. colDtlEntity.setRtnPodrUnqNo(entity.getRtnPodrUnqNo());
  278. colDtlEntity.setRtnPodrDtlNo(entity.getRtnOdrDtlInfo().getRtnPodrDtlNo());
  279. colDtlEntity.setRtnReqUnqNo(entity.getRtnOdrDtlInfo().getRtnReqUnqNo());
  280. colDtlEntity.setRtnReqDtlNo(entity.getRtnOdrDtlInfo().getRtnReqDtlNo());
  281. colDtlList.add(colDtlEntity);
  282. pickInfoMgntEntity.setColPickUnqNo(colPickUnqNo);
  283. pickInfoMgntEntity.setSpplyId(entity.getSpplyId());
  284. pickInfoMgntEntity.setSpplyNm(entity.getSpplyNm());
  285. pickInfoMgntEntity.setStoreId(entity.getStoreId());
  286. pickInfoMgntEntity.setColTotAmt(colTotalAmt);
  287. pickInfoMgntEntity.setColDvsn(entity.getColDvsn());
  288. pickInfoMgntEntity.setPickMgrNm(instColOdrRequest.getPickMgrNm());
  289. pickInfoMgntEntity.setPickMgrTelNo(instColOdrRequest.getPickMgrTelNo().replaceAll("-",""));
  290. pickInfoMgntEntity.setPndrTelNo(entity.getPickTelNo().replaceAll("-",""));
  291. pickInfoMgntEntity.setPickStCd("PICK0");
  292. pickInfoMgntEntity.setColReqDt(instColOdrRequest.getColSchDt().replaceAll("\\.",""));
  293. pickInfoMgntEntity.setColSchDt(instColOdrRequest.getColSchDt().replaceAll("\\.",""));
  294. pickInfoMgntEntity.setColCmpltDt(null);
  295. pickInfoMgntEntity.setWhsId(entity.getRtnWhsId());
  296. pickInfoMgntEntity.setLocation(entity.getRtnLocation());
  297. //pickInfoMgntEntity.setColDvsn(entity.getColDvsn());
  298. pickInfoMgntEntity.setWhsDvsn(entity.getColDvsn() == "C001" ? "W02" : "W01"); // 본사엣 수거면 매장,,, 공급사에서 수거면 본사
  299. pickInfoMgntEntity.setBrandId(entity.getBrandId());
  300. pickInfoMgntEntity.setColDesc(null);
  301. pickDtlEntity.setColPickUnqNo(colPickUnqNo);
  302. pickDtlEntity.setColPickDtlNo("10");
  303. pickDtlEntity.setRtnPodrUnqNo(entity.getRtnPodrUnqNo());
  304. pickDtlEntity.setRtnPodrDtlNo(entity.getRtnOdrDtlInfo().getRtnPodrDtlNo());
  305. pickDtlEntity.setRtnReqUnqNo(entity.getRtnOdrDtlInfo().getRtnReqUnqNo());
  306. pickDtlEntity.setRtnReqDtlNo(entity.getRtnOdrDtlInfo().getRtnReqDtlNo());
  307. pickDtlEntity.setColCmdUnqNo(colCmdUnqNo);
  308. pickDtlEntity.setColCmdDtlNo("10");
  309. pickDtlEntity.setItemId(entity.getRtnOdrDtlInfo().getItemId());
  310. pickDtlEntity.setItemNm(entity.getRtnOdrDtlInfo().getItemNm());
  311. pickDtlEntity.setUnit(entity.getRtnOdrDtlInfo().getUnit());
  312. pickDtlEntity.setUnitAmt(entity.getRtnOdrDtlInfo().getUnitAmt());
  313. pickDtlEntity.setRodrQty(entity.getRtnOdrDtlInfo().getRtnOdrQty());
  314. pickDtlEntity.setColReqQty(colQty);
  315. pickDtlEntity.setColReqAmt(colQty * entity.getRtnOdrDtlInfo().getUnitAmt());
  316. pickDtlList.add(pickDtlEntity);
  317. }
  318. // 마지막 부분일 경우
  319. if (i == jobList.size() - 1) {
  320. if (colDtlList.size() > 0) {
  321. colOdrMapper.insertColOdrBase(userId,colOdrBaseEntity);
  322. colOdrMapper.insertColOdrDtl(userId,colDtlList);
  323. colOdrMapper.insertPickMgntBase(userId,pickInfoMgntEntity);
  324. colOdrMapper.insertPickDtlPtcl(userId,pickDtlList);
  325. }
  326. }
  327. // 수거상태 변경처리
  328. // 1. 수거상세정보 상태 없데이트 한후 pchOrdMapper
  329. for (int poi = 0; poi < gridInsertData.size(); poi++) {
  330. gridInsertData.get(poi).setRodrDtlStCd("ROD3");
  331. }
  332. rtnOdrMapper.updateChangeMultiRodrDtlStCd(userId, gridInsertData);
  333. // 반품발주 헤더 상태 처리 updateChgMultiPodrStCd
  334. String rtnPodrUnqNo = "";
  335. for (int k = 0; k < gridInsertData.size(); k++) {
  336. if (!rtnPodrUnqNo.equals(gridInsertData.get(k).getRtnPodrUnqNo())) {
  337. rtnPodrUnqNo = gridInsertData.get(k).getRtnPodrUnqNo();
  338. String rtnOdrStCd = rtnOdrService.selectRtnOdrDtlStatusList(rtnPodrUnqNo);
  339. rtnOdrMapper.updateChgRodrStCd(userId, rtnPodrUnqNo, rtnOdrStCd);
  340. }
  341. }
  342. }
  343. } catch (GlobalException e) {
  344. //e.getStackTrace();
  345. e.printStackTrace();
  346. throw new GlobalException(e.getSystemMessageCode());
  347. } catch (Exception e) {
  348. e.printStackTrace();
  349. throw new RuntimeException();
  350. }
  351. }
  352. /* 수거현황 */
  353. public GridResponse selectColSearchGridList(String sBrandId, String fromDt, String toDt, String sColDvsn, String sWhsId, String sRtnWhsId, String sColCmdDtlStCd, String sItemNm, GridRequest gridRequest) throws Exception {
  354. int gridPage = gridRequest.getGridPage();
  355. int gridSize = gridRequest.getGridSize();
  356. fromDt = fromDt == null ? null : fromDt.replace(".", "");
  357. toDt = toDt == null ? null : toDt.replace(".", "");
  358. int gridRecords = colOdrMapper.selectColGridCnt(sBrandId, fromDt, toDt, sColDvsn, sWhsId, sRtnWhsId, sColCmdDtlStCd, sItemNm);
  359. int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
  360. List<ColOdrBaseEntity> entities = colOdrMapper.selectColGridList(sBrandId, fromDt, toDt, sColDvsn, sWhsId, sRtnWhsId, sColCmdDtlStCd, sItemNm, gridRequest);
  361. List<Object> gridRows = entities.stream()
  362. .map(m -> ColSearchListResponse.builder()
  363. .viewCd("R")
  364. .brandId(m.getBrandId() == null ? "" : m.getBrandId())
  365. .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
  366. .colCmdUnqNo(m.getColCmdUnqNo() == null ? "" : m.getColCmdUnqNo())
  367. .colCmdDtlNo(m.getColDtlInfo() == null ? "" : m.getColDtlInfo().getColCmdDtlNo() == null ? "" : m.getColDtlInfo().getColCmdDtlNo())
  368. .rtnPodrUnqNo(m.getColDtlInfo() == null ? "" : m.getColDtlInfo().getRtnPodrUnqNo() == null ? "" : m.getColDtlInfo().getRtnPodrUnqNo())
  369. .rtnPodrDtlNo(m.getColDtlInfo() == null ? "" : m.getColDtlInfo().getRtnPodrDtlNo() == null ? "" : m.getColDtlInfo().getRtnPodrDtlNo())
  370. .colCmdDtlStCd(m.getColDtlInfo() == null ? "" : m.getColDtlInfo().getColCmdDtlStCd() == null ? "" : m.getColDtlInfo().getColCmdDtlStCd())
  371. .colCmdDtlStNm(m.getColDtlInfo() == null ? "" : m.getColDtlInfo().getColCmdDtlStNm() == null ? "" : m.getColDtlInfo().getColCmdDtlStNm())
  372. .itemId(m.getColDtlInfo() == null ? "" : m.getColDtlInfo().getItemId() == null ? "" : m.getColDtlInfo().getItemId())
  373. .itemNm(m.getColDtlInfo() == null ? "" : m.getColDtlInfo().getItemNm() == null ? "" : m.getColDtlInfo().getItemNm())
  374. .rtnWhsId(m.getRtnWhsId() == null ? "" : m.getRtnWhsId())
  375. .rtnLocation(m.getRtnLocation() == null ? "" : m.getRtnLocation())
  376. .rtnWhsNm(m.getRtnWhsNm() == null ? "" : m.getRtnWhsNm())
  377. .colDvsn(m.getColDvsn() == null ? "" : m.getColDvsn())
  378. .colDvsnNm(m.getColDvsnNm() == null ? "" : m.getColDvsnNm())
  379. .whsId(m.getWhsId() == null ? "" : m.getWhsId())
  380. .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm())
  381. .rtnQty(m.getColDtlInfo() == null ? 0 : m.getColDtlInfo().getRtnQty() == null ? 0 : m.getColDtlInfo().getRtnQty())
  382. .colQty(m.getColDtlInfo() == null ? 0 : m.getColDtlInfo().getColQty() == null ? 0 : m.getColDtlInfo().getColQty())
  383. .colAmt(m.getColDtlInfo() == null ? 0 : m.getColDtlInfo().getColAmt() == null ? 0 : m.getColDtlInfo().getColAmt())
  384. .colDt(m.getColDt() == null ? "" : m.getColDt())
  385. .colCnfmNm(m.getColCnfmNm() == null ? "" : m.getColCnfmNm())
  386. .colPickUnqNo(m.getColPickUnqNo() == null ? "" : m.getColPickUnqNo())
  387. .build())
  388. .collect(Collectors.toList());
  389. return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
  390. }
  391. /* 수거서 정보 */
  392. public ColInfoResponse selectPickInfo(String brandId, String colPickUnqNo) throws Exception {
  393. PickInfoMgntEntity entity = colOdrMapper.selectPickInfo(brandId, colPickUnqNo);
  394. List<PickDtlPtclEntity> dtlEntity = colOdrMapper.selectPickDtlPtcl(brandId, colPickUnqNo);
  395. // 공급사
  396. // 수거처 정보
  397. BrandEntity brandEntity = brandMapper.selectBrandInfo(brandId);
  398. if ("C001".equals(entity.getColDvsn())) { // 본사수거
  399. //브랜드정보 수거
  400. entity.setColBsnsRegno(brandEntity.getBsnsRegNo());
  401. entity.setColNm(brandEntity.getBrandNm());
  402. entity.setColOwnerNm(brandEntity.getOwnerNm());
  403. entity.setColAddr(brandEntity.getAddr1() + " " + brandEntity.getAddr2());
  404. } else {
  405. //공급사 수거
  406. SpplyEntity dlv_spplyEntity = supplyMapper.selectSpplyInfo(brandId, entity.getSpplyId());
  407. entity.setColBsnsRegno(dlv_spplyEntity.getBsnsRegNo());
  408. entity.setColNm(dlv_spplyEntity.getSpplyNm());
  409. entity.setColOwnerNm(dlv_spplyEntity.getOwnerNm());
  410. entity.setColAddr(dlv_spplyEntity.getAddr1() + " " + dlv_spplyEntity.getAddr2());
  411. }
  412. //반품처 정보 -- 수거장소가 매장
  413. if ("W01".equals(entity.getWhsDvsn())) {
  414. //납품창고 본사
  415. entity.setRtnBsnsRegno(brandEntity.getBsnsRegNo());
  416. entity.setRtnNm(brandEntity.getBrandNm());
  417. entity.setRtnOwnerNm(brandEntity.getOwnerNm());
  418. entity.setRtnAddr(brandEntity.getAddr1() + " " + brandEntity.getAddr2());
  419. } else {
  420. //납품창고 매장
  421. StoreBaseInfoEntity whs_storeBaseInfoEntity = storeBaseInfoMapper.selectStoreInfo(brandId, entity.getStoreId());
  422. entity.setRtnBsnsRegno(whs_storeBaseInfoEntity.getBsnsRegNo());
  423. entity.setRtnNm(whs_storeBaseInfoEntity.getStoreNm());
  424. entity.setRtnOwnerNm(whs_storeBaseInfoEntity.getOwnerNm());
  425. entity.setRtnAddr(whs_storeBaseInfoEntity.getAddr1() + " " + whs_storeBaseInfoEntity.getAddr2());
  426. }
  427. // 브랜드 로고 brand_logo_file_no
  428. List<FileEntity> logFileList = null;
  429. if (!"".equals(brandEntity.getBrandLogoFileNo())) {
  430. logFileList = fileMapper.selectFileList(brandEntity.getBrandLogoFileNo());
  431. } else {
  432. logFileList = new ArrayList<FileEntity>();
  433. }
  434. return ColInfoResponse.toDTO(entity, dtlEntity, logFileList);
  435. }
  436. /*
  437. 공급사 수거대상 그리드 리스트 조회
  438. */
  439. public GridResponse selectSpplyTargetRtnGridList(String sBrandId, String fromDt, String toDt, String sSpplyId, String sRtnWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
  440. int gridPage = gridRequest.getGridPage();
  441. int gridSize = gridRequest.getGridSize();
  442. fromDt = fromDt == null ? null : fromDt.replace(".", "");
  443. toDt = toDt == null ? null : toDt.replace(".", "");
  444. int gridRecords = colOdrMapper.selectColSpplyTargetRtnGridCnt(sBrandId,fromDt, toDt,sSpplyId, sRtnWhsId, sItemNm);
  445. int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
  446. List<RtnOdrBaseInfoEntity> entities = colOdrMapper.selectColSpplyTargetRtnGridList(sBrandId,fromDt, toDt,sSpplyId, sRtnWhsId, sItemNm, gridRequest);
  447. List<Object> gridRows = entities.stream()
  448. .map(m -> SpplyTargerRtnSearchListResponse.builder()
  449. .viewCd("R")
  450. .brandId(m.getBrandId() == null ? "" : m.getBrandId())
  451. .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
  452. .rtnPodrUnqNo(m.getRtnPodrUnqNo() == null ? "" : m.getRtnPodrUnqNo())
  453. .rtnPodrDtlNo(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getRtnPodrDtlNo() == null ? "" : m.getRtnOdrDtlInfo().getRtnPodrDtlNo())
  454. .itemId(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getItemId() == null ? "" : m.getRtnOdrDtlInfo().getItemId())
  455. .itemNm(m.getRtnOdrDtlInfo() == null ? "" : m.getRtnOdrDtlInfo().getItemNm() == null ? "" : m.getRtnOdrDtlInfo().getItemNm())
  456. .rtnWhsId(m.getRtnWhsId() == null ? "" : m.getRtnWhsId())
  457. .rtnWhsNm(m.getRtnWhsNm() == null ? "" : m.getRtnWhsNm() + " - " + m.getRtnLocationNm())
  458. .rtnLocation(m.getRtnLocation() == null ? "" : m.getRtnLocation())
  459. .unitAmt(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getUnitAmt() == null ? 0 : m.getRtnOdrDtlInfo().getUnitAmt())
  460. .rtnOdrQty(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrQty() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrQty())
  461. .rtnOdrAmt(m.getRtnOdrDtlInfo() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrAmt() == null ? 0 : m.getRtnOdrDtlInfo().getRtnOdrAmt())
  462. .colReqDt(m.getColReqDt() == null ? "" : m.getColReqDt())
  463. .build())
  464. .collect(Collectors.toList());
  465. return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
  466. }
  467. /* 공급사 납품서 생성 초기 정보*/
  468. public SpplyPickInitResponse selectSpplyShmtOdrInfo(String brandId, String spplyId, String rtnPodrUnqNo) throws Exception {
  469. RtnOdrBaseInfoEntity entity = colOdrMapper.selectSpplyColOdrInfo(brandId, spplyId, rtnPodrUnqNo);
  470. List<RtnOdrDtlPtclEntity> dtlEntity = colOdrMapper.selectSpplyColRtnList(rtnPodrUnqNo);
  471. return SpplyPickInitResponse.toDTO(entity, dtlEntity);
  472. }
  473. /* 공급사 수거서 생성 저장 */
  474. @Transactional
  475. public void saveSpplyPick(String userId, SaveSpplyPickRequest saveSpplyPickRequest) throws Exception {
  476. try {
  477. List<RtnOdrDtlPtclEntity> gridInsertData = saveSpplyPickRequest.toCodeEntities(saveSpplyPickRequest.getGridInsertData());
  478. List<RtnOdrBaseInfoEntity> jobList = colOdrMapper.selectPickJobDataList(saveSpplyPickRequest.getBrandId(), gridInsertData);
  479. long colTotalAmt = 0;
  480. int colQty = 0;
  481. String colPickUnqNo = "";
  482. PickInfoMgntEntity pickInfoMgntEntity = new PickInfoMgntEntity();
  483. List<PickDtlPtclEntity> pickDtlList = new ArrayList<PickDtlPtclEntity>();
  484. for (int i = 0; i < jobList.size(); i++) {
  485. RtnOdrBaseInfoEntity entity = jobList.get(i);
  486. for (int j = 0; j < gridInsertData.size(); j++) {
  487. RtnOdrDtlPtclEntity reqEntity = gridInsertData.get(j);
  488. if (entity.getRtnPodrUnqNo().equals(reqEntity.getRtnPodrUnqNo()) && entity.getRtnOdrDtlInfo().getRtnPodrDtlNo().equals(reqEntity.getRtnPodrDtlNo())) {
  489. if (reqEntity.getColQty() > entity.getRtnOdrDtlInfo().getRtnOdrQty()) {
  490. // 반품발주수량보다 수거수량이 많을수 없습니다.
  491. throw new GlobalException(SystemMessageCode.ERR_POPICKQTY);
  492. }
  493. colQty = reqEntity.getColQty();
  494. break;
  495. }
  496. }
  497. colTotalAmt = colTotalAmt + (entity.getRtnOdrDtlInfo().getUnitAmt() * colQty);
  498. if (i == 0 ) {
  499. colPickUnqNo = fnGetDealNo(15, ""); // 수거서번호
  500. pickInfoMgntEntity.setColPickUnqNo(colPickUnqNo);
  501. pickInfoMgntEntity.setSpplyId(entity.getSpplyId());
  502. pickInfoMgntEntity.setSpplyNm(entity.getSpplyNm());
  503. pickInfoMgntEntity.setStoreId(entity.getStoreId());
  504. pickInfoMgntEntity.setPickMgrNm(saveSpplyPickRequest.getPickMgrNm());
  505. pickInfoMgntEntity.setPickMgrTelNo(saveSpplyPickRequest.getPickMgrTelNo().replaceAll("-",""));
  506. pickInfoMgntEntity.setPndrTelNo(entity.getPickTelNo().replaceAll("-",""));
  507. pickInfoMgntEntity.setPickStCd("PICK0");
  508. pickInfoMgntEntity.setColReqDt(saveSpplyPickRequest.getColSchDt().replaceAll("\\.",""));
  509. pickInfoMgntEntity.setColSchDt(saveSpplyPickRequest.getColSchDt().replaceAll("\\.",""));
  510. pickInfoMgntEntity.setColCmpltDt(null);
  511. pickInfoMgntEntity.setWhsId(entity.getRtnWhsId());
  512. pickInfoMgntEntity.setLocation(entity.getRtnLocation());
  513. pickInfoMgntEntity.setColDvsn(entity.getColDvsn());
  514. pickInfoMgntEntity.setWhsDvsn(entity.getColDvsn() == "C001" ? "W02" : "W01"); // 본사엣 수거면 매장,,, 공급사에서 수거면 본사
  515. pickInfoMgntEntity.setBrandId(entity.getBrandId());
  516. pickInfoMgntEntity.setColDesc(null);
  517. PickDtlPtclEntity pickDtlEntity = new PickDtlPtclEntity();
  518. pickDtlEntity.setColPickUnqNo(colPickUnqNo);
  519. pickDtlEntity.setColPickDtlNo("10");
  520. pickDtlEntity.setRtnPodrUnqNo(entity.getRtnPodrUnqNo());
  521. pickDtlEntity.setRtnPodrDtlNo(entity.getRtnOdrDtlInfo().getRtnPodrDtlNo());
  522. pickDtlEntity.setRtnReqUnqNo(entity.getRtnOdrDtlInfo().getRtnReqUnqNo());
  523. pickDtlEntity.setRtnReqDtlNo(entity.getRtnOdrDtlInfo().getRtnReqDtlNo());
  524. pickDtlEntity.setColCmdUnqNo(null);
  525. pickDtlEntity.setColCmdDtlNo(null);
  526. pickDtlEntity.setItemId(entity.getRtnOdrDtlInfo().getItemId());
  527. pickDtlEntity.setItemNm(entity.getRtnOdrDtlInfo().getItemNm());
  528. pickDtlEntity.setUnit(entity.getRtnOdrDtlInfo().getUnit());
  529. pickDtlEntity.setUnitAmt(entity.getRtnOdrDtlInfo().getUnitAmt());
  530. pickDtlEntity.setRodrQty(entity.getRtnOdrDtlInfo().getRtnOdrQty());
  531. pickDtlEntity.setColReqQty(colQty);
  532. colTotalAmt = colQty * entity.getRtnOdrDtlInfo().getUnitAmt();
  533. pickDtlEntity.setColReqAmt(colTotalAmt);
  534. pickDtlList.add(pickDtlEntity);
  535. } else {
  536. int dtlNo = (i + 1) * 10;
  537. PickDtlPtclEntity pickDtlEntity = new PickDtlPtclEntity();
  538. pickDtlEntity.setColPickUnqNo(colPickUnqNo);
  539. pickDtlEntity.setColPickDtlNo(Integer.toString(dtlNo));
  540. pickDtlEntity.setRtnPodrUnqNo(entity.getRtnPodrUnqNo());
  541. pickDtlEntity.setRtnPodrDtlNo(entity.getRtnOdrDtlInfo().getRtnPodrDtlNo());
  542. pickDtlEntity.setRtnReqUnqNo(entity.getRtnOdrDtlInfo().getRtnReqUnqNo());
  543. pickDtlEntity.setRtnReqDtlNo(entity.getRtnOdrDtlInfo().getRtnReqDtlNo());
  544. pickDtlEntity.setColCmdUnqNo(null);
  545. pickDtlEntity.setColCmdDtlNo(null);
  546. pickDtlEntity.setItemId(entity.getRtnOdrDtlInfo().getItemId());
  547. pickDtlEntity.setItemNm(entity.getRtnOdrDtlInfo().getItemNm());
  548. pickDtlEntity.setUnit(entity.getRtnOdrDtlInfo().getUnit());
  549. pickDtlEntity.setUnitAmt(entity.getRtnOdrDtlInfo().getUnitAmt());
  550. pickDtlEntity.setRodrQty(entity.getRtnOdrDtlInfo().getRtnOdrQty());
  551. pickDtlEntity.setColReqQty(colQty);
  552. pickDtlEntity.setColReqAmt(colQty * entity.getRtnOdrDtlInfo().getUnitAmt());
  553. pickDtlList.add(pickDtlEntity);
  554. }
  555. }
  556. pickInfoMgntEntity.setColTotAmt(colTotalAmt);
  557. colOdrMapper.insertPickMgntBase(userId, pickInfoMgntEntity);
  558. colOdrMapper.insertPickDtlPtcl(userId, pickDtlList);
  559. for (int poi = 0; poi < gridInsertData.size(); poi++) {
  560. gridInsertData.get(poi).setRodrDtlStCd("ROD3");
  561. }
  562. rtnOdrMapper.updateChangeMultiRodrDtlStCd(userId, gridInsertData);
  563. // 반품발주 헤더 상태 처리 updateChgMultiPodrStCd
  564. String rtnPodrUnqNo = "";
  565. for (int k = 0; k < gridInsertData.size(); k++) {
  566. if (!rtnPodrUnqNo.equals(gridInsertData.get(k).getRtnPodrUnqNo())) {
  567. rtnPodrUnqNo = gridInsertData.get(k).getRtnPodrUnqNo();
  568. String rtnOdrStCd = rtnOdrService.selectRtnOdrDtlStatusList(rtnPodrUnqNo);
  569. rtnOdrMapper.updateChgRodrStCd(userId, rtnPodrUnqNo, rtnOdrStCd);
  570. }
  571. }
  572. } catch (GlobalException e) {
  573. //e.getStackTrace();
  574. e.printStackTrace();
  575. throw new GlobalException(e.getSystemMessageCode());
  576. } catch (Exception e) {
  577. e.printStackTrace();
  578. throw new RuntimeException();
  579. }
  580. }
  581. /*
  582. 공급사 - 수거서 현황 그리드 리스트 조회
  583. */
  584. public GridResponse selectSpplyPickGridList(String sBrandId, String fromDt, String toDt, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
  585. int gridPage = gridRequest.getGridPage();
  586. int gridSize = gridRequest.getGridSize();
  587. fromDt = fromDt == null ? null : fromDt.replace(".", "");
  588. toDt = toDt == null ? null : toDt.replace(".", "");
  589. int gridRecords = colOdrMapper.selectColSpplyPickGridCnt(sBrandId, fromDt, toDt, sSpplyId, sWhsId, sItemNm);
  590. int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
  591. List<PickInfoMgntEntity> entities = colOdrMapper.selectColSpplyPickGridList(sBrandId, fromDt, toDt, sSpplyId, sWhsId, sItemNm, gridRequest);
  592. List<Object> gridRows = entities.stream()
  593. .map(m -> PickDtlSearchListResponse.builder()
  594. .viewCd("R")
  595. .brandId(m.getBrandId() == null ? "" : m.getBrandId())
  596. .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
  597. .colPickUnqNo(m.getColPickUnqNo() == null ? "" : m.getColPickUnqNo())
  598. .pickStCd(m.getPickStCd() == null ? "" : m.getPickStCd())
  599. .pickStNm(m.getPickStNm() == null ? "" : m.getPickStNm())
  600. .colRegDt(m.getColRegDt() == null ? "" : m.getColRegDt())
  601. .colReqDt(m.getColReqDt() == null ? "" : m.getColReqDt())
  602. .colSchDt(m.getColSchDt() == null ? "" : m.getColSchDt())
  603. .colCmpltDt(m.getColCmpltDt() == null ? "" : m.getColCmpltDt())
  604. .itemId(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getItemId() == null ? "" : m.getPickDtlInfo().getItemId())
  605. .itemNm(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getItemNm() == null ? "" : m.getPickDtlInfo().getItemNm())
  606. .colReqQty(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColReqQty() == null ? 0 : m.getPickDtlInfo().getColReqQty())
  607. .rtnRsnDvsn(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getRtnRsnDvsn() == null ? "" : m.getPickDtlInfo().getRtnRsnDvsn())
  608. .rtnRsnDvsnNm(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getRtnRsnDvsnNm() == null ? "" : m.getPickDtlInfo().getRtnRsnDvsnNm())
  609. .unitAmt(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getUnitAmt() == null ? 0 : m.getPickDtlInfo().getUnitAmt())
  610. .colReqAmt(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColReqAmt() == null ? 0 : m.getPickDtlInfo().getColReqAmt())
  611. .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm() + " - " + m.getLocationNm())
  612. .pickMgrNm(m.getPickMgrNm() == null ? "" : m.getPickMgrNm())
  613. .pickMgrTelNo(m.getPickMgrTelNo() == null ? "" : m.getPickMgrTelNo())
  614. .build())
  615. .collect(Collectors.toList());
  616. return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
  617. }
  618. /*
  619. 반품처리 그리드 리스트 조회
  620. */
  621. public GridResponse selectRtnStockTargetList(String sBrandId, String sStoreId, String fromDt, String toDt, String sRtnWhsId, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
  622. int gridPage = gridRequest.getGridPage();
  623. int gridSize = gridRequest.getGridSize();
  624. fromDt = fromDt == null ? null : fromDt.replace(".", "");
  625. toDt = toDt == null ? null : toDt.replace(".", "");
  626. int gridRecords = colOdrMapper.selectColRtnInstGridCnt(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm);
  627. int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
  628. List<PickInfoMgntEntity> entities = colOdrMapper.selectColRtnInstGridList(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm, gridRequest);
  629. List<Object> gridRows = entities.stream()
  630. .map(m -> RtnStockTargetResponse.builder()
  631. .viewCd("R")
  632. .brandId(m.getBrandId() == null ? "" : m.getBrandId())
  633. .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
  634. .colPickUnqNo(m.getColPickUnqNo() == null ? "" : m.getColPickUnqNo())
  635. .colPickDtlNo(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getColPickDtlNo() == null ? "" :m.getPickDtlInfo().getColPickDtlNo() )
  636. .rtnPodrUnqNo(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getRtnPodrUnqNo() == null ? "" :m.getPickDtlInfo().getRtnPodrUnqNo() )
  637. .rtnPodrDtlNo(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getRtnPodrDtlNo() == null ? "" :m.getPickDtlInfo().getRtnPodrDtlNo() )
  638. .itemId(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getItemId() == null ? "" :m.getPickDtlInfo().getItemId() )
  639. .itemNm(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getItemNm() == null ? "" :m.getPickDtlInfo().getItemNm() )
  640. .colQty(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColQty() == null ? 0 :m.getPickDtlInfo().getColQty() )
  641. .colReqQty(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColReqQty() == null ? 0 :m.getPickDtlInfo().getColReqQty() )
  642. .rodrQty(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getRodrQty() == null ? 0 :m.getPickDtlInfo().getRodrQty() )
  643. .colAmt(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColAmt() == null ? 0 :m.getPickDtlInfo().getColAmt() )
  644. .whsId(m.getWhsId() == null ? "" : m.getWhsId())
  645. .location(m.getLocation() == null ? "" : m.getLocation())
  646. .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm() + " - " + m.getLocationNm())
  647. .rtnWhsId(m.getRtnWhsId() == null ? "" : m.getRtnWhsId())
  648. .rtnLocation(m.getRtnLocation() == null ? "" : m.getRtnLocation())
  649. .rtnWhsNm(m.getRtnWhsNm() == null ? "" : m.getRtnWhsNm())
  650. .colSchDt(m.getColSchDt() == null ? "" : m.getColSchDt())
  651. .pickMgrNm(m.getPickMgrNm() == null ? "" : m.getPickMgrNm())
  652. .pickMgrTelNo(m.getPickMgrTelNo() == null ? "" : m.getPickMgrTelNo())
  653. .spplyId(m.getSpplyId() == null ? "" : m.getSpplyId())
  654. .spplyNm(m.getSpplyNm() == null ? "" : m.getSpplyNm())
  655. .build())
  656. .collect(Collectors.toList());
  657. return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
  658. }
  659. /* 입고처리 저장
  660. @Transactional
  661. public void saveRtnStockProc(String userId, SaveRtnStockProcRequest saveRtnStockProcRequest) throws Exception {
  662. try {
  663. List<RtnProcInfoPtclEntity> gridInsertData = saveRtnStockProcRequest.toCodeEntities(saveRtnStockProcRequest.getGridInsertData());
  664. List<RtnProcInfoPtclEntity> searchList = new ArrayList<RtnProcInfoPtclEntity>();
  665. if (gridInsertData.size() > 0) {
  666. for (int i = 0; i < gridInsertData.size(); i++) {
  667. RtnProcInfoPtclEntity targetData = gridInsertData.get(i);
  668. RtnProcInfoPtclEntity procData = new RtnProcInfoPtclEntity();
  669. procData.setColPickUnqNo(targetData.getColPickUnqNo() + targetData.getColPickDtlNo());
  670. searchList.add(procData);
  671. }
  672. //로그인 사용자 정보
  673. UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
  674. // 반품처리를 위한 관련정보를 가져온다
  675. List<PickInfoMgntEntity> targetList = colOdrMapper.selectColRtnInstProcList(saveRtnStockProcRequest.getBrandId(), saveRtnStockProcRequest.getWhsId(), searchList);
  676. for (int i = 0; i < gridInsertData.size(); i++) {
  677. RtnProcInfoPtclEntity requestData = gridInsertData.get(i);
  678. for (int j = 0; j < targetList.size(); j++) {
  679. PickInfoMgntEntity targetData = targetList.get(j);
  680. RtnProcInfoPtclEntity rtnProcInfoEntity = new RtnProcInfoPtclEntity();
  681. if (requestData.getColPickDtlNo().equals(targetData.getColPickUnqNo()) && requestData.getColPickDtlNo().equals(targetData.getPickDtlInfo().getColPickDtlNo())) {
  682. if (requestData.getColQty() > targetData.getPickDtlInfo().getColReqQty()) {
  683. // 반품입고수량이 수거요청수량보다 클 수 없습니다.
  684. throw new GlobalException(SystemMessageCode.ERR_NOTRTNQTY);
  685. }
  686. if (targetData.getColDvsn().equals("C001") && !saveRtnStockProcRequest.getWhsId().equals(targetData.getWhsId())) {
  687. // 본사 수거이변서 입고창고가 상이하면 오류
  688. throw new GlobalException(SystemMessageCode.ERR_NOTRTNINWHS);
  689. }
  690. }
  691. // 반품처리 진행 데이타생성
  692. String rtnMgntUnqNo = fnGetDealNo(37,"");
  693. rtnProcInfoEntity.setRtnMgntUnqNo(rtnMgntUnqNo);
  694. rtnProcInfoEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
  695. rtnProcInfoEntity.setStoreId(saveRtnStockProcRequest.getStoreId());
  696. rtnProcInfoEntity.setItemId(requestData.getItemId());
  697. rtnProcInfoEntity.setItemNm(targetData.getPickDtlInfo().getItemNm());
  698. rtnProcInfoEntity.setWhsId(targetData.getRtnWhsId());
  699. rtnProcInfoEntity.setLocation(targetData.getRtnLocation());
  700. rtnProcInfoEntity.setUnit(targetData.getPickDtlInfo().getUnit());
  701. rtnProcInfoEntity.setUnitAmt(targetData.getPickDtlInfo().getUnitAmt());
  702. rtnProcInfoEntity.setRtnReqQty(targetData.getPickDtlInfo().getRtnReqQty());
  703. rtnProcInfoEntity.setRtnOdrQty(targetData.getPickDtlInfo().getRodrQty());
  704. rtnProcInfoEntity.setColReqQty(targetData.getPickDtlInfo().getColReqQty());
  705. rtnProcInfoEntity.setColQty(requestData.getColQty());
  706. rtnProcInfoEntity.setColReqDt(targetData.getColReqDt());
  707. rtnProcInfoEntity.setColSchDt(targetData.getColSchDt());
  708. rtnProcInfoEntity.setColCnfmNm(uEntity.getUserNm());
  709. rtnProcInfoEntity.setColMgrTelNo(targetData.getPickMgrTelNo());
  710. rtnProcInfoEntity.setColAmt(requestData.getColQty() * targetData.getPickDtlInfo().getUnitAmt());
  711. rtnProcInfoEntity.setColAgrYn("Y");
  712. // rtnProcInfoEntity.setColCnfmDocFileNo(saveRtnStockProcRequest.); 수거서 파일 첨부 제거
  713. rtnProcInfoEntity.setSttlYn("N");
  714. rtnProcInfoEntity.setSpplyId(targetData.getSpplyId());
  715. rtnProcInfoEntity.setSpplyNm(targetData.getSpplyNm());
  716. rtnProcInfoEntity.setColPickUnqNo(targetData.getColPickUnqNo());
  717. rtnProcInfoEntity.setColPickDtlNo(targetData.getPickDtlInfo().getColPickDtlNo());
  718. rtnProcInfoEntity.setColCmdUnqNo(targetData.getPickDtlInfo().getColCmdUnqNo());
  719. rtnProcInfoEntity.setColCmdDtlNo(targetData.getPickDtlInfo().getColCmdDtlNo());
  720. rtnProcInfoEntity.setRtnPodrUnqNo(targetData.getPickDtlInfo().getRtnPodrUnqNo());
  721. rtnProcInfoEntity.setRtnPodrDtlNo(targetData.getPickDtlInfo().getRtnPodrDtlNo());
  722. rtnProcInfoEntity.setRtnReqUnqNo(targetData.getPickDtlInfo().getRtnReqUnqNo());
  723. rtnProcInfoEntity.setRtnReqDtlNo(targetData.getPickDtlInfo().getRtnReqDtlNo());
  724. // 본사 수거 반품입고처리시
  725. if (targetData.getColDvsn().equals("C001") && requestData.getColQty() > 0) {
  726. //본사수거 .
  727. // 1. 매장재고참감처리, 본사재고 증가, 2. 반품처리테이블 생성, 3. 수거서 업데이타, 4, 반품발주건 업데이트
  728. // 매장재고 차감
  729. StckMgntBaseInfoEntity stckWEntity = new StckMgntBaseInfoEntity();
  730. stckWEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
  731. stckWEntity.setWhsId(targetData.getRtnWhsId());
  732. stckWEntity.setLocation(targetData.getRtnLocation());
  733. stckWEntity.setItemId(requestData.getItemId());
  734. stckWEntity.setStckQty(requestData.getColQty() * (-1));
  735. stckWEntity.setUnit(targetData.getPickDtlInfo().getUnit());
  736. //StckBaseList.add(stckWEntity);
  737. // 재고 이력정보 등록
  738. StckMgntDtlHistEntity stckWHist = new StckMgntDtlHistEntity();
  739. stckWHist.setStckMgntDtlNo("");
  740. stckWHist.setBrandId(saveRtnStockProcRequest.getBrandId());
  741. stckWHist.setWhsId(targetData.getRtnWhsId());
  742. stckWHist.setLocation(targetData.getRtnLocation());
  743. stckWHist.setItemId(requestData.getItemId());
  744. stckWHist.setItemNm(targetData.getPickDtlInfo().getItemNm());
  745. stckWHist.setInoutCd("OUT");
  746. stckWHist.setInoutQty(requestData.getColQty());
  747. stckWHist.setChgDvsn("ROUT");
  748. stckWHist.setRelationNo(rtnMgntUnqNo);
  749. //StckHistList.add(stckWHist);
  750. //본사재고 증가
  751. StckMgntBaseInfoEntity stckW1Entity = new StckMgntBaseInfoEntity();
  752. stckW1Entity.setBrandId(saveRtnStockProcRequest.getBrandId());
  753. stckW1Entity.setWhsId(saveRtnStockProcRequest.getWhsId());
  754. stckW1Entity.setLocation(targetData.getLocation());
  755. stckW1Entity.setItemId(requestData.getItemId());
  756. stckW1Entity.setStckQty(requestData.getColQty());
  757. stckW1Entity.setUnit(targetData.getPickDtlInfo().getUnit());
  758. //StckBaseList.add(stckWEntity);
  759. // 재고 이력정보 등록
  760. StckMgntDtlHistEntity stckW1Hist = new StckMgntDtlHistEntity();
  761. stckW1Hist.setStckMgntDtlNo("");
  762. stckW1Hist.setBrandId(saveRtnStockProcRequest.getBrandId());
  763. stckW1Hist.setWhsId(saveRtnStockProcRequest.getWhsId());
  764. stckW1Hist.setLocation(targetData.getLocation());
  765. stckW1Hist.setItemId(requestData.getItemId());
  766. stckW1Hist.setItemNm(targetData.getPickDtlInfo().getItemNm());
  767. stckW1Hist.setInoutCd("OUT");
  768. stckW1Hist.setInoutQty(requestData.getColQty());
  769. stckW1Hist.setChgDvsn("ROUT");
  770. stckW1Hist.setRelationNo(rtnMgntUnqNo); //======================================
  771. //StckHistList.add(stckWHist);
  772. } else if (targetData.getColDvsn().equals("C002") && requestData.getColQty() > 0) {
  773. // 공급사 수거일경우 - 본사창고 재고 차감 처리
  774. // 1. 참감처리 , 2. 반품처리테이블 생성, 3. 수거서 업데이타, 4, 반품발주건 업데이트
  775. // 본사재고 차감 처리 stck_mgnt_base_info stck_mgnt_dtl_hist
  776. StckMgntBaseInfoEntity stckWEntity = new StckMgntBaseInfoEntity();
  777. stckWEntity.setBrandId(saveRtnStockProcRequest.getBrandId());
  778. stckWEntity.setWhsId(saveRtnStockProcRequest.getWhsId());
  779. stckWEntity.setLocation(targetData.getLocation());
  780. stckWEntity.setItemId(requestData.getItemId());
  781. stckWEntity.setStckQty(requestData.getColQty() * (-1));
  782. stckWEntity.setUnit(targetData.getPickDtlInfo().getUnit());
  783. //StckBaseList.add(stckWEntity);
  784. // 재고 이력정보 등록
  785. StckMgntDtlHistEntity stckWHist = new StckMgntDtlHistEntity();
  786. stckWHist.setStckMgntDtlNo("");
  787. stckWHist.setBrandId(saveRtnStockProcRequest.getBrandId());
  788. stckWHist.setWhsId(saveRtnStockProcRequest.getWhsId());
  789. stckWHist.setLocation(targetData.getLocation());
  790. stckWHist.setItemId(requestData.getItemId());
  791. stckWHist.setItemNm(targetData.getPickDtlInfo().getItemNm());
  792. stckWHist.setInoutCd("OUT");
  793. stckWHist.setInoutQty(requestData.getColQty());
  794. stckWHist.setChgDvsn("ROUT");
  795. stckWHist.setRelationNo(rtnMgntUnqNo); //======================================
  796. //StckHistList.add(stckWHist);
  797. }
  798. // 반품수거서 건별 업데이트
  799. ColOdrDtlPtclEntity colOdrDtlPtclEntity = new ColOdrDtlPtclEntity;
  800. colOdrDtlPtclEntity.setColCmdUnqNo(targetData.getPickDtlInfo().getColCmdUnqNo());
  801. colOdrDtlPtclEntity.setColCmdDtlNo(targetData.getPickDtlInfo().getColCmdDtlNo());
  802. if (requestData.getColQty() > 0) {
  803. colOdrDtlPtclEntity.setColCmdDtlStCd("CDLD2");
  804. } else {
  805. colOdrDtlPtclEntity.setColCmdDtlStCd("COLD3");
  806. }
  807. //저장된 정보 신규 등록 및 업데이트 처리함
  808. colOdrMapper.insertRtnProcInfoPtcl(userId,rtnProcInfoEntity );
  809. } //==> targetList db에서 가온 수거정보
  810. } //==> request에서 가져온 전달받은 정보
  811. }
  812. } catch (GlobalException e) {
  813. //e.getStackTrace();
  814. e.printStackTrace();
  815. throw new GlobalException(e.getSystemMessageCode());
  816. } catch (Exception e) {
  817. e.printStackTrace();
  818. throw new RuntimeException();
  819. }
  820. }
  821. */
  822. /*
  823. 반품처리현황 그리드 리스트 조회
  824. */
  825. public GridResponse selectRtnStockResultList(String sBrandId, String sStoreId, String fromDt, String toDt, String sRtnWhsId, String sSpplyId, String sWhsId, String sItemNm, GridRequest gridRequest) throws Exception {
  826. int gridPage = gridRequest.getGridPage();
  827. int gridSize = gridRequest.getGridSize();
  828. fromDt = fromDt == null ? null : fromDt.replace(".", "");
  829. toDt = toDt == null ? null : toDt.replace(".", "");
  830. int gridRecords = colOdrMapper.selectColRtnInstResultGridCnt(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm);
  831. int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
  832. List<PickInfoMgntEntity> entities = colOdrMapper.selectColRtnInstResultGridList(sBrandId, sStoreId, fromDt, toDt, sSpplyId, sRtnWhsId, sWhsId, sItemNm, gridRequest);
  833. List<Object> gridRows = entities.stream()
  834. .map(m -> RtnColStockResultResponse.builder()
  835. .viewCd("R")
  836. .brandId(m.getBrandId() == null ? "" : m.getBrandId())
  837. .brandNm(m.getBrandNm() == null ? "" : m.getBrandNm())
  838. .colPickUnqNo(m.getColPickUnqNo() == null ? "" : m.getColPickUnqNo())
  839. .colPickDtlNo(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getColPickDtlNo() == null ? "" :m.getPickDtlInfo().getColPickDtlNo() )
  840. .rtnPodrUnqNo(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getRtnPodrUnqNo() == null ? "" :m.getPickDtlInfo().getRtnPodrUnqNo() )
  841. .rtnPodrDtlNo(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getRtnPodrDtlNo() == null ? "" :m.getPickDtlInfo().getRtnPodrDtlNo() )
  842. .itemId(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getItemId() == null ? "" :m.getPickDtlInfo().getItemId() )
  843. .itemNm(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getItemNm() == null ? "" :m.getPickDtlInfo().getItemNm() )
  844. .colQty(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColQty() == null ? 0 :m.getPickDtlInfo().getColQty() )
  845. .colReqQty(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColReqQty() == null ? 0 :m.getPickDtlInfo().getColReqQty() )
  846. .rodrQty(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getRodrQty() == null ? 0 :m.getPickDtlInfo().getRodrQty() )
  847. .colAmt(m.getPickDtlInfo() == null ? 0 : m.getPickDtlInfo().getColAmt() == null ? 0 :m.getPickDtlInfo().getColAmt() )
  848. .whsId(m.getWhsId() == null ? "" : m.getWhsId())
  849. .location(m.getLocation() == null ? "" : m.getLocation())
  850. .whsNm(m.getWhsNm() == null ? "" : m.getWhsNm() + " - " + m.getLocationNm())
  851. .rtnWhsId(m.getRtnWhsId() == null ? "" : m.getRtnWhsId())
  852. .rtnLocation(m.getRtnLocation() == null ? "" : m.getRtnLocation())
  853. .rtnWhsNm(m.getRtnWhsNm() == null ? "" : m.getRtnWhsNm())
  854. .colSchDt(m.getColSchDt() == null ? "" : m.getColSchDt())
  855. .colCmpltDt(m.getColCmpltDt() == null ? "" : m.getColCmpltDt())
  856. .pickDtlStCd(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getPickDtlStCd() == null ? "" : m.getPickDtlInfo().getPickDtlStCd())
  857. .pickDtlStNm(m.getPickDtlInfo() == null ? "" : m.getPickDtlInfo().getPickDtlStNm() == null ? "" : m.getPickDtlInfo().getPickDtlStNm())
  858. .pickMgrNm(m.getPickMgrNm() == null ? "" : m.getPickMgrNm())
  859. .pickMgrTelNo(m.getPickMgrTelNo() == null ? "" : m.getPickMgrTelNo())
  860. .spplyId(m.getSpplyId() == null ? "" : m.getSpplyId())
  861. .spplyNm(m.getSpplyNm() == null ? "" : m.getSpplyNm())
  862. .build())
  863. .collect(Collectors.toList());
  864. return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
  865. }
  866. }