From b53aab797d4f4d47225da967a1cd40a7d8860292 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 3 Sep 2024 11:53:58 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E7=BB=88=E9=AA=8C=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hz/pm/api/common/util/BizDateUtil.java | 54 ++++++++++++++++ .../java/com/hz/pm/api/common/util/BizUtils.java | 28 --------- .../manage/FinalAcceptanceManage.java | 72 ++++++++++------------ .../api/projectlib/model/req/ProjectListReq.java | 2 +- 4 files changed, 88 insertions(+), 68 deletions(-) create mode 100644 hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizDateUtil.java diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizDateUtil.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizDateUtil.java new file mode 100644 index 0000000..30d6a77 --- /dev/null +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizDateUtil.java @@ -0,0 +1,54 @@ +package com.hz.pm.api.common.util; + +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.StrUtil; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.Date; +import java.util.Objects; + +/** + *

+ * BizDateUtil + *

+ * + * @author WendyYang + * @since 11:24 2024/9/3 + */ +public class BizDateUtil { + + private BizDateUtil() { + + } + + public static String toDateStr(LocalDate date) { + if (date == null) { + return StrUtil.EMPTY; + } + return LocalDateTimeUtil.format(date, "yyyy-MM-dd"); + } + + public static String toDateStr(LocalDateTime date) { + if (date == null) { + return StrUtil.EMPTY; + } + return LocalDateTimeUtil.format(date, "yyyy-MM-dd"); + } + + public static String toDateTimeStr(LocalDateTime dateTime) { + if (dateTime == null) { + return StrUtil.EMPTY; + } + return LocalDateTimeUtil.format(dateTime, "yyyy-MM-dd HH:mm:ss"); + } + + public static LocalDateTime convertDate(Date date) { + if (Objects.nonNull(date)) { + return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + } + return null; + } + +} diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java index ac62f7f..cc201d8 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/common/util/BizUtils.java @@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONArray; import com.hz.pm.api.projectlib.model.enumeration.ProjectTypeNewEnum; import com.ningdatech.basic.util.StrPool; import com.ningdatech.file.entity.vo.result.FileResultVO; -import liquibase.pro.packaged.O; import org.apache.commons.lang3.StringUtils; import org.springframework.util.NumberUtils; @@ -112,13 +111,6 @@ public class BizUtils { return StringUtils.EMPTY; } - public static LocalDateTime convertDate(Date date) { - if (Objects.nonNull(date)) { - return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); - } - return null; - } - public static String computeRise(Integer numa, Integer numb) { if ((Objects.isNull(numb) || numb.equals(0)) && (Objects.isNull(numa) || numa.equals(0))) { @@ -140,24 +132,4 @@ public class BizUtils { return JSON.toJSONString(jsonArray); } - public static LocalDateTime convertLocalDateTime(String time) { - if (StringUtils.isBlank(time)) { - return null; - } - String[] timeSplit = time.split(StrPool.DASH); - String year = timeSplit[0]; - String month = "01"; - String dayOfMonth = "01"; - if (timeSplit.length > 1) { - month = timeSplit[1]; - } - if (timeSplit.length > 2) { - dayOfMonth = timeSplit[2]; - } - return LocalDateTime.of(Integer.parseInt(year), - Integer.parseInt(month), - Integer.parseInt(dayOfMonth) - , 0, 0, 0); - } - } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java index 96b3432..5e8dadc 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectdeclared/manage/FinalAcceptanceManage.java @@ -14,6 +14,8 @@ import com.hz.pm.api.common.enumeration.ProjectProcessType; import com.hz.pm.api.common.helper.UserInfoHelper; import com.hz.pm.api.common.statemachine.util.ProjectStateMachineUtil; import com.hz.pm.api.common.statemachine.util.TenderStateMachineUtil; +import com.hz.pm.api.common.util.BizDateUtil; +import com.hz.pm.api.common.util.BizUtils; import com.hz.pm.api.common.util.ExcelDownUtil; import com.hz.pm.api.common.util.ExcelExportStyle; import com.hz.pm.api.projectdeclared.model.dto.DeclaredProjectExportDTO; @@ -52,7 +54,6 @@ import com.wflow.workflow.bean.vo.ProcessStartParamsVo; import com.wflow.workflow.service.ProcessInstanceService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -61,10 +62,9 @@ import javax.servlet.http.HttpServletResponse; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; -import java.util.function.Function; import java.util.stream.Collectors; -import static com.hz.pm.api.user.helper.MhUnitQueryHelper.*; +import static com.hz.pm.api.user.helper.MhUnitQueryHelper.UnitQueryState; /** * @Classname FinalAcceptanceManage @@ -92,14 +92,14 @@ public class FinalAcceptanceManage { //================================================================================================================== - private static final List FINAL_INSPECTED_TENDER_STATUS; + private static final List FINAL_INSPECTED_TENDER_STATUS; static { FINAL_INSPECTED_TENDER_STATUS = new ArrayList<>(); - FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY); - FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.ON_FINALLY_INSPECTED_APPLY); - FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.FINALLY_INSPECTED_PASSED); - FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.FINALLY_INSPECTED_FAILED); + FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.TO_BE_SUBMIT_FINALLY_INSPECTED_APPLY.getCode()); + FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.ON_FINALLY_INSPECTED_APPLY.getCode()); + FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.FINALLY_INSPECTED_PASSED.getCode()); + FINAL_INSPECTED_TENDER_STATUS.add(TenderMainStatus.FINALLY_INSPECTED_FAILED.getCode()); } /** @@ -111,7 +111,7 @@ public class FinalAcceptanceManage { public FinalAcceptProgressStatisticsVO finalAcceptProgressStatistics(ProjectListReq req) { LambdaQueryWrapper purchaseQuery = Wrappers.lambdaQuery(Purchase.class) .select(Purchase::getProjectId, Purchase::getStatus) - .in(Purchase::getStatus, CollUtils.fieldList(FINAL_INSPECTED_TENDER_STATUS, TenderMainStatus::getCode)); + .in(Purchase::getStatus, FINAL_INSPECTED_TENDER_STATUS); List purchases = purchaseService.list(purchaseQuery); if (purchases.isEmpty()) { return null; @@ -157,22 +157,30 @@ public class FinalAcceptanceManage { * @return \ */ public PageVo projectLibList(ProjectListReq req) { - Set projectIds = purchaseService.listProjectIdByStatus(FINAL_INSPECTED_TENDER_STATUS); - if (projectIds.isEmpty()) { - return PageVo.empty(); - } UserInfoDetails user = LoginUserUtil.loginUserDetail(); String buildOrgCode = req.getBuildOrgCode(); req.setBuildOrgCode(null); - LambdaQueryWrapper query = ProjectManageUtil.projectQuery(req) - .in(Project::getId, projectIds) - .eq(Project::getNewest, Boolean.TRUE) - .orderByAsc(Project::getApprovalDate); Long buildOrgCodeNum = NumberUtil.parseLong(buildOrgCode, null); UnitQueryState queryState = mhUnitQueryHelper.listCanViewUnitIds(buildOrgCodeNum, user); if (!queryState.isState()) { return null; } + LambdaQueryWrapper purchaseQuery = Wrappers.lambdaQuery(Purchase.class) + .select(Purchase::getStatus, Purchase::getProjectId, Purchase::getId, Purchase::getBidName); + if (req.getTabStatus() == null) { + purchaseQuery.in(Purchase::getStatus, FINAL_INSPECTED_TENDER_STATUS); + } else { + purchaseQuery.eq(Purchase::getStatus, req.getTabStatus()); + } + List purchases = purchaseService.list(purchaseQuery); + if (purchases.isEmpty()) { + return PageVo.empty(); + } + List projectIds = CollUtils.fieldList(purchases, Purchase::getProjectId); + LambdaQueryWrapper query = ProjectManageUtil.projectQuery(req) + .in(Project::getId, projectIds) + .eq(Project::getNewest, Boolean.TRUE) + .orderByAsc(Project::getApprovalDate); if (CollUtil.isNotEmpty(queryState.getUnitIds())) { query.in(Project::getBuildOrgCode, CollUtils.convert(queryState.getUnitIds(), String::valueOf)); } @@ -180,20 +188,8 @@ public class FinalAcceptanceManage { if (page.getTotal() == 0) { return PageVo.empty(); } - Set allProjectIds = CollUtils.fieldSet(page.getRecords(), Project::getId); - Wrapper purchaseQuery = Wrappers.lambdaQuery(Purchase.class) - .in(Purchase::getProjectId, allProjectIds) - .eq(Purchase::getStatus, req.getTabStatus()); - List purchases = purchaseService.list(purchaseQuery); - Map> purchaseMap; - Map contractMap; - if (!purchases.isEmpty()) { - purchaseMap = CollUtils.group(purchases, Purchase::getProjectId); - contractMap = contractService.listByProjectIds(projectIds); - } else { - purchaseMap = Collections.emptyMap(); - contractMap = Collections.emptyMap(); - } + Map> purchaseMap = CollUtils.group(purchases, Purchase::getProjectId); + Map contractMap = contractService.listByProjectIds(projectIds); List records = CollUtils.convert(page.getRecords(), w -> { ProjectLibListItemVO item = new ProjectLibListItemVO(); item.setId(w.getId()); @@ -212,11 +208,10 @@ public class FinalAcceptanceManage { item.setReviewAmount(w.getReviewAmount()); item.setApprovedAmount(w.getApprovalAmount()); item.setApprovalDate(w.getApprovalDate()); - item.setBuildCycle(StrUtil.isNotBlank(w.getBuildCycle()) ? Integer.valueOf(w.getBuildCycle()) : null); + item.setBuildCycle(NumberUtil.parseInt(w.getBuildCycle(), null)); item.setPlanAcceptanceTime(w.getPlanAcceptanceTime()); - List currPurchases = purchaseMap.get(w.getId()); - if (currPurchases != null) { - List tmpPurchases = CollUtils.convert(currPurchases, x -> { + BizUtils.notNull(purchaseMap.get(w.getId()), tmp -> { + List tenders = CollUtils.convert(tmp, x -> { TenderListInfoVO tender = new TenderListInfoVO(); tender.setBidName(x.getBidName()); tender.setBidId(x.getId()); @@ -228,8 +223,8 @@ public class FinalAcceptanceManage { } return tender; }); - item.setTenders(tmpPurchases); - } + item.setTenders(tenders); + }); return item; }); return PageVo.of(records, page.getTotal()); @@ -260,8 +255,7 @@ public class FinalAcceptanceManage { String createOnStr = NdDateUtils.format(r.getCreateOn(), "yyyy-MM-dd HH:mm"); item.setCreateOn(createOnStr); item.setSerialNumber(serialNumber.incrementAndGet()); - item.setPlanAcceptanceTime(Objects.nonNull(r.getPlanAcceptanceTime()) ? - NdDateUtils.format(r.getPlanAcceptanceTime(), "yyyy-MM-dd") : StringUtils.EMPTY); + item.setPlanAcceptanceTime(BizDateUtil.toDateStr(r.getPlanAcceptanceTime())); collect.add(item); }); } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java index b596e79..7e95dba 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/req/ProjectListReq.java @@ -1,7 +1,7 @@ package com.hz.pm.api.projectlib.model.req; -import com.ningdatech.basic.model.PagePo; import com.hz.pm.api.common.enumeration.ExportOptionEnum; +import com.ningdatech.basic.model.PagePo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.*;