소스 검색

新增气瓶新项目

hecheng 3 년 전
부모
커밋
0a4d6f5f7f

+ 128 - 0
zd-modules/zd-bottle-parent/zd-bottle-api/src/main/java/com/zd/bottle/vo/UseRecordVo.java

@@ -0,0 +1,128 @@
+package com.zd.bottle.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.zd.common.core.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 使用记录对象 qp_use_record
+ * @author hanson
+ */
+@ApiModel("使用记录视图类")
+@Data
+@Accessors(chain = true)
+@ToString(callSuper = true)
+@EqualsAndHashCode(callSuper = false)
+public class UseRecordVo {
+    /**
+     * 主键id,数据唯一标识
+     */
+    @ApiModelProperty(value = "${comment}")
+    private Long id;
+    private Long userId;
+    /**
+     * 联系人
+     */
+    @Excel(name = "使用人")
+    @ApiModelProperty(value = "使用人")
+    private String contacts;
+    /**
+     * 联系方式
+     */
+    @Excel(name = "联系方式")
+    @ApiModelProperty(value = "联系方式")
+    private String phone;
+    /**
+     * 实验地点
+     */
+    @Excel(name = "实验地点")
+    @ApiModelProperty(value = "实验地点")
+    private String location;
+    /**
+     * 气瓶入库ID
+     */
+    @ApiModelProperty(value = "气瓶入库ID")
+    private Long storageId;
+    /**
+     * 气体名称(冗余字段)
+     */
+    @Excel(name = "气瓶名称")
+    @ApiModelProperty(value = "气体名称")
+    private String airName;
+
+    /**
+     * 使用前照片
+     */
+    @ApiModelProperty(value = "使用前照片")
+    private String beforeUsePic;
+    /**
+     * 使用前气压
+     */
+    @ApiModelProperty(value = "使用前气压")
+    private BigDecimal beforeUse;
+    /**
+     * 使用后照片
+     */
+    @ApiModelProperty(value = "使用后照片")
+    private String afterUsePic;
+    /**
+     * 使用后气压
+     */
+    @ApiModelProperty(value = "使用后气压")
+    private BigDecimal afterUse;
+
+    /**
+     * 使用前气压导出字段
+     */
+    @Excel(name = "使用前气压")
+    @ApiModelProperty(value = "使用前气压")
+    private String beforeUseValue;
+    /**
+     * 使用后气压导出字段
+     */
+    @Excel(name = "使用后气压")
+    @ApiModelProperty(value = "使用后气压")
+    private String afterUseValue;
+    /**
+     * 使用量
+     */
+    @ApiModelProperty(value = "使用量")
+    private BigDecimal amount;
+    /**
+     * 使用时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "使用时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "使用时间")
+    private Date useTime;
+    /**
+     * 归还时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "归还时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "归还时间")
+    private Date backTime;
+
+    /**
+     * 实验室id
+     */
+    @ApiModelProperty(value = "实验室id")
+    private Long subjectId;
+
+    @ApiModelProperty(value = "数量")
+    private Integer countNumber;
+
+    @ApiModelProperty(value = "格式化后的使用时间")
+    private String useTimeApp;
+
+    @ApiModelProperty(value = "格式化后的归还时间")
+    private String backTimeApp;
+}

+ 6 - 0
zd-modules/zd-bottle-parent/zd-bottle/pom.xml

@@ -13,6 +13,12 @@
 
     <dependencies>
 
+        <!-- SpringCloud Alibaba Nacos -->
+        <dependency>
+            <groupId>com.alibaba.cloud</groupId>
+            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        </dependency>
+
         <!-- SpringCloud Alibaba Nacos Config -->
         <dependency>
             <groupId>com.alibaba.cloud</groupId>

+ 246 - 1
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/controller/UseRecordController.java

@@ -1,9 +1,31 @@
 package com.zd.bottle.controller;
 
+import cn.hutool.core.collection.CollUtil;
 import com.zd.bottle.domain.UseRecord;
