parent
a89571643c
commit
063acde4fe
|
|
@ -0,0 +1,102 @@
|
|||
package com.gunshi.project.hsz.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.hsz.entity.dto.ExportCommonDto;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceFarmerRecordPageSo;
|
||||
import com.gunshi.project.hsz.model.ByLog;
|
||||
import com.gunshi.project.hsz.model.MentenceFarmerRecord;
|
||||
import com.gunshi.project.hsz.service.FileAssociationsService;
|
||||
import com.gunshi.project.hsz.service.HiddenInfoService;
|
||||
import com.gunshi.project.hsz.service.MentenceFarmerRecordService;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "维护养护-日常养护记录")
|
||||
@RestController
|
||||
@RequestMapping(value="/mfr")
|
||||
public class MentenceFarmerRecordController extends AbstractCommonFileController{
|
||||
|
||||
|
||||
@Autowired
|
||||
private MentenceFarmerRecordService mentenceFarmerRecordService;
|
||||
|
||||
@Autowired
|
||||
private HiddenInfoService hiddenInfoService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<MentenceFarmerRecord> insert(@Validated(Insert.class) @RequestBody MentenceFarmerRecord dto, HttpServletRequest request) {
|
||||
boolean result = mentenceFarmerRecordService.saveDate(dto);
|
||||
if(result){
|
||||
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
|
||||
}
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<MentenceFarmerRecord> update(@Validated(Update.class) @RequestBody MentenceFarmerRecord dto) {
|
||||
boolean flag = mentenceFarmerRecordService.update(dto);
|
||||
if (flag) {
|
||||
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString());
|
||||
}
|
||||
return R.ok(flag ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
boolean result = mentenceFarmerRecordService.delete(id);
|
||||
if(result){
|
||||
fileService.deleteFile(getGroupId(),id.toString());
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<MentenceFarmerRecord>> page(@RequestBody MentenceFarmerRecordPageSo pageSo) {
|
||||
Page<MentenceFarmerRecord> byPage = mentenceFarmerRecordService.pageQuery(pageSo);
|
||||
if(!CollectionUtils.isEmpty(byPage.getRecords())){
|
||||
byPage.getRecords().forEach(o -> o.setFiles(
|
||||
fileService.getFiles(getGroupId(),o.getId().toString())
|
||||
));
|
||||
}
|
||||
return R.ok(byPage);
|
||||
}
|
||||
|
||||
@Operation(description = "日志导出")
|
||||
@PostMapping("/export")
|
||||
public void export(@RequestBody MentenceFarmerRecordPageSo pageSo,HttpServletResponse response) {
|
||||
pageSo.getPageSo().setPageSize(9999);
|
||||
Page<MentenceFarmerRecord> byPage = mentenceFarmerRecordService.pageQuery(pageSo);
|
||||
List<MentenceFarmerRecord> records = byPage.getRecords();
|
||||
mentenceFarmerRecordService.exportToExcel(records,response);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "mentenceFarmerRecord";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
package com.gunshi.project.hsz.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.core.session.entity.SessionUser;
|
||||
import com.gunshi.project.hsz.entity.so.ByPlanPageSo;
|
||||
import com.gunshi.project.hsz.entity.so.MentencePlanPageSo;
|
||||
import com.gunshi.project.hsz.model.ByPlan;
|
||||
import com.gunshi.project.hsz.model.MentencePlan;
|
||||
import com.gunshi.project.hsz.model.MentencePlanDetail;
|
||||
import com.gunshi.project.hsz.service.FileAssociationsService;
|
||||
import com.gunshi.project.hsz.service.MentencePlanDetailService;
|
||||
import com.gunshi.project.hsz.service.MentencePlanService;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Tag(name = "维护养护-维护计划")
|
||||
@RestController
|
||||
@RequestMapping(value="/mtpl")
|
||||
public class MentencePlanController extends AbstractCommonFileController {
|
||||
|
||||
@Autowired
|
||||
private MentencePlanService mentencePlanService;
|
||||
|
||||
@Autowired
|
||||
private MentencePlanDetailService mentencePlanDetailService;
|
||||
|
||||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<MentencePlan> insert(@Validated(Insert.class) @RequestBody MentencePlan dto, HttpServletRequest request) {
|
||||
SessionUser sessionUser = checkLogin(request);
|
||||
if(sessionUser == null){
|
||||
throw new IllegalArgumentException("未登录");
|
||||
}
|
||||
Long userId = sessionUser.getUserId();
|
||||
String userName = sessionUser.getUserName();
|
||||
dto.setCreateId(userId.toString());
|
||||
dto.setCreateName(userName);
|
||||
boolean flag = mentencePlanService.saveData(dto);
|
||||
if(flag){
|
||||
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
|
||||
}
|
||||
return R.ok(dto);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<MentencePlan> update(@Validated(Update.class) @RequestBody MentencePlan dto) {
|
||||
boolean flag = mentencePlanService.update(dto);
|
||||
if (flag) {
|
||||
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString());
|
||||
}
|
||||
return R.ok(flag ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
LambdaQueryWrapper<MentencePlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentencePlan::getId, id);
|
||||
MentencePlan one = mentencePlanService.getOne(queryWrapper);
|
||||
if(Objects.isNull(one)){
|
||||
throw new RuntimeException("该计划不存在");
|
||||
}
|
||||
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
||||
queryWrapperDetail.eq(MentencePlanDetail::getMentencePlanId, id);
|
||||
//先删细节
|
||||
boolean remove = mentencePlanDetailService.remove(queryWrapperDetail);
|
||||
if(remove){
|
||||
//再删主体
|
||||
mentencePlanService.removeById(id);
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "审批")
|
||||
@PostMapping("/approving")
|
||||
public R<Boolean> approve(@Validated @RequestBody MentencePlan dto){
|
||||
LambdaQueryWrapper<MentencePlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentencePlan::getId, dto.getId());
|
||||
MentencePlan one = mentencePlanService.getOne(queryWrapper);
|
||||
if(Objects.isNull(one)){
|
||||
throw new RuntimeException("该计划不存在");
|
||||
}
|
||||
mentencePlanService.updateById(dto);
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<MentencePlan>> page(@RequestBody MentencePlanPageSo pageSo) {
|
||||
Page<MentencePlan> byPlanPage = mentencePlanService.pageQuery(pageSo);
|
||||
if(!CollectionUtils.isEmpty(byPlanPage.getRecords())){
|
||||
byPlanPage.getRecords().forEach(o -> o.setFiles(
|
||||
fileService.getFiles(getGroupId(),o.getId().toString())
|
||||
));
|
||||
}
|
||||
return R.ok(byPlanPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "mentencePlan";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
package com.gunshi.project.hsz.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceStPageSo;
|
||||
import com.gunshi.project.hsz.entity.so.PrePlacePageSo;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import com.gunshi.project.hsz.model.MentenceStDetail;
|
||||
import com.gunshi.project.hsz.model.PrePlace;
|
||||
import com.gunshi.project.hsz.model.PrePlaceDetail;
|
||||
import com.gunshi.project.hsz.service.FileAssociationsService;
|
||||
import com.gunshi.project.hsz.service.MentenceStDetailService;
|
||||
import com.gunshi.project.hsz.service.MentenceStService;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "维护养护-维护标准")
|
||||
@RestController
|
||||
@RequestMapping(value="/mtst")
|
||||
public class MentenceStController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MentenceStService mentenceStService;
|
||||
|
||||
@Autowired
|
||||
private MentenceStDetailService mentenceStDetailService;
|
||||
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<MentenceSt> insert(@Validated(Insert.class) @RequestBody MentenceSt dto) {
|
||||
|
||||
boolean result = mentenceStService.saveDate(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<MentenceSt> update(@Validated(Update.class) @RequestBody MentenceSt dto) {
|
||||
boolean result = mentenceStService.updateById(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
boolean b = mentenceStService.deleteById(id);
|
||||
return R.ok(b);
|
||||
}
|
||||
|
||||
@Operation(summary = "列表")
|
||||
@GetMapping("/list")
|
||||
public List<MentenceSt> list() {
|
||||
List<MentenceSt> list = mentenceStService.lambdaQuery().orderByAsc(MentenceSt::getCreateTime).list();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "维护项目新增")
|
||||
@PostMapping("/detail/insert")
|
||||
public R<MentenceStDetail> insert(@Validated(Insert.class) @RequestBody MentenceStDetail dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
boolean result = mentenceStDetailService.save(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "维护项目修改")
|
||||
@PostMapping("/detail/update")
|
||||
public R<MentenceStDetail> detailUpdate(@Validated(Update.class) @RequestBody MentenceStDetail dto) {
|
||||
boolean result = mentenceStDetailService.update(dto);
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "维护项目列表")
|
||||
@GetMapping("/detail/list")
|
||||
public List<MentenceStDetail> detailList() {
|
||||
List<MentenceStDetail> list = mentenceStDetailService.lambdaQuery().orderByAsc(MentenceStDetail::getOrder).list();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "维护项目删除")
|
||||
@GetMapping("/detail/del/{id}")
|
||||
public R<Boolean> detailDel(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
boolean b = mentenceStDetailService.deleteById(id);
|
||||
return R.ok(b);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "是否启用")
|
||||
@GetMapping("/switch/{id}")
|
||||
public R<Boolean> isEnable(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
MentenceStDetail byId = mentenceStDetailService.getById(id);
|
||||
if(byId == null) {
|
||||
throw new RuntimeException("该数据不存在,请检查");
|
||||
}
|
||||
Integer isEnable = byId.getIsEnable();
|
||||
if(isEnable > 0){
|
||||
byId.setIsEnable(0);
|
||||
}else{
|
||||
byId.setIsEnable(1);
|
||||
}
|
||||
boolean result = mentenceStDetailService.updateById(byId);
|
||||
return R.ok(result ? false : true);
|
||||
}
|
||||
|
||||
|
||||
//根据维护对象id,查询维护项目
|
||||
@Operation(summary = "根据维护对象id,查询维护项目")
|
||||
@PostMapping("/detail/page")
|
||||
public Page<MentenceStDetail> page(@RequestBody MentenceStPageSo dto) {
|
||||
return mentenceStDetailService.pageQuery(dto);
|
||||
}
|
||||
|
||||
//查询养护对象 (可根据 防治点查询,也可以根据防治部位查询)
|
||||
@Operation(summary = "查询防治部位(可根据 维护对象,也可以根据维护项目查询)")
|
||||
@PostMapping("/tree")
|
||||
public List<MentenceSt> tree(@RequestBody MentenceStPageSo dto) {
|
||||
List<MentenceSt> res = mentenceStService.tree(dto);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package com.gunshi.project.hsz.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.core.session.entity.SessionUser;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceTemplatePageSo;
|
||||
import com.gunshi.project.hsz.model.MentenceTemplate;
|
||||
import com.gunshi.project.hsz.service.FileAssociationsService;
|
||||
import com.gunshi.project.hsz.service.MentenceTemplateService;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Tag(name = "维护养护-模板")
|
||||
@RestController
|
||||
@RequestMapping(value="/mt")
|
||||
public class MentenceTemplateController extends AbstractCommonFileController {
|
||||
|
||||
@Autowired
|
||||
private MentenceTemplateService mentenceTemplateService;
|
||||
|
||||
@Autowired
|
||||
private FileAssociationsService fileService;
|
||||
|
||||
@Operation(summary = "新增")
|
||||
@PostMapping("/insert")
|
||||
public R<MentenceTemplate> insert(@Validated(Insert.class) @RequestBody MentenceTemplate dto, HttpServletRequest request) {
|
||||
SessionUser sessionUser = checkLogin(request);
|
||||
if(sessionUser == null){
|
||||
throw new IllegalArgumentException("未登录");
|
||||
}
|
||||
Long userId = sessionUser.getUserId();
|
||||
String userName = sessionUser.getUserName();
|
||||
dto.setCreateId(userId.toString());
|
||||
dto.setCreateName(userName);
|
||||
boolean result = mentenceTemplateService.saveDate(dto);
|
||||
if(result){
|
||||
fileService.saveFile(dto.getFiles(),getGroupId(),dto.getId().toString());
|
||||
}
|
||||
return R.ok(result ? dto : null);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "修改")
|
||||
@PostMapping("/update")
|
||||
public R<MentenceTemplate> update(@Validated(Update.class) @RequestBody MentenceTemplate dto) {
|
||||
boolean flag = mentenceTemplateService.update(dto);
|
||||
if (flag) {
|
||||
fileService.saveFile(dto.getFiles(), getGroupId(), dto.getId().toString());
|
||||
}
|
||||
return R.ok(flag ? dto : null);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/del/{id}")
|
||||
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
||||
LambdaQueryWrapper<MentenceTemplate> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentenceTemplate::getId, id);
|
||||
boolean result = mentenceTemplateService.remove(queryWrapper);
|
||||
if(result){
|
||||
fileService.deleteFile(getGroupId(),id.toString());
|
||||
}
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "分页")
|
||||
@PostMapping("/page")
|
||||
public R<Page<MentenceTemplate>> page(@RequestBody MentenceTemplatePageSo pageSo) {
|
||||
Page<MentenceTemplate> byPage = mentenceTemplateService.pageQuery(pageSo);
|
||||
if(!CollectionUtils.isEmpty(byPage.getRecords())){
|
||||
byPage.getRecords().forEach(o -> o.setFiles(
|
||||
fileService.getFiles(getGroupId(),o.getId().toString())
|
||||
));
|
||||
}
|
||||
return R.ok(byPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "mentenceTemplate";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MentenceFarmerRecordPageSo {
|
||||
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description = "维护对象主键ID")
|
||||
private Long mentenceStId;
|
||||
|
||||
@Schema(description = "维护项目Id")
|
||||
private Long mentenceStDetailId;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.bouncycastle.cert.dane.DANEEntry;
|
||||
|
||||
|
||||
@Data
|
||||
@Schema(description = "分页查询对象")
|
||||
public class MentencePlanPageSo {
|
||||
|
||||
@NotNull(message = "分页参数不能为空")
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description = "年度")
|
||||
private String year;
|
||||
|
||||
|
||||
@Schema(description = "计划名称")
|
||||
private String planName;
|
||||
|
||||
@Schema(description = "审批状态 0 待审批 1 未通过 2 已通过 ")
|
||||
private Integer status;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MentenceStPageSo {
|
||||
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description = "维护标注名称")
|
||||
private String stName;
|
||||
|
||||
@Schema(description = "维护项目名称")
|
||||
private String stDetailName;
|
||||
|
||||
@Schema(description = "维护对象id")
|
||||
private Long stId;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.gunshi.project.hsz.entity.so;
|
||||
|
||||
|
||||
import com.gunshi.db.dto.PageSo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.bouncycastle.cert.dane.DANEEntry;
|
||||
|
||||
@Data
|
||||
public class MentenceTemplatePageSo {
|
||||
|
||||
@Schema(description = "分页参数")
|
||||
private PageSo pageSo;
|
||||
|
||||
@Schema(description = "模板名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板类型")
|
||||
private Integer type;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.HiddenInfo;
|
||||
import com.gunshi.project.hsz.model.MentenceFarmerRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface HiddenInfoMapper extends BaseMapper<HiddenInfo> {
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceFarmerRecordPageSo;
|
||||
import com.gunshi.project.hsz.model.MentenceFarmerRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface MentenceFarmerRecordMapper extends BaseMapper<MentenceFarmerRecord> {
|
||||
|
||||
|
||||
@Select("""
|
||||
select t1.*,t2.name as mentenceStDetailName,t3.st_name as mentenceStName from mentence_farmer_record t1
|
||||
join mentence_st_detail t2 on t1.mentence_st_detail_id = t2.id
|
||||
join mentence_st t3 on t1.mentence_st_id = t3.id
|
||||
""")
|
||||
Page<MentenceFarmerRecord> pageQuery(Page<MentenceFarmerRecord> page, MentenceFarmerRecordPageSo pageSo);
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.MentencePlanDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MentencePlanDetailMapper extends BaseMapper<MentencePlanDetail> {
|
||||
|
||||
@Select("""
|
||||
select t1.*,t2.name as mentenceStDetailName,t3.id as mentenceStId,t3.st_name as mentenceStName from
|
||||
mentence_plan_detail t1
|
||||
left join mentence_st_detail t2
|
||||
on t1.mentence_st_detail_id = t2.id and t2.is_enable = 0
|
||||
left join mentence_st t3
|
||||
on t2.mentence_st_id = t3.id
|
||||
""")
|
||||
List<MentencePlanDetail> selectDetail(@Param("id") Long id);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.MentencePlan;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MentencePlanMapper extends BaseMapper<MentencePlan> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.MentenceStDetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MentenceStDetailMapper extends BaseMapper<MentenceStDetail> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MentenceStMapper extends BaseMapper<MentenceSt> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.gunshi.project.hsz.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.project.hsz.model.MentenceTemplate;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MentenceTemplateMapper extends BaseMapper<MentenceTemplate> {
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@TableName("hidden_info")
|
||||
@Data
|
||||
public class HiddenInfo {
|
||||
@TableId("id")
|
||||
private Long id;
|
||||
|
||||
@TableField("mentence_farmer_record_id")
|
||||
@Schema(description = "日常维护记录id")
|
||||
private Long mentenceFarmerRecordId;
|
||||
|
||||
@TableField("found_time")
|
||||
@Schema(description = "隐患发现时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date foundTime;
|
||||
|
||||
@TableField("hidden_desc")
|
||||
@Schema(description = "隐患描述")
|
||||
private String hiddenDesc;
|
||||
|
||||
@TableField("status")
|
||||
@Schema(description = "状态 0已处理 1未处理")
|
||||
private Integer status;
|
||||
|
||||
@TableField("resolve_method")
|
||||
@Schema(description = "解决办法")
|
||||
private String resolveMethod;
|
||||
|
||||
@TableField("resolve_time")
|
||||
@Schema(description = "解决时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date resolveTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@TableName("mentence_farmer_record")
|
||||
@Schema(description = "维修养护-日常养护")
|
||||
@Data
|
||||
public class MentenceFarmerRecord {
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@TableField("mentence_st_detail_id")
|
||||
@Schema(description = "维护项目Id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long mentenceStDetailId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "维护项目名称")
|
||||
private String mentenceStDetailName;
|
||||
|
||||
@Schema(description = "维护对象Id")
|
||||
@TableField("mentence_st_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long mentenceStId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "维护对象名称")
|
||||
private String mentenceStName;
|
||||
|
||||
|
||||
@TableField("mentence_person_id")
|
||||
@Schema(description = "维护人员id")
|
||||
private String mentencePersonId;
|
||||
|
||||
@TableField("mentence_person_name")
|
||||
@Schema(description = "维护人员名称")
|
||||
private String mentencePersonName;
|
||||
|
||||
@TableField("mentence_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@Schema(description = "维护时间")
|
||||
private Date mentenceTime;
|
||||
|
||||
@TableField("fill_time")
|
||||
@Schema(description = "填报时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date fillTime;
|
||||
|
||||
@TableField("mentence_context")
|
||||
@Schema(description = "维护内容")
|
||||
private String mentenceContext;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<FileAssociations> files;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<HiddenInfo> details;
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("mentence_plan")
|
||||
@Schema(description = "维修养护-计划管理")
|
||||
public class MentencePlan {
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@NotNull(message = "id不能为空",groups = {Update.class})
|
||||
private Long id;
|
||||
|
||||
@TableField("plan_name")
|
||||
@NotNull(message = "计划名称不能为空", groups = {Insert.class, Update.class})
|
||||
@Schema(description = "计划名称")
|
||||
private String planName;
|
||||
|
||||
@TableField("plan_year")
|
||||
@NotNull(message = "年份不能为空", groups = {Insert.class, Update.class})
|
||||
@Schema(description = "计划年份")
|
||||
private String planYear;
|
||||
|
||||
@TableField("plan_status")
|
||||
@Schema(description = "审批状态 0 待审批 1 未通过 2 已通过 ")
|
||||
private Integer planStatus;
|
||||
|
||||
@TableField("create_id")
|
||||
@Schema(description = "创建者id")
|
||||
private String createId;
|
||||
|
||||
@TableField("create_name")
|
||||
@Schema(description = "创建者名称")
|
||||
private String createName;
|
||||
|
||||
@TableField("create_date")
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createDate;
|
||||
|
||||
@TableField("approve_opinion")
|
||||
@Schema(description = "审批意见")
|
||||
private String approveOpinion;
|
||||
|
||||
@TableField("approve_person_id")
|
||||
@Schema(description = "审批人id")
|
||||
private String approvePersonId;
|
||||
|
||||
@TableField("approve_person_name")
|
||||
@Schema(description = "审批人名称")
|
||||
private String approvePersonName;
|
||||
|
||||
@TableField("remark")
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<MentencePlanDetail> details;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<FileAssociations> files;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Schema(description = "维修养护-计划管理细节")
|
||||
@TableName("mentence_plan_detail")
|
||||
public class MentencePlanDetail {
|
||||
|
||||
@TableId("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@TableField("mentence_plan_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long mentencePlanId;
|
||||
|
||||
@TableField("mentence_st_detail_id")
|
||||
@Schema(description = "维护项目id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long mentenceStDetailId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "维护项目名称")
|
||||
private String mentenceStDetailName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "维护对象id")
|
||||
private String mentenceStId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(description = "维护对象名称")
|
||||
private String mentenceStName;
|
||||
|
||||
@TableField("plan_begin")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date planBegin;
|
||||
|
||||
@TableField("plan_end")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date planEnd;
|
||||
|
||||
@TableField("charge_person_id")
|
||||
private String chargePersonId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@TableName("mentence_st")
|
||||
@Data
|
||||
@Schema(description = "维护养护-维护标准")
|
||||
public class MentenceSt {
|
||||
@TableId("id")
|
||||
private Long id;
|
||||
|
||||
@TableField("st_name")
|
||||
@Schema(description = "维护对象名")
|
||||
@NotNull(message = "维护对象名不能为空", groups = {Insert.class, Update.class})
|
||||
private String stName;
|
||||
|
||||
|
||||
@TableField("create_time")
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<MentenceStDetail> childrens;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@TableName("mentence_st_detail")
|
||||
@Data
|
||||
@Schema(description = "维护养护-维护标准细节")
|
||||
public class MentenceStDetail {
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
@TableField("mentence_st_id")
|
||||
@Schema(description = "维护对象名id")
|
||||
@NotNull(message = "维护对象名称Id不能为空",groups = {Insert.class, Update.class})
|
||||
private Long mentenceStId;
|
||||
|
||||
@TableField("name")
|
||||
@Schema(description = "维护项目名称")
|
||||
private String name;
|
||||
|
||||
@TableField("context")
|
||||
@Schema(description = "维护内容")
|
||||
private String context;
|
||||
|
||||
@TableField("_order")
|
||||
@Schema(description = "排序号")
|
||||
private Long order;
|
||||
|
||||
@TableField("is_enable")
|
||||
@Schema(description = "是否启用 0启用 1禁用")
|
||||
private Integer isEnable;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.gunshi.project.hsz.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.gunshi.project.hsz.validate.markers.Insert;
|
||||
import com.gunshi.project.hsz.validate.markers.Update;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "维修养护-模板")
|
||||
@TableName("mentence_template")
|
||||
public class MentenceTemplate {
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
@TableField("name")
|
||||
@Schema(description = "模板名称")
|
||||
@NotNull(message = "模板名称不能为空", groups = {Insert.class, Update.class})
|
||||
private String name;
|
||||
|
||||
@TableField("type")
|
||||
@Schema(description = "模板类型")
|
||||
@NotNull(message = "模板类型不能为空",groups = {Insert.class, Update.class})
|
||||
private Integer type;
|
||||
|
||||
@TableField("create_id")
|
||||
private String createId;
|
||||
|
||||
@TableField("create_name")
|
||||
private String createName;
|
||||
|
||||
@TableField("create_time")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<FileAssociations> files;
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.mapper.HiddenInfoMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceFarmerRecordMapper;
|
||||
import com.gunshi.project.hsz.model.HiddenInfo;
|
||||
import com.gunshi.project.hsz.model.MentenceFarmerRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class HiddenInfoService extends ServiceImpl<HiddenInfoMapper, HiddenInfo> {
|
||||
}
|
||||
|
|
@ -0,0 +1,371 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceFarmerRecordPageSo;
|
||||
import com.gunshi.project.hsz.mapper.HiddenInfoMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceFarmerRecordMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentencePlanDetailMapper;
|
||||
import com.gunshi.project.hsz.model.HiddenInfo;
|
||||
import com.gunshi.project.hsz.model.MentenceFarmerRecord;
|
||||
import com.gunshi.project.hsz.model.MentencePlanDetail;
|
||||
import com.gunshi.project.hsz.model.MentenceTemplate;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MentenceFarmerRecordService extends ServiceImpl<MentenceFarmerRecordMapper, MentenceFarmerRecord> {
|
||||
|
||||
@Autowired
|
||||
private HiddenInfoMapper hiddenInfoMapper;
|
||||
|
||||
public boolean saveDate(MentenceFarmerRecord dto) {
|
||||
LambdaQueryWrapper<MentenceFarmerRecord> query = new LambdaQueryWrapper<>();
|
||||
query.eq(MentenceFarmerRecord::getMentenceStDetailId, dto.getMentenceStDetailId());
|
||||
MentenceFarmerRecord mentenceFarmerRecord = this.baseMapper.selectOne(query);
|
||||
if(Objects.nonNull(mentenceFarmerRecord)){
|
||||
throw new IllegalArgumentException("该维护项目,记录已存在");
|
||||
}
|
||||
dto.setFillTime(new Date());
|
||||
dto.setId(IdWorker.getId());
|
||||
save(dto);
|
||||
List<HiddenInfo> details = dto.getDetails();
|
||||
if(details.isEmpty()){
|
||||
throw new IllegalArgumentException("请添加隐患记录");
|
||||
}
|
||||
details.stream().forEach(o ->{
|
||||
o.setId(IdWorker.getId());
|
||||
o.setMentenceFarmerRecordId(dto.getId());
|
||||
});
|
||||
hiddenInfoMapper.insert(details);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean update(MentenceFarmerRecord dto) {
|
||||
LambdaQueryWrapper<MentenceFarmerRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentenceFarmerRecord::getId, dto.getId());
|
||||
MentenceFarmerRecord mentenceFarmerRecord = this.getOne(queryWrapper);
|
||||
if(Objects.isNull(mentenceFarmerRecord)){
|
||||
throw new IllegalArgumentException("该日常养护记录不存在");
|
||||
}
|
||||
updateById(dto);
|
||||
LambdaQueryWrapper<HiddenInfo> queryHiddenWrapper= new LambdaQueryWrapper<>();
|
||||
queryHiddenWrapper.eq(HiddenInfo::getMentenceFarmerRecordId,dto.getId());
|
||||
hiddenInfoMapper.delete(queryHiddenWrapper);
|
||||
List<HiddenInfo> details = dto.getDetails();
|
||||
if(details.isEmpty()){
|
||||
throw new IllegalArgumentException("隐患点信息至少一条");
|
||||
}
|
||||
details.stream().forEach(o ->{
|
||||
o.setId(IdWorker.getId());
|
||||
o.setMentenceFarmerRecordId(dto.getId());
|
||||
});
|
||||
hiddenInfoMapper.insert(details);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean delete(Serializable id) {
|
||||
LambdaQueryWrapper<HiddenInfo> queryHiddenWrapper = new LambdaQueryWrapper<>();
|
||||
queryHiddenWrapper.eq(HiddenInfo::getMentenceFarmerRecordId,id);
|
||||
int delete = hiddenInfoMapper.delete(queryHiddenWrapper);
|
||||
if(delete > 0){
|
||||
LambdaQueryWrapper<MentenceFarmerRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentenceFarmerRecord::getId, id);
|
||||
boolean result = remove(queryWrapper);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Page<MentenceFarmerRecord> pageQuery(MentenceFarmerRecordPageSo pageSo) {
|
||||
Page<MentenceFarmerRecord> pageRecord = baseMapper.pageQuery(pageSo.getPageSo().toPage(),pageSo);
|
||||
List<MentenceFarmerRecord> records = pageRecord.getRecords();
|
||||
records.stream().forEach(o ->{
|
||||
LambdaQueryWrapper<HiddenInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(HiddenInfo::getMentenceFarmerRecordId,o.getId());
|
||||
List<HiddenInfo> hiddenInfos = hiddenInfoMapper.selectList(queryWrapper);
|
||||
o.setDetails(hiddenInfos);
|
||||
});
|
||||
return pageRecord;
|
||||
}
|
||||
|
||||
public void exportToExcel(List<MentenceFarmerRecord> records, HttpServletResponse response) {
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet("日常养护记录");
|
||||
|
||||
// 1. 创建所有样式
|
||||
StyleGroup styles = createAllStyles(workbook);
|
||||
|
||||
// 2. 创建标题行
|
||||
createHeaderRow(sheet, styles.headerStyle);
|
||||
|
||||
// 3. 填充数据
|
||||
fillDataWithMerge(sheet, styles, records);
|
||||
|
||||
// 4. 调整列宽
|
||||
adjustColumnWidth(sheet);
|
||||
|
||||
// 5. 响应处理
|
||||
String fileName = "日常养护记录_" + System.currentTimeMillis();
|
||||
try {
|
||||
setResponseHeaders(response, fileName);
|
||||
workbook.write(response.getOutputStream());
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("导出Excel失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class StyleGroup {
|
||||
CellStyle headerStyle;
|
||||
CellStyle dataStyle;
|
||||
CellStyle detailStyle;
|
||||
CellStyle dateStyle;
|
||||
CellStyle dateTimeStyle;
|
||||
|
||||
StyleGroup(CellStyle headerStyle, CellStyle dataStyle, CellStyle detailStyle,
|
||||
CellStyle dateStyle, CellStyle dateTimeStyle) {
|
||||
this.headerStyle = headerStyle;
|
||||
this.dataStyle = dataStyle;
|
||||
this.detailStyle = detailStyle;
|
||||
this.dateStyle = dateStyle;
|
||||
this.dateTimeStyle = dateTimeStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private StyleGroup createAllStyles(Workbook workbook) {
|
||||
// 基础数据样式
|
||||
CellStyle dataStyle = workbook.createCellStyle();
|
||||
dataStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
dataStyle.setBorderBottom(BorderStyle.THIN);
|
||||
dataStyle.setBorderTop(BorderStyle.THIN);
|
||||
dataStyle.setBorderLeft(BorderStyle.THIN);
|
||||
dataStyle.setBorderRight(BorderStyle.THIN);
|
||||
|
||||
// 表头样式
|
||||
CellStyle headerStyle = workbook.createCellStyle();
|
||||
headerStyle.cloneStyleFrom(dataStyle);
|
||||
Font headerFont = workbook.createFont();
|
||||
headerFont.setBold(true);
|
||||
headerFont.setFontHeightInPoints((short) 12);
|
||||
headerStyle.setFont(headerFont);
|
||||
headerStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
|
||||
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
|
||||
// 详情样式
|
||||
CellStyle detailStyle = workbook.createCellStyle();
|
||||
detailStyle.cloneStyleFrom(dataStyle);
|
||||
detailStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
detailStyle.setWrapText(true);
|
||||
|
||||
// 日期样式
|
||||
CreationHelper createHelper = workbook.getCreationHelper();
|
||||
CellStyle dateStyle = workbook.createCellStyle();
|
||||
dateStyle.cloneStyleFrom(dataStyle);
|
||||
dateStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-MM-dd"));
|
||||
|
||||
// 日期时间样式
|
||||
CellStyle dateTimeStyle = workbook.createCellStyle();
|
||||
dateTimeStyle.cloneStyleFrom(dataStyle);
|
||||
dateTimeStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
return new StyleGroup(headerStyle, dataStyle, detailStyle, dateStyle, dateTimeStyle);
|
||||
}
|
||||
|
||||
private void createHeaderRow(Sheet sheet, CellStyle headerStyle) {
|
||||
Row headerRow = sheet.createRow(0);
|
||||
String[] headers = {
|
||||
"序号", "维护对象", "维护项目", "维护人员", "维护时间", "填报时间", "维护内容",
|
||||
"隐患发现时间", "隐患描述", "状态", "解决办法", "解决时间"
|
||||
};
|
||||
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = headerRow.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
cell.setCellStyle(headerStyle);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillDataWithMerge(Sheet sheet, StyleGroup styles, List<MentenceFarmerRecord> records) {
|
||||
int currentRow = 1;
|
||||
int serialNumber = 1;
|
||||
|
||||
for (MentenceFarmerRecord record : records) {
|
||||
// 获取隐患信息数量
|
||||
int hiddenInfoCount = record.getDetails() != null ? record.getDetails().size() : 0;
|
||||
int rowSpan = Math.max(hiddenInfoCount, 1);
|
||||
|
||||
Row row = sheet.createRow(currentRow);
|
||||
|
||||
// 1. 序号
|
||||
createMergedCell(sheet, row, 0, serialNumber, styles.dataStyle, currentRow, rowSpan, 0, 0);
|
||||
|
||||
// 2. 维护对象
|
||||
String mentenceStName = record.getMentenceStName() != null ? record.getMentenceStName() : "";
|
||||
createMergedCell(sheet, row, 1, mentenceStName, styles.dataStyle, currentRow, rowSpan, 1, 1);
|
||||
|
||||
// 3. 维护项目
|
||||
String mentenceStDetailName = record.getMentenceStDetailName() != null ? record.getMentenceStDetailName() : "";
|
||||
createMergedCell(sheet, row, 2, mentenceStDetailName, styles.dataStyle, currentRow, rowSpan, 2, 2);
|
||||
|
||||
// 4. 维护人员
|
||||
String mentencePersonName = record.getMentencePersonName() != null ? record.getMentencePersonName() : "";
|
||||
createMergedCell(sheet, row, 3, mentencePersonName, styles.dataStyle, currentRow, rowSpan, 3, 3);
|
||||
|
||||
// 5. 维护时间
|
||||
createDateMergedCell(sheet, row, 4, record.getMentenceTime(), styles.dateTimeStyle, currentRow, rowSpan, 4, 4);
|
||||
|
||||
// 6. 填报时间
|
||||
createDateMergedCell(sheet, row, 5, record.getFillTime(), styles.dateTimeStyle, currentRow, rowSpan, 5, 5);
|
||||
|
||||
// 7. 维护内容
|
||||
String mentenceContext = record.getMentenceContext() != null ? record.getMentenceContext() : "";
|
||||
createMergedCell(sheet, row, 6, mentenceContext, styles.detailStyle, currentRow, rowSpan, 6, 6);
|
||||
|
||||
// 填充隐患信息
|
||||
if (hiddenInfoCount > 0) {
|
||||
fillHiddenInfo(row, record.getDetails().get(0), styles);
|
||||
|
||||
// 创建额外的行用于其他隐患信息
|
||||
for (int i = 1; i < hiddenInfoCount; i++) {
|
||||
Row detailRow = sheet.createRow(currentRow + i);
|
||||
// 为前7列创建空单元格并设置样式
|
||||
for (int col = 0; col <= 6; col++) {
|
||||
Cell emptyCell = detailRow.createCell(col);
|
||||
emptyCell.setCellValue("");
|
||||
emptyCell.setCellStyle(styles.dataStyle);
|
||||
}
|
||||
fillHiddenInfo(detailRow, record.getDetails().get(i), styles);
|
||||
}
|
||||
} else {
|
||||
// 如果没有隐患信息,创建空单元格
|
||||
for (int i = 7; i <= 11; i++) {
|
||||
Cell cell = row.createCell(i);
|
||||
cell.setCellValue("");
|
||||
cell.setCellStyle(styles.dataStyle);
|
||||
}
|
||||
}
|
||||
|
||||
currentRow += rowSpan;
|
||||
serialNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
private void createMergedCell(Sheet sheet, Row row, int column, Object value, CellStyle style,
|
||||
int startRow, int rowSpan, int firstCol, int lastCol) {
|
||||
Cell cell = row.createCell(column);
|
||||
setCellValue(cell, value, style);
|
||||
|
||||
if (rowSpan > 1) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(startRow, startRow + rowSpan - 1, firstCol, lastCol));
|
||||
}
|
||||
}
|
||||
|
||||
private void createDateMergedCell(Sheet sheet, Row row, int column, Date date, CellStyle style,
|
||||
int startRow, int rowSpan, int firstCol, int lastCol) {
|
||||
Cell cell = row.createCell(column);
|
||||
if (date != null) {
|
||||
cell.setCellValue(date);
|
||||
cell.setCellStyle(style);
|
||||
} else {
|
||||
cell.setCellValue("");
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
if (rowSpan > 1) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(startRow, startRow + rowSpan - 1, firstCol, lastCol));
|
||||
}
|
||||
}
|
||||
|
||||
private void fillHiddenInfo(Row row, HiddenInfo hiddenInfo, StyleGroup styles) {
|
||||
// 8. 隐患发现时间
|
||||
createCell(row, 7, hiddenInfo.getFoundTime(), styles.dateTimeStyle);
|
||||
|
||||
// 9. 隐患描述
|
||||
String hiddenDesc = hiddenInfo.getHiddenDesc() != null ? hiddenInfo.getHiddenDesc() : "";
|
||||
createCell(row, 8, hiddenDesc, styles.detailStyle);
|
||||
|
||||
// 10. 状态
|
||||
String status = "";
|
||||
if (hiddenInfo.getStatus() != null) {
|
||||
status = hiddenInfo.getStatus() == 0 ? "已处理" : "未处理";
|
||||
}
|
||||
createCell(row, 9, status, styles.dataStyle);
|
||||
|
||||
// 11. 解决办法
|
||||
String resolveMethod = hiddenInfo.getResolveMethod() != null ? hiddenInfo.getResolveMethod() : "";
|
||||
createCell(row, 10, resolveMethod, styles.detailStyle);
|
||||
|
||||
// 12. 解决时间
|
||||
createCell(row, 11, hiddenInfo.getResolveTime(), styles.dateTimeStyle);
|
||||
}
|
||||
|
||||
private void createCell(Row row, int column, Object value, CellStyle style) {
|
||||
Cell cell = row.createCell(column);
|
||||
setCellValue(cell, value, style);
|
||||
}
|
||||
|
||||
private void setCellValue(Cell cell, Object value, CellStyle style) {
|
||||
if (value == null) {
|
||||
cell.setCellValue("");
|
||||
} else if (value instanceof String) {
|
||||
cell.setCellValue((String) value);
|
||||
} else if (value instanceof Date) {
|
||||
cell.setCellValue((Date) value);
|
||||
} else if (value instanceof Number) {
|
||||
cell.setCellValue(value.toString());
|
||||
} else {
|
||||
cell.setCellValue(value.toString());
|
||||
}
|
||||
cell.setCellStyle(style);
|
||||
}
|
||||
|
||||
private void adjustColumnWidth(Sheet sheet) {
|
||||
int[] columnWidths = {
|
||||
8 * 256, // 序号
|
||||
20 * 256, // 维护对象
|
||||
20 * 256, // 维护项目
|
||||
15 * 256, // 维护人员
|
||||
20 * 256, // 维护时间
|
||||
20 * 256, // 填报时间
|
||||
30 * 256, // 维护内容
|
||||
20 * 256, // 隐患发现时间
|
||||
30 * 256, // 隐患描述
|
||||
10 * 256, // 状态
|
||||
30 * 256, // 解决办法
|
||||
20 * 256 // 解决时间
|
||||
};
|
||||
|
||||
for (int i = 0; i < columnWidths.length; i++) {
|
||||
sheet.setColumnWidth(i, columnWidths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void setResponseHeaders(HttpServletResponse response, String fileName) throws IOException {
|
||||
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8)
|
||||
.replaceAll("\\+", "%20");
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\"" + encodedFileName + ".xlsx\"");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.mapper.MentencePlanDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStMapper;
|
||||
import com.gunshi.project.hsz.model.MentencePlan;
|
||||
import com.gunshi.project.hsz.model.MentencePlanDetail;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import com.gunshi.project.hsz.model.MentenceStDetail;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MentencePlanDetailService extends ServiceImpl<MentencePlanDetailMapper, MentencePlanDetail> {
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.ByPlanPageSo;
|
||||
import com.gunshi.project.hsz.entity.so.MentencePlanPageSo;
|
||||
import com.gunshi.project.hsz.mapper.MentencePlanDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentencePlanMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStMapper;
|
||||
import com.gunshi.project.hsz.model.ByPlan;
|
||||
import com.gunshi.project.hsz.model.MentencePlan;
|
||||
import com.gunshi.project.hsz.model.MentencePlanDetail;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import com.gunshi.session.util.SessionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MentencePlanService extends ServiceImpl<MentencePlanMapper, MentencePlan> {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MentencePlanDetailMapper mentencePlanDetailMapper;
|
||||
|
||||
public boolean saveData(MentencePlan dto) {
|
||||
String planName = dto.getPlanName();//计划名称
|
||||
String planYear = dto.getPlanYear();//计划年份
|
||||
LambdaQueryWrapper<MentencePlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentencePlan::getPlanName,planName);
|
||||
queryWrapper.eq(MentencePlan::getPlanYear,planYear);
|
||||
MentencePlan mentencePlan = baseMapper.selectOne(queryWrapper);
|
||||
if(Objects.nonNull(mentencePlan)){
|
||||
throw new IllegalArgumentException("该年份计划已存在");
|
||||
}
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setCreateDate(new Date());
|
||||
dto.setPlanStatus(0);
|
||||
save(dto);
|
||||
//保存细节
|
||||
List<MentencePlanDetail> details = dto.getDetails();
|
||||
details.stream().forEach(detail->{
|
||||
detail.setId(IdWorker.getId());
|
||||
detail.setMentencePlanId(dto.getId());
|
||||
});
|
||||
if(details == null || details.isEmpty()){
|
||||
throw new IllegalArgumentException("请添加维护内容");
|
||||
}
|
||||
mentencePlanDetailMapper.insert(details);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean update(MentencePlan dto) {
|
||||
String planName = dto.getPlanName();//计划名称
|
||||
String planYear = dto.getPlanYear();//计划年份
|
||||
LambdaQueryWrapper<MentencePlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentencePlan::getPlanName,planName);
|
||||
queryWrapper.eq(MentencePlan::getPlanYear,planYear);
|
||||
MentencePlan mentencePlan = baseMapper.selectOne(queryWrapper);
|
||||
if(Objects.isNull(mentencePlan)){
|
||||
throw new IllegalArgumentException("该年份计划不存在,请检查");
|
||||
}
|
||||
updateById(dto);
|
||||
List<MentencePlanDetail> details = dto.getDetails();
|
||||
//先删除细节
|
||||
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
||||
queryWrapperDetail.eq(MentencePlanDetail::getMentencePlanId,mentencePlan.getId());
|
||||
int delete = mentencePlanDetailMapper.delete(queryWrapperDetail);
|
||||
|
||||
//再插入
|
||||
details.stream().forEach(detail->{
|
||||
detail.setId(IdWorker.getId());
|
||||
});
|
||||
mentencePlanDetailMapper.insert(details);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Page<MentencePlan> pageQuery(MentencePlanPageSo pageSo) {
|
||||
LambdaQueryWrapper<MentencePlan> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(pageSo.getPlanName())){
|
||||
queryWrapper.like(MentencePlan::getPlanName,pageSo.getPlanName());
|
||||
}
|
||||
if(!StringUtils.isBlank(pageSo.getYear())){
|
||||
queryWrapper.eq(MentencePlan::getPlanYear,pageSo.getYear());
|
||||
}
|
||||
if(Objects.nonNull(pageSo.getStatus())){
|
||||
queryWrapper.eq(MentencePlan::getPlanStatus,pageSo.getStatus());
|
||||
}
|
||||
Page<MentencePlan> mentencePlanPage = baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
|
||||
List<MentencePlan> records = mentencePlanPage.getRecords();
|
||||
for (MentencePlan record : records) {
|
||||
Long id = record.getId();
|
||||
List<MentencePlanDetail> details = mentencePlanDetailMapper.selectDetail(id);
|
||||
record.setDetails(details);
|
||||
}
|
||||
return mentencePlanPage;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceStPageSo;
|
||||
import com.gunshi.project.hsz.mapper.MentencePlanDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStMapper;
|
||||
import com.gunshi.project.hsz.model.MentencePlanDetail;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import com.gunshi.project.hsz.model.MentenceStDetail;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MentenceStDetailService extends ServiceImpl<MentenceStDetailMapper, MentenceStDetail> {
|
||||
|
||||
@Autowired
|
||||
private MentencePlanDetailMapper mentencePlanDetailMapper;
|
||||
|
||||
public boolean deleteById(Serializable id) {
|
||||
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
||||
queryWrapperDetail.eq(MentencePlanDetail::getMentenceStDetailId, id);
|
||||
Long count = mentencePlanDetailMapper.selectCount(queryWrapperDetail);
|
||||
if(count > 0) {
|
||||
throw new IllegalArgumentException("该维护项目,正关联着维护计划,不允许删除");
|
||||
}
|
||||
int delete = baseMapper.deleteById(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean update(MentenceStDetail dto) {
|
||||
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
|
||||
queryWrapperDetail.eq(MentencePlanDetail::getMentenceStDetailId, dto.getId());
|
||||
Long count = mentencePlanDetailMapper.selectCount(queryWrapperDetail);
|
||||
if(count > 0) {
|
||||
throw new IllegalArgumentException("该维护项目,正关联着维护计划,不允许更新");
|
||||
}
|
||||
baseMapper.updateById(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Page<MentenceStDetail> pageQuery(MentenceStPageSo dto) {
|
||||
LambdaQueryWrapper<MentenceStDetail> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentenceStDetail::getMentenceStId,dto.getStId());
|
||||
Page<MentenceStDetail> mentenceStDetailPage = baseMapper.selectPage(dto.getPageSo().toPage(), queryWrapper);
|
||||
return mentenceStDetailPage;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceStPageSo;
|
||||
import com.gunshi.project.hsz.mapper.MentencePlanDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStDetailMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStMapper;
|
||||
import com.gunshi.project.hsz.mapper.MessageCenterMapper;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import com.gunshi.project.hsz.model.MentenceStDetail;
|
||||
import com.gunshi.project.hsz.model.MessageCenter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MentenceStService extends ServiceImpl<MentenceStMapper, MentenceSt> {
|
||||
|
||||
@Autowired
|
||||
private MentenceStDetailMapper mentenceStDetailMapper;
|
||||
|
||||
|
||||
|
||||
public boolean deleteById(Serializable id) {
|
||||
LambdaQueryWrapper<MentenceStDetail> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentenceStDetail::getId, id);
|
||||
Long count = mentenceStDetailMapper.selectCount(queryWrapper);
|
||||
if(count > 0) {
|
||||
throw new IllegalArgumentException("存在养护项目,无法删除");
|
||||
}
|
||||
mentenceStDetailMapper.deleteById(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<MentenceSt> tree(MentenceStPageSo dto) {
|
||||
LambdaQueryWrapper<MentenceSt> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(dto.getStName())){
|
||||
queryWrapper.like(MentenceSt::getStName, dto.getStName());
|
||||
}
|
||||
List<MentenceSt> mentenceSts = baseMapper.selectList(queryWrapper);
|
||||
Iterator<MentenceSt> iterator = mentenceSts.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
MentenceSt mentenceSt = iterator.next();
|
||||
LambdaQueryWrapper<MentenceStDetail> queryWrapper2 = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(dto.getStDetailName())){
|
||||
queryWrapper2.like(MentenceStDetail::getName, dto.getStDetailName());
|
||||
}
|
||||
queryWrapper2.eq(MentenceStDetail::getMentenceStId,mentenceSt.getId());
|
||||
queryWrapper2.eq(MentenceStDetail::getIsEnable,0);
|
||||
List<MentenceStDetail> mentenceStDetails = mentenceStDetailMapper.selectList(queryWrapper2);
|
||||
if(mentenceStDetails.isEmpty()){
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
mentenceSt.setChildrens(mentenceStDetails);
|
||||
}
|
||||
return mentenceSts;
|
||||
}
|
||||
|
||||
public boolean saveDate(MentenceSt dto) {
|
||||
LambdaQueryWrapper<MentenceSt> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MentenceSt::getStName, dto.getStName());
|
||||
MentenceSt mentenceSt = baseMapper.selectOne(queryWrapper);
|
||||
if(Objects.nonNull(mentenceSt)){
|
||||
throw new IllegalArgumentException("该名称已存在,请检查");
|
||||
}
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setCreateTime(new Date());
|
||||
save(mentenceSt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.gunshi.project.hsz.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.hsz.entity.so.MentenceTemplatePageSo;
|
||||
import com.gunshi.project.hsz.mapper.MentenceStMapper;
|
||||
import com.gunshi.project.hsz.mapper.MentenceTemplateMapper;
|
||||
import com.gunshi.project.hsz.model.MentencePlan;
|
||||
import com.gunshi.project.hsz.model.MentenceSt;
|
||||
import com.gunshi.project.hsz.model.MentenceTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MentenceTemplateService extends ServiceImpl<MentenceTemplateMapper, MentenceTemplate> {
|
||||
public boolean saveDate(MentenceTemplate dto) {
|
||||
dto.setId(IdWorker.getId());
|
||||
dto.setCreateTime(new Date());
|
||||
save(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean update(MentenceTemplate dto) {
|
||||
LambdaQueryWrapper<MentenceTemplate> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(MentenceTemplate::getId, dto.getId());
|
||||
MentenceTemplate entity = getOne(wrapper);
|
||||
if(Objects.isNull(entity)){
|
||||
throw new IllegalArgumentException("该模板不存在,请检查");
|
||||
}
|
||||
updateById(dto);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Page<MentenceTemplate> pageQuery(MentenceTemplatePageSo pageSo) {
|
||||
LambdaQueryWrapper<MentenceTemplate> wrapper = new LambdaQueryWrapper<>();
|
||||
if(!StringUtils.isBlank(pageSo.getName())){
|
||||
wrapper.like(MentenceTemplate::getName,pageSo.getName());
|
||||
}
|
||||
if(pageSo.getType() != null){
|
||||
wrapper.eq(MentenceTemplate::getType,pageSo.getType());
|
||||
}
|
||||
Page<MentenceTemplate> mentenceTemplatePage = baseMapper.selectPage(pageSo.getPageSo().toPage(), wrapper);
|
||||
return mentenceTemplatePage;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue