Sfoglia il codice sorgente

v3项目-修改20250828

wwh 2 mesi fa
parent
commit
ff113b08e0

+ 6 - 6
app-admin/src/main/java/com/ruoyi/web/controller/app/EntranceInspectionController.java

@@ -38,7 +38,7 @@ public class EntranceInspectionController extends BaseController
     /**
      * 查询入场检验列表
      */
-    @PreAuthorize("@ss.hasPermi('app:entranceInspection:list')")
+//    @PreAuthorize("@ss.hasPermi('app:entranceInspection:list')")
     @GetMapping("/list")
     public TableDataInfo list(EntranceInspection entranceInspection)
     {
@@ -50,7 +50,7 @@ public class EntranceInspectionController extends BaseController
     /**
      * 导出入场检验列表
      */
-    @PreAuthorize("@ss.hasPermi('app:entranceInspection:export')")
+//    @PreAuthorize("@ss.hasPermi('app:entranceInspection:export')")
     @Log(title = "入场检验", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, EntranceInspection entranceInspection)
@@ -63,7 +63,7 @@ public class EntranceInspectionController extends BaseController
     /**
      * 获取入场检验详细信息
      */
-    @PreAuthorize("@ss.hasPermi('app:entranceInspection:query')")
+//    @PreAuthorize("@ss.hasPermi('app:entranceInspection:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
@@ -73,7 +73,7 @@ public class EntranceInspectionController extends BaseController
     /**
      * 新增入场检验
      */
-    @PreAuthorize("@ss.hasPermi('app:entranceInspection:add')")
+//    @PreAuthorize("@ss.hasPermi('app:entranceInspection:add')")
     @Log(title = "入场检验", businessType = BusinessType.INSERT)
     @PostMapping
     public AjaxResult add(@Validated  @RequestBody EntranceInspection entranceInspection)
@@ -85,7 +85,7 @@ public class EntranceInspectionController extends BaseController
     /**
      * 修改入场检验
      */
-    @PreAuthorize("@ss.hasPermi('app:entranceInspection:edit')")
+//    @PreAuthorize("@ss.hasPermi('app:entranceInspection:edit')")
     @Log(title = "入场检验", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@Validated @RequestBody EntranceInspection entranceInspection)
@@ -97,7 +97,7 @@ public class EntranceInspectionController extends BaseController
     /**
      * 删除入场检验
      */
-    @PreAuthorize("@ss.hasPermi('app:entranceInspection:remove')")
+//    @PreAuthorize("@ss.hasPermi('app:entranceInspection:remove')")
     @Log(title = "入场检验", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)

+ 72 - 3
app-admin/src/main/java/com/ruoyi/web/v2/v1/service/impl/JsCheckDeviceServiceImpl.java

@@ -2,19 +2,34 @@ package com.ruoyi.web.v2.v1.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.uuid.UUID;
 import com.ruoyi.web.v2.v1.entity.JsCheckDevice;
-import com.ruoyi.web.v2.v1.entity.JsWorkshop;
+import com.ruoyi.web.v2.v1.entity.JsDeviceMaintenance;
 import com.ruoyi.web.v2.v1.mapper.JsCheckDeviceMapper;
+import com.ruoyi.web.v2.v1.mapper.JsDeviceMaintenanceMapper;
 import com.ruoyi.web.v2.v1.service.IJsCheckDeviceService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.web.v2.v1.utils.PhoneNumberValidator;
+import com.ruoyi.web.v3.model.response.JsCheckDeviceDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.util.ObjectUtils;
+
+import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 import static com.ruoyi.common.core.domain.AjaxResult.error;
 import static com.ruoyi.common.core.domain.AjaxResult.success;
@@ -30,9 +45,14 @@ import static com.ruoyi.common.core.domain.AjaxResult.success;
 @Service
 public class JsCheckDeviceServiceImpl extends ServiceImpl<JsCheckDeviceMapper, JsCheckDevice> implements IJsCheckDeviceService {
 
+    private static final Logger logger = LoggerFactory.getLogger(JsCheckDeviceServiceImpl.class);
+
     @Autowired
     private JsCheckDeviceMapper checkDeviceMapper;
 
+    @Resource
+    private JsDeviceMaintenanceMapper deviceMaintenanceMapper;
+
     @Override
     public AjaxResult add(JsCheckDevice checkDevice) {
         String deviceName = checkDevice.getDeviceName();
@@ -89,11 +109,60 @@ public class JsCheckDeviceServiceImpl extends ServiceImpl<JsCheckDeviceMapper, J
         Page<JsCheckDevice> page = new Page<>(pageNum, pageSize);
         queryWrapper.like(StringUtils.isNotEmpty(deviceNum), "device_num", deviceNum).or()
                 .like(StringUtils.isNotEmpty(deviceName), "device_name", deviceName);
-        return success(checkDeviceMapper.selectPage(page, queryWrapper));
+        return success(checkDeviceMapper.selectPage(page, queryWrapper)
+                .getRecords()
+                .stream()
+                .filter(Objects::nonNull)  // 过滤非空记录
+                .map(this::fixMaintenanceDate)
+                .collect(Collectors.toList()));
     }
 
     @Override
     public AjaxResult listAll() {
         return success(checkDeviceMapper.selectList(null));
     }
+
+    /**
+     * 计算维护日期,并补充致返回数据集
+     */
+    private JsCheckDeviceDTO fixMaintenanceDate(JsCheckDevice checkDevice) {
+        JsCheckDeviceDTO result = new JsCheckDeviceDTO();
+        BeanUtils.copyProperties(checkDevice, result);
+        if(ObjectUtils.isEmpty(checkDevice.getInvestmentTime()) ||
+                ( ObjectUtils.isEmpty(checkDevice.getDays()) || checkDevice.getDays() == 0) ) {
+            //如果投入使用日期或维护区间是无效值,那么不计算,直接原样返回
+            return result;
+        }
+        try {
+            LocalDateTime baseDate = LocalDateTime.parse(checkDevice.getInvestmentTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+            long cycles = ChronoUnit.DAYS.between(baseDate, LocalDateTime.now()) / checkDevice.getDays();
+            result.setLastDueDate(baseDate.plusDays(cycles * checkDevice.getDays()));
+            result.setNextDueDate(result.getLastDueDate().plusDays(checkDevice.getDays()));
+            //查询维护登记记录,以便判断是否给出需要维护的提示
+            List<JsDeviceMaintenance> records = deviceMaintenanceMapper.selectList(
+                    Wrappers.<JsDeviceMaintenance>lambdaQuery()
+                            .eq(JsDeviceMaintenance::getDeviceNum, checkDevice.getDeviceNum())
+                            .eq(JsDeviceMaintenance::getDeviceName, checkDevice.getDeviceName())
+                            .orderByDesc(JsDeviceMaintenance::getId).last("LIMIT 1"));
+            if(!ObjectUtils.isEmpty(records) && !ObjectUtils.isEmpty(records.get(0).getMaintenanceTime())) {
+                LocalDateTime maintenanceTime = LocalDateTime.parse(records.get(0).getMaintenanceTime(),
+                        DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                if(maintenanceTime.toLocalDate().isBefore(result.getLastDueDate().toLocalDate())) {
+                    //维护日期在最后约定维护日之前,说明当前需要维护
+                    result.setNeedCareImmediately(Boolean.TRUE);
+                }
+            }else {
+                //查询不到任何维护记录,直接判断当前时间和维护日期
+                if(LocalDate.now().isAfter(result.getLastDueDate().toLocalDate())) {
+                    result.setNeedCareImmediately(Boolean.TRUE);
+                }
+            }
+        }catch (Exception e) {
+            logger.error("根据投入使用日期‘ {} ’计算约定维护日发生异常...", checkDevice.getInvestmentTime());
+        }
+        return result;
+    }
+
+
+
 }

+ 41 - 0
app-admin/src/main/java/com/ruoyi/web/v3/model/response/JsCheckDeviceDTO.java

@@ -0,0 +1,41 @@
+package com.ruoyi.web.v3.model.response;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.web.v2.v1.entity.JsCheckDevice;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * v2.0设备档案管理
+ * </p>
+ *
+ * @author author
+ * @since 2025-05-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="JsCheckDeviceDTO对象", description="v3.0设备档案管理")
+public class JsCheckDeviceDTO extends JsCheckDevice implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "上次约定维护日")
+    private LocalDateTime lastDueDate;
+
+    @ApiModelProperty(value = "下次约定维护日")
+    private LocalDateTime nextDueDate;
+
+    @ApiModelProperty(value = "当前是否需要维护")
+    private boolean needCareImmediately = false;
+}