+import com.zd.bottle.service.UseRecordService;
+import com.zd.bottle.vo.UseRecordVo;
+import com.zd.common.core.utils.DateUtils;
+import com.zd.common.core.utils.poi.ExcelUtil;
+import com.zd.common.core.web.controller.BaseController;
+import com.zd.common.core.web.page.TableDataInfo;
+import com.zd.common.log.annotation.Log;
+import com.zd.common.log.enums.BusinessType;
+import com.zd.common.security.annotation.PreAuthorize;
+import com.zd.common.security.service.TokenService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import com.zd.common.core.web.controller.BaseController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -16,5 +38,228 @@ import com.zd.common.core.web.controller.BaseController;
 @RestController
 @RequestMapping("/useRecord")
 public class UseRecordController extends BaseController<UseRecord> {
+    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
+
+    @Autowired
+    private UseRecordService useRecordService;
+
+    @Autowired
+    private TokenService tokenService;
+
+    /**
+     * 查询使用记录列表
+     */
+    @PreAuthorize(hasPermi = "airbottle:use:record:list")
+    @GetMapping("/list")
+    @ApiOperation(value = "查询使用记录列表")
+    public TableDataInfo<UseRecordVo> list(UseRecord useRecord) {
+        startPage("use_time","descending");
+        List<UseRecord> records =useRecordService.getList(useRecord);
+        TableDataInfo<UseRecord> dataTable = getDataTable(records);
+        TableDataInfo<UseRecordVo> info = new TableDataInfo<>();
+        if (CollUtil.isNotEmpty(records)) {
+            BeanUtils.copyProperties(dataTable, info);
+            List<UseRecordVo> recordVos = useRecordService.getListVo(records);
+            info.setRows(recordVos);
+        }
+        return info;
+    }
+
+//    /**
+//     * 信息统计查询使用记录列表
+//     * @param storageId 库存主ID
+//     * @return 集合对象
+//     */
+//    @GetMapping("/bottle/list/{storageId}")
+//    @ApiOperation(value = "信息统计查询使用记录列表")
+//    public List<QpUseRecordVo> bottleList(@PathVariable Long storageId) {
+//        return qpUseRecordService.getBottleInfoByStorageId(storageId);
+//    }
 
+    /**
+     * 导出使用记录列表
+     */
+    @ApiOperation(value = "导出使用记录列表")
+    @Log(title = "使用记录", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, UseRecord useRecord) throws IOException {
+        List<UseRecord> records =useRecordService.getList(useRecord);
+        List<UseRecordVo> info = new ArrayList<>();
+        if (CollUtil.isNotEmpty(records)) {
+            info = useRecordService.getListVo(records);
+            info.forEach(i-> {
+                BigDecimal afterUse = i.getAfterUse();
+                i.setBeforeUseValue(i.getBeforeUse().stripTrailingZeros().toPlainString()+"MPa");
+                if (afterUse!=null){
+                    i.setAfterUseValue(afterUse.stripTrailingZeros().toPlainString()+"MPa");
+                }
+            });
+        }
+        ExcelUtil<UseRecordVo> util = new ExcelUtil<>(UseRecordVo.class);
+        util.exportExcel(response, info, "使用记录数据" + DateUtils.getDate());
+    }
+//
+//    /**
+//     * 小程序端获取使用记录详细信息
+//     */
+//    @ApiOperation(value = "小程序端获取使用记录详细信息")
+//    @GetMapping(value = "/{id}")
+//    public ResultData<QpUseRecordVo> getInfo(@PathVariable("id") Long id) {
+//        return ResultData.success(qpUseRecordService.selectQpUseRecordById(id));
+//    }
+//
+//    /**
+//     * 管理端端获取使用记录详细信息
+//     */
+//    @ApiOperation(value = "管理端端获取使用记录详细信息")
+//    @GetMapping(value = "/bottle/{id}")
+//    public ResultData<WebUseRecordVo> getBottleInfo(@PathVariable("id") Long id) {
+//        return ResultData.success(qpUseRecordService.getBottleInfo(id));
+//    }
+//
+//    /**
+//     * 信息统计管理端端获取气瓶使用记录详细信息
+//     */
+//    @ApiOperation(value = "信息统计管理端端获取气瓶使用记录详细信息")
+//    @GetMapping(value = "/bottle/record/{storageId}")
+//    public ResultData<WebUseRecordVo> getBottleRecord(@PathVariable("storageId") Long storageId) {
+//        return ResultData.success(qpUseRecordService.getBottleRecord(storageId));
+//    }
+//
+//    /**
+//     * 出入库信息统计
+//     */
+//    @ApiOperation(value = "出入库信息统计")
+//    @GetMapping(value = "/calcRepertory")
+//    public ResultData<List<AirAmount>> calcRepertory(String airName) {
+//        return ResultData.success(qpUseRecordService.calcRepertory(airName));
+//    }
+//
+//    /**
+//     * 用气量信息统计
+//     */
+//    @ApiOperation(value = "用气量信息统计")
+//    @GetMapping(value = "/calcAmount")
+//    public ResultData<List<AirAmount>> calcAmount(String airName) {
+//        return ResultData.success(qpUseRecordService.calcAmount(airName));
+//    }
+//
+//    /**
+//     * 气瓶申请统计
+//     */
+//    @ApiOperation(value = "气瓶申请统计")
+//    @GetMapping(value = "/calcApply")
+//    public ResultData<List<AirAmount>> calcApply(String airName) {
+//        return ResultData.success(qpUseRecordService.calcApply(airName));
+//    }
+//
+//    /**
+//     * 新增使用登记
+//     * value 说明:
+//     * 1:正常状态
+//     * 2:气瓶余量接近安全值
+//     * 3:用户没有用气资格
+//     * 4:气瓶正在使用中
+//     */
+//    @ApiOperation(value = "新增使用登记")
+//    @Log(title = "新增使用登记", businessType = BusinessType.INSERT)
+//    @PostMapping
+//    public ResultData<Integer> add(@RequestBody QpUseRecordDto recordDto) {
+//        return ResultData.success(qpUseRecordService.insertQpUseRecord(recordDto));
+//    }
+//
+//    /**
+//     * 归还登记
+//     */
+//    @ApiOperation(value = "归还登记")
+//    @Log(title = "归还登记", businessType = BusinessType.UPDATE)
+//    @PutMapping
+//    public ResultData<Boolean> edit(@RequestBody QpUseRecord qpUseRecord) {
+//        return ResultData.result(qpUseRecordService.updateQpUseRecord(qpUseRecord));
+//    }
+//
+//    /***
+//     * 查询使用记录
+//     */
+//    @ApiOperation(value = "查询使用记录")
+//    @GetMapping(value = "/getUseDetails")
+//    public TableDataInfo<QpUseRecord> getUseDetails( QpUseRecord qpUseRecord) {
+//        startPage();
+//        List<QpUseRecordVo> list =  qpUseRecordService.getUseDetailsList(qpUseRecord);
+//        return getDataTable(list);
+//    }
+//
+//    /**
+//     * 当前登录人 申请并入库的气瓶使用记录
+//     */
+//    @ApiOperation(value = "当前登录人 申请并入库的气瓶使用记录")
+//    @GetMapping(value = "/getUseDetailsByUserId")
+//    public TableDataInfo<QpUseRecord> getUseDetailsByUserId(QpUseRecord qpUseRecord) {
+//        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+//        List<QpUseRecordVo> list =  qpUseRecordService.getUseDetailsListByUserId(qpUseRecord);
+//        qpUseRecord.setUserId(sysUser.getUserId());
+//        startPage();
+//        return getDataTable(list);
+//    }
+//
+//    /***
+//     * 查询某个气瓶的使用记录汇总
+//     */
+//    @ApiOperation(value = "查询某个气瓶的使用记录汇总")
+//    @GetMapping(value = "/getUseDetailsByStorageId")
+//    public TableDataInfo<QpUseRecordVo> getUseDetailsByStorageId(QpUseRecordVo qpUseRecordVo) {
+//        startPage();
+//        List<QpUseRecordVo> list =  qpUseRecordService.getUseDetailsListByStorageId(qpUseRecordVo);
+//        return new TableDataInfo<QpUseRecordVo>().getDataTable(list);
+//    }
+//
+//    /***
+//     * 查询使用记录-小程序端
+//     */
+//    @ApiOperation(value = "查询使用记录")
+//    @GetMapping(value = "/getUseDetailsApp")
+//    public TableDataInfo<QpUseRecord> getUseDetailsApp( QpUseRecord qpUseRecord) {
+//        startPage();
+//        List<QpUseRecordVo> list =  qpUseRecordService.getUseDetailsList(qpUseRecord);
+//        for (QpUseRecordVo useRecordVo:list) {
+//            useRecordVo.setUseTimeApp(useRecordVo.getUseTime()!=null?sdf.format(useRecordVo.getUseTime()):null);
+//            useRecordVo.setBackTimeApp(useRecordVo.getBackTime()!=null?sdf.format(useRecordVo.getBackTime()):null);
+//        }
+//        return getDataTable(list);
+//    }
+//
+//    /**
+//     * 当前登录人 申请并入库的气瓶使用记录-小程序端
+//     */
+//    @ApiOperation(value = "当前登录人 申请并入库的气瓶使用记录-小程序端")
+//    @GetMapping(value = "/getUseDetailsByUserIdApp")
+//    public TableDataInfo<QpUseRecord> getUseDetailsByUserIdApp(QpUseRecord qpUseRecord) {
+//        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+//        qpUseRecord.setUserId(sysUser.getUserId());
+//        startPage();
+//        List<QpUseRecordVo> list =  qpUseRecordService.getUseDetailsListByUserId(qpUseRecord);
+//        //时间格式化处理
+//        for (QpUseRecordVo useRecord: list) {
+//            useRecord.setUseTimeApp(useRecord.getUseTime()!=null?sdf.format(useRecord.getUseTime()):null);
+//            useRecord.setBackTimeApp(useRecord.getBackTime()!=null?sdf.format(useRecord.getBackTime()):null);
+//        }
+//        return getDataTable(list);
+//    }
+//
+//    /**
+//     * 当前登录人 申请并入库的气瓶使用记录-小程序端
+//     */
+//    @ApiOperation(value = "当前登录人 申请并入库的气瓶使用记录-小程序端")
+//    @GetMapping(value = "/getUseRecordSpecsListApp")
+//    public TableDataInfo<QpAirGoodsConfigRelationVo> getUseRecordSpecsListApp(QpAirGoodsConfigRelationVo vo) {
+//        SysUser sysUser = tokenService.getLoginUser().getSysUser();
+//        vo.setUserId(sysUser.getUserId());
+//        startPage();
+//        List<QpAirGoodsConfigRelationVo> list =  qpUseRecordService.getUseRecordSpecsList(vo);
+//        for (QpAirGoodsConfigRelationVo useRecord:list) {
+//            useRecord.setUseTimeApp(useRecord.getUseTime()!=null?sdf.format(useRecord.getUseTime()):null);
+//            useRecord.setBackTimeApp(useRecord.getBackTime()!=null?sdf.format(useRecord.getBackTime()):null);
+//        }
+//        return getDataTable(list);
+//    }
 }

