From e61476d06bd63ec2c783c53ccf50e9e5dd203e1a Mon Sep 17 00:00:00 2001 From: Penknife Date: Sun, 13 Oct 2024 12:36:58 +0800 Subject: [PATCH] =?UTF-8?q?fix():=E8=BD=A7=E8=BE=8A=E9=85=8D=E8=BE=8A?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/controller/RollerController.java | 21 +++++-- .../fizz/business/form/RollHistoryForm.java | 4 ++ .../business/service/RollDataService.java | 5 +- .../business/service/RollHistoryService.java | 3 +- .../service/impl/RollDataServiceImpl.java | 57 ++++++++++++------- .../service/impl/RollHistoryServiceImpl.java | 14 ++++- .../resources/mapper/RollHistoryMapper.xml | 2 +- .../classes/mapper/RollHistoryMapper.xml | 2 +- 8 files changed, 77 insertions(+), 31 deletions(-) diff --git a/business/src/main/java/com/fizz/business/controller/RollerController.java b/business/src/main/java/com/fizz/business/controller/RollerController.java index 55d33a3..d9bd792 100644 --- a/business/src/main/java/com/fizz/business/controller/RollerController.java +++ b/business/src/main/java/com/fizz/business/controller/RollerController.java @@ -1,5 +1,6 @@ package com.fizz.business.controller; +import cn.hutool.core.util.ObjectUtil; import com.fizz.business.domain.CrmPdiPlan; import com.fizz.business.domain.RollData; import com.fizz.business.domain.RollHistory; @@ -8,6 +9,7 @@ import com.fizz.business.service.RollDataService; import com.fizz.business.service.RollHistoryService; import com.fizz.business.vo.OnlineRollDataVO; import com.fizz.business.vo.ReadyRollDataVO; +import com.github.pagehelper.PageInfo; import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.core.domain.R; import io.swagger.annotations.Api; @@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.Map; @RestController @RequestMapping("/roller") @@ -30,8 +33,8 @@ public class RollerController { @GetMapping("/data/standby") @ApiOperation("轧辊数据-获取当前备辊信息") - public R > getReadyRollList() { - return R.ok(rollDataService.getReadyRollList(null,null,"STANDBY")); + public R> getReadyRollList() { + return R.ok(rollDataService.getAllReadyRollList()); } @GetMapping("/data/ready/{position}/{type}") @@ -48,8 +51,14 @@ public class RollerController { @PostMapping("/change/standby") @ApiOperation("轧辊操作-备辊") - public R> backupRoll(@RequestBody List rollList) { - return R.ok(rollDataService.BackupRoll(rollList)); + public R backupRoll(@RequestBody List rollList) { + String msg = rollDataService.BackupRoll(rollList); + if(ObjectUtil.isEmpty(msg)){ + return R.ok(); + } + else{ + return R.fail(msg); + } } @PostMapping("/change/online") @@ -70,9 +79,9 @@ public class RollerController { return R.ok(rollHistoryService.getRollIdList()); } - @GetMapping("/history/list") + @PostMapping("/history/list") @ApiOperation("轧辊历史-获取换辊记录") - public R> getRollHistorytList(@RequestBody RollHistoryForm rollHistoryForm) { + public R> getRollHistorytList(@RequestBody RollHistoryForm rollHistoryForm) { return R.ok(rollHistoryService.getRollHistory(rollHistoryForm)); } } diff --git a/business/src/main/java/com/fizz/business/form/RollHistoryForm.java b/business/src/main/java/com/fizz/business/form/RollHistoryForm.java index 8c093a6..ed49afc 100644 --- a/business/src/main/java/com/fizz/business/form/RollHistoryForm.java +++ b/business/src/main/java/com/fizz/business/form/RollHistoryForm.java @@ -21,4 +21,8 @@ public class RollHistoryForm { @ApiModelProperty(value = "轧辊号") private String rollid; + + private int pageNum; + + private int pageSize; } diff --git a/business/src/main/java/com/fizz/business/service/RollDataService.java b/business/src/main/java/com/fizz/business/service/RollDataService.java index 18b0048..e4dda03 100644 --- a/business/src/main/java/com/fizz/business/service/RollDataService.java +++ b/business/src/main/java/com/fizz/business/service/RollDataService.java @@ -6,15 +6,18 @@ import com.fizz.business.vo.OnlineRollDataVO; import com.fizz.business.vo.ReadyRollDataVO; import java.util.List; +import java.util.Map; public interface RollDataService extends IService { List getList(String position,String type,String status); List getReadyRollList(String position,String type,String status); + Map getAllReadyRollList(); + List getOnlineRollList(); - List BackupRoll(List rollList); + String BackupRoll(List rollList); List onlineRoll(); } diff --git a/business/src/main/java/com/fizz/business/service/RollHistoryService.java b/business/src/main/java/com/fizz/business/service/RollHistoryService.java index 5a247ea..6356419 100644 --- a/business/src/main/java/com/fizz/business/service/RollHistoryService.java +++ b/business/src/main/java/com/fizz/business/service/RollHistoryService.java @@ -3,6 +3,7 @@ package com.fizz.business.service; import com.baomidou.mybatisplus.extension.service.IService; import com.fizz.business.domain.RollHistory; import com.fizz.business.form.RollHistoryForm; +import com.github.pagehelper.PageInfo; import java.util.List; @@ -11,5 +12,5 @@ public interface RollHistoryService extends IService { List getRollIdList(); - List getRollHistory(RollHistoryForm rollHistoryForm); + PageInfo getRollHistory(RollHistoryForm rollHistoryForm); } diff --git a/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java b/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java index 74c8ffa..ef5a7a3 100644 --- a/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java +++ b/business/src/main/java/com/fizz/business/service/impl/RollDataServiceImpl.java @@ -76,6 +76,25 @@ public class RollDataServiceImpl extends ServiceImpl i return readyRollDataVOList; } + @Override + public Map getAllReadyRollList() { + List readyRollDataVOList = new ArrayList<>(); + List rollDataList = getList(null,null,"STANDBY"); + for (RollData rollData : rollDataList) { + ReadyRollDataVO readyRollDataVO = new ReadyRollDataVO(); + // 使用 BeanUtils 复制属性 + BeanUtils.copyProperties(rollData, readyRollDataVO); + readyRollDataVO.setPosition(RollerPositionEnum.valueOf(rollData.getPosition())); + readyRollDataVO.setType(RollerTypeEnum.valueOf(rollData.getType())); + readyRollDataVOList.add(readyRollDataVO); + } + //补充6个位置 + return readyRollDataVOList.stream() + .collect(Collectors.toMap( + ReadyRollDataVO->ReadyRollDataVO.getPosition().getValue()+ReadyRollDataVO.getType().getValue() + , obj -> obj,(key1, key2)->key1)); + } + @Override public List getOnlineRollList() { Map plantConfigMap = plantConfigService.getAllConfig(); @@ -124,9 +143,9 @@ public class RollDataServiceImpl extends ServiceImpl i } @Override - public List BackupRoll(List rollList) { + public String BackupRoll(List rollList) { if(ObjectUtil.isEmpty(rollList)){ - return Arrays.asList("轧辊数量为空,无法备辊"); + return "轧辊数量为空,无法备辊"; } //统一检查所有轧辊状态 List rollidList = rollList.stream() @@ -136,7 +155,7 @@ public class RollDataServiceImpl extends ServiceImpl i if(rollDataList.stream() .anyMatch(item->item.getStatus().equals("ONLINE"))){ - return Arrays.asList("存在轧辊已在线,无法备辊"); + return "存在轧辊已在线,无法备辊"; } Map plantConfigMap = plantConfigService.getAllConfig(); //检查是否成对 @@ -149,15 +168,15 @@ public class RollDataServiceImpl extends ServiceImpl i checkRollDia( plantConfigMap,rollList,result,"BACKUP"); //清楚所有已有备辊,添加新备辊,有则更新数据,没有则新增 - if(ObjectUtil.isEmpty(result)){ - lambdaUpdate().set(RollData::getStatus,"OFFLINE") - .eq(RollData::getStatus,"STANDBY") + if(ObjectUtil.isEmpty(result)) { + lambdaUpdate().set(RollData::getStatus, "OFFLINE") + .eq(RollData::getStatus, "STANDBY") .update(); List newDataList = Lists.newArrayList(); - rollList.forEach(item->{ + rollList.forEach(item -> { - RollData temp = rollDataList.stream().filter(n->n.getRollid().equals(item.getRollid())) + RollData temp = rollDataList.stream().filter(n -> n.getRollid().equals(item.getRollid())) .findFirst().orElse(RollData.builder() .rollid(item.getRollid()) .position(item.getPosition().getValue()) @@ -176,7 +195,7 @@ public class RollDataServiceImpl extends ServiceImpl i this.saveOrUpdateBatch(newDataList); } - return result; + return String.join(",",result); } @Override @@ -248,13 +267,13 @@ public class RollDataServiceImpl extends ServiceImpl i maxValueKey = "MAX_BR_DIA"; minValueKey = "MIN_BR_DIA"; diffValueKey = "MAX_BR_DIA_DIFF"; - name = "工作辊"; + name = "支撑辊"; break; case "INTERMEDIATE": maxValueKey = "MAX_IR_DIA"; minValueKey = "MIN_IR_DIA"; diffValueKey = "MAX_IR_DIA_DIFF"; - name = "工作辊"; + name = "中间辊"; break; case "WORK": maxValueKey = "MAX_WR_DIA"; @@ -265,7 +284,7 @@ public class RollDataServiceImpl extends ServiceImpl i } List rolls = rollList.stream() - .filter(item->item.getType().equals(type)) + .filter(item->item.getType().getValue().equals(type)&&ObjectUtil.isNotEmpty(item.getRollid())) .collect(Collectors.toList()); if(rolls.size()>0){ //工作辊成对更换 @@ -273,11 +292,11 @@ public class RollDataServiceImpl extends ServiceImpl i double rollDia2; if(type.equals("WORK")||type.equals("INTERMEDIATE")) { if (rolls.size() != 2) { - result.add(String.format("{0}必须成对更换", name)); + result.add(String.format("%s必须成对更换", name)); return; } else { if (rolls.get(0).getPosition().equals(rolls.get(1).getPosition())) { - result.add(String.format("{0}备辊位置重复", name)); + result.add(String.format("%s备辊位置重复", name)); return; } rollDia1 = rolls.get(0).getDiameter(); @@ -286,13 +305,13 @@ public class RollDataServiceImpl extends ServiceImpl i } else{ if(rolls.size()>2){ - result.add(String.format("{0}备辊数量错误",name)); + result.add(String.format("%s备辊数量错误",name)); return; }else { rollDia1 = rolls.get(0).getDiameter(); if(rolls.size()==2) { if (rolls.get(0).getPosition().equals(rolls.get(1).getPosition())) { - result.add(String.format("{0}备辊位置重复", name)); + result.add(String.format("%s备辊位置重复", name)); return; } rollDia2 = rolls.get(1).getDiameter(); @@ -311,21 +330,21 @@ public class RollDataServiceImpl extends ServiceImpl i if(plantConfigMap.containsKey(maxValueKey)){ double value = Double.parseDouble(plantConfigMap.get(maxValueKey).getValue()); if(rollDia1>value||rollDia2>value){ - result.add(String.format("{0}径超限[max:{1}]",name,value)); + result.add(String.format("%s辊径超限[max:{1}]",name,value)); } } //最小值 if(plantConfigMap.containsKey(minValueKey)){ double value = Double.parseDouble(plantConfigMap.get(minValueKey).getValue()); if(rollDia1value){ - result.add(String.format("{0}径超限[diff:{1}]",name,value)); + result.add(String.format("{%s辊径超限[diff:{1}]",name,value)); } } } diff --git a/business/src/main/java/com/fizz/business/service/impl/RollHistoryServiceImpl.java b/business/src/main/java/com/fizz/business/service/impl/RollHistoryServiceImpl.java index e9c8a81..4cb3260 100644 --- a/business/src/main/java/com/fizz/business/service/impl/RollHistoryServiceImpl.java +++ b/business/src/main/java/com/fizz/business/service/impl/RollHistoryServiceImpl.java @@ -8,6 +8,8 @@ import com.fizz.business.domain.RollHistory; import com.fizz.business.form.RollHistoryForm; import com.fizz.business.mapper.RollHistoryMapper; import com.fizz.business.service.RollHistoryService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.springframework.stereotype.Service; import java.util.List; @@ -25,7 +27,11 @@ public class RollHistoryServiceImpl extends ServiceImpl getRollHistory(RollHistoryForm rollHistoryForm) { + public PageInfo getRollHistory(RollHistoryForm rollHistoryForm) { + + // 调用分页查询方法,获取EventRecords的分页结果 + PageHelper.startPage(rollHistoryForm.getPageNum(), rollHistoryForm.getPageSize()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); if(ObjectUtil.isNotEmpty(rollHistoryForm.getStartTime())){ queryWrapper.ge(RollHistory::getChangeTime,rollHistoryForm.getStartTime()); @@ -40,7 +46,11 @@ public class RollHistoryServiceImpl extends ServiceImpl list = this.list(queryWrapper); + PageInfo pageInfo = new PageInfo<>(list); + + return pageInfo; } } diff --git a/business/src/main/resources/mapper/RollHistoryMapper.xml b/business/src/main/resources/mapper/RollHistoryMapper.xml index 1be345d..edc40eb 100644 --- a/business/src/main/resources/mapper/RollHistoryMapper.xml +++ b/business/src/main/resources/mapper/RollHistoryMapper.xml @@ -4,7 +4,7 @@ - select distinct change_id from roll_history + select distinct changeid from roll_history