“zhuo”
2023-08-09 80b2025993331ac057b9a63210be2cb6ba124806
8-9提交代码
已修改3个文件
已添加6个文件
271 ■■■■■ 文件已修改
inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/PlanController.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspection-server/src/main/java/com/yuanchu/limslaboratory/mapper/PlanMapper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspection-server/src/main/java/com/yuanchu/limslaboratory/pojo/vo/PlanVo.java 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/PlanService.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspection-server/src/main/resources/mapper/PlanMapper.xml 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspection-server/src/main/resources/mapper/ReportMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sys/src/main/resources/application-dev.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sys/src/test/java/com/yuanchu/limslaboratory/SysApplicationTests.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/PlanController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,49 @@
package com.yuanchu.limslaboratory.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.pojo.vo.PlanVo;
import com.yuanchu.limslaboratory.service.PlanService;
import com.yuanchu.limslaboratory.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.*;
/**
 * <p>
 * å‰ç«¯æŽ§åˆ¶å™¨
 * </p>
 *
 * @author æ±Ÿè‹éµ·é›ç½‘络科技有限公司
 * @since 2023-08-09
 */
@Api(tags = "检验模块-->检验计划")
@RestController
@RequestMapping("/plan")
public class PlanController {
    @Resource
    private PlanService planService;
    @ApiOperation("查询检验计划")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "deviceId", value = "设备名称Id", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "beginTime", value = "检验开始时间", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "endTime", value = "检验结束时间", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "userId", value = "检验人", dataTypeClass = Integer.class)
    })
    @GetMapping("/selectAllPlan")
    public Result selectAllPlan(Integer deviceId, @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime, Integer userId) {
        List<PlanVo> planVoList = planService.selectAllPlan(deviceId, beginTime, endTime, userId);
        return Result.success(planVoList);
    }
}
inspection-server/src/main/java/com/yuanchu/limslaboratory/mapper/PlanMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package com.yuanchu.limslaboratory.mapper;
import com.yuanchu.limslaboratory.pojo.vo.PlanVo;
import java.util.Date;
import java.util.List;
public interface PlanMapper {
    /**
     * æŸ¥è¯¢æ£€éªŒè®¡åˆ’
     * @return
     */
    List<PlanVo> selectAllPlan(Integer deviceId, Date beginTime, Date endTime, Integer userId);
}
inspection-server/src/main/java/com/yuanchu/limslaboratory/pojo/vo/PlanVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
package com.yuanchu.limslaboratory.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
 * æ£€éªŒè®¡åˆ’VO
 */
