품의서 생성 로직 개선: 동일 품번 그룹핑 + QTY 분기 + M-BOM 복사 개선
- 품의서 대상 조회 시 구매리스트와 동일 기준(PART_OBJID+SUPPLY_TYPE+RAW_MATERIAL+SIZE)으로 동일 품번 그룹핑 - 소재 유무에 따라 QTY를 PO_QTY(소재O) 또는 PRODUCTION_QTY(소재X)로 분기 - INSERT 쿼리를 VALUES 기반으로 변경하여 그룹핑된 합산 데이터 직접 삽입 - M-BOM 복사 시 수주수량 기반 제작수량 자동계산 + PROPOSAL_DATE 초기화 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1593,7 +1593,7 @@ public class ProductionPlanningService {
|
||||
* 동일 품번의 최신 M-BOM을 새 프로젝트에 자동 복사 (독립 트랜잭션)
|
||||
*/
|
||||
public String copyMbomFromTemplate(HttpServletRequest request, String projectObjId,
|
||||
String templateHeaderObjId, String partNo, String partName) {
|
||||
String templateHeaderObjId, String partNo, String partName, int orderQuantity) {
|
||||
SqlSession sqlSession = null;
|
||||
String newHeaderObjid = null;
|
||||
|
||||
@@ -1603,7 +1603,7 @@ public class ProductionPlanningService {
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
String userId = CommonUtils.checkNull(person.getUserId());
|
||||
|
||||
newHeaderObjid = copyMbomFromTemplate(sqlSession, userId, projectObjId, templateHeaderObjId, partNo, partName);
|
||||
newHeaderObjid = copyMbomFromTemplate(sqlSession, userId, projectObjId, templateHeaderObjId, partNo, partName, orderQuantity);
|
||||
|
||||
if(newHeaderObjid != null) {
|
||||
sqlSession.commit();
|
||||
@@ -1624,7 +1624,7 @@ public class ProductionPlanningService {
|
||||
* 수주 확정 → 프로젝트 자동생성 시 ContractMgmtService에서 호출
|
||||
*/
|
||||
public String copyMbomFromTemplate(SqlSession sqlSession, String userId, String projectObjId,
|
||||
String templateHeaderObjId, String partNo, String partName) {
|
||||
String templateHeaderObjId, String partNo, String partName, int orderQuantity) {
|
||||
String newHeaderObjid = null;
|
||||
|
||||
try {
|
||||
@@ -1696,9 +1696,18 @@ public class ProductionPlanningService {
|
||||
insertParam.put("processingVendor", detail.get("PROCESSING_VENDOR"));
|
||||
insertParam.put("processingDeadline", detail.get("PROCESSING_DEADLINE"));
|
||||
insertParam.put("grindingDeadline", detail.get("GRINDING_DEADLINE"));
|
||||
// REQUIRED_QTY(소요량)는 원본 복사, 나머지 수량은 수주수량 기준 재계산
|
||||
double requiredQty = 0;
|
||||
try {
|
||||
Object reqObj = detail.get("REQUIRED_QTY");
|
||||
if(reqObj != null) requiredQty = Double.parseDouble(String.valueOf(reqObj));
|
||||
} catch(Exception ignore) {}
|
||||
|
||||
double productionQty = requiredQty * orderQuantity;
|
||||
|
||||
insertParam.put("requiredQty", detail.get("REQUIRED_QTY"));
|
||||
insertParam.put("orderQty", null);
|
||||
insertParam.put("productionQty", null);
|
||||
insertParam.put("productionQty", productionQty > 0 ? productionQty : null);
|
||||
insertParam.put("stockQty", null);
|
||||
insertParam.put("shortageQty", null);
|
||||
insertParam.put("netQty", null);
|
||||
@@ -1710,7 +1719,7 @@ public class ProductionPlanningService {
|
||||
insertParam.put("currency", detail.get("CURRENCY"));
|
||||
insertParam.put("leadTime", detail.get("LEAD_TIME"));
|
||||
insertParam.put("minOrderQty", detail.get("MIN_ORDER_QTY"));
|
||||
insertParam.put("proposalDate", detail.get("PROPOSAL_DATE"));
|
||||
insertParam.put("proposalDate", null);
|
||||
insertParam.put("remark", detail.get("REMARK"));
|
||||
insertParam.put("sessionUserId", userId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user