|
@@ -37,10 +37,17 @@ class MonthClosingServiceTest {
|
|
|
private static final String PROJECT_FORM = "FORM-PROJECT-APPROVAL";
|
|
private static final String PROJECT_FORM = "FORM-PROJECT-APPROVAL";
|
|
|
private static final String OTHER_FORM = "FORM-OTHER-APPROVAL";
|
|
private static final String OTHER_FORM = "FORM-OTHER-APPROVAL";
|
|
|
private static final String SUMMARY_FORM = "FORM-SUMMARY";
|
|
private static final String SUMMARY_FORM = "FORM-SUMMARY";
|
|
|
|
|
+ private static final String REPAIR_SUMMARY_FORM = "FORM-REPAIR-SUMMARY";
|
|
|
private static final String CLOSING_MONTH_FIELD = "dateField_closing_month";
|
|
private static final String CLOSING_MONTH_FIELD = "dateField_closing_month";
|
|
|
private static final String CLOSING_STATUS_FIELD = "radioField_closing_status";
|
|
private static final String CLOSING_STATUS_FIELD = "radioField_closing_status";
|
|
|
private static final String SYNC_STATUS_FIELD = "selectField_sync_status";
|
|
private static final String SYNC_STATUS_FIELD = "selectField_sync_status";
|
|
|
private static final String SUMMARY_STATUS_FIELD = "selectField_summary_status";
|
|
private static final String SUMMARY_STATUS_FIELD = "selectField_summary_status";
|
|
|
|
|
+ private static final String APPROVAL_MONTH_FIELD = "textField_mmd2lv0y";
|
|
|
|
|
+ private static final String FILL_TYPE_FIELD = "radioField_fill_type";
|
|
|
|
|
+ private static final String PROJECT_REPAIR_SUBMIT_DATE_FIELD = "dateField_project_repair_submit";
|
|
|
|
|
+ private static final String OTHER_REPAIR_SUBMIT_DATE_FIELD = "dateField_other_repair_submit";
|
|
|
|
|
+ private static final String REPAIR_SUMMARY_SUBMIT_DATE_FIELD = "dateField_repair_summary_submit";
|
|
|
|
|
+ private static final String REPAIR_SUMMARY_STATUS_FIELD = "selectField_repair_summary_status";
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
void shouldRejectInvalidMonthBeforeQueryingYida() {
|
|
void shouldRejectInvalidMonthBeforeQueryingYida() {
|
|
@@ -207,6 +214,147 @@ class MonthClosingServiceTest {
|
|
|
assertEquals(1, result.getWriteBackPendingCount());
|
|
assertEquals(1, result.getWriteBackPendingCount());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void shouldAssignRunningRepairApprovalToSubmitMonthInsteadOfSourceMonth() {
|
|
|
|
|
+ YDClient ydClient = mock(YDClient.class);
|
|
|
|
|
+ when(ydClient.queryData(any(YDParam.class), any(YDConf.FORM_QUERY.class)))
|
|
|
|
|
+ .thenAnswer(invocation -> {
|
|
|
|
|
+ YDParam param = invocation.getArgument(0);
|
|
|
|
|
+ if (PROJECT_FORM.equals(param.getFormUuid())
|
|
|
|
|
+ && "RUNNING".equals(param.getInstanceStatus())) {
|
|
|
|
|
+ return response(Collections.singletonList(
|
|
|
|
|
+ repairApproval(PROJECT_REPAIR_SUBMIT_DATE_FIELD,
|
|
|
|
|
+ "2026-09-15", "", "")));
|
|
|
|
|
+ }
|
|
|
|
|
+ return response(Collections.emptyList());
|
|
|
|
|
+ });
|
|
|
|
|
+ MonthClosingService service = service(ydClient);
|
|
|
|
|
+
|
|
|
|
|
+ MonthClosingValidationResult september = service.validate(request("202609"));
|
|
|
|
|
+ MonthClosingValidationResult august = service.validate(request("202608"));
|
|
|
|
|
+
|
|
|
|
|
+ assertFalse(september.isAllowed());
|
|
|
|
|
+ assertEquals(1, september.getProjectRunningCount());
|
|
|
|
|
+ assertTrue(august.isAllowed());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void shouldBlockClosingWhenOtherRepairApprovalAwaitsWriteBack() {
|
|
|
|
|
+ YDClient ydClient = mock(YDClient.class);
|
|
|
|
|
+ when(ydClient.queryData(any(YDParam.class), any(YDConf.FORM_QUERY.class)))
|
|
|
|
|
+ .thenAnswer(invocation -> {
|
|
|
|
|
+ YDParam param = invocation.getArgument(0);
|
|
|
|
|
+ if (OTHER_FORM.equals(param.getFormUuid())
|
|
|
|
|
+ && "COMPLETED".equals(param.getInstanceStatus())) {
|
|
|
|
|
+ return response(Collections.singletonList(
|
|
|
|
|
+ repairApproval(OTHER_REPAIR_SUBMIT_DATE_FIELD,
|
|
|
|
|
+ "2026-09-15", "agree", "部分失败")));
|
|
|
|
|
+ }
|
|
|
|
|
+ return response(Collections.emptyList());
|
|
|
|
|
+ });
|
|
|
|
|
+ MonthClosingService service = service(ydClient);
|
|
|
|
|
+
|
|
|
|
|
+ MonthClosingValidationResult result = service.validate(request("202609"));
|
|
|
|
|
+
|
|
|
|
|
+ assertFalse(result.isAllowed());
|
|
|
|
|
+ assertEquals(1, result.getWriteBackPendingCount());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void shouldAllowClosingAfterRepairApprovalAndSummaryWriteBackFinish() {
|
|
|
|
|
+ YDClient ydClient = mock(YDClient.class);
|
|
|
|
|
+ when(ydClient.queryData(any(YDParam.class), any(YDConf.FORM_QUERY.class)))
|
|
|
|
|
+ .thenAnswer(invocation -> {
|
|
|
|
|
+ YDParam param = invocation.getArgument(0);
|
|
|
|
|
+ if (OTHER_FORM.equals(param.getFormUuid())
|
|
|
|
|
+ && "COMPLETED".equals(param.getInstanceStatus())) {
|
|
|
|
|
+ return response(Collections.singletonList(
|
|
|
|
|
+ repairApproval(OTHER_REPAIR_SUBMIT_DATE_FIELD,
|
|
|
|
|
+ "2026-09-15", "agree", "全部成功")));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (REPAIR_SUMMARY_FORM.equals(param.getFormUuid())) {
|
|
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
|
|
+ data.put(REPAIR_SUMMARY_SUBMIT_DATE_FIELD, "2026-09-15");
|
|
|
|
|
+ data.put(REPAIR_SUMMARY_STATUS_FIELD, "全部成功");
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("formData", data);
|
|
|
|
|
+ return response(Collections.singletonList(item));
|
|
|
|
|
+ }
|
|
|
|
|
+ return response(Collections.emptyList());
|
|
|
|
|
+ });
|
|
|
|
|
+ MonthClosingService service = service(ydClient);
|
|
|
|
|
+
|
|
|
|
|
+ MonthClosingValidationResult result = service.validate(request("202609"));
|
|
|
|
|
+
|
|
|
|
|
+ assertTrue(result.isAllowed());
|
|
|
|
|
+ assertEquals(0, result.getWriteBackPendingCount());
|
|
|
|
|
+ assertEquals(0, result.getSummaryPendingCount());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void shouldBlockClosingWhileRepairSummaryWriteBackIsPartial() {
|
|
|
|
|
+ YDClient ydClient = mock(YDClient.class);
|
|
|
|
|
+ when(ydClient.queryData(any(YDParam.class), any(YDConf.FORM_QUERY.class)))
|
|
|
|
|
+ .thenAnswer(invocation -> {
|
|
|
|
|
+ YDParam param = invocation.getArgument(0);
|
|
|
|
|
+ if (REPAIR_SUMMARY_FORM.equals(param.getFormUuid())) {
|
|
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
|
|
+ data.put(REPAIR_SUMMARY_SUBMIT_DATE_FIELD, "2026-09-15");
|
|
|
|
|
+ data.put(REPAIR_SUMMARY_STATUS_FIELD, "部分成功");
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("formData", data);
|
|
|
|
|
+ return response(Collections.singletonList(item));
|
|
|
|
|
+ }
|
|
|
|
|
+ return response(Collections.emptyList());
|
|
|
|
|
+ });
|
|
|
|
|
+ MonthClosingService service = service(ydClient);
|
|
|
|
|
+
|
|
|
|
|
+ MonthClosingValidationResult result = service.validate(request("202609"));
|
|
|
|
|
+ MonthClosingValidationResult previousMonth = service.validate(request("202608"));
|
|
|
|
|
+
|
|
|
|
|
+ assertFalse(result.isAllowed());
|
|
|
|
|
+ assertEquals(1, result.getSummaryPendingCount());
|
|
|
|
|
+ assertTrue(previousMonth.isAllowed());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void shouldKeepBlockingClosingForNormalSummaryInApproval() {
|
|
|
|
|
+ YDClient ydClient = mock(YDClient.class);
|
|
|
|
|
+ when(ydClient.queryData(any(YDParam.class), any(YDConf.FORM_QUERY.class)))
|
|
|
|
|
+ .thenAnswer(invocation -> {
|
|
|
|
|
+ YDParam param = invocation.getArgument(0);
|
|
|
|
|
+ if (SUMMARY_FORM.equals(param.getFormUuid())) {
|
|
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
|
|
+ data.put("textField_mmbffvda", "202609");
|
|
|
|
|
+ data.put(SUMMARY_STATUS_FIELD, "审批中");
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("formData", data);
|
|
|
|
|
+ return response(Collections.singletonList(item));
|
|
|
|
|
+ }
|
|
|
|
|
+ return response(Collections.emptyList());
|
|
|
|
|
+ });
|
|
|
|
|
+ MonthClosingService service = service(ydClient);
|
|
|
|
|
+
|
|
|
|
|
+ MonthClosingValidationResult result = service.validate(request("202609"));
|
|
|
|
|
+
|
|
|
|
|
+ assertFalse(result.isAllowed());
|
|
|
|
|
+ assertEquals(1, result.getSummaryPendingCount());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> repairApproval(String submitDateField,
|
|
|
|
|
+ String submitDate, String result,
|
|
|
|
|
+ String syncStatus) {
|
|
|
|
|
+ Map<String, Object> formData = new HashMap<>();
|
|
|
|
|
+ formData.put(APPROVAL_MONTH_FIELD, "202608");
|
|
|
|
|
+ formData.put(FILL_TYPE_FIELD, "补填");
|
|
|
|
|
+ formData.put(submitDateField, submitDate);
|
|
|
|
|
+ formData.put(SYNC_STATUS_FIELD, syncStatus);
|
|
|
|
|
+ Map<String, Object> item = new HashMap<>();
|
|
|
|
|
+ item.put("approvedResult", result);
|
|
|
|
|
+ item.put("formData", formData);
|
|
|
|
|
+ return item;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private DDR_New queryResponse(InvocationOnMock invocation) {
|
|
private DDR_New queryResponse(InvocationOnMock invocation) {
|
|
|
YDParam param = invocation.getArgument(0);
|
|
YDParam param = invocation.getArgument(0);
|
|
|
YDConf.FORM_QUERY queryType = invocation.getArgument(1);
|
|
YDConf.FORM_QUERY queryType = invocation.getArgument(1);
|
|
@@ -227,9 +375,15 @@ class MonthClosingServiceTest {
|
|
|
whConf.setFormUuidApproval(PROJECT_FORM);
|
|
whConf.setFormUuidApproval(PROJECT_FORM);
|
|
|
whConf.setFormUuidOtherApproval(OTHER_FORM);
|
|
whConf.setFormUuidOtherApproval(OTHER_FORM);
|
|
|
whConf.setFormUuidWorkHoursSummary(SUMMARY_FORM);
|
|
whConf.setFormUuidWorkHoursSummary(SUMMARY_FORM);
|
|
|
|
|
+ whConf.setFormUuidRepairWorkHoursSummary(REPAIR_SUMMARY_FORM);
|
|
|
whConf.setApprovalSyncStatusField(SYNC_STATUS_FIELD);
|
|
whConf.setApprovalSyncStatusField(SYNC_STATUS_FIELD);
|
|
|
whConf.setOtherApprovalSyncStatusField(SYNC_STATUS_FIELD);
|
|
whConf.setOtherApprovalSyncStatusField(SYNC_STATUS_FIELD);
|
|
|
whConf.setSummaryApprovalStatusField(SUMMARY_STATUS_FIELD);
|
|
whConf.setSummaryApprovalStatusField(SUMMARY_STATUS_FIELD);
|
|
|
|
|
+ whConf.setApprovalFillTypeField(FILL_TYPE_FIELD);
|
|
|
|
|
+ whConf.setApprovalRepairSubmitDateField(PROJECT_REPAIR_SUBMIT_DATE_FIELD);
|
|
|
|
|
+ whConf.setOtherApprovalRepairSubmitDateField(OTHER_REPAIR_SUBMIT_DATE_FIELD);
|
|
|
|
|
+ whConf.setRepairSummarySubmitDateField(REPAIR_SUMMARY_SUBMIT_DATE_FIELD);
|
|
|
|
|
+ whConf.setRepairSummarySyncStatusField(REPAIR_SUMMARY_STATUS_FIELD);
|
|
|
|
|
|
|
|
MonthClosingConf closingConf = new MonthClosingConf();
|
|
MonthClosingConf closingConf = new MonthClosingConf();
|
|
|
closingConf.setFormUuid(CLOSING_FORM);
|
|
closingConf.setFormUuid(CLOSING_FORM);
|