main-business/src/main/java/com/ruoyi/business/controller/OfficialInventoryController.java
@@ -8,6 +8,7 @@ import com.ruoyi.business.vo.OfficialInventoryVo; import com.ruoyi.common.core.domain.R; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -23,6 +24,7 @@ @RestController @AllArgsConstructor @Slf4j @RequestMapping("/officialInventory") public class OfficialInventoryController { @@ -61,6 +63,7 @@ return R.ok(officialInventoryService.editOfficial(officialInventoryDto)); } /** * åå¹¶ */ main-business/src/main/java/com/ruoyi/business/dto/OfficialInventoryDto.java
@@ -22,6 +22,6 @@ private String supplierCoal; //ä¾åºå + ç ¤ç§ private List<CoalValue> coalValues; //åªè´¨æ¹æ¡åæ®µå¼ private List<Map<String, String>> coalValues; //åªè´¨æ¹æ¡åæ®µå¼ } main-business/src/main/java/com/ruoyi/business/entity/EquipmentUsageRecord.java
@@ -44,7 +44,7 @@ @TableField(value = "department_id") private Long departmentId; /** * 设å¤ç¶æï¼æ£å¸¸/æ é/ç»´ä¿®ä¸ï¼ * 设å¤ç¶æï¼ä½¿ç¨ä¸ï¼å·²å½è¿ï¼ */ @TableField(value = "equipment_status") private String equipmentStatus; main-business/src/main/java/com/ruoyi/business/entity/OfficialInventory.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; @@ -19,8 +20,6 @@ @Data @TableName("official_inventory") public class OfficialInventory extends MyBaseEntity { private static final long serialVersionUID = 1L; /** * 主é®ID @@ -88,6 +87,7 @@ * ç»è®°æ¥æ */ @TableField(value = "registration_date") @JsonFormat(pattern = "yyyy-MM-dd") private LocalDate registrationDate; /** main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentManagementServiceImpl.java
@@ -11,11 +11,15 @@ import com.ruoyi.business.service.EquipmentManagementService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.business.vo.EquipmentManagementVo; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanUtils; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; import java.beans.Transient; import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -109,7 +113,18 @@ } @Override @Transactional(isolation = Isolation.REPEATABLE_READ) public int delByIds(Long[] ids) { // 1. æ£æ¥è®¾å¤æ¯å¦æ£å¨ä½¿ç¨ï¼æ·»å è¡é for updateï¼ List<EquipmentUsageRecord> records = equipmentUsageRecordMapper.selectList( new LambdaQueryWrapper<EquipmentUsageRecord>() .in(EquipmentUsageRecord::getEquipmentId, Arrays.asList(ids)) .last("FOR UPDATE") // æ·»å è¡éï¼é宿¥è¯¢ç»æ ); if (!records.isEmpty()) { throw new BaseException("è®¾å¤æ£å¨ä½¿ç¨ä¸ï¼è¯·æ ¸å¯¹!"); } else { return equipmentManagementMapper.deleteByIds(Arrays.asList(ids)); } } } main-business/src/main/java/com/ruoyi/business/service/impl/EquipmentUsageRecordServiceImpl.java
@@ -20,6 +20,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -92,6 +93,12 @@ @Override @Transactional(rollbackFor = Exception.class) public int addOrEditUsageRecord(EquipmentUsageRecordDto equipmentUsageRecordDto) { // åæ°æ ¡éª if (equipmentUsageRecordDto == null) { throw new IllegalArgumentException("设å¤ä½¿ç¨è®°å½åæ°ä¸è½ä¸ºç©º"); } // å¤å¶å±æ§å°å®ä½å¯¹è±¡ EquipmentUsageRecord equipmentUsageRecord = new EquipmentUsageRecord(); BeanUtils.copyProperties(equipmentUsageRecordDto, equipmentUsageRecord); @@ -99,12 +106,13 @@ Long equipmentId = equipmentUsageRecordDto.getEquipmentId(); Integer newUsageQuantity = equipmentUsageRecordDto.getUsageQuantity(); // æ¥è¯¢è®¾å¤ä¿¡æ¯ï¼å¸¦ä¹è§éçæ¬å·ï¼ // æ¥è¯¢è®¾å¤ä¿¡æ¯ EquipmentManagement equipment = equipmentManagementMapper.selectById(equipmentId); if (equipment == null) { throw new RuntimeException("设å¤ä¸åå¨"); } // æ°å¢è®°å½é»è¾ if (Objects.isNull(equipmentUsageRecordDto.getId())) { // æ£æ¥åºåæ¯å¦å è¶³ if (equipment.getQuantity() < newUsageQuantity) { @@ -115,9 +123,18 @@ equipment.setQuantity(equipment.getQuantity() - newUsageQuantity); equipmentManagementMapper.updateById(equipment); // å建é¢ç¨è®°å½ // 设置使ç¨å¼å§æ¶é´ä¸ºå½åæ¶é´ equipmentUsageRecord.setUsageStartTime(LocalDate.now()); // å¦æç¶æä¸º1(å·²å½è¿)ï¼åè®¾ç½®ç»ææ¶é´ if ("1".equals(equipmentUsageRecordDto.getEquipmentStatus())) { equipmentUsageRecord.setUsageEndTime(LocalDate.now()); } return equipmentUsageRecordMapper.insert(equipmentUsageRecord); } else { } // æ´æ°è®°å½é»è¾ else { // 1. æ¥è¯¢åé¢ç¨è®°å½ EquipmentUsageRecord originalRecord = equipmentUsageRecordMapper.selectById(equipmentUsageRecordDto.getId()); if (originalRecord == null) { @@ -128,7 +145,7 @@ int quantityDelta = newUsageQuantity - originalRecord.getUsageQuantity(); if (quantityDelta != 0) { // 3. æ£æ¥è°æ´ååºåæ¯å¦å è¶³ï¼èèå¢å ååå°ä¸¤ç§æ åµï¼ // 3. æ£æ¥è°æ´ååºåæ¯å¦å è¶³ int newInventory = equipment.getQuantity() - quantityDelta; if (newInventory < 0) { throw new RuntimeException("åºåä¸è¶³ï¼è°æ´ååºåå°ä¸ºï¼" + newInventory); @@ -141,7 +158,13 @@ } } // 5. æ´æ°é¢ç¨è®°å½ // 5. å¦æç¶æå为1(å·²å½è¿)ï¼åè®¾ç½®ç»ææ¶é´ä¸ºå½åæ¶é´ if ("1".equals(equipmentUsageRecordDto.getEquipmentStatus()) && (originalRecord.getEquipmentStatus() == null || !"1".equals(originalRecord.getEquipmentStatus()))) { equipmentUsageRecord.setUsageEndTime(LocalDate.now()); } // 6. æ´æ°é¢ç¨è®°å½ return equipmentUsageRecordMapper.updateById(equipmentUsageRecord); } } main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
@@ -391,7 +391,15 @@ dto.setSupplierCoal(supply.getSupplierName() + " - " + coalInfo.getCoal()); } // è®¾ç½®ç ¤è´¨æ°æ® dto.setCoalValues(coalValuesMap.getOrDefault(inventory.getCoalPlanId(), Collections.emptyList())); dto.setCoalValues(coalValuesMap.getOrDefault(inventory.getCoalPlanId(), Collections.emptyList()) .stream() .map(coalValue -> { Map<String, String> map = new HashMap<>(); map.put("fieldName", coalValue.getFieldName()); map.put("coalValue", coalValue.getCoalValue()); return map; }) .collect(Collectors.toList())); return dto; }) .collect(Collectors.toList()); main-business/src/main/resources/db/migration/postgresql/V20250701142700__create_table_equipment_management.sql
@@ -7,7 +7,7 @@ equipment_name VARCHAR(100) NOT NULL, -- 设å¤åç§° quantity INT NOT NULL DEFAULT 0, -- æ°é specification VARCHAR(50) NOT NULL, -- è§æ ¼åå· usage_status VARCHAR(20) NOT NULL, -- 使ç¨ç¶æ usage_status VARCHAR(20), -- 使ç¨ç¶æ using_department VARCHAR(50) NOT NULL, -- 使ç¨é¨é¨ user_id BIGINT, -- 使ç¨äºº storage_location VARCHAR(100) NOT NULL, -- åæ¾ä½ç½® pom.xml
@@ -272,12 +272,6 @@ <version>${freemarker.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>2.0.38</version> <!-- éç¨ææ°ç¨³å®çæ¬ --> </dependency> </dependencies> <modules> ruoyi-admin/src/main/java/com/ruoyi/PlusCodeGenerator.java
@@ -24,7 +24,6 @@ * åè½ï¼æ ¹æ®æ°æ®åºè¡¨ç»æèªå¨çæEntityãMapperãServiceãControllerç代ç * ä¿®å¤ï¼è§£å³Freemarker模æ¿ä¸generateServiceåé缺失çé®é¢ */ @SpringBootApplication public class PlusCodeGenerator { // æ°æ®åºé ç½® ruoyi-admin/src/main/resources/application-druid.yml.example1
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,84 @@ # æ°æ®æºé ç½® spring: datasource: type: com.alibaba.druid.pool.DruidDataSource # driverClassName: com.mysql.cj.jdbc.Driver # mysqlé©±å¨ driverClassName: org.postgresql.Driver druid: # ä¸»åºæ°æ®æº master: # mysql # url: jdbc:mysql://124.220.0.228:3300/ruoyi-java?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # pg # url: jdbc:postgresql://localhost:5433/ruoyi-zd url: jdbc:postgresql://localhost:5433/zd-01 username: postgres password: 123456 # ä»åºæ°æ®æº slave: # 仿°æ®æºå¼å ³/é»è®¤å ³é enabled: false url: username: password: # åå§è¿æ¥æ° initialSize: 5 # æå°è¿æ¥æ± æ°é minIdle: 10 # æå¤§è¿æ¥æ± æ°é maxActive: 20 # é ç½®è·åè¿æ¥çå¾ è¶ æ¶çæ¶é´ maxWait: 60000 # é ç½®è¿æ¥è¶ æ¶æ¶é´ connectTimeout: 30000 # é ç½®ç½ç»è¶ æ¶æ¶é´ socketTimeout: 60000 # é ç½®é´éå¤ä¹ æè¿è¡ä¸æ¬¡æ£æµï¼æ£æµéè¦å ³éç空é²è¿æ¥ï¼å使¯æ¯«ç§ timeBetweenEvictionRunsMillis: 60000 # é ç½®ä¸ä¸ªè¿æ¥å¨æ± 䏿å°çåçæ¶é´ï¼å使¯æ¯«ç§ minEvictableIdleTimeMillis: 300000 # é ç½®ä¸ä¸ªè¿æ¥å¨æ± 䏿大çåçæ¶é´ï¼å使¯æ¯«ç§ maxEvictableIdleTimeMillis: 900000 # é ç½®æ£æµè¿æ¥æ¯å¦ææ validationQuery: SELECT VERSION() testWhileIdle: true testOnBorrow: false testOnReturn: false webStatFilter: enabled: true statViewServlet: enabled: true # 设置ç½ååï¼ä¸å¡«åå 许ææè®¿é® allow: url-pattern: /druid/* # æ§å¶å°ç®¡çç¨æ·ååå¯ç login-username: ruoyi login-password: 123456 filter: stat: enabled: true # æ ¢SQLè®°å½ log-slow-sql: true slow-sql-millis: 1000 merge-sql: true wall: config: multi-statement-allow: true # å ¬å¸æå¡å¨ minio minio: # endpoint: http://114.132.189.42/ # port: 7019 # secure: false # accessKey: admin # secretKey: 12345678 # preview-expiry: 24 # é¢è§å°åé»è®¤24å°æ¶ # default-bucket: ruoyi-zd # é»è®¤å卿¡¶ endpoint: 127.0.0.1 port: 9002 secure: false accessKey: admin secretKey: 12345678 preview-expiry: 24 # é¢è§å°åé»è®¤24å°æ¶ default-bucket: ruoyi-zd # é»è®¤å卿¡¶ ruoyi-admin/src/main/resources/application-prod.yml.example
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,76 @@ # æ°æ®æºé ç½® spring: datasource: type: com.alibaba.druid.pool.DruidDataSource # driverClassName: com.mysql.cj.jdbc.Driver # mysqlé©±å¨ driverClassName: org.postgresql.Driver druid: # ä¸»åºæ°æ®æº master: # mysql # url: jdbc:mysql://124.220.0.228:3300/ruoyi-java?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # pg url: jdbc:postgresql://114.132.189.42:5432/zd-test username: postgres password: bYD#nM+-BiLb # ä»åºæ°æ®æº slave: # 仿°æ®æºå¼å ³/é»è®¤å ³é enabled: false url: username: password: # åå§è¿æ¥æ° initialSize: 5 # æå°è¿æ¥æ± æ°é minIdle: 10 # æå¤§è¿æ¥æ± æ°é maxActive: 20 # é ç½®è·åè¿æ¥çå¾ è¶ æ¶çæ¶é´ maxWait: 60000 # é ç½®è¿æ¥è¶ æ¶æ¶é´ connectTimeout: 30000 # é ç½®ç½ç»è¶ æ¶æ¶é´ socketTimeout: 60000 # é ç½®é´éå¤ä¹ æè¿è¡ä¸æ¬¡æ£æµï¼æ£æµéè¦å ³éç空é²è¿æ¥ï¼å使¯æ¯«ç§ timeBetweenEvictionRunsMillis: 60000 # é ç½®ä¸ä¸ªè¿æ¥å¨æ± 䏿å°çåçæ¶é´ï¼å使¯æ¯«ç§ minEvictableIdleTimeMillis: 300000 # é ç½®ä¸ä¸ªè¿æ¥å¨æ± 䏿大çåçæ¶é´ï¼å使¯æ¯«ç§ maxEvictableIdleTimeMillis: 900000 # é ç½®æ£æµè¿æ¥æ¯å¦ææ validationQuery: SELECT VERSION() testWhileIdle: true testOnBorrow: false testOnReturn: false webStatFilter: enabled: true statViewServlet: enabled: true # 设置ç½ååï¼ä¸å¡«åå 许ææè®¿é® allow: url-pattern: /druid/* # æ§å¶å°ç®¡çç¨æ·ååå¯ç login-username: ruoyi login-password: 123456 filter: stat: enabled: true # æ ¢SQLè®°å½ log-slow-sql: true slow-sql-millis: 1000 merge-sql: true wall: config: multi-statement-allow: true # å ¬å¸æå¡å¨ minio minio: endpoint: http://114.132.189.42/ port: 7019 secure: false accessKey: admin secretKey: 12345678 preview-expiry: 24 # é¢è§å°åé»è®¤24å°æ¶ default-bucket: ruoyi-zd # é»è®¤å卿¡¶