From ce6a0d5d95f33025eb8782f9a933aa128f7cc168 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Jan 2024 10:06:39 +0800 Subject: [PATCH 1/9] =?UTF-8?q?update:=20=E6=BC=94=E7=BB=83=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/dto/RehearsalExportDTO.java | 4 +- .../safeproduct/entity/RehearsalPlanEntity.java | 3 + .../controller/RehearsalController.java | 151 +++++++++++++++++++++ .../controller/RehearsalRecordController.java | 151 --------------------- .../service/impl/RehearsalPlanServiceImpl.java | 7 +- .../service/impl/RehearsalRecordServiceImpl.java | 17 +-- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 39 ++++++ 7 files changed, 203 insertions(+), 169 deletions(-) create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java index 1f2903b..800f911 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java @@ -26,11 +26,11 @@ public class RehearsalExportDTO { private String subject; @ApiModelProperty("演练计划开始时间") - @ExcelProperty(value = "演练计划开始时间", index = 2) + @ExcelProperty(value = "计划开始时间", index = 2) private Date scheduledStartTime; @ApiModelProperty("演练计划结束时间") - @ExcelProperty(value = "演练计划结束时间", index = 3) + @ExcelProperty(value = "计划结束时间", index = 3) private Date scheduledEndTime; @ApiModelProperty("演练地点") diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java index bdff1a1..4cd4306 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java @@ -1,6 +1,7 @@ package com.hnac.hzims.safeproduct.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,10 +33,12 @@ public class RehearsalPlanEntity extends BaseEntity { private String subject; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("演练计划开始时间") private Date scheduledStartTime; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("演练计划结束时间") private Date scheduledEndTime; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java new file mode 100644 index 0000000..58b036e --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java @@ -0,0 +1,151 @@ +package com.hnac.hzims.safeproduct.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; +import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; +import com.hnac.hzims.safeproduct.service.IRehearsalPlanService; +import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; +import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; +import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.util.Map; + +/** + * 演练管理接口类 + * + * @author liwen + * @date 2023-12-13 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/rehearsal") +@Api(value = "演练管理", tags = "演练管理接口") +public class RehearsalController extends BladeController { + + private final IRehearsalRecordService rehearsalRecordService; + + private final IRehearsalPlanService rehearsalPlanService; + + @PostMapping("/save") + @ApiOperation(value = "新增演练计划") + @ApiOperationSupport(order = 1) + public R save(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { + return R.status(rehearsalPlanService.save(rehearsalPlan)); + } + + @PostMapping("/update") + @ApiOperation(value = "修改演练计划") + @ApiOperationSupport(order = 2) + public R update(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { + return R.status(rehearsalPlanService.updateById(rehearsalPlan)); + } + + @PostMapping("/remove") + @ApiOperation(value = "删除演练计划") + @ApiOperationSupport(order = 3) + public R remove(@RequestParam Long id) { + return R.status(rehearsalPlanService.removeRehearsalPlan(id)); + } + + @GetMapping("/detail") + @ApiOperation(value = "演练计划详情") + @ApiOperationSupport(order = 4) + public R detail(@RequestParam Long id) { + return R.data(rehearsalPlanService.getById(id)); + } + + @GetMapping("/page") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练计划分页") + @ApiOperationSupport(order = 5) + public R> page(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = rehearsalPlanService.rehearsalPlanPage(param, query); + return R.data(page); + } + + @PostMapping("/saveRehearsalRecord") + @ApiOperation(value = "新增演练记录") + @ApiOperationSupport(order = 6) + public R saveRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { + return R.status(rehearsalRecordService.saveRehearsalRecord(rehearsalRecord)); + } + + @PostMapping("/updateRehearsalRecord") + @ApiOperation(value = "修改演练记录") + @ApiOperationSupport(order = 7) + public R updateRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { + return R.status(rehearsalRecordService.updateRehearsalRecord(rehearsalRecord)); + } + + @PostMapping("/removeRehearsalRecord") + @ApiOperation(value = "删除演练记录") + @ApiOperationSupport(order = 8) + public R removeRehearsalRecord(@RequestParam Long id) { + return R.status(rehearsalRecordService.removeById(id)); + } + + @GetMapping("/rehearsalRecordDetail") + @ApiOperation(value = "演练记录详情") + @ApiOperationSupport(order = 9) + public R rehearsalRecordDetail(@RequestParam Long id) { + return R.data(rehearsalRecordService.getById(id)); + } + + @GetMapping("/rehearsalRecordPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "rehearsalPlanId", value = "演练计划id", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练记录分页") + @ApiOperationSupport(order = 10) + public R> rehearsalRecordPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = rehearsalRecordService.page(Condition.getPage(query), + Condition.getQueryWrapper(param, RehearsalRecordEntity.class)); + return R.data(page); + } + + @GetMapping("/dataByMonth") + @ApiOperation(value = "月度统计表") + @ApiOperationSupport(order = 11) + public R> dataByMonth(@RequestParam String month, Query query) { + IPage page = rehearsalPlanService.dataByMonth(month, query); + return R.data(page); + } + + @GetMapping("/dataByYear") + @ApiOperation(value = "年度统计表") + @ApiOperationSupport(order = 12) + public R> dataByYear(@RequestParam String year, Query query) { + IPage page = rehearsalPlanService.dataByYear(year, query); + return R.data(page); + } + + @GetMapping("/exportRehearsalData") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练数据导出") + @ApiOperationSupport(order = 13) + public void exportRehearsalData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { + rehearsalPlanService.exportRehearsalPlanData(param, response); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java deleted file mode 100644 index f80e0fa..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.hnac.hzims.safeproduct.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.common.utils.Condition; -import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; -import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; -import com.hnac.hzims.safeproduct.service.IRehearsalPlanService; -import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; -import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; -import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; - -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.util.Map; - -/** - * 演练记录接口类 - * - * @author liwen - * @date 2023-12-13 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/rehearsal") -@Api(value = "演练记录", tags = "演练记录接口") -public class RehearsalRecordController extends BladeController { - - private final IRehearsalRecordService rehearsalRecordService; - - private final IRehearsalPlanService rehearsalPlanService; - - @PostMapping("/save") - @ApiOperation(value = "新增演练计划") - @ApiOperationSupport(order = 1) - public R save(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { - return R.status(rehearsalPlanService.save(rehearsalPlan)); - } - - @PostMapping("/update") - @ApiOperation(value = "修改演练计划") - @ApiOperationSupport(order = 2) - public R update(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { - return R.status(rehearsalPlanService.updateById(rehearsalPlan)); - } - - @PostMapping("/remove") - @ApiOperation(value = "删除演练计划") - @ApiOperationSupport(order = 3) - public R remove(@RequestParam Long id) { - return R.status(rehearsalPlanService.removeRehearsalPlan(id)); - } - - @GetMapping("/detail") - @ApiOperation(value = "演练计划详情") - @ApiOperationSupport(order = 4) - public R detail(@RequestParam Long id) { - return R.data(rehearsalPlanService.getById(id)); - } - - @GetMapping("/page") - @ApiImplicitParams({ - @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") - }) - @ApiOperation(value = "演练计划分页") - @ApiOperationSupport(order = 5) - public R> page(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = rehearsalPlanService.rehearsalPlanPage(param, query); - return R.data(page); - } - - @PostMapping("/saveRehearsalRecord") - @ApiOperation(value = "新增演练记录") - @ApiOperationSupport(order = 6) - public R saveRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { - return R.status(rehearsalRecordService.saveRehearsalRecord(rehearsalRecord)); - } - - @PostMapping("/updateRehearsalRecord") - @ApiOperation(value = "修改演练记录") - @ApiOperationSupport(order = 7) - public R updateRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { - return R.status(rehearsalRecordService.updateRehearsalRecord(rehearsalRecord)); - } - - @PostMapping("/removeRehearsalRecord") - @ApiOperation(value = "删除演练记录") - @ApiOperationSupport(order = 8) - public R removeRehearsalRecord(@RequestParam Long id) { - return R.status(rehearsalRecordService.removeById(id)); - } - - @GetMapping("/rehearsalRecordDetail") - @ApiOperation(value = "演练记录详情") - @ApiOperationSupport(order = 9) - public R rehearsalRecordDetail(@RequestParam Long id) { - return R.data(rehearsalRecordService.getById(id)); - } - - @GetMapping("/rehearsalRecordPage") - @ApiImplicitParams({ - @ApiImplicitParam(name = "rehearsalPlanId", value = "演练计划id", dataType = "query", paramType = "string") - }) - @ApiOperation(value = "演练记录分页") - @ApiOperationSupport(order = 10) - public R> rehearsalRecordPage(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = rehearsalRecordService.page(Condition.getPage(query), - Condition.getQueryWrapper(param, RehearsalRecordEntity.class)); - return R.data(page); - } - - @GetMapping("/dataByMonth") - @ApiOperation(value = "月度统计表") - @ApiOperationSupport(order = 11) - public R> dataByMonth(@RequestParam String month, Query query) { - IPage page = rehearsalPlanService.dataByMonth(month, query); - return R.data(page); - } - - @GetMapping("/dataByYear") - @ApiOperation(value = "年度统计表") - @ApiOperationSupport(order = 12) - public R> dataByYear(@RequestParam String year, Query query) { - IPage page = rehearsalPlanService.dataByYear(year, query); - return R.data(page); - } - - @GetMapping("/exportRehearsalData") - @ApiImplicitParams({ - @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") - }) - @ApiOperation(value = "演练数据导出") - @ApiOperationSupport(order = 13) - public void exportRehearsalData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { - rehearsalPlanService.exportRehearsalPlanData(param, response); - } -} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java index 647fb1f..1d1932c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java @@ -24,6 +24,7 @@ import org.springblade.core.mp.support.Query; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; @@ -72,6 +73,10 @@ public class RehearsalPlanServiceImpl extends ServiceImpl page = new Page<>(query.getCurrent(), query.getSize()); IPage unitPage = baseMapper.selectByMonth(page, month); List unitList = unitPage.getRecords(); + // 若无数据,返回空页面 + if (CollectionUtils.isEmpty(unitList)) { + return unitPage; + } // 查询当月各单位已完成的演练数据 IPage page1 = new Page<>(query.getCurrent(), query.getSize()); IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); @@ -102,7 +107,7 @@ public class RehearsalPlanServiceImpl extends ServiceImpl unitPage = baseMapper.selectUnitByYear(page, year); List records = unitPage.getRecords(); // 若无数据,返回空页面 - if (org.springframework.util.CollectionUtils.isEmpty(records)) { + if (CollectionUtils.isEmpty(records)) { return unitPage; } List unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList()); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java index b3a6701..6aa0b5d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java @@ -12,6 +12,7 @@ import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; import com.hnac.hzims.safeproduct.mapper.RehearsalPlanMapper; import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper; import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -42,21 +43,7 @@ public class RehearsalRecordServiceImpl extends ServiceImpl Date: Tue, 2 Jan 2024 10:52:03 +0800 Subject: [PATCH 2/9] =?UTF-8?q?update:=20=E5=9F=B9=E8=AE=AD=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/entity/TrainPlanEntity.java | 7 ++- .../safeproduct/entity/TrainRecordEntity.java | 1 - .../safeproduct/controller/TrainController.java | 4 +- .../safeproduct/service/impl/TestServiceImpl.java | 53 +++++++++------------- .../service/impl/TrainPlanServiceImpl.java | 4 ++ .../service/impl/TrainRecordServiceImpl.java | 18 +------- 6 files changed, 35 insertions(+), 52 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java index 9b1b0fb..93db233 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java @@ -4,6 +4,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,12 +33,14 @@ public class TrainPlanEntity extends BaseEntity { private String unit; @NotNull - @ApiModelProperty("计划培训开始时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划开始时间") @ExcelProperty(value = "计划开始时间", index = 6) private Date scheduledStartTime; @NotNull - @ApiModelProperty("计划培训结束时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划结束时间") @ExcelProperty(value = "计划结束时间", index = 7) private Date scheduledEndTime; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java index 24f2e2f..b8728dc 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java @@ -41,7 +41,6 @@ public class TrainRecordEntity extends BaseEntity { @ExcelProperty(value = "培训学员", index = 3) private String peopleName; - @Size(max = 5000, message = "培训内容字段长度超出限制范围") @ApiModelProperty("培训内容") @ExcelProperty(value = "培训内容", index = 2) private String content; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java index d306a47..172a59b 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java @@ -83,8 +83,8 @@ public class TrainController extends BladeController { @GetMapping("/trainPlanPage") @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledStartTime", value = "计划培训开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划培训结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训计划分页") @ApiOperationSupport(order = 5) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java index 8ab1dfa..9df05c4 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.date.DatePattern; import com.alibaba.excel.util.CollectionUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.TestDTO; import com.hnac.hzims.safeproduct.entity.TestEntity; @@ -14,6 +13,7 @@ import com.hnac.hzims.safeproduct.mapper.TestMapper; import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.service.ITestScoreService; import com.hnac.hzims.safeproduct.service.ITestService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import org.springblade.core.tool.api.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -56,21 +56,7 @@ public class TestServiceImpl extends ServiceImpl impleme // 查询是否存在同月编号 String lastCode = getLastCode(currentMonth); // 若不存在,新增编号 - String code; - if (StringUtils.isNull(lastCode)) { - code = "KSJL" + currentMonth + "001"; - } else { // 若存在,编号递增 - String oldNum = lastCode.substring(lastCode.length() - 3); - int value = Integer.parseInt(oldNum) + 1; - // 根据数位拼接编号 - if (value < 10) { - code = "KSJL" + currentMonth + "00" + value; - } else if (value < 100) { - code = "KSJL" + currentMonth + "0" + value; - } else { - code = "KSJL" + currentMonth + value; - } - } + String code = BaseUtil.getUniqueCode("KSJL", lastCode, currentMonth); testEntity.setCode(code); boolean saveTest = this.save(testEntity); // 若新增考试记录成功,添加相关的参考人员数据 @@ -81,13 +67,7 @@ public class TestServiceImpl extends ServiceImpl impleme String people = test.getPeopleName(); String[] person = people.split(",|,"); // 新增参考人员成绩数据 - List scoreList = new ArrayList<>(); - for(String name : person) { - TestScoreEntity testScoreEntity = new TestScoreEntity(); - testScoreEntity.setTestId(test.getId()); - testScoreEntity.setName(name); - scoreList.add(testScoreEntity); - } + List scoreList = getReferenceTestScore(test, person); return R.status(testScoreService.saveBatch(scoreList)); } return R.fail("新增考试记录失败"); @@ -185,20 +165,31 @@ public class TestServiceImpl extends ServiceImpl impleme if (removeByIds) { String[] person = testEntity.getPeopleName().split(",|,"); // 新增参考人员成绩数据 - List res = new ArrayList<>(); - for (String name : person) { - TestScoreEntity testScoreEntity = new TestScoreEntity(); - testScoreEntity.setTestId(testEntity.getId()); - testScoreEntity.setName(name); - res.add(testScoreEntity); - } - return testScoreService.saveBatch(res); + List scoreList = getReferenceTestScore(testEntity, person); + return testScoreService.saveBatch(scoreList); } } return false; } /** + * 获取成绩列表 + * @param testEntity 考试记录实体类 + * @param person 参考人员 + * @return 成绩列表 + */ + private List getReferenceTestScore(TestEntity testEntity, String[] person) { + List res = new ArrayList<>(); + for (String name : person) { + TestScoreEntity testScoreEntity = new TestScoreEntity(); + testScoreEntity.setTestId(testEntity.getId()); + testScoreEntity.setName(name); + res.add(testScoreEntity); + } + return res; + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java index cba9def..27a8d8e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java @@ -63,6 +63,10 @@ public class TrainPlanServiceImpl extends ServiceImpl page = new Page<>(query.getCurrent(), query.getSize()); IPage unitPage = baseMapper.selectByMonth(page, month); List unitList = unitPage.getRecords(); + // 若无数据,返回空页面 + if (CollectionUtils.isEmpty(unitList)) { + return unitPage; + } // 查询当月各单位已完成的培训数据 IPage page1 = new Page<>(query.getCurrent(), query.getSize()); IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java index 230a4d2..79d9c05 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java @@ -10,7 +10,6 @@ import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; @@ -20,6 +19,7 @@ import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.mapper.TrainRecordMapper; import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITrainRecordService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import org.springblade.core.log.exception.ServiceException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -61,21 +61,7 @@ public class TrainRecordServiceImpl extends ServiceImpl Date: Tue, 2 Jan 2024 10:52:15 +0800 Subject: [PATCH 3/9] =?UTF-8?q?update:=20=E4=BC=9A=E8=AE=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/entity/ConferencePlanEntity.java | 3 +++ .../safeproduct/entity/ConferenceRecordEntity.java | 1 - .../service/impl/ConferencePlanServiceImpl.java | 4 ++-- .../service/impl/ConferenceRecordServiceImpl.java | 18 ++---------------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java index a7261a9..914c031 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java @@ -1,6 +1,7 @@ package com.hnac.hzims.safeproduct.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,10 +33,12 @@ public class ConferencePlanEntity extends BaseEntity { private String theme; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("会议计划开始时间") private Date scheduledStartTime; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("会议计划结束时间") private Date scheduledEndTime; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java index 1aa0309..99e3341 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java @@ -41,7 +41,6 @@ public class ConferenceRecordEntity extends BaseEntity { @ApiModelProperty("记录人") private String recorder; - @Size(max = 250, message = "会议内容字段长度不能超过250") @ApiModelProperty("会议内容") private String content; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java index 2d742ce..803b972 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java @@ -62,8 +62,8 @@ public class ConferencePlanServiceImpl extends ServiceImpl planPage(Map param, Query query) { QueryWrapper queryWrapper = new QueryWrapper<>(); String unit = String.valueOf(param.get("unit")); - String startTime = String.valueOf(param.get("startTime")); - String endTime = String.valueOf((param.get("endTime"))); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf((param.get("scheduledEndTime"))); if (!unit.equals("null") && !unit.equals("")) { queryWrapper.lambda().like(ConferencePlanEntity::getUnit, unit); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java index 622683c..7350c86 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.date.DatePattern; import com.alibaba.excel.util.CollectionUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; @@ -12,6 +11,7 @@ import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; import com.hnac.hzims.safeproduct.mapper.ConferencePlanMapper; import com.hnac.hzims.safeproduct.mapper.ConferenceRecordMapper; import com.hnac.hzims.safeproduct.service.IConferenceRecordService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -59,21 +59,7 @@ public class ConferenceRecordServiceImpl extends ServiceImpl Date: Tue, 2 Jan 2024 13:38:49 +0800 Subject: [PATCH 4/9] =?UTF-8?q?#=E8=AE=BE=E5=A4=87=E6=A1=A3=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/spare/feign/ISpareClient.java | 6 ++ .../hzims/spare/feign/ISpareClientFallback.java | 6 ++ .../java/com/hnac/hzims/spare/vo/SparePartVO.java | 36 +++++++++ .../hnac/hzims/equipment/feign/IEmInfoClient.java | 5 ++ .../hzims/equipment/feign/IEmInfoClientBack.java | 5 ++ .../access/feign/AccessMaterialClientFallback.java | 20 +++++ .../access/feign/IAccessMaterialClient.java | 28 +++++++ .../operational/access/vo/MaterialConsumeVO.java | 17 +++++ .../com/hnac/hzims/spare/feign/SpareClient.java | 11 +++ .../hnac/hzims/spare/mapper/WtSpBasicMapper.java | 3 + .../hnac/hzims/spare/mapper/WtSpBasicMapper.xml | 16 ++++ .../hzims/spare/service/IWtSpBasicService.java | 3 + .../spare/service/impl/WtSpBasicServiceImpl.java | 6 ++ hzims-service/equipment/pom.xml | 4 + .../equipment/controller/EmInfoController.java | 3 +- .../hnac/hzims/equipment/feign/EmInfoClient.java | 16 ++++ .../hnac/hzims/equipment/mapper/EmInfoMapper.java | 2 +- .../hnac/hzims/equipment/mapper/EmInfoMapper.xml | 2 +- .../hzims/equipment/service/IEmInfoService.java | 3 + .../equipment/service/impl/EmInfoServiceImpl.java | 85 +++++++++++++++++++++- .../com/hnac/hzims/equipment/vo/SparePartVO.java | 32 -------- .../access/feign/AccessMaterialClient.java | 34 +++++++++ .../access/mapper/OperAccessMaterialMapper.java | 3 + .../access/mapper/OperAccessMaterialMapper.xml | 15 ++++ .../access/mapper/OperAccessTaskMapper.java | 2 +- .../access/mapper/OperAccessTaskMapper.xml | 10 ++- .../access/service/IOperAccessMaterialService.java | 3 + .../impl/OperAccessMaterialServiceImpl.java | 11 +++ .../service/impl/OperAccessTaskServiceImpl.java | 27 ++++++- .../hzims/operational/access/vo/RepairBillVO.java | 3 + .../workTicket/mapper/WorkTicketInfoMapper.java | 2 +- .../workTicket/mapper/xml/WorkTicketInfoMapper.xml | 12 +-- .../service/impl/WorkTicketInfoServiceImpl.java | 25 +++++-- .../ticket/workTicket/vo/WorkTicketBillVO.java | 4 + 34 files changed, 399 insertions(+), 61 deletions(-) create mode 100644 hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SparePartVO.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClientFallback.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessMaterialClient.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/MaterialConsumeVO.java delete mode 100644 hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java create mode 100644 hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClient.java diff --git a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java index ba86f10..0318679 100644 --- a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java +++ b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClient.java @@ -3,6 +3,7 @@ package com.hnac.hzims.spare.feign; import com.hnac.hzims.operational.census.vo.AreaTimelyVo; import com.hnac.hzims.spare.entity.*; import com.hnac.hzims.spare.vo.ExceedVo; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.spare.vo.WtSpBasicVO; import org.springblade.core.tool.api.R; import org.springframework.cloud.openfeign.FeignClient; @@ -23,6 +24,8 @@ public interface ISpareClient { String EXCEED_LIMIT = API_PREFIX + "/exceedLimit" ; + String SPARE_PART = API_PREFIX + "/sparePart" ; + /** * 保存工单与出库单关联信息 * @param recordEntity @@ -33,4 +36,7 @@ public interface ISpareClient { @PostMapping(EXCEED_LIMIT) List exceedLimit(@RequestParam("deptId") Long deptId); + + @GetMapping(EXCEED_LIMIT) + List sparePart(@RequestParam("basics") List basics); } diff --git a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java index 6a55a8e..35e052e 100644 --- a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java +++ b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/feign/ISpareClientFallback.java @@ -2,6 +2,7 @@ package com.hnac.hzims.spare.feign; import com.hnac.hzims.operational.census.vo.AreaTimelyVo; import com.hnac.hzims.spare.entity.*; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.spare.vo.WtSpBasicVO; import org.springblade.core.tool.api.R; import org.springframework.stereotype.Component; @@ -24,4 +25,9 @@ public class ISpareClientFallback implements ISpareClient { public List exceedLimit(Long deptId) { return new ArrayList<>(); } + + @Override + public List sparePart(List basics) { + return new ArrayList<>(); + } } diff --git a/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SparePartVO.java b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SparePartVO.java new file mode 100644 index 0000000..52ca7de --- /dev/null +++ b/hzims-service-api/assets-api/src/main/java/com/hnac/hzims/spare/vo/SparePartVO.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.spare.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author tanghaihao + * @date 2023年07月13日 17:23 + */ +@Data +public class SparePartVO { + + @ApiModelProperty(value = "物资类别编号") + private Long basicId; + + @ApiModelProperty(value = "设备名称") + private String emName; + + @ApiModelProperty(value = "仓库") + private String houseName; + + @ApiModelProperty(value = "物资种类") + private String basicName; + + @ApiModelProperty(value = "物资消耗(件)") + private Integer expend; + + @ApiModelProperty(value = "库存上限") + private Integer upperLimit; + + @ApiModelProperty(value = "库存下限") + private Integer lowerLimit; + + @ApiModelProperty(value = "物资库存(件)") + private Integer stock; +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java index 235ccdc..084f3b0 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java @@ -82,6 +82,8 @@ public interface IEmInfoClient { String GET_EM_CREATE_TABLE = API_PREFIX + "/getEmCreateTable"; String GET_VIDEO_DEVICE_BY_EM_CODE = API_PREFIX + "/getVideoDeviceByEmCode"; + String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath"; + @PostMapping(DETAIL) EmInfoEntity getByCode(@RequestParam("code") String id); @@ -161,4 +163,7 @@ public interface IEmInfoClient { @GetMapping(value = GET_VIDEO_DEVICE_BY_EM_CODE) List getVideoDeviceByEmCode(EmInfoEntity emInfo); + + @GetMapping(DEVICE_BY_PATH) + List deviceByPath(@RequestParam("emCode") String emCode); } diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java index 02ccc38..9239354 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java @@ -104,4 +104,9 @@ public class IEmInfoClientBack implements IEmInfoClient { public List getVideoDeviceByEmCode(EmInfoEntity emInfo) { return new ArrayList<>(); } + + @Override + public List deviceByPath(String emCode) { + return new ArrayList<>(); + } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClientFallback.java new file mode 100644 index 0000000..7acb56b --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClientFallback.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.operational.access.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.vo.MaterialConsumeVO; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author ysj + */ +@Component +public class AccessMaterialClientFallback implements IAccessMaterialClient { + + @Override + public List materialConsume(List basics) { + return new ArrayList<>(); + } +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessMaterialClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessMaterialClient.java new file mode 100644 index 0000000..f77298c --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IAccessMaterialClient.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.operational.access.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.OperationalConstants; +import com.hnac.hzims.operational.access.vo.MaterialConsumeVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author ysj + */ +@FeignClient( + value = OperationalConstants.APP_NAME, + fallback = AccessMaterialClientFallback.class +) +public interface IAccessMaterialClient { + + String API_PREFIX = "/feign/accessMaterial"; + + String MATERIAL_CONSUME = API_PREFIX + "/materialConsume"; + + @GetMapping(MATERIAL_CONSUME) + List materialConsume(@RequestParam("basics") List basics); +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/MaterialConsumeVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/MaterialConsumeVO.java new file mode 100644 index 0000000..ed1c28f --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/MaterialConsumeVO.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.operational.access.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class MaterialConsumeVO { + + @ApiModelProperty(value = "物资编号") + private Long basicId; + + @ApiModelProperty(value = "消耗数量") + private Integer expend; +} diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java index 4711db9..7eaa129 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/feign/SpareClient.java @@ -6,6 +6,7 @@ import com.hnac.hzims.spare.entity.*; import com.hnac.hzims.spare.mapper.SpRecordMapper; import com.hnac.hzims.spare.mapper.SpWarehouseOutMapper; import com.hnac.hzims.spare.service.*; +import com.hnac.hzims.spare.vo.SparePartVO; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -129,4 +130,14 @@ public class SpareClient implements ISpareClient{ } return exceeds; } + + /** + * 备品备件台账 + * @param basics + * @return + */ + @Override + public List sparePart(List basics) { + return wtSpBasicService.sparePart(basics); + } } diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java index 74bf8bb..3ec89f4 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.java @@ -2,9 +2,11 @@ package com.hnac.hzims.spare.mapper; import com.hnac.hzims.spare.entity.SpTemporaryStockDetailEntity; import com.hnac.hzims.spare.entity.WtSpBasicEntity; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.spare.vo.WtSpBasicVO; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; import java.util.Map; @@ -46,4 +48,5 @@ public interface WtSpBasicMapper extends UserDataScopeBaseMapper getInList(Long spBasicId); + List sparePart(@RequestParam("basics") List basics); } diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml index d832b9d..7db89ac 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/mapper/WtSpBasicMapper.xml @@ -94,4 +94,20 @@ AND b.type = 5 + + diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/IWtSpBasicService.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/IWtSpBasicService.java index 64fcef5..0bf27a7 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/IWtSpBasicService.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/IWtSpBasicService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.spare.entity.SpTemporaryStockDetailEntity; import com.hnac.hzims.spare.entity.SpTemporaryStockEntity; import com.hnac.hzims.spare.entity.WtSpBasicEntity; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.spare.vo.WtSpBasicVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; @@ -73,6 +74,8 @@ public interface IWtSpBasicService extends BaseService { R importExcel(MultipartFile file) throws Exception; + List sparePart(List basics); + /** * 获取流程中的用户 * @param deptId diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java index 8955c81..6f40e06 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java @@ -29,6 +29,7 @@ import com.hnac.hzims.spare.service.IWtSpTotalService; import com.hnac.hzims.spare.service.IWtSpWarehouseService; import com.hnac.hzims.spare.utils.ExcelToolListener; import com.hnac.hzims.spare.utils.SheetWriteStyleHandler; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.spare.vo.WtSpBasicVO; import com.hnac.hzims.ticket.allTicket.fegin.ITicketInfoAllClient; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; @@ -580,6 +581,11 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl sparePart(List basics) { + return this.basicMapper.sparePart(basics); + } + private InputStream copyStream(InputStream source) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; diff --git a/hzims-service/equipment/pom.xml b/hzims-service/equipment/pom.xml index 90808d8..e2286e6 100644 --- a/hzims-service/equipment/pom.xml +++ b/hzims-service/equipment/pom.xml @@ -98,6 +98,10 @@ com.hnac.hzims inspect-api + + com.hnac.hzims + assets-api + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java index 92ab91d..e1346c1 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java @@ -10,14 +10,13 @@ import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.equipment.dto.DeviceTreeDTO; import com.hnac.hzims.equipment.entity.EmInfoEntity; -import com.hnac.hzims.equipment.entity.EmTreeEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.EmInfoAddVo; import com.hnac.hzims.equipment.vo.EmInfoContentVO; import com.hnac.hzims.equipment.vo.EmInfoVO; -import com.hnac.hzims.equipment.vo.SparePartVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.util.MemoryPagination; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import io.swagger.annotations.Api; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java index fbbef97..ca0e5f3 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java @@ -9,11 +9,16 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.DeviceVO; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.vo.CreateTableVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -131,6 +136,17 @@ public class EmInfoClient implements IEmInfoClient { public List getVideoDeviceByEmCode(EmInfoEntity emInfo) { return service.getVideoDeviceByEmCode(emInfo); } + + /** + * 获取设备路径下的设备 + * @param emCode + * @return + */ + @Override + public List deviceByPath(String emCode) { + return service.deviceByPath(emCode); + } + @PostMapping(GET_EM_CREATE_TABLE) @Override public List getEmCreateTable(List tableNames) { diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java index 3f2cb5c..f9b826b 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java @@ -4,7 +4,7 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.EmInfoExtendVo; import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; -import com.hnac.hzims.equipment.vo.SparePartVO; +import com.hnac.hzims.spare.vo.SparePartVO; import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml index 7b3e34f..e9d738a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml @@ -120,7 +120,7 @@ select max(em_index) from hzims_em_info where DEPARTMENT = #{department} and em_grade = #{emGrade} and is_deleted = 0 - select info.`NAME` as emName,house.`NAME` as houseName,basic.`NAME` as basicName, mat.number as expend,basic.UPPER_LIMIT,basic.LOWER_LIMIT,total.stock from hzims_em_info info diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java index 8562541..e3527c3 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.equipment.dto.DeviceTreeDTO; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.*; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.tool.api.R; @@ -91,4 +92,6 @@ public interface IEmInfoService extends BaseService { List getVideoDeviceByEmCode(EmInfoEntity emInfo); List hkVideoDevices(); + + List deviceByPath(String emCode); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index cadc489..c796b39 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -17,9 +17,13 @@ import com.hnac.hzims.equipment.mapper.EmInfoNoScopeMapper; import com.hnac.hzims.equipment.service.*; import com.hnac.hzims.equipment.vo.*; import com.hnac.hzims.fdp.service.IFdpQuestionService; +import com.hnac.hzims.operational.access.feign.IAccessMaterialClient; +import com.hnac.hzims.operational.access.vo.MaterialConsumeVO; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; +import com.hnac.hzims.spare.feign.ISpareClient; +import com.hnac.hzims.spare.vo.SparePartVO; import com.hnac.hzims.util.TableJsonUtils; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; @@ -87,12 +91,17 @@ public class EmInfoServiceImpl extends BaseServiceImpl getSparePart(String emCode, String startTime, String endTime) { - EmInfoEntity emInfo = this.getEmInfoByEmCode(emCode); - return baseMapper.getSparePart(emInfo.getPath(), startTime, endTime); + // 查询路径设备 + List devices = deviceByPath(emCode); + if(CollectionUtil.isEmpty(devices)){ + return new ArrayList<>(); + } + // 物资台账记录 + List trees = devices.stream().map(EmInfoEntity::getTreeId).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(trees)){ + return new ArrayList<>(); + } + List treeBasics = emTreeBasicService.list(Wrappers.lambdaQuery() + .in(EmTreeBasicEntity::getTreeId,trees)); + if(CollectionUtil.isEmpty(treeBasics)){ + return new ArrayList<>(); + } + List basics = treeBasics.stream().map(EmTreeBasicEntity::getBasicId).filter(ObjectUtil::isNotEmpty).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(basics)){ + return new ArrayList<>(); + } + // 仓库、物资种类、库存上限、库存下限、物资库存 + List spares = spareClient.sparePart(basics); + if(CollectionUtil.isEmpty(spares)){ + return new ArrayList<>(); + } + // 物资消耗 + List consumes = accessMaterialClient.materialConsume(basics); + return spares.stream().peek(spare -> { + List spareConsumes = consumes.stream().filter(consume->consume.getBasicId().equals(spare.getBasicId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(spareConsumes)){ + spare.setExpend(0); + }else{ + spare.setExpend(spareConsumes.get(0).getExpend()); + } + // 设备名称 + List deviceBasics = treeBasics.stream().filter(tree->tree.getBasicId().equals(spare.getBasicId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(deviceBasics)){ + spare.setEmName("未知设备"); + }else{ + List deivceEntitys = devices.stream().filter(device->device.getTreeId().equals(deviceBasics.get(0).getTreeId())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(deivceEntitys)){ + spare.setEmName("未知设备"); + }else{ + spare.setEmName(deivceEntitys.get(0).getName()); + } + } + }).collect(Collectors.toList()); } @Override @@ -911,4 +971,23 @@ public class EmInfoServiceImpl extends BaseServiceImpl deviceByPath(String emCode) { + EmInfoEntity device = this.getOne(Wrappers.lambdaQuery(). + eq(EmInfoEntity::getNumber,emCode)); + if(ObjectUtil.isEmpty(device)){ + return new ArrayList<>(); + } + if(StringUtil.isEmpty(device.getPath())){ + return Collections.singletonList(device); + } + String[] deviceCodes = device.getPath().split("/"); + return this.list(Wrappers.lambdaQuery().in(EmInfoEntity::getNumber, Arrays.asList(deviceCodes))); + } + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java deleted file mode 100644 index d97b830..0000000 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/SparePartVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.hnac.hzims.equipment.vo; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -/** - * @author tanghaihao - * @date 2023年07月13日 17:23 - */ -@Data -public class SparePartVO { - @ApiModelProperty(value = "设备名称") - private String emName; - - @ApiModelProperty(value = "仓库") - private String houseName; - - @ApiModelProperty(value = "物资种类") - private String basicName; - - @ApiModelProperty(value = "物资消耗(件)") - private Integer expend; - - @ApiModelProperty(value = "库存上限") - private Integer upperLimit; - - @ApiModelProperty(value = "库存下限") - private Integer lowerLimit; - - @ApiModelProperty(value = "物资库存(件)") - private Integer stock; -} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClient.java new file mode 100644 index 0000000..803857f --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/AccessMaterialClient.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.operational.access.feign; + +import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.service.AccessPlanV4Service; +import com.hnac.hzims.operational.access.service.IOperAccessMaterialService; +import com.hnac.hzims.operational.access.vo.MaterialConsumeVO; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author ysj + */ +@RestController +@RequestMapping("/feign/accessMaterial") +@Slf4j +@RequiredArgsConstructor +public class AccessMaterialClient implements IAccessMaterialClient { + + private final IOperAccessMaterialService accessMaterialService; + + /** + * 备品备件台账-物资消耗 + * @param basics + * @return + */ + @Override + public List materialConsume(@RequestParam("basics") List basics) { + return accessMaterialService.materialConsume(basics); + } +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.java index a7c726c..d68d1f1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.java @@ -2,6 +2,7 @@ package com.hnac.hzims.operational.access.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.hnac.hzims.operational.access.entity.OperAccessMaterialEntity; +import com.hnac.hzims.operational.access.vo.MaterialConsumeVO; import org.apache.ibatis.annotations.Param; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; @@ -17,4 +18,6 @@ import java.util.List; public interface OperAccessMaterialMapper extends BaseMapper { List getList(@Param(value = "planId") String planId,@Param(value = "taskId") String taskId); + + List materialConsume(@Param(value = "basics") List basics); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml index 60ead9a..1310abb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessMaterialMapper.xml @@ -39,4 +39,19 @@ + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java index b45f846..9cb87d3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java @@ -41,5 +41,5 @@ public interface OperAccessTaskMapper extends UserDataScopeBaseMapper selectAccessTask(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("list")List list); - List getRepairBill(@Param("path") String path, @Param("startTime") String startTime, @Param("endTime") String endTime); + List getRepairBill(@Param("deviceCodes") List deviceCodes,@Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml index 4606b2d..7810d05 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml @@ -207,15 +207,17 @@ - - \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java index 96ac415..b888c54 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java @@ -1,10 +1,14 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import org.apache.ibatis.annotations.Mapper; +import java.util.Map; + /** * 卫生自查记录Mapper类 * @@ -20,4 +24,12 @@ public interface HygieneRecordMapper extends BaseMapper { * @return 卫生自查记录详情VO类 */ HygieneRecordDetailVO getRecordDetail(Long id); + + /** + * 卫生自查记录页面 + * @param param 入参 + * @param page 分页类 + * @return 记录数据页 + */ + IPage recordPage(IPage page, Map param); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml index 9913b1a..68efbe5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml @@ -3,13 +3,24 @@ + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.java new file mode 100644 index 0000000..b3d0e5c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface HygieneZoneMapper extends BaseMapper { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.xml new file mode 100644 index 0000000..8113ac8 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java index 6b62e72..6d3e98d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java @@ -2,7 +2,9 @@ package com.hnac.hzims.safeproduct.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; +import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -35,30 +37,43 @@ public interface IHygienePlanService extends IService { /** * 新增卫生自查计划 - * @param hygienePlanEntity 卫生自查计划实体类 + * @param hygienePlanDTO 卫生自查DTO类 * @return 结果封装类 */ - R savePlan(HygienePlanEntity hygienePlanEntity); + R savePlan(HygienePlanDTO hygienePlanDTO); /** * 修改卫生自查计划 - * @param hygienePlanEntity 卫生自查计划实体类 + * @param hygienePlanDTO 卫生自查DTO类 * @return 结果封装类 */ - R updatePlan(HygienePlanEntity hygienePlanEntity); + R updatePlan(HygienePlanDTO hygienePlanDTO); /** * 卫生自查月度数据 * @param month 月份 + * @param unit 单位 * @param query 分页类 * @return 月度统计分页 */ - IPage dataByMonth(String month, Query query); + IPage dataByMonth(String month, String unit, Query query); /** - * 卫生自查数据导出 - * @param param 入参 - * @param response 响应类 + * 卫生自查计划数据详情 + * @param id 卫生自查计划id + * @return 卫生自查计划详情VO类 + */ + HygienePlanDetailVO getPlan(Long id); + + /** + * 根据编码查询卫生自查计划 + * @param code 编码 + * @return 卫生自查计划实体类 + */ + HygienePlanEntity getPlanByCode(String code); + + /** + * 月度数据导出 */ - void exportHygieneData(Map param, HttpServletResponse response); + void exportMonthData(Map param, Query query, HttpServletResponse response); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java index 93ac01e..d717ad5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java @@ -1,10 +1,17 @@ package com.hnac.hzims.safeproduct.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + /** * 卫生自查记录服务类 * @@ -22,17 +29,17 @@ public interface IHygieneRecordService extends IService { /** * 新增卫生自查记录 - * @param hygieneRecordEntity 卫生自查记录实体类 + * @param hygieneRecordDTO 卫生自查记录DTO类 * @return 封装结果类 */ - R saveRecord(HygieneRecordEntity hygieneRecordEntity); + R saveRecord(HygieneRecordDTO hygieneRecordDTO); /** * 修改卫生自查记录 - * @param hygieneRecordEntity 卫生自查记录实体类 - * @return true-成功,false-失败 + * @param hygieneRecordDTO 卫生自查记录DTO类 + * @return 封装结果类 */ - R updateRecord(HygieneRecordEntity hygieneRecordEntity); + R updateRecord(HygieneRecordDTO hygieneRecordDTO); /** * 查询卫生自查记录详情 @@ -40,4 +47,19 @@ public interface IHygieneRecordService extends IService { * @return 卫生自查记录详情VO类 */ HygieneRecordDetailVO getRecordDetail(Long id); + + /** + * 卫生自查记录页面 + * @param param 入参 + * @param query 分页类 + * @return 记录数据页 + */ + IPage recordPage(Map param, Query query); + + /** + * 卫生自查记录数据导出 + * @param hygieneRecordId 卫生自查记录id + * @param response 响应类 + */ + void exportHygieneData(Long hygieneRecordId, HttpServletResponse response); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneZoneService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneZoneService.java new file mode 100644 index 0000000..3c62284 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneZoneService.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; + +import java.util.List; + +public interface IHygieneZoneService extends IService { + + /** + * 删除关联责任区数据 + * @param hygienePlanId 卫生自查计划id + * @return true-成功,false-失败 + */ + boolean removeReferenceZone(Long hygienePlanId); + + /** + * 查询关联责任区数据 + * @param hygienePlanId 卫生自查计划id + * @return 关联责任区数据 + */ + List getReferenceZone(Long hygienePlanId); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index 4ca5f3c..659fc88 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -10,18 +10,22 @@ 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.hnac.hzims.common.utils.Condition; -import com.hnac.hzims.safeproduct.dto.HygieneExportDTO; +import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; -import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; import com.hnac.hzims.safeproduct.service.IHygienePlanService; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; +import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; @@ -45,14 +49,24 @@ public class HygienePlanServiceImpl extends ServiceImpl planPage(Map param, Query query) { QueryWrapper queryWrapper = new QueryWrapper<>(); - String zone = String.valueOf(param.get("zone")); - String principal = String.valueOf(param.get("principal")); - if (!zone.equals("null") && !zone.equals("")) { - queryWrapper.lambda().like(HygienePlanEntity::getZone, zone); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf(param.get("scheduledEndTime")); + if (!startTime.equals("null") && !startTime.equals("")) { + queryWrapper.lambda().ge(HygienePlanEntity::getScheduledStartTime, startTime); } - if (!principal.equals("null") && !principal.equals("")) { - queryWrapper.lambda().ge(HygienePlanEntity::getPrincipal, principal); + if (!endTime.equals("null") && !endTime.equals("")) { + queryWrapper.lambda().le(HygienePlanEntity::getScheduledEndTime, endTime); } return this.page(Condition.getPage(query), queryWrapper); } @@ -77,48 +91,84 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); + // 若计划新增成功,新增关联责任区数据 + if (savePlan) { + HygienePlanEntity hygienePlan = getPlanByCode(hygienePlanDTO.getCode()); + for (HygieneZoneEntity zone : zoneList) { + // 传计划id + if (hygienePlan != null) { + zone.setHygienePlanId(hygienePlan.getId()); + } + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + R res = getSumScore(scores, hygienePlanDTO.getStandardScore()); + if (!res.isSuccess()) { + return res; + } + } + // 校验通过则批量新增责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); + } + return R.status(Boolean.FALSE); } /** * 修改卫生自查计划 */ @Override - public R updatePlan(HygienePlanEntity hygienePlanEntity) { - String[] scores = hygienePlanEntity.getCheckItemScore().split(",|,"); - Integer standardScore = hygienePlanEntity.getStandardScore(); - R res = getSumScore(scores, standardScore); - return res.isSuccess() ? R.status(this.updateById(hygienePlanEntity)) : res; + public R updatePlan(HygienePlanDTO hygienePlanDTO) { + // 修改卫生自查计划 + HygienePlanEntity hygienePlanEntity = new HygienePlanEntity(); + BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); + boolean updatePlan = this.updateById(hygienePlanEntity); + List zoneList = hygienePlanDTO.getZoneList(); + // 若计划修改成功,修改关联责任区数据 + if (updatePlan) { + for (HygieneZoneEntity zone : zoneList) { + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + R res = getSumScore(scores, hygienePlanDTO.getStandardScore()); + if (!res.isSuccess()) { + return res; + } + } + // 校验通过则批量修改责任区数据 + return R.status(hygieneZoneService.updateBatchById(zoneList)); + } + return R.status(Boolean.FALSE); } /** * 卫生自查月度数据 */ @Override - public IPage dataByMonth(String month, Query query) { + public IPage dataByMonth(String month, String unit, Query query) { // 查询当月各单位的卫生自查总数 IPage page = new Page<>(query.getCurrent(), query.getSize()); - IPage unitPage = baseMapper.selectByMonth(page, month); + IPage unitPage = baseMapper.selectByMonth(page, unit, month); List unitList = unitPage.getRecords(); // 查询当月各单位已完成的卫生自查数据 IPage page1 = new Page<>(query.getCurrent(), query.getSize()); - IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); + IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, unit, month); List finishedList = finishedPage.getRecords(); // 处理统计数据 - for (HygieneMonthVO unit : unitList) { - Long taskNum = unit.getScheduledCheckNum(); - Optional finishedHygiene = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); + for (HygieneMonthVO u : unitList) { + Long taskNum = u.getScheduledCheckNum(); + Optional finishedHygiene = finishedList.stream().filter(x -> x.getUnit().equals(u.getUnit())).findFirst(); Long finishedTaskNum = finishedHygiene.isPresent() ? finishedHygiene.get().getFinishedCheckNum() : 0L; - unit.setFinishedCheckNum(finishedTaskNum); - unit.setUnfinishedCheckNum(taskNum - finishedTaskNum); + u.setFinishedCheckNum(finishedTaskNum); + u.setUnfinishedCheckNum(taskNum - finishedTaskNum); BigDecimal taskDecimal = new BigDecimal(taskNum); BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); - unit.setCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) + u.setCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) .setScale(2, RoundingMode.HALF_UP)); } unitPage.setRecords(unitList); @@ -126,32 +176,61 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygieneZoneService.getReferenceZone(id); + hygienePlanDetailVO.setZoneList(zoneList); + return hygienePlanDetailVO; + } + + /** + * 计算累计分值 + * @param scores 各项分值 + * @param standardScore 标准总分值 + * @return 累计分值等于标准总分值时,返回数据,否则返回错误信息 + */ + private R getSumScore(String[] scores, Integer standardScore) { + int sum = 0; + for (String score : scores) { + sum += Integer.parseInt(score); + if (sum > standardScore) { + return R.fail("累计分值已超过标准总分值"); + } + } + return sum < standardScore ? R.fail("标准总分值未全部分配") : R.data(sum); + } + + /** + * 根据编码查询卫生自查计划 + */ + @Override + public HygienePlanEntity getPlanByCode(String code) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygienePlanEntity::getCode, code); + return this.getOne(queryWrapper); + } + + /** + * 月度数据导出 */ @Override - public void exportHygieneData(Map param, HttpServletResponse response) { + public void exportMonthData(Map param, Query query, HttpServletResponse response) { ServletOutputStream outputStream = null; try { outputStream = response.getOutputStream(); String unit = String.valueOf(param.get("unit")); - String startTime = String.valueOf(param.get("scheduledStartTime")); - String endTime = String.valueOf(param.get("scheduledEndTime")); - List rehearsalList = getHygieneByUnitAndDate(unit, startTime, endTime); - // 处理卫生自查状态信息 - rehearsalList.forEach(record -> { - String status; - if (record.getHygieneStatus().equals(HygieneStatusEnum.WAITING.getValue())) { - status = HygieneStatusEnum.WAITING.getDesc(); - } else if (record.getHygieneStatus().equals(HygieneStatusEnum.UNFINISHED.getValue())) { - status = HygieneStatusEnum.UNFINISHED.getDesc(); - } else { - status = HygieneStatusEnum.FINISHED.getDesc(); - } - record.setHygieneStatus(status); - }); + String month = String.valueOf(param.get("month")); + IPage monthPage = dataByMonth(month, unit, query); + List records = monthPage.getRecords(); // 设置响应头 // URLEncoder.encode防止中文乱码 - String fileName = URLEncoder.encode("卫生自查数据表", "UTF-8"); + String fileName = URLEncoder.encode("卫生自查月度统计表", "UTF-8"); response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("UTF-8"); @@ -162,52 +241,24 @@ public class HygienePlanServiceImpl extends ServiceImpl standardScore) { - return R.fail("累计分值已超过标准总分值"); - } - } - return sum < standardScore ? R.fail("标准总分值未全部分配") : R.data(sum); - } - - /** - * 根据单位和计划时间查询卫生自查记录 - * @param unit 单位 - * @param startTime 计划开始时间 - * @param endTime 计划结束时间 - * @return 卫生自查记录 - */ - public List getHygieneByUnitAndDate(String unit, String startTime, String endTime) { - return baseMapper.getHygieneByUnitAndDate(unit, startTime, endTime); - } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 321078c..469d5fa 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -1,26 +1,48 @@ package com.hnac.hzims.safeproduct.service.impl; import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.converters.longconverter.LongStringConverter; import com.alibaba.excel.util.CollectionUtils; +import com.alibaba.excel.write.merge.LoopMergeStrategy; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; 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.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; import com.hnac.hzims.safeproduct.mapper.HygieneRecordMapper; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; +import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; +import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; +import com.hnac.hzims.safeproduct.vo.HygieneZoneDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.ss.usermodel.CellStyle; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; import java.time.LocalDate; import java.time.ZoneId; import java.time.temporal.WeekFields; -import java.util.Date; -import java.util.List; -import java.util.Locale; +import java.util.*; import java.util.stream.Collectors; /** @@ -35,6 +57,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl 0) { - return R.fail("评分不能大于标准总分值"); + String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",|,"); + for (String score : scores) { + int sc = Integer.parseInt(score); + if (sc > hygienePlanEntity.getStandardScore()) { + return R.fail("评分不能大于标准总分值"); + } } return R.status(this.save(hygieneRecordEntity)); } @@ -94,14 +111,20 @@ public class HygieneRecordServiceImpl extends ServiceImpl 0) { - return R.fail("评分不能大于标准总分值"); + String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",|,"); + for (String score : scores) { + int sc = Integer.parseInt(score); + if (sc > hygienePlanEntity.getStandardScore()) { + return R.fail("评分不能大于标准总分值"); + } } return R.status(this.updateById(hygieneRecordEntity)); } @@ -111,7 +134,80 @@ public class HygieneRecordServiceImpl extends ServiceImpl checkDetailVOList = new ArrayList<>(); + for (int i = 0; i < zoneIds.length ; i++) { + HygieneZoneDetailVO zoneDetailVO = new HygieneZoneDetailVO(); + HygieneZoneEntity hygieneZoneEntity = hygieneZoneService.getById(zoneIds[i]); + BeanUtils.copyProperties(hygieneZoneEntity, zoneDetailVO); + zoneDetailVO.setResult(results[i]); + zoneDetailVO.setScore(Integer.parseInt(scores[i])); + checkDetailVOList.add(zoneDetailVO); + } + recordDetailVO.setCheckList(checkDetailVOList); + return recordDetailVO; + } + + /** + * 卫生自查记录页面 + */ + @Override + public IPage recordPage(Map param, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + return baseMapper.recordPage(page, param); + } + + /** + * 卫生自查数据导出 + */ + @Override + public void exportHygieneData(Long hygieneRecordId, HttpServletResponse response) { + ServletOutputStream outputStream = null; + try { + outputStream = response.getOutputStream(); + HygieneRecordDetailVO recordDetailVO = getRecordDetail(hygieneRecordId); + List records = recordDetailVO.getCheckList(); + // 设置响应头 + // URLEncoder.encode防止中文乱码 + String fileName = URLEncoder.encode("卫生自查记录数据表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // ExcelWriter初始化 + ExcelWriter excelWriter = EasyExcel + .write(response.getOutputStream()) + .autoCloseStream(Boolean.TRUE) + .registerConverter(new LongStringConverter()) + .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) + .build(); + Date endTime = recordDetailVO.getActualEndTime(); + String name = DateUtil.format(endTime, "yyyy年mm月") + "第" + recordDetailVO.getWeekNum() + "周卫生自查表"; + List head = new ArrayList<>(); + head.add(name); + WriteSheet writeSheet = EasyExcel.writerSheet(1, "卫生自查记录数据表") + .head(Collections.singletonList(head)) + .head(HygieneZoneDetailVO.class) + .build(); + excelWriter.write(records, writeSheet); + excelWriter.finish(); + } catch (Exception e) { + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + throw new ServiceException("卫生自查记录数据导出异常: " + e.getMessage()); + } finally { + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error("卫生自查记录数据导出输出流关闭异常: " + e.getMessage()); + } + } + } } /** diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneZoneServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneZoneServiceImpl.java new file mode 100644 index 0000000..2cedf06 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneZoneServiceImpl.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.safeproduct.service.impl; + +import com.alibaba.excel.util.CollectionUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; +import com.hnac.hzims.safeproduct.mapper.HygieneZoneMapper; +import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class HygieneZoneServiceImpl extends ServiceImpl implements IHygieneZoneService { + + /** + * 删除关联责任区数据 + */ + @Override + public boolean removeReferenceZone(Long hygienePlanId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneZoneEntity::getHygienePlanId, hygienePlanId); + List zoneList = this.list(queryWrapper); + // 若无关联卫生自查责任区,直接返回true + if (CollectionUtils.isEmpty(zoneList)) { + return true; + } + List ids = zoneList.stream().map(HygieneZoneEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } + + /** + * 查询关联责任区数据 + */ + @Override + public List getReferenceZone(Long hygienePlanId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneZoneEntity::getHygienePlanId, hygienePlanId); + return this.list(queryWrapper); + } +} diff --git a/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql index 57e4455..419e469 100644 --- a/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql @@ -80,7 +80,7 @@ CREATE TABLE `hzims_train_record` ( `train_record_name` varchar(50) NOT NULL DEFAULT '' COMMENT '培训记录名称', `code` varchar(50) NOT NULL COMMENT '编号', `people_name` varchar(5000) DEFAULT '' COMMENT '培训学员', - `content` varchar(5000) DEFAULT '' COMMENT '培训内容', + `content` mediumtext DEFAULT '' COMMENT '培训内容', `actual_start_time` datetime DEFAULT NULL COMMENT '实际培训开始时间', `actual_end_time` datetime DEFAULT NULL COMMENT '实际培训结束时间', `command` varchar(250) DEFAULT NULL COMMENT '培训评价', @@ -164,7 +164,7 @@ CREATE TABLE `hzims_conference_record` ( `actual_start_time` datetime DEFAULT NULL COMMENT '会议实际开始时间', `actual_end_time` datetime DEFAULT NULL COMMENT '会议实际结束时间', `recorder` varchar(20) DEFAULT '' COMMENT '记录人', - `content` varchar(250) DEFAULT '' DEFAULT '' COMMENT '会议内容', + `content` mediumtext DEFAULT '' DEFAULT '' COMMENT '会议内容', `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '会议图片', `file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '会议附件', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', @@ -179,15 +179,27 @@ CREATE TABLE `hzims_conference_record` ( CREATE TABLE `hzims_hygiene_plan` ( `id` bigint(20) NOT NULL COMMENT '主键id', - `unit` varchar(50) NOT NULL COMMENT '单位', + `code` varchar(50) NOT NULL COMMENT '编码', + `standard_score` int(10) NOT NULL DEFAULT '100' COMMENT '标准总分值', + `scheduled_start_time` date NOT NULL COMMENT '计划开始时间', + `scheduled_end_time` date NOT NULL COMMENT '计划结束时间', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='卫生自查计划表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_hygiene_zone` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `hygiene_plan_id` bigint(20) NOT NULL COMMENT '卫生自查计划id', `zone` varchar(50) NOT NULL COMMENT '责任区', `principal` varchar(20) NOT NULL COMMENT '责任人', `check_item` mediumtext NOT NULL COMMENT '检查项', `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值', - `standard_score` int(10) NOT NULL DEFAULT '100' COMMENT '标准总分值', - `scheduled_start_time` date NOT NULL COMMENT '计划开始时间', - `scheduled_end_time` date NOT NULL COMMENT '计划结束时间', - `hygiene_status` varchar(20) NOT NULL DEFAULT 'WAITING' COMMENT '卫生自查状态', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', @@ -196,14 +208,17 @@ CREATE TABLE `hzims_hygiene_plan` ( `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='卫生自查表' ROW_FORMAT=Dynamic; +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='卫生自查区域表' ROW_FORMAT=Dynamic; CREATE TABLE `hzims_hygiene_record` ( `id` bigint(20) NOT NULL COMMENT '主键id', + `hygiene_plan_id` bigint(20) NOT NULL COMMENT '卫生自查计划id', + `unit` varchar(50) NOT NULL COMMENT '单位', `code` varchar(50) NOT NULL COMMENT '编号', `actual_start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际开始时间', `actual_end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际结束时间', `check_user` varchar(20) NOT NULL DEFAULT '' COMMENT '检查人', + `hygiene_zone_ids` varchar(1000) NOT NULL COMMENT '卫生自查区域id', `check_result` mediumtext NOT NULL COMMENT '检查结果', `comprehensive_score` int(10) NOT NULL COMMENT '综合评分', `week_num` int(10) NOT NULL COMMENT '周数', From 2ef6c51b3524ceffbef32360a6a4578a69fcdae7 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 3 Jan 2024 13:49:30 +0800 Subject: [PATCH 9/9] =?UTF-8?q?#=20=E7=BA=BF=E4=B8=8B=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E7=A5=A8=E9=A2=84=E8=A7=88=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service/ticket/pom.xml | 9 ++++++++- .../service/impl/FirstWorkTicketServiceImpl.java | 17 ++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hzims-service/ticket/pom.xml b/hzims-service/ticket/pom.xml index 5bf9e3d..3ce24e7 100644 --- a/hzims-service/ticket/pom.xml +++ b/hzims-service/ticket/pom.xml @@ -298,7 +298,14 @@ false - + + org.springframework.boot + spring-boot-maven-plugin + + + true + + diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java index 677cb96..97f7589 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java @@ -395,27 +395,27 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl documents, String savePath) throws IOException { - FileOutputStream out = new FileOutputStream(savePath, true); - Path file = Paths.get(path); - if(Files.exists(file)) { - Files.delete(file); - } - new File(savePath).createNewFile(); + FileOutputStream out = new FileOutputStream(savePath); for (XWPFDocument document : documents) { document.write(out); }