+ 16 - 0
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/UseRecordService.java

@@ -2,6 +2,9 @@ package com.zd.bottle.service;
 
 import com.zd.bottle.domain.UseRecord;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zd.bottle.vo.UseRecordVo;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +16,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface UseRecordService extends IService<UseRecord> {
 
+    /**
+     * 集合转视图类接口
+     * @param records 源数据
+     * @return List
+     */
+    List<UseRecordVo> getListVo(List<UseRecord> records);
+
+    /**
+     * 获取数据
+     * @param useRecord 查询参数
+     * @return List
+     */
+    List<UseRecord> getList(UseRecord useRecord);
 }

+ 36 - 0
zd-modules/zd-bottle-parent/zd-bottle/src/main/java/com/zd/bottle/service/impl/UseRecordServiceImpl.java

@@ -1,11 +1,22 @@
 package com.zd.bottle.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.zd.bottle.domain.BottleStorage;
 import com.zd.bottle.domain.UseRecord;
 import com.zd.bottle.mapper.UseRecordMapper;
+import com.zd.bottle.service.BottleStorageService;
 import com.zd.bottle.service.UseRecordService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zd.bottle.vo.UseRecordVo;
+import com.zd.common.core.utils.bean.TransferUtils;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * <p>
  * 使用记录表 服务实现类