+ 12 - 0
app-system/src/main/java/com/ruoyi/app/domain/PigCategory.java

@@ -25,6 +25,10 @@ public class PigCategory extends BaseEntity
     @Excel(name = "品种名称")
     private String categoryName;
 
+    /** 默认重量 */
+    @Excel(name = "默认重量")
+    private String defaultWeight;
+
     /** 删除标志 */
     private String delFlag;
 
@@ -50,6 +54,14 @@ public class PigCategory extends BaseEntity
         return categoryName;
     }
 
+    public String getDefaultWeight() {
+        return defaultWeight;
+    }
+
+    public void setDefaultWeight(String defaultWeight) {
+        this.defaultWeight = defaultWeight;
+    }
+
     public void setDelFlag(String delFlag) 
     {
         this.delFlag = delFlag;

+ 5 - 1
app-system/src/main/resources/mapper/app/PigCategoryMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="PigCategory" id="PigCategoryResult">
         <result property="id"    column="id"    />
         <result property="categoryName"    column="category_name"    />
+        <result property="defaultWeight"    column="default_weight"  />
         <result property="createTime"    column="create_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateTime"    column="update_time"    />
@@ -15,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectPigCategoryVo">
-        select id, category_name, create_time, create_by, update_time, update_by, del_flag from pig_category
+        select id, category_name, default_weight, create_time, create_by, update_time, update_by, del_flag from pig_category
     </sql>
 
     <select id="selectPigCategoryList" parameterType="PigCategory" resultMap="PigCategoryResult">
@@ -38,12 +39,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into pig_category
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="categoryName != null and categoryName != ''">category_name,</if>
+            <if test="defaultWeight != null and defaultWeight != ''">default_weight,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createBy != null">create_by,</if>
             del_flag
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="categoryName != null and categoryName != ''">#{categoryName},</if>
+            <if test="defaultWeight != null and defaultWeight != ''">#{defaultWeight},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createBy != null">#{createBy},</if>
             '0'
@@ -56,6 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="defaultWeight != null">default_weight = #{defaultWeight},</if>
         </trim>
         where id = #{id}
     </update>

+ 4 - 1
sql/v3_biz_20250814.sql

@@ -491,4 +491,7 @@ ALTER TABLE `js_instrument_maintenance`  ADD COLUMN `specification_no_group` VAR
     ADD COLUMN `create_by` VARCHAR(255) DEFAULT NULL COMMENT '创建者',
     ADD COLUMN `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
     ADD COLUMN `update_by` VARCHAR(255) DEFAULT NULL COMMENT '更新者',
-    ADD COLUMN `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间';
+    ADD COLUMN `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间';
+
+-- 生猪品种管理新增品种的默认重量
+ALTER TABLE `pig_category`  ADD COLUMN `default_weight` INT (7) DEFAULT 0 COMMENT '默认重量';