품의서는 공급업체별 아님;;
This commit is contained in:
@@ -2758,7 +2758,7 @@ public class SalesMngService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 구매요청서 품의서 생성 (PURCHASE_REG 전용) - 업체별로 분리 생성
|
||||
* 구매요청서 품의서 생성 (PURCHASE_REG 전용) - 하나의 품의서로 생성
|
||||
*/
|
||||
public Map createProposalFromPurchaseReg(HttpServletRequest request, Map paramMap) {
|
||||
SqlSession sqlSession = null;
|
||||
@@ -2794,68 +2794,46 @@ public class SalesMngService {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
// 3. 업체별로 품목 그룹화
|
||||
Map<String, List<Map>> partsByVendor = new LinkedHashMap<String, List<Map>>();
|
||||
for(Map part : targetParts) {
|
||||
String vendorPm = CommonUtils.checkNull(part.get("VENDOR_PM"));
|
||||
if(vendorPm.isEmpty()) {
|
||||
vendorPm = CommonUtils.checkNull(part.get("vendor_pm"));
|
||||
}
|
||||
|
||||
if(!partsByVendor.containsKey(vendorPm)) {
|
||||
partsByVendor.put(vendorPm, new ArrayList<Map>());
|
||||
}
|
||||
partsByVendor.get(vendorPm).add(part);
|
||||
}
|
||||
// 3. 품의서 번호 생성
|
||||
String proposalNo = (String)sqlSession.selectOne("salesMng.getNextProposalNo");
|
||||
|
||||
// 4. 업체별로 품의서 생성
|
||||
List<String> createdProposalNos = new ArrayList<String>();
|
||||
// 4. 품의서 마스터 생성 (하나만)
|
||||
Map proposalMaster = new HashMap();
|
||||
String proposalMasterObjid = CommonUtils.createObjId();
|
||||
proposalMaster.put("OBJID", proposalMasterObjid);
|
||||
proposalMaster.put("REQUEST_MNG_NO", proposalNo);
|
||||
proposalMaster.put("PROJECT_NO", purchaseRequestInfo.get("PROJECT_NO"));
|
||||
proposalMaster.put("PURCHASE_TYPE", purchaseRequestInfo.get("PURCHASE_TYPE"));
|
||||
proposalMaster.put("ORDER_TYPE", purchaseRequestInfo.get("ORDER_TYPE"));
|
||||
proposalMaster.put("PRODUCT_NAME", purchaseRequestInfo.get("PRODUCT_NAME"));
|
||||
proposalMaster.put("AREA_CD", purchaseRequestInfo.get("AREA_CD"));
|
||||
proposalMaster.put("CUSTOMER_OBJID", purchaseRequestInfo.get("CUSTOMER_OBJID"));
|
||||
proposalMaster.put("PAID_TYPE", purchaseRequestInfo.get("PAID_TYPE"));
|
||||
proposalMaster.put("DELIVERY_REQUEST_DATE", purchaseRequestInfo.get("DELIVERY_REQUEST_DATE"));
|
||||
proposalMaster.put("REQUEST_USER_ID", userId);
|
||||
proposalMaster.put("WRITER", userId);
|
||||
|
||||
sqlSession.insert("salesMng.insertProposalFromPurchaseReg", proposalMaster);
|
||||
|
||||
// 5. 모든 품목을 하나의 품의서에 생성
|
||||
List<String> allSourceObjids = new ArrayList<String>();
|
||||
|
||||
for(String vendorPm : partsByVendor.keySet()) {
|
||||
List<Map> vendorParts = partsByVendor.get(vendorPm);
|
||||
|
||||
// 품의서 번호 생성
|
||||
String proposalNo = (String)sqlSession.selectOne("salesMng.getNextProposalNo");
|
||||
createdProposalNos.add(proposalNo);
|
||||
|
||||
// 품의서 마스터 생성
|
||||
Map proposalMaster = new HashMap();
|
||||
String proposalMasterObjid = CommonUtils.createObjId();
|
||||
proposalMaster.put("OBJID", proposalMasterObjid);
|
||||
proposalMaster.put("REQUEST_MNG_NO", proposalNo);
|
||||
proposalMaster.put("PROJECT_NO", purchaseRequestInfo.get("PROJECT_NO"));
|
||||
proposalMaster.put("PURCHASE_TYPE", purchaseRequestInfo.get("PURCHASE_TYPE"));
|
||||
proposalMaster.put("ORDER_TYPE", purchaseRequestInfo.get("ORDER_TYPE"));
|
||||
proposalMaster.put("PRODUCT_NAME", purchaseRequestInfo.get("PRODUCT_NAME"));
|
||||
proposalMaster.put("AREA_CD", purchaseRequestInfo.get("AREA_CD"));
|
||||
proposalMaster.put("CUSTOMER_OBJID", purchaseRequestInfo.get("CUSTOMER_OBJID"));
|
||||
proposalMaster.put("PAID_TYPE", purchaseRequestInfo.get("PAID_TYPE"));
|
||||
proposalMaster.put("DELIVERY_REQUEST_DATE", purchaseRequestInfo.get("DELIVERY_REQUEST_DATE"));
|
||||
proposalMaster.put("REQUEST_USER_ID", userId);
|
||||
proposalMaster.put("WRITER", userId);
|
||||
|
||||
sqlSession.insert("salesMng.insertProposalFromPurchaseReg", proposalMaster);
|
||||
|
||||
// 해당 업체의 품목 생성
|
||||
for(Map part : vendorParts) {
|
||||
String sourceObjid = CommonUtils.checkNull(part.get("OBJID"));
|
||||
if(sourceObjid.isEmpty()) {
|
||||
sourceObjid = CommonUtils.checkNull(part.get("objid"));
|
||||
}
|
||||
allSourceObjids.add(sourceObjid);
|
||||
|
||||
Map partParam = new HashMap();
|
||||
partParam.put("NEW_OBJID", CommonUtils.createObjId());
|
||||
partParam.put("PROPOSAL_MASTER_OBJID", proposalMasterObjid);
|
||||
partParam.put("SOURCE_OBJID", sourceObjid);
|
||||
partParam.put("WRITER", userId);
|
||||
|
||||
sqlSession.insert("salesMng.insertProposalPartFromPurchaseReg", partParam);
|
||||
for(Map part : targetParts) {
|
||||
String sourceObjid = CommonUtils.checkNull(part.get("OBJID"));
|
||||
if(sourceObjid.isEmpty()) {
|
||||
sourceObjid = CommonUtils.checkNull(part.get("objid"));
|
||||
}
|
||||
allSourceObjids.add(sourceObjid);
|
||||
|
||||
Map partParam = new HashMap();
|
||||
partParam.put("NEW_OBJID", CommonUtils.createObjId());
|
||||
partParam.put("PROPOSAL_MASTER_OBJID", proposalMasterObjid);
|
||||
partParam.put("SOURCE_OBJID", sourceObjid);
|
||||
partParam.put("WRITER", userId);
|
||||
|
||||
sqlSession.insert("salesMng.insertProposalPartFromPurchaseReg", partParam);
|
||||
}
|
||||
|
||||
// 5. 원본 품목 PROPOSAL_DATE 업데이트
|
||||
// 6. 원본 품목 PROPOSAL_DATE 업데이트
|
||||
if(!allSourceObjids.isEmpty()) {
|
||||
Map updateParam = new HashMap();
|
||||
updateParam.put("PART_OBJIDS", allSourceObjids);
|
||||
@@ -2865,13 +2843,10 @@ public class SalesMngService {
|
||||
sqlSession.commit();
|
||||
|
||||
// 결과 메시지 생성
|
||||
String message = "품의서가 " + createdProposalNos.size() + "건 생성되었습니다.\n";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < createdProposalNos.size(); i++) {
|
||||
if(i > 0) sb.append(", ");
|
||||
sb.append(createdProposalNos.get(i));
|
||||
}
|
||||
message += sb.toString();
|
||||
String message = "품의서가 생성되었습니다. (" + proposalNo + ")";
|
||||
|
||||
List<String> createdProposalNos = new ArrayList<String>();
|
||||
createdProposalNos.add(proposalNo);
|
||||
|
||||
resultMap.put("resultFlag", "S");
|
||||
resultMap.put("message", message);
|
||||
|
||||
Reference in New Issue
Block a user