diff --git a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldDev.java b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldDev.java index 626c68c54..2e74c2c2a 100644 --- a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldDev.java +++ b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldDev.java @@ -54,22 +54,20 @@ public class AntiPressureFoldDev implements Serializable { */ @Excel(name = "厂家名称", width = 15) @ApiModelProperty(value = "厂家名称") - private java.lang.String manufacturerName; - /** - * 进场时间 - */ - @Excel(name = "进场时间", width = 15, format = "yyyy-MM-dd") - @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") - @DateTimeFormat(pattern = "yyyy-MM-dd") - @ApiModelProperty(value = "进场时间") - private java.util.Date entryTime; - /** - * 负责人 - */ - @Excel(name = "负责人", width = 15) - @ApiModelProperty(value = "负责人") - private java.lang.String personInCharge; - /** + private java.lang.String manufacturerName; + /** + * 进场时间 + */ + @Excel(name = "进场时间", width = 15, format = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty(value = "进场时间") + private java.util.Date entryTime; + @ApiModelProperty(value = "负责人") + private java.lang.Long dutyUserId; + @ApiModelProperty(value = "负责人名称") + private java.lang.String dutyUserName; + /** * 所属试验室 */ @Excel(name = "所属试验室", width = 15) diff --git a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldManage.java b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldManage.java index 4bf6b6f65..1d8e3251e 100644 --- a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldManage.java +++ b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/entity/AntiPressureFoldManage.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.Date; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -155,14 +156,20 @@ public class AntiPressureFoldManage implements Serializable { * 更新时间 yyyy-MM-dd HH:mm:ss */ @Excel(name = "更新时间 yyyy-MM-dd HH:mm:ss", width = 20, format = "yyyy-MM-dd HH:mm:ss") - @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss") - private java.util.Date updateDate; - /** - * 项目sn - */ - @Excel(name = "项目sn", width = 15) - @ApiModelProperty(value = "项目sn") - private java.lang.String projectSn; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新时间 yyyy-MM-dd HH:mm:ss") + private java.util.Date updateDate; + /** + * 项目sn + */ + @Excel(name = "项目sn", width = 15) + @ApiModelProperty(value = "项目sn") + private java.lang.String projectSn; + @TableField(exist = false) + @ApiModelProperty(value = "所属试验室") + private java.lang.String affiliatedLaboratory; + @TableField(exist = false) + @ApiModelProperty(value = "设备名称") + private java.lang.String deviceName; } diff --git a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/AntiPressureFoldManageMapper.java b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/AntiPressureFoldManageMapper.java index ab6305773..c2df9e34e 100644 --- a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/AntiPressureFoldManageMapper.java +++ b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/AntiPressureFoldManageMapper.java @@ -1,8 +1,15 @@ package com.zhgd.xmgl.modules.antipressurefold.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhgd.xmgl.modules.antipressurefold.entity.AntiPressureFoldManage; import org.apache.ibatis.annotations.Mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * @Description: 抗压抗折一体机-管理 @@ -13,4 +20,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; @Mapper public interface AntiPressureFoldManageMapper extends BaseMapper { + IPage queryList(Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + + List queryList(@Param(Constants.WRAPPER) QueryWrapper queryWrapper); } diff --git a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/xml/AntiPressureFoldManageMapper.xml b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/xml/AntiPressureFoldManageMapper.xml index 894acb47a..47c77f131 100644 --- a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/xml/AntiPressureFoldManageMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/mapper/xml/AntiPressureFoldManageMapper.xml @@ -1,4 +1,9 @@ + diff --git a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/service/impl/AntiPressureFoldManageServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/service/impl/AntiPressureFoldManageServiceImpl.java index 2457881f4..fbc2f3575 100644 --- a/src/main/java/com/zhgd/xmgl/modules/antipressurefold/service/impl/AntiPressureFoldManageServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/antipressurefold/service/impl/AntiPressureFoldManageServiceImpl.java @@ -1,21 +1,20 @@ package com.zhgd.xmgl.modules.antipressurefold.service.impl; -import com.zhgd.xmgl.modules.antipressurefold.entity.AntiPressureFoldManage; -import com.zhgd.xmgl.modules.antipressurefold.mapper.AntiPressureFoldManageMapper; -import com.zhgd.xmgl.modules.antipressurefold.service.IAntiPressureFoldManageService; -import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.zhgd.jeecg.common.system.query.QueryGenerator; -import com.zhgd.xmgl.util.PageUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.zhgd.jeecg.common.system.query.QueryGenerator; +import com.zhgd.xmgl.modules.antipressurefold.entity.AntiPressureFoldManage; +import com.zhgd.xmgl.modules.antipressurefold.mapper.AntiPressureFoldManageMapper; +import com.zhgd.xmgl.modules.antipressurefold.service.IAntiPressureFoldManageService; +import com.zhgd.xmgl.util.PageUtil; +import com.zhgd.xmgl.util.RefUtil; +import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; -import com.zhgd.xmgl.util.RefUtil; - /** * @Description: 抗压抗折一体机-管理 * @author: pds @@ -28,7 +27,7 @@ public class AntiPressureFoldManageServiceImpl extends ServiceImpl queryPageList(HashMap paramMap) { QueryWrapper queryWrapper = getQueryWrapper(paramMap); Page page = PageUtil.getPage(paramMap); - IPage pageList = this.page(page, queryWrapper); + IPage pageList = baseMapper.queryList(page, queryWrapper); pageList.setRecords(dealList(pageList.getRecords())); return pageList; } @@ -36,12 +35,13 @@ public class AntiPressureFoldManageServiceImpl extends ServiceImpl queryList(HashMap paramMap) { QueryWrapper queryWrapper = getQueryWrapper(paramMap); - return dealList(this.list(queryWrapper)); + return dealList(baseMapper.queryList(queryWrapper)); } private QueryWrapper getQueryWrapper(HashMap paramMap) { - QueryWrapper queryWrapper = QueryGenerator.initPageQueryWrapper(AntiPressureFoldManage.class, paramMap); - queryWrapper.orderByDesc(RefUtil.fieldNameUlc(AntiPressureFoldManage::getId)); + String alias = "apfm."; + QueryWrapper queryWrapper = QueryGenerator.initPageQueryWrapper(AntiPressureFoldManage.class, paramMap, alias); + queryWrapper.orderByDesc(alias + RefUtil.fieldNameUlc(AntiPressureFoldManage::getId)); return queryWrapper; } diff --git a/src/main/java/com/zhgd/xmgl/modules/material/controller/MaterialApproachRecordController.java b/src/main/java/com/zhgd/xmgl/modules/material/controller/MaterialApproachRecordController.java index 8a6cb4fd4..8f957c3cd 100644 --- a/src/main/java/com/zhgd/xmgl/modules/material/controller/MaterialApproachRecordController.java +++ b/src/main/java/com/zhgd/xmgl/modules/material/controller/MaterialApproachRecordController.java @@ -13,12 +13,14 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.util.IOUtils; import org.jeecgframework.poi.excel.ExcelImportUtil; import org.jeecgframework.poi.excel.def.NormalExcelConstants; import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -27,8 +29,11 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.net.URLEncoder; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -46,194 +51,210 @@ import java.util.Map; @Slf4j @Api(tags = "材料进场记录相关Api") public class MaterialApproachRecordController { - @Autowired - private IMaterialApproachRecordService materialApproachRecordService; + @Autowired + private IMaterialApproachRecordService materialApproachRecordService; - /** - * 分页列表查询 - * - * @param materialApproachRecord - * @param pageNo 页码 - * @param pageSize 条数 - * @param req - * @return - */ - @ApiOperation(value = "分页列表查询材料进场记录 信息", notes = "分页列表查询材料进场记录 信息", httpMethod = "GET") + /** + * 分页列表查询 + * + * @param materialApproachRecord + * @param pageNo 页码 + * @param pageSize 条数 + * @param req + * @return + */ + @ApiOperation(value = "分页列表查询材料进场记录 信息", notes = "分页列表查询材料进场记录 信息", httpMethod = "GET") @GetMapping(value = "/page") - public Result> queryPageList(MaterialApproachRecord materialApproachRecord, - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, - HttpServletRequest req) { + public Result> queryPageList(MaterialApproachRecord materialApproachRecord, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(materialApproachRecord, req.getParameterMap()); - queryWrapper.lambda().orderByDesc(MaterialApproachRecord::getEntryTime); - Page page = new Page(pageNo, pageSize); - IPage pageList = materialApproachRecordService.page(page, queryWrapper); - return Result.success(pageList); - } + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(materialApproachRecord, req.getParameterMap()); + queryWrapper.lambda().orderByDesc(MaterialApproachRecord::getEntryTime); + Page page = new Page(pageNo, pageSize); + IPage pageList = materialApproachRecordService.page(page, queryWrapper); + return Result.success(pageList); + } - /** - * 列表查询 - * - * @param materialApproachRecord - * @param pageNo 页码 - * @param pageSize 条数 - * @param req - * @return - */ + /** + * 列表查询 + * + * @param materialApproachRecord + * @param pageNo 页码 + * @param pageSize 条数 + * @param req + * @return + */ @ApiOperation(value = "列表查询材料进场记录 信息", notes = "列表查询材料进场记录 信息", httpMethod = "GET") @GetMapping(value = "/list") - public Result> queryList(MaterialApproachRecord materialApproachRecord, - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, - HttpServletRequest req) { + public Result> queryList(MaterialApproachRecord materialApproachRecord, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, + HttpServletRequest req) { - QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(materialApproachRecord, req.getParameterMap()); - queryWrapper.lambda().orderByDesc(MaterialApproachRecord::getEntryTime); - return Result.success(materialApproachRecordService.list(queryWrapper)); - } + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(materialApproachRecord, req.getParameterMap()); + queryWrapper.lambda().orderByDesc(MaterialApproachRecord::getEntryTime); + return Result.success(materialApproachRecordService.list(queryWrapper)); + } - /** - * 添加 - * - * @param materialApproachRecord - * @return - */ + /** + * 添加 + * + * @param materialApproachRecord + * @return + */ @ApiOperation(value = "添加材料进场记录 信息", notes = "添加材料进场记录 信息", httpMethod = "POST") @PostMapping(value = "/add") - public Result add(@RequestBody MaterialApproachRecord materialApproachRecord) { - materialApproachRecordService.save(materialApproachRecord); - return Result.ok(); - } + public Result add(@RequestBody MaterialApproachRecord materialApproachRecord) { + materialApproachRecordService.save(materialApproachRecord); + return Result.ok(); + } - /** - * 编辑 - * - * @param materialApproachRecord - * @return - */ - @ApiOperation(value = "编辑材料进场记录 信息", notes = "编辑材料进场记录 信息", httpMethod = "POST") - @PostMapping(value = "/edit") - public Result edit(@RequestBody MaterialApproachRecord materialApproachRecord) { - materialApproachRecordService.updateById(materialApproachRecord); - return Result.ok(); - } + /** + * 编辑 + * + * @param materialApproachRecord + * @return + */ + @ApiOperation(value = "编辑材料进场记录 信息", notes = "编辑材料进场记录 信息", httpMethod = "POST") + @PostMapping(value = "/edit") + public Result edit(@RequestBody MaterialApproachRecord materialApproachRecord) { + materialApproachRecordService.updateById(materialApproachRecord); + return Result.ok(); + } - /** - * 通过id删除 - * - * @param id - * @return - */ - @ApiOperation(value = "删除材料进场记录 信息", notes = "删除材料进场记录 信息", httpMethod = "POST") - @ApiImplicitParam(name = "id", value = "材料进场记录 ID", paramType = "body", required = true, dataType = "Integer") - @PostMapping(value = "/delete") - public Result delete(@RequestBody String id) { - materialApproachRecordService.removeById(JSON.parseObject(id).get("id").toString()); - return Result.ok(); - } + /** + * 通过id删除 + * + * @param id + * @return + */ + @ApiOperation(value = "删除材料进场记录 信息", notes = "删除材料进场记录 信息", httpMethod = "POST") + @ApiImplicitParam(name = "id", value = "材料进场记录 ID", paramType = "body", required = true, dataType = "Integer") + @PostMapping(value = "/delete") + public Result delete(@RequestBody String id) { + materialApproachRecordService.removeById(JSON.parseObject(id).get("id").toString()); + return Result.ok(); + } - /** - * 批量删除 - * - * @param ids - * @return - */ - @ApiOperation(value = "批量删除材料进场记录 信息", notes = "批量删除材料进场记录 信息", httpMethod = "DELETE") - @ApiImplicitParam(name = "id", value = "材料进场记录 ID字符串", paramType = "query", required = true, dataType = "String") - @DeleteMapping(value = "/deleteBatch") - public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { - if (ids == null || "".equals(ids.trim())) { - throw new IllegalArgumentException("参数不识别!"); - } else { - this.materialApproachRecordService.removeByIds(Arrays.asList(ids.split(","))); - } - return Result.ok(); - } + /** + * 批量删除 + * + * @param ids + * @return + */ + @ApiOperation(value = "批量删除材料进场记录 信息", notes = "批量删除材料进场记录 信息", httpMethod = "DELETE") + @ApiImplicitParam(name = "id", value = "材料进场记录 ID字符串", paramType = "query", required = true, dataType = "String") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + if (ids == null || "".equals(ids.trim())) { + throw new IllegalArgumentException("参数不识别!"); + } else { + this.materialApproachRecordService.removeByIds(Arrays.asList(ids.split(","))); + } + return Result.ok(); + } - /** - * 通过id查询 - * - * @param id - * @return - */ - @ApiOperation(value = "通过id查询材料进场记录 信息", notes = "通过id查询材料进场记录 信息", httpMethod = "GET") - @ApiImplicitParam(name = "id", value = "材料进场记录 ID", paramType = "query", required = true, dataType = "Integer") - @GetMapping(value = "/queryById") - public Result queryById(@RequestParam(name = "id", required = true) String id) { - MaterialApproachRecord materialApproachRecord = materialApproachRecordService.getById(id); - return Result.success(materialApproachRecord); - } + /** + * 通过id查询 + * + * @param id + * @return + */ + @ApiOperation(value = "通过id查询材料进场记录 信息", notes = "通过id查询材料进场记录 信息", httpMethod = "GET") + @ApiImplicitParam(name = "id", value = "材料进场记录 ID", paramType = "query", required = true, dataType = "Integer") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name = "id", required = true) String id) { + MaterialApproachRecord materialApproachRecord = materialApproachRecordService.getById(id); + return Result.success(materialApproachRecord); + } - /** - * 导出excel - * - * @param request - * @param response - */ - @ApiOperation(value = "导出excel材料进场记录 信息", notes = "导出excel材料进场记录 信息", httpMethod = "POST") - @RequestMapping(value = "/exportXls") - public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) { - // Step.1 组装查询条件 - QueryWrapper queryWrapper = null; - try { - String paramsStr = request.getParameter("paramsStr"); - if (oConvertUtils.isNotEmpty(paramsStr)) { - String deString = URLDecoder.decode(paramsStr, "UTF-8"); - MaterialApproachRecord materialApproachRecord = JSON.parseObject(deString, MaterialApproachRecord.class); - queryWrapper = QueryGenerator.initQueryWrapper(materialApproachRecord, request.getParameterMap()); - } - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } + /** + * 导出excel + * + * @param request + * @param response + */ + @ApiOperation(value = "导出excel材料进场记录 信息", notes = "导出excel材料进场记录 信息", httpMethod = "POST") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) { + // Step.1 组装查询条件 + QueryWrapper queryWrapper = null; + try { + String paramsStr = request.getParameter("paramsStr"); + if (oConvertUtils.isNotEmpty(paramsStr)) { + String deString = URLDecoder.decode(paramsStr, "UTF-8"); + MaterialApproachRecord materialApproachRecord = JSON.parseObject(deString, MaterialApproachRecord.class); + queryWrapper = QueryGenerator.initQueryWrapper(materialApproachRecord, request.getParameterMap()); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } - //Step.2 AutoPoi 导出Excel - ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); - List pageList = materialApproachRecordService.list(queryWrapper); - //导出文件名称 - mv.addObject(NormalExcelConstants.FILE_NAME, "材料进场记录 列表"); - mv.addObject(NormalExcelConstants.CLASS, MaterialApproachRecord.class); - mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("材料进场记录 列表数据", "导出人:Jeecg", "导出信息")); - mv.addObject(NormalExcelConstants.DATA_LIST, pageList); - return mv; - } + //Step.2 AutoPoi 导出Excel + ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); + List pageList = materialApproachRecordService.list(queryWrapper); + //导出文件名称 + mv.addObject(NormalExcelConstants.FILE_NAME, "材料进场记录 列表"); + mv.addObject(NormalExcelConstants.CLASS, MaterialApproachRecord.class); + mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(null, "导出信息")); + mv.addObject(NormalExcelConstants.DATA_LIST, pageList); + return mv; + } - /** - * 通过excel导入数据 - * - * @param request - * @param response - * @return - */ - @ApiOperation(value = "通过excel导入材料进场记录 信息", notes = "通过excel导入材料进场记录 信息", httpMethod = "POST") - @RequestMapping(value = "/importExcel", method = RequestMethod.POST) - public Result importExcel(HttpServletRequest request, HttpServletResponse response) { - MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; - Map fileMap = multipartRequest.getFileMap(); - for (Map.Entry entity : fileMap.entrySet()) { - MultipartFile file = entity.getValue();// 获取上传文件对象 - ImportParams params = new ImportParams(); - params.setTitleRows(2); - params.setHeadRows(1); - params.setNeedSave(true); - try { - List listMaterialApproachRecords = ExcelImportUtil.importExcel(file.getInputStream(), MaterialApproachRecord.class, params); - for (MaterialApproachRecord materialApproachRecordExcel : listMaterialApproachRecords) { - materialApproachRecordService.save(materialApproachRecordExcel); - } - return Result.ok("文件导入成功!数据行数:" + listMaterialApproachRecords.size()); - } catch (Exception e) { - log.error(e.getMessage()); - return Result.error("文件导入失败!"); - } finally { - try { - file.getInputStream().close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return Result.ok("文件导入失败!"); - } + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @ApiOperation(value = "通过excel导入材料进场记录 信息", notes = "通过excel导入材料进场记录 信息", httpMethod = "POST") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + for (Map.Entry entity : fileMap.entrySet()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + ImportParams params = new ImportParams(); + params.setTitleRows(0); + params.setHeadRows(1); + params.setNeedSave(true); + try { + List listMaterialApproachRecords = ExcelImportUtil.importExcel(file.getInputStream(), MaterialApproachRecord.class, params); + for (MaterialApproachRecord materialApproachRecordExcel : listMaterialApproachRecords) { + materialApproachRecordService.save(materialApproachRecordExcel); + } + return Result.ok("文件导入成功!数据行数:" + listMaterialApproachRecords.size()); + } catch (Exception e) { + log.error(e.getMessage()); + return Result.error("文件导入失败!"); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.ok("文件导入失败!"); + } + @GetMapping(value = "/downloadTemplate") + @ApiOperation(value = "下载导入模板") + public void downloadTemplate(HttpServletResponse response) { + try { + OutputStream out = response.getOutputStream(); + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-project"); + response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("材料进场记录导入模板.xlsx", "UTF-8")); + InputStream fis = new ClassPathResource("template/材料进场记录导入模板.xlsx").getInputStream(); + IOUtils.copy(fis, out); + out.flush(); + out.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/material/entity/MaterialApproachRecord.java b/src/main/java/com/zhgd/xmgl/modules/material/entity/MaterialApproachRecord.java index ea4cc50f9..659bb065f 100644 --- a/src/main/java/com/zhgd/xmgl/modules/material/entity/MaterialApproachRecord.java +++ b/src/main/java/com/zhgd/xmgl/modules/material/entity/MaterialApproachRecord.java @@ -34,8 +34,8 @@ public class MaterialApproachRecord implements Serializable { /** * 进场时间 */ - @Excel(name = "进场时间", width = 15, format = "yyyy-MM-dd") - @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @Excel(name = "进场时间(格式:yyyy-MM-dd)", width = 15, format = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "进场时间") private Date entryTime; @@ -63,8 +63,10 @@ public class MaterialApproachRecord implements Serializable { @Excel(name = "进场量", width = 15) @ApiModelProperty(value = "进场量") private Double approachVolume; + @Excel(name = "出场重量", width = 15) @ApiModelProperty(value = "出场量") private Double appearanceVolume; + @Excel(name = "净重量", width = 15) @ApiModelProperty(value = "净重量") private Double netWeightVolume; diff --git a/src/main/java/com/zhgd/xmgl/modules/pressuretest/entity/PressureTestMachineManage.java b/src/main/java/com/zhgd/xmgl/modules/pressuretest/entity/PressureTestMachineManage.java index 9eef4baf6..795a2fabc 100644 --- a/src/main/java/com/zhgd/xmgl/modules/pressuretest/entity/PressureTestMachineManage.java +++ b/src/main/java/com/zhgd/xmgl/modules/pressuretest/entity/PressureTestMachineManage.java @@ -138,6 +138,8 @@ public class PressureTestMachineManage implements Serializable { @Excel(name = "公称直径(mm)", width = 15) @ApiModelProperty(value = "公称直径(mm)") private java.lang.Double nominalDiameter; + @ApiModelProperty(value = "施工部位") + private String constructionPart; /** * 创建时间 yyyy-MM-dd HH:mm:ss */ diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardAlarmController.java b/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardAlarmController.java index e0264de47..2d1dd23b3 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardAlarmController.java +++ b/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardAlarmController.java @@ -1,7 +1,9 @@ package com.zhgd.xmgl.modules.standard.controller; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.zhgd.annotation.OperLog; import com.zhgd.jeecg.common.api.vo.Result; +import com.zhgd.xmgl.modules.antipressurefold.entity.AntiPressureFoldManageBlockNumber; import com.zhgd.xmgl.modules.standard.entity.StandardAlarm; import com.zhgd.xmgl.modules.standard.service.IStandardAlarmService; import io.swagger.annotations.Api; @@ -10,11 +12,10 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -23,25 +24,40 @@ import java.util.Map; * @Title: Controller * @Description: 标养室报警记录 * @author: pds - * @date: 2020-12-02 - * @version: V1.0 - */ -@RestController -@RequestMapping("/xmgl/standardAlarm") -@Slf4j -@Api(tags = "标养室报警记录") -public class StandardAlarmController { - @Autowired - private IStandardAlarmService standardAlarmService; + * @date: 2020-12-02 + * @version: V1.0 + */ + @RestController + @RequestMapping("/xmgl/standardAlarm") + @Slf4j + @Api(tags = "标养室报警记录") + public class StandardAlarmController { + @Autowired + private IStandardAlarmService standardAlarmService; + /** + * 分页列表查询 + * + * @return + */ + @ApiOperation(value = "分页列表查询标养室报警记录", notes = "分页列表查询标养室报警记录", httpMethod = "GET") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "query", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "query", required = true, dataType = "Integer"), + @ApiImplicitParam(name = "type", value = "1当天", paramType = "query", required = false, dataType = "Integer"), + }) + @GetMapping(value = "/page") + public Result> queryPageList(@ApiIgnore @RequestParam HashMap paramMap) { + return Result.success(standardAlarmService.queryPageList(paramMap)); + } @ApiOperation(value = "标养室报警统计", notes = "标养室报警统计", httpMethod = "POST") @ApiImplicitParams({ - @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"), - @ApiImplicitParam(name = "devSn", value = "标养室设备唯一标识", paramType = "body", required = true, dataType = "String"), + @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = false, dataType = "String"), + @ApiImplicitParam(name = "devSn", value = "标养室设备唯一标识", paramType = "body", required = false, dataType = "String"), }) @PostMapping(value = "/getStandardAlarmStatistics") - public Result> getStandardAlarmStatistics(@RequestBody Map map) { + public Result> getStandardAlarmStatistics(@RequestBody Map map) { return Result.success(standardAlarmService.getStandardAlarmStatistics(map)); } diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardCurrentDataController.java b/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardCurrentDataController.java index c70b30860..d19b81f2d 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardCurrentDataController.java +++ b/src/main/java/com/zhgd/xmgl/modules/standard/controller/StandardCurrentDataController.java @@ -66,7 +66,6 @@ public class StandardCurrentDataController { */ @ApiOperation(value = "添加标养室实时数据信息", notes = "添加标养室实时数据信息", httpMethod = "POST") - //@PostMapping(value = "/add",produces = {"application/json;charset=UTF-8"}) @PostMapping(value = "/saveStandardCurrentData", produces = {"application/json;charset=UTF-8"}) public Result saveStandardCurrentData(@RequestBody final JSONObject json) { log.info("saveStandardCurrentData:{}", JSON.toJSONString(json)); @@ -81,7 +80,6 @@ public class StandardCurrentDataController { * @return */ @ApiOperation(value = "添加标养室实时数据信息", notes = "添加标养室实时数据信息", httpMethod = "POST") - //@PostMapping(value = "/saveStandardCurrentData") @PostMapping(value = "/addCurrentData") public Result addCurrentData(@RequestBody StandardCurrentData standardCurrentData) { log.info("addCurrentData:{}", JSON.toJSONString(standardCurrentData)); @@ -129,8 +127,8 @@ public class StandardCurrentDataController { @ApiOperation(value = "查询设备最新一条实时数据", notes = "查询设备最新一条实时数据", httpMethod = "POST") @ApiImplicitParams({ - @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"), - @ApiImplicitParam(name = "devSn", value = "标养室设备唯一标识", paramType = "body", required = true, dataType = "String"), + @ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = false, dataType = "String"), + @ApiImplicitParam(name = "devSn", value = "标养室设备唯一标识", paramType = "body", required = false, dataType = "String"), @ApiImplicitParam(name = "type", value = "1当天", paramType = "body", required = false, dataType = "Integer"), }) @PostMapping(value = "/selectNewCurrentData") @@ -194,7 +192,7 @@ public class StandardCurrentDataController { @ApiImplicitParams({ @ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = false, dataType = "String"), @ApiImplicitParam(name = "devSn", value = "标养室设备唯一标识", dataType = "String", paramType = "body", required = false), - @ApiImplicitParam(name = "type", value = "查询类型,1过去24小时 ", dataType = "Integer", paramType = "body", required = true), + @ApiImplicitParam(name = "type", value = "查询类型,1过去24小时 2今天", dataType = "Integer", paramType = "body", required = true), }) @PostMapping(value = "/countStandardCurrentData") public Result> countStandardCurrentData(@RequestBody @ApiIgnore Map map) { diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/entity/StandardAlarm.java b/src/main/java/com/zhgd/xmgl/modules/standard/entity/StandardAlarm.java index d120ac86b..274d50aa6 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/entity/StandardAlarm.java +++ b/src/main/java/com/zhgd/xmgl/modules/standard/entity/StandardAlarm.java @@ -3,6 +3,7 @@ package com.zhgd.xmgl.modules.standard.entity; import java.io.Serializable; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -22,7 +23,7 @@ import io.swagger.annotations.ApiModelProperty; @ApiModel(value="StandardAlarm实体类",description="StandardAlarm") public class StandardAlarm implements Serializable { private static final long serialVersionUID = 1L; - + /**id*/ @TableId(type = IdType.ASSIGN_ID) @ApiModelProperty(value="id") @@ -41,14 +42,22 @@ public class StandardAlarm implements Serializable { private java.lang.String alarmType ; /**报警值*/ @Excel(name = "报警值", width = 15) - @ApiModelProperty(value="报警值") - private java.lang.String alarmValue ; - /**报警时间*/ - @Excel(name = "报警时间", width = 15) - @ApiModelProperty(value="报警时间") - private java.lang.String alarmTime ; - /**阀值*/ - @Excel(name = "阀值", width = 15) - @ApiModelProperty(value="阀值") - private java.lang.String thresholdValue ; + @ApiModelProperty(value = "报警值") + private java.lang.String alarmValue; + /** + * 报警时间 + */ + @Excel(name = "报警时间", width = 15) + @ApiModelProperty(value = "报警时间") + private java.lang.String alarmTime; + /** + * 阀值 + */ + @Excel(name = "阀值", width = 15) + @ApiModelProperty(value = "阀值") + private java.lang.String thresholdValue; + + @TableField(exist = false) + @ApiModelProperty(value = "实验室名称(设备名称)") + private java.lang.String laboratoryName; } diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/mapper/StandardAlarmMapper.java b/src/main/java/com/zhgd/xmgl/modules/standard/mapper/StandardAlarmMapper.java index 5ff5d856b..af8b997b0 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/mapper/StandardAlarmMapper.java +++ b/src/main/java/com/zhgd/xmgl/modules/standard/mapper/StandardAlarmMapper.java @@ -1,12 +1,17 @@ package com.zhgd.xmgl.modules.standard.mapper; +import java.util.HashMap; import java.util.List; import java.util.Map; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhgd.jeecg.common.mybatis.EntityMap; import org.apache.ibatis.annotations.Mapper; import com.zhgd.xmgl.modules.standard.entity.StandardAlarm; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; /** * @Description: 标养室报警记录 @@ -28,4 +33,6 @@ public interface StandardAlarmMapper extends BaseMapper { List> selectDevAlarmList(Map map); List selectExcelStandardDevAlarmList(Map map); + + IPage queryPageList(Page page, @Param("p") HashMap paramMap); } diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardAlarmMapper.xml b/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardAlarmMapper.xml index 6195b0795..3bf497e31 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardAlarmMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardAlarmMapper.xml @@ -5,14 +5,26 @@ - \ No newline at end of file + + + diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardCurrentDataMapper.xml b/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardCurrentDataMapper.xml index b0dfb6589..a5fa6ee55 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardCurrentDataMapper.xml +++ b/src/main/java/com/zhgd/xmgl/modules/standard/mapper/xml/StandardCurrentDataMapper.xml @@ -6,7 +6,13 @@ parameterType="map"> SELECT a.* from standard_current_data a - WHERE a.dev_sn=#{devSn} AND a.project_sn=#{projectSn} + WHERE 1=1 + + and a.dev_sn=#{devSn} + + + AND a.project_sn=#{projectSn} + and a.receive_time > current_date @@ -129,6 +135,9 @@ and receive_time>=CONCAT(date_sub(curdate(),INTERVAL 2 DAY),' 00:00:00') + + and receive_time>=current_date + GROUP BY time diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/service/IStandardAlarmService.java b/src/main/java/com/zhgd/xmgl/modules/standard/service/IStandardAlarmService.java index 9705f071a..e758bb774 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/service/IStandardAlarmService.java +++ b/src/main/java/com/zhgd/xmgl/modules/standard/service/IStandardAlarmService.java @@ -1,11 +1,13 @@ package com.zhgd.xmgl.modules.standard.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.zhgd.xmgl.modules.standard.entity.StandardAlarm; import com.baomidou.mybatisplus.extension.service.IService; import com.zhgd.xmgl.modules.standard.entity.StandardCurrentData; import com.zhgd.xmgl.modules.standard.entity.StandardDev; import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -29,4 +31,5 @@ public interface IStandardAlarmService extends IService { void exporExcelStandardDevAlarm(HttpServletResponse response, Map map); + IPage queryPageList(HashMap paramMap); } diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardAlarmServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardAlarmServiceImpl.java index 460e4e683..1b62e7f25 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardAlarmServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardAlarmServiceImpl.java @@ -1,6 +1,8 @@ package com.zhgd.xmgl.modules.standard.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zhgd.jeecg.common.mybatis.EntityMap; import com.zhgd.xmgl.modules.basicdata.service.ICompanyService; @@ -13,6 +15,7 @@ import com.zhgd.xmgl.modules.standard.mapper.StandardWarningMapper; import com.zhgd.xmgl.modules.standard.service.IStandardAlarmService; import com.zhgd.xmgl.util.DateUtils; import com.zhgd.xmgl.util.JxlExcelUtils; +import com.zhgd.xmgl.util.PageUtil; import org.apache.commons.collections.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -144,6 +147,12 @@ public class StandardAlarmServiceImpl extends ServiceImpl queryPageList(HashMap paramMap) { + Page page = PageUtil.getPage(paramMap); + return standardAlarmMapper.queryPageList(page, paramMap); + } + @Override public void addStandardAlarmData(StandardCurrentData standardCurrentData, StandardDev standardDev) { QueryWrapper queryWrapper = new QueryWrapper<>(); diff --git a/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardCurrentDataServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardCurrentDataServiceImpl.java index e43d8443d..eaf36a054 100644 --- a/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardCurrentDataServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/standard/service/impl/StandardCurrentDataServiceImpl.java @@ -19,6 +19,7 @@ import com.zhgd.xmgl.modules.standard.service.IStandardCurrentDataService; import com.zhgd.xmgl.util.DateUtils; import com.zhgd.xmgl.util.JxlExcelUtils; import com.zhgd.xmgl.util.MessageUtil; +import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -33,7 +34,7 @@ import java.util.stream.Collectors; /** * @Description: 标养室实时数据 * @author: pds - * @date: 2020-11-30 + * @date: 2020-11-30 * @version: V1.0 */ @Service @@ -58,10 +59,10 @@ public class StandardCurrentDataServiceImpl extends ServiceImpl queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(StandardDev::getDevSn,standardCurrentData.getDevSn()); - StandardDev standardDev=standardDevMapper.selectOne(queryWrapper); - if(standardDev==null){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(StandardDev::getDevSn, standardCurrentData.getDevSn()); + StandardDev standardDev = standardDevMapper.selectOne(queryWrapper); + if (standardDev == null) { throw new OpenAlertException(MessageUtil.get("EquipmentNumIncorrectErr")); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -88,18 +89,18 @@ public class StandardCurrentDataServiceImpl extends ServiceImpl page = new Page<>(pageNo, pageSize); - List list=standardCurrentDataMapper.queryStandardCurrentDataPageList(page, map); + List list = standardCurrentDataMapper.queryStandardCurrentDataPageList(page, map); return page.setRecords(list); } @Override public void exportExcelStandardCurrentData(HttpServletResponse response, Map map) { try { - List list=standardCurrentDataMapper.selectDownloadStandardCurrentDataList(map); - String[] heads = { "实验室名称","温度","湿度","日期"}; - String[] headsStr = { "laboratoryName","temperature","humidity","receiveTime"}; - JxlExcelUtils.excelExport("标养室历史数据",heads,headsStr,list,response); - }catch (Exception e){ + List list = standardCurrentDataMapper.selectDownloadStandardCurrentDataList(map); + String[] heads = {"实验室名称", "温度", "湿度", "日期"}; + String[] headsStr = {"laboratoryName", "temperature", "humidity", "receiveTime"}; + JxlExcelUtils.excelExport("标养室历史数据", heads, headsStr, list, response); + } catch (Exception e) { e.printStackTrace(); } } @@ -111,39 +112,39 @@ public class StandardCurrentDataServiceImpl extends ServiceImpl queryWrapper=new QueryWrapper<>(); - queryWrapper.lambda().eq(StandardDev::getDevSn,json.getString("devSn")); - StandardDev standardDev=standardDevMapper.selectOne(queryWrapper); - if(standardDev==null){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(StandardDev::getDevSn, json.getString("devSn")); + StandardDev standardDev = standardDevMapper.selectOne(queryWrapper); + if (standardDev == null) { throw new OpenAlertException(MessageUtil.get("EquipmentNumIncorrectErr")); } - StandardCurrentData standardCurrentData=new StandardCurrentData(); + StandardCurrentData standardCurrentData = new StandardCurrentData(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); standardCurrentData.setReceiveTime(sdf.format(new Date())); standardCurrentData.setProjectSn(standardDev.getProjectSn()); standardCurrentData.setDevSn(standardDev.getDevSn()); - List temperatureList=new ArrayList<>(); - List humidityList=new ArrayList<>(); - JSONArray array=json.getJSONArray("data"); - if(array!=null&&array.size()>0){ - for (int i=0;i temperatureList = new ArrayList<>(); + List humidityList = new ArrayList<>(); + JSONArray array = json.getJSONArray("data"); + if (array != null && array.size() > 0) { + for (int i = 0; i < array.size(); i++) { + JSONObject obj = array.getJSONObject(i); + String temperature = obj.getString("temperature"); + if (StringUtils.isNotEmpty(temperature)) { temperatureList.add(Double.valueOf(temperature)); } - String humidity=obj.getString("humidity"); - if(StringUtils.isNotEmpty(humidity)){ + String humidity = obj.getString("humidity"); + if (StringUtils.isNotEmpty(humidity)) { humidityList.add(Double.valueOf(humidity)); } } } - if(temperatureList.size()>0){ + if (temperatureList.size() > 0) { //计算温度平均值 double avg = temperatureList.stream().collect(Collectors.averagingDouble(n -> n)); standardCurrentData.setTemperature(String.valueOf(avg)); } - if(humidityList.size()>0){ + if (humidityList.size() > 0) { //计算湿度平均值 double avg = humidityList.stream().collect(Collectors.averagingDouble(n -> n)); standardCurrentData.setHumidity(String.valueOf(avg)); @@ -159,22 +160,43 @@ public class StandardCurrentDataServiceImpl extends ServiceImpl countStandardCurrentData(Map map) { - List standardCurrentDataExts = baseMapper.countStandardCurrentData(map); - List dateStrList = DateUtils.getDateTimeStrList(20, "yyyy-MM-dd HH:00:00"); - List rtList = new ArrayList<>(); - Map m = standardCurrentDataExts.stream().collect(Collectors.toMap(StandardCurrentDataExt::getTime, Function.identity())); - for (String date : dateStrList) { - StandardCurrentDataExt e = m.get(date); - if (e == null) { - e = new StandardCurrentDataExt(); - e.setTime(date); - e.setHumidity("0"); - e.setTemperature("0"); + Integer type = MapUtils.getInteger(map, "type"); + if (Objects.equals(type, 1)) { + List standardCurrentDataExts = baseMapper.countStandardCurrentData(map); + List dateStrList = DateUtils.getDateTimeStrList(20, "yyyy-MM-dd HH:00:00"); + List rtList = new ArrayList<>(); + Map m = standardCurrentDataExts.stream().collect(Collectors.toMap(StandardCurrentDataExt::getTime, Function.identity())); + for (String date : dateStrList) { + StandardCurrentDataExt e = m.get(date); + if (e == null) { + e = new StandardCurrentDataExt(); + e.setTime(date); + e.setHumidity("0"); + e.setTemperature("0"); + } + e.setTime(DateUtil.format(DateUtil.parse(e.getTime()), "HH:00")); + rtList.add(e); } - e.setTime(DateUtil.format(DateUtil.parse(e.getTime()), "HH:00")); - rtList.add(e); + return rtList; + } else if (Objects.equals(type, 2)) { + List standardCurrentDataExts = baseMapper.countStandardCurrentData(map); + List dateStrList = DateUtils.getDateTimeStrList(100, "yyyy-MM-dd HH:00:00"); + List rtList = new ArrayList<>(); + Map m = standardCurrentDataExts.stream().collect(Collectors.toMap(StandardCurrentDataExt::getTime, Function.identity())); + for (String date : dateStrList) { + StandardCurrentDataExt e = m.get(date); + if (e == null) { + e = new StandardCurrentDataExt(); + e.setTime(date); + e.setHumidity("0"); + e.setTemperature("0"); + } + e.setTime(DateUtil.format(DateUtil.parse(e.getTime()), "HH:00")); + rtList.add(e); + } + return rtList; } - return rtList; + return null; } diff --git a/src/main/resources/template/材料进场记录导入模板.xlsx b/src/main/resources/template/材料进场记录导入模板.xlsx new file mode 100644 index 000000000..723e93a19 Binary files /dev/null and b/src/main/resources/template/材料进场记录导入模板.xlsx differ