Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workorder에 제품 이름 추가 시키는중 #203

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public String planRegisterGET(Model model, ProductionPlanVO planVO) throws Excep

logger.info("planList : "+ planList);
return "productionplan/plan";
}
}//



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.mrbean.common.NumberGenerationService;
import com.mrbean.productionplan.ProductionPlanVO;
import com.mrbean.warehouse.WarehouseService;
import com.mrbean.warehouse.WarehouseVO;

@Controller
Expand All @@ -28,14 +29,16 @@ public class WorkOrdersController {
private NumberGenerationService ngs;
@Inject
private WorkOrdersService wos;
@Inject
private WarehouseService whs;

/**
* 작업지시등록 페이지(GET) - 등록 form 과 List 함께출력
* http://localhost:8088/workorders/work
*
*/
@RequestMapping(value = "/work", method = RequestMethod.GET)
public String orderRegisterGET(Model model, WorkOrdersVO workVO) {
public String orderRegisterGET(Model model, WorkOrdersVO workVO) throws Exception {
logger.info("orderRegisterGET 호출()");

// 작업지시 목록을 조회해서 모델이 추가
Expand All @@ -44,9 +47,9 @@ public String orderRegisterGET(Model model, WorkOrdersVO workVO) {
logger.info("workList : "+ workList);

// 창고에게 받은 목록 jsp에 뿌려주기
// List<WarehouseVO> warehouses =
// model.addAttribute("warehouses", warehouses);
// logger.info("warehouses : "+ warehouses);
List<WarehouseVO> warehouses = whs.getWarehouseList();
model.addAttribute("warehouses", warehouses);
logger.info("warehouses : "+ warehouses);

return "workorders/work";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mrbean.common.NumberGenerationService;
import com.mrbean.enums.ProductionplanStatus;
import com.mrbean.productionplan.ProductionPlanVO;
Expand Down Expand Up @@ -43,10 +45,24 @@ public class WorkOrdersRestController {
@RequestMapping(value = "/work",method = RequestMethod.POST)
public ResponseEntity<?> workordersRegisterPOST(@RequestBody WorkOrdersVO workVO) {
logger.info("workordersPOST");
logger.info("전체 요청 데이터: {}", workVO);
logger.info("wName 값: {}", workVO.getWName());
logger.info("wName 타입: {}", (workVO.getWName() != null ? workVO.getWName().getClass().getName() : "null"));
try {

// Jackson이 어떻게 데이터를 파싱하는지 확인
ObjectMapper mapper = new ObjectMapper();
String jsonStr = mapper.writeValueAsString(workVO);
logger.info("JSON 형태로 변환된 데이터: {}", jsonStr);





// 작업지시 등록
wos.insertWorkOrders(workVO);


// 연관된 plan의 상태를 WAITING으로 업데이트
ProductionPlanVO planVO = new ProductionPlanVO();
planVO.setPlanId(workVO.getPlanId());
Expand All @@ -55,6 +71,7 @@ public ResponseEntity<?> workordersRegisterPOST(@RequestBody WorkOrdersVO workVO
// rqcs.processAndInsertRawMaterials(); // 원자재 검사 관리

List<WorkOrdersVO> workList = wos.getWorkList(workVO);
logger.info("workList $$$$$$$$$$$$$$: "+ workList);
logger.info("등록완료");
return ResponseEntity.ok(workList);
} catch (Exception e) {
Expand Down
20 changes: 20 additions & 0 deletions MrBean/src/main/java/com/mrbean/workorders/WorkOrdersVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.sql.Date;
import java.sql.Timestamp;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.mrbean.enums.WorkOrdersStatus;
import lombok.Data;

Expand All @@ -22,6 +23,25 @@ public class WorkOrdersVO {
private Date workUpdatedAt; // 수정일시
private boolean shouldUpdatePlan; // plan 상태 업데이트 여부 플래그

// 변수명은 camelCase를 사용 (첫 글자 소문자)
// 클래스명은 PascalCase를 사용 (첫 글자 대문자)
// 위 사항을 지키지 못한 이름들 때문에 데이터 null값 발생으로 @JsonProperty 어노테이션 사용


@JsonProperty("wName") // 자바 명명규칙을 안지켜서.. json과 호환성 문제 일으킴
private String wName;

@JsonProperty("wCode")
private String wCode;

@JsonProperty("pName")
private String pName; //product






private int planId; // 생산계획 ID
private String rmlNo; // 원자재 로트 번호

Expand Down
16 changes: 14 additions & 2 deletions MrBean/src/main/resources/mappers/workOrdersMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<result property="workStartTime" column="workStartTime"/>
<result property="workEndTime" column="workEndTime"/>
<result property="completedQuantity" column="completedQuantity"/>
<result property="wCode" column="w_code"/>
<result property="wName" column="w_name"/>
<result property="pName" column="p_name"/>


<!-- 검색용 파라미터 (테이블에 없는 필드) -->
<result property="searchStartDate" column="search_start_date"/>
Expand Down Expand Up @@ -70,7 +74,11 @@
work_status,
work_remark,
work_created_by,
rml_no
rml_no,
w_code,
w_name,
p_name




Expand All @@ -84,7 +92,11 @@
#{workStatus},
#{workRemark},
#{workCreatedBy},
#{rmlNo}
#{rmlNo},
#{wCode},
#{wName},
#{pName}

)
</insert>

Expand Down
8 changes: 5 additions & 3 deletions MrBean/src/main/webapp/WEB-INF/views/workorders/work.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
<!-- 넷째 줄 -->
<div class="col-md-12">
<div class="form-floating mb-3">
<select class="form-select" id="wCode" aria-label="State">
<select class="form-select" id="wName" aria-label="State">
<option value="">창고를 선택하세요</option>
<c:forEach var="warehouses" items="${wCodes}">
<option value="${warehouses.wName}">${warehouses.wName}</option>
<c:forEach var="warehouses" items="${warehouses}">
<option value="${warehouses.WName}" data-code="${warehouses.WCode}">${warehouses.WName}/${warehouses.WCode}</option>
</c:forEach>
</select>
<label for="wCode">창고구분</label>
Expand Down Expand Up @@ -121,6 +121,7 @@
<thead>
<tr>
<th>작업지시번호</th>
<th>제품명</th>
<th>생산계획번호</th>
<th>작업시작일</th>
<th>작업수량</th>
Expand All @@ -136,6 +137,7 @@
<c:forEach var="work" items="${workList}">
<tr>
<td>${work.workOrderNo}</td>
<td>${work.PName}</td>
<td>${work.workPlanNo}</td>
<td>${work.workStartDate}</td>
<td>${work.workQuantity}</td>
Expand Down
4 changes: 4 additions & 0 deletions MrBean/src/main/webapp/resources/js/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export const SELECTORS = {
WORK_COMQUANTITY:'#completedQuantity',
WORK_START_DATE: '#workStartDate',
WORK_REMARK: '#workRemark',
WAREHOUSE: '#wName',




// Common Form Elements
INSERT_BTN: '#insertBtn',
Expand Down
3 changes: 3 additions & 0 deletions MrBean/src/main/webapp/resources/js/modules/work.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ export const workModule = {
workQuantity: parseInt($(SELECTORS.FORM.WORK_QUANTITY).val()),
workRemark: $(SELECTORS.FORM.WORK_REMARK).val(),
workCreatedBy: DEFAULTS.WORK.CREATED_BY,
wName: $(SELECTORS.FORM.WAREHOUSE).val(),
wCode: $(SELECTORS.FORM.WAREHOUSE + ' option:selected').data('code'),
workStatus: STATUS.WORK.WAITING, // 명시적으로 WAITING 상태 설정
shouldUpdatePlan: true // plan 상태도 함께 업데이트
};
Expand All @@ -135,6 +137,7 @@ export const workModule = {
data: JSON.stringify(formData),
success: (response) => {
this.updateList(response);
console.log('formData:', formData);
alert(MESSAGES.SUCCESS.WORK_CREATE);
this.resetForm();
},
Expand Down