From cb966ac5c02835eab5a99b7b93a5a9a063cf3201 Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期三, 25 六月 2025 15:55:08 +0800 Subject: [PATCH] 人员优化 --- main-business/src/main/resources/db/migration/postgresql/V20250604104500__create_table_pending_inventory.sql | 2 main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java | 1 main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java | 24 ++++++++++++ main-business/src/main/java/com/ruoyi/business/dto/PendingInventoryDto.java | 2 + main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java | 3 + ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 16 +++++++ main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java | 7 +-- ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java | 2 + main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java | 4 + main-business/src/main/java/com/ruoyi/business/entity/Production.java | 2 main-business/src/main/resources/db/migration/postgresql/V20250604101800__create_table_production.sql | 2 11 files changed, 56 insertions(+), 9 deletions(-) diff --git a/main-business/src/main/java/com/ruoyi/business/dto/PendingInventoryDto.java b/main-business/src/main/java/com/ruoyi/business/dto/PendingInventoryDto.java index 663d58c..e81edb6 100644 --- a/main-business/src/main/java/com/ruoyi/business/dto/PendingInventoryDto.java +++ b/main-business/src/main/java/com/ruoyi/business/dto/PendingInventoryDto.java @@ -43,4 +43,6 @@ * 鐓ょ */ private String coal; + + private String registrant; } diff --git a/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java b/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java index ec91e00..1b4c928 100644 --- a/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java +++ b/main-business/src/main/java/com/ruoyi/business/entity/PendingInventory.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.MyBaseEntity; import lombok.Data; @@ -81,10 +82,11 @@ * 鐧昏浜� */ @TableField(value = "registrant_id") - private String registrantId; + private Long registrantId; /** * 鐧昏鏃ユ湡 */ @TableField(value = "registration_date") + @JsonFormat(pattern = "yyyy-MM-dd") private LocalDate registrationDate; } \ No newline at end of file diff --git a/main-business/src/main/java/com/ruoyi/business/entity/Production.java b/main-business/src/main/java/com/ruoyi/business/entity/Production.java index d760a80..a01fbb6 100644 --- a/main-business/src/main/java/com/ruoyi/business/entity/Production.java +++ b/main-business/src/main/java/com/ruoyi/business/entity/Production.java @@ -76,7 +76,7 @@ * 鐢熶骇浜篒D */ @TableField(value = "producer_id") - private String producerId; + private Long producerId; /** * 鐢熶骇鏃ユ湡 */ diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java index 9075267..09c460c 100644 --- a/main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/ArchiveServiceImpl.java @@ -57,6 +57,9 @@ // 1. 鍒嗛〉鏌ヨ涓绘暟鎹� LambdaQueryWrapper<Archive> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.orderByDesc(Archive::getCreateTime); + if (archiveDto.getTreeId() != null) { + queryWrapper.eq(Archive::getTreeId, archiveDto.getTreeId()); + } IPage<Archive> archivePage = archiveMapper.selectPage(page, queryWrapper); // 2. 鏃犳暟鎹彁鍓嶈繑鍥� diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java index a38e13b..5e340eb 100644 --- a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java @@ -20,8 +20,10 @@ import com.ruoyi.business.service.InputInventoryRecordService; import com.ruoyi.business.service.InventorySummaryService; import com.ruoyi.business.service.PendingInventoryService; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.system.mapper.SysUserMapper; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -52,6 +54,8 @@ private final CoalFieldMapper coalFieldMapper; private final CoalInfoMapper coalInfoMapper; + + private final SysUserMapper sysUserMapper; private final InputInventoryRecordService inputInventoryRecordService; @@ -91,6 +95,20 @@ coalInfoMap = new HashMap<>(); } + // 5. 鎵归噺鏌ヨ鐧昏浜篿d + List<Long> registrantIds = pendingInventoryPage.getRecords().stream() + .map(PendingInventory::getRegistrantId) + .distinct() + .toList(); + // 鎵归噺鏌ヨ鐧昏浜� + Map<Long, SysUser> sysUserMap; + if (!registrantIds.isEmpty()) { + List<SysUser> sysUsers = sysUserMapper.selectList(registrantIds); + sysUserMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity())); + } else { + sysUserMap = new HashMap<>(); + } + // 鎵归噺鏌ヨ姝e紡搴撳瓨淇℃伅 Map<Long, Long> pendingToOfficialMap = getOfficialInventoryMap(pendingIds); @@ -105,6 +123,12 @@ dto.setCoal(coalInfo.getCoal()); } + // 璁剧疆鐧昏浜� + SysUser sysUser = sysUserMap.get(record.getRegistrantId()); + if (sysUser != null) { + dto.setRegistrant(sysUser.getNickName()); + } + // 浠庨鍔犺浇鐨凪ap涓幏鍙杘fficialId dto.setOfficialId(pendingToOfficialMap.getOrDefault(record.getId(), null)); diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java index bb958f0..3d006fd 100644 --- a/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/ProductionMasterServiceImpl.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.ruoyi.basic.entity.CoalInfo; import com.ruoyi.basic.mapper.CoalInfoMapper; import com.ruoyi.business.dto.ProductionMasterDto; import com.ruoyi.business.entity.*; @@ -18,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -211,8 +211,6 @@ coalIds.add(p.getCoalId()); } - List<CoalInfo> coalInfos = coalInfoMapper.selectList(new LambdaQueryWrapper<CoalInfo>().in(CoalInfo::getId, coalIds)); - ProductionMaster master = new ProductionMaster(); master.setProductionQuantity(totalQuantity); master.setTotalCost(totalCost); @@ -263,7 +261,8 @@ pending.setSupplierName("鐢熶骇鍔犲伐鍏ュ簱"); pending.setTotalPriceIncludingTax(p.getTotalCost()); pending.setPriceIncludingTax(p.getPurchasePrice()); - pending.setPriceIncludingTax(p.getPurchasePrice()); + pending.setRegistrantId(p.getProducerId()); + pending.setRegistrationDate(LocalDate.now()); pendingInventoryMapper.insert(pending); } } diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java index c549d74..191b172 100644 --- a/main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/TreeServiceImpl.java @@ -33,6 +33,7 @@ public List<TreeVo> selectTreeList(TreeDto treeDto) { // 鏌ヨ鏍硅妭鐐癸紙parentId 涓� null锛� LambdaQueryWrapper<Tree> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.orderByAsc(Tree::getCreateTime); queryWrapper.isNull(Tree::getParentId); // 濡傛灉鏈変骇鍝佸悕绉版潯浠讹紝娣诲姞鍒版煡璇腑 diff --git a/main-business/src/main/resources/db/migration/postgresql/V20250604101800__create_table_production.sql b/main-business/src/main/resources/db/migration/postgresql/V20250604101800__create_table_production.sql index c1e6c28..a733470 100644 --- a/main-business/src/main/resources/db/migration/postgresql/V20250604101800__create_table_production.sql +++ b/main-business/src/main/resources/db/migration/postgresql/V20250604101800__create_table_production.sql @@ -10,7 +10,7 @@ equipment_depreciation DECIMAL(10, 2) NOT NULL, -- 璁惧鎶樻棫 purchase_price DECIMAL(10, 2) NOT NULL, -- 閲囪喘鍗曚环 total_cost DECIMAL(10, 2) NOT NULL, -- 鎬绘垚鏈� - producer_id VARCHAR(50), -- 鐢熶骇浜篿d + producer_id BIGINT, -- 鐢熶骇浜篿d producer VARCHAR(50), -- 鐢熶骇浜� production_date DATE, -- 鐢熶骇鏃ユ湡 diff --git a/main-business/src/main/resources/db/migration/postgresql/V20250604104500__create_table_pending_inventory.sql b/main-business/src/main/resources/db/migration/postgresql/V20250604104500__create_table_pending_inventory.sql index f686498..d51c775 100644 --- a/main-business/src/main/resources/db/migration/postgresql/V20250604104500__create_table_pending_inventory.sql +++ b/main-business/src/main/resources/db/migration/postgresql/V20250604104500__create_table_pending_inventory.sql @@ -12,7 +12,7 @@ registration_time TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP, -- 鐧昏鏃堕棿 price_excluding_tax VARCHAR(255), -- 鍗曚环锛堜笉鍚◣锛� total_price_excluding_tax VARCHAR(255), -- 鎬讳环锛堜笉鍚◣锛� - registrant_id VARCHAR(32), -- 鐧昏浜篒D + registrant_id BIGINT, -- 鐧昏浜篒D registration_date DATE, -- 鐧昏鏃ユ湡 supplier_id BIGINT, -- 渚涜揣鍟咺D coal_id BIGINT, -- 鐓ょID diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 72d0c91..a5063ac 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -129,4 +129,6 @@ * 鏌ヨ鎵�鏈夌敤鎴� */ List<SysUser> selectUserListAll(); + + List<SysUser> selectList(List<Long> registrantIds); } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index a41723f..8cbe2d3 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -144,8 +144,22 @@ <select id="selectUserListAll" resultType="com.ruoyi.common.core.domain.entity.SysUser"> select user_id, nick_name from sys_user where del_flag = '0' </select> + <select id="selectList" resultType="com.ruoyi.common.core.domain.entity.SysUser"> + SELECT user_id, nick_name FROM sys_user + <where> + <if test="list != null and list.size() > 0"> + user_id IN + <foreach item="id" collection="list" open="(" separator="," close=")"> + #{id} + </foreach> + </if> + <if test="list == null or list.size() == 0"> + 1=0 <!-- 绌哄垪琛ㄦ椂杩斿洖绌虹粨鏋� --> + </if> + </where> + </select> - <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> + <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> insert into sys_user( <if test="userId != null and userId != 0">user_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if> -- Gitblit v1.9.3