@@ -17,4 +28,29 @@ import org.springframework.stereotype.Service;
 @Service
 public class UseRecordServiceImpl extends ServiceImpl<UseRecordMapper, UseRecord> implements UseRecordService {
 
+    @Resource
+    private BottleStorageService storageService;
+
+    @Override
+    public List<UseRecordVo> getListVo(List<UseRecord> records) {
+        List<UseRecordVo> recordVos = TransferUtils.transferList(records, UseRecordVo.class);
+        List<Long> storageIds = recordVos.stream().map(UseRecordVo::getStorageId).collect(Collectors.toList());
+        List<BottleStorage> storages = storageService.listByIds(storageIds);
+        Map<Long, BottleStorage> storageMap = storages.stream().collect(Collectors.toMap(BottleStorage::getId, b -> b));
+        recordVos.forEach(u -> {
+            Long storageId = u.getStorageId();
+            if (storageMap.containsKey(storageId)) {
+                BottleStorage bottleStorage = storageMap.get(storageId);
+                u.setAirName(bottleStorage.getAirBottleName());
+            }
+        });
+        return recordVos;
+    }
+
+    @Override
+    public List<UseRecord> getList(UseRecord useRecord) {
+        LambdaQueryWrapper<UseRecord> queryWrapper = Wrappers.lambdaQuery(UseRecord.class);
+        queryWrapper.setEntity(useRecord);
+        return list(queryWrapper);
+    }
 }