¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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); |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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> |
| | |
| | | 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> |
| | |
| | | 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æ°æ®æºé
ç½® |
| | |
| | | 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() { |
| | |
| | | } |
| | | @Test |
| | | void TT() { |
| | | System.out.println(MyUtil.getTimeSixNumberCode("BG")); |
| | | |
| | | List<PlanVo> planVos = planService.selectAllPlan(null, null, null, null); |
| | | planVos.forEach(System.out::println); |
| | | } |
| | | } |
| | | |