@Data
public class PlanVo {
    @ApiModelProperty(value = "设备名称")
    @JsonSerialize
    private String device;
    @ApiModelProperty(value = "样品名称")
    @JsonSerialize
    private String samplename;
    @ApiModelProperty(value = "样品编号")
    @JsonSerialize
    private String sampleid;
    @ApiModelProperty(value = "规格型号")
    @JsonSerialize
    private String modelandspecification;
    @ApiModelProperty(value = "单位")
    @JsonSerialize
    private String unit;
    @ApiModelProperty(value = "数量")
    @JsonSerialize
    private Integer amount;
    @ApiModelProperty(value = "检验项目")
    @JsonSerialize
    private String checkproject;
    @ApiModelProperty(value = "检验人")
    @JsonSerialize
    private String checker;
    @ApiModelProperty(value = "计划工期")
    @JsonSerialize
    private Integer duration;
    @ApiModelProperty(value = "检验进度0:未分配, 50:检验中, 100:已完成")
    @JsonSerialize
    private Integer progress;
    @ApiModelProperty(value = "计划开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date starttime;
    @ApiModelProperty(value = "计划结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date finishtime;
    @ApiModelProperty(value = "设备id")
    @JsonSerialize
    private Integer deviceId;
    @ApiModelProperty(value = "检验人id")
    @JsonSerialize
    private Integer userId;
    //判断项目状态
    private Integer state;
}
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/PlanService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.yuanchu.limslaboratory.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.pojo.vo.PlanVo;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
 * <p>
 *  æœåŠ¡ç±»
 * </p>
 *
 * @author æ±Ÿè‹éµ·é›ç½‘络科技有限公司
 * @since 2023-08-09
 */
public interface PlanService {
    /**
     * æŸ¥è¯¢æ£€éªŒè®¡åˆ’
     * @return
     */
    List<PlanVo> selectAllPlan(Integer deviceId, Date beginTime, Date endTime, Integer userId);
}
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/PlanServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,61 @@
package com.yuanchu.limslaboratory.service.impl;
import com.yuanchu.limslaboratory.mapper.PlanMapper;
import com.yuanchu.limslaboratory.pojo.vo.PlanVo;
import com.yuanchu.limslaboratory.service.PlanService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
 * <p>
 * æœåŠ¡å®žçŽ°ç±»
 * </p>
 *
 * @author æ±Ÿè‹éµ·é›ç½‘络科技有限公司
 * @since 2023-08-09
 */
@Service
public class PlanServiceImpl implements PlanService {
    @Resource
    private PlanMapper planMapper;
    /**
     * æŸ¥è¯¢æ£€éªŒè®¡åˆ’
     *
     * @return
     */
    @Override
    public List<PlanVo> selectAllPlan(Integer deviceId, Date beginTime, Date endTime, Integer userId) {
        //获取数据库数据
        List<PlanVo> planVos = planMapper.selectAllPlan(deviceId, beginTime, endTime, userId);
        //添加计划工期和检验进度
        planVos.forEach(planVo -> {
            //添加检验进度
            //判断是否是已完成
            if (planVo.getState() != null) {
                planVo.setProgress(100);
            }
            //判断是否是未分配
            if (planVo.getCheckproject() == null) {
                planVo.setProgress(0);
            }
            //判断是否是进行中
            if (planVo.getState() == null && planVo.getCheckproject() != null) {
                planVo.setProgress(50);
            }
            //添加计划工期
            if (planVo.getFinishtime() != null && planVo.getStarttime() != null) {
                long startTimeInMillis = planVo.getStarttime().getTime();
                long endTimeInMillis = planVo.getFinishtime().getTime();
                long durationInMillis = endTimeInMillis - startTimeInMillis;
                long duration = durationInMillis / (1000 * 60 * 60);
                planVo.setDuration(Integer.valueOf((int) duration));
            }
        });
        return planVos;
    }
}
inspection-server/src/main/resources/mapper/PlanMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yuanchu.limslaboratory.mapper.PlanMapper">
    <!--查询检验计划-->
    <select id="selectAllPlan" resultType="com.yuanchu.limslaboratory.pojo.vo.PlanVo">
        select i.equipment_name device,
        im.name samplename,
        im.code sampleid,
        im.specifications modelandspecification,
        im.unit unit,
        im.num amount,
        ip.name checkproject,
        u.name checker,
        ip.start_time starttime,
        ip.end_time finishtime,
        i.id deviceId,
        u.id userId,
        ip.test_state state
        from instrument i
        left join (select ip.*
        from inspection_product ip
        right join (select instrument_id, max(ip.end_time) t
        from inspection_product ip
        group by instrument_id) it
        on ip.instrument_id = it.instrument_id and ip.end_time = it.t) ip
        on i.id = ip.instrument_id
        left join inspection_material im on im.id = ip.inspection_material_id
        left join user u on u.id = ip.user_id
        <where>
            <if test="deviceId != null">
                and i.id = #{deviceId}
            </if>
            <if test="userId != null">
                and u.id = #{userId}
            </if>
            <if test="beginTime != null and endTime != null">
                and ip.start_time between #{beginTime} and #{endTime}
            </if>
        </where>
    </select>
</mapper>
inspection-server/src/main/resources/mapper/ReportMapper.xml
@@ -39,6 +39,9 @@
        join inspection i on r.inspection_id = i.id
        join inspection_material im on i.id = im.inspection_id
        <where>
            <if test="status == null">
                and r.status in (0, 1)
            </if>
            <if test="status != null">
                and r.status = #{status}
            </if>
sys/src/main/resources/application-dev.yml
@@ -40,8 +40,8 @@
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/lims_laboratory?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
    username: root
    url: jdbc:mysql://192.168.110.209:3306/lims_laboratory?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
    username: user
    password: 123456
    druid:
      #   Druid数据源配置
sys/src/test/java/com/yuanchu/limslaboratory/SysApplicationTests.java
@@ -1,10 +1,18 @@
package com.yuanchu.limslaboratory;
import com.yuanchu.limslaboratory.pojo.vo.PlanVo;
import com.yuanchu.limslaboratory.service.PlanService;
import com.yuanchu.limslaboratory.utils.MyUtil;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.util.List;
@SpringBootTest
class SysApplicationTests {
    @Resource
    private PlanService planService;
    @Test
    void contextLoads() {
@@ -14,8 +22,8 @@
    }
    @Test
    void TT() {
        System.out.println(MyUtil.getTimeSixNumberCode("BG"));
        List<PlanVo> planVos = planService.selectAllPlan(null, null, null, null);
        planVos.forEach(System.out::println);
    }
}