fix():轧辊配辊接口
This commit is contained in:
@@ -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<List<ReadyRollDataVO> > getReadyRollList() {
|
||||
return R.ok(rollDataService.getReadyRollList(null,null,"STANDBY"));
|
||||
public R<Map<String,ReadyRollDataVO>> getReadyRollList() {
|
||||
return R.ok(rollDataService.getAllReadyRollList());
|
||||
}
|
||||
|
||||
@GetMapping("/data/ready/{position}/{type}")
|
||||
@@ -48,8 +51,14 @@ public class RollerController {
|
||||
|
||||
@PostMapping("/change/standby")
|
||||
@ApiOperation("轧辊操作-备辊")
|
||||
public R<List<String>> backupRoll(@RequestBody List<ReadyRollDataVO> rollList) {
|
||||
return R.ok(rollDataService.BackupRoll(rollList));
|
||||
public R<String> backupRoll(@RequestBody List<ReadyRollDataVO> 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<List<RollHistory>> getRollHistorytList(@RequestBody RollHistoryForm rollHistoryForm) {
|
||||
public R<PageInfo<RollHistory>> getRollHistorytList(@RequestBody RollHistoryForm rollHistoryForm) {
|
||||
return R.ok(rollHistoryService.getRollHistory(rollHistoryForm));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,8 @@ public class RollHistoryForm {
|
||||
|
||||
@ApiModelProperty(value = "轧辊号")
|
||||
private String rollid;
|
||||
|
||||
private int pageNum;
|
||||
|
||||
private int pageSize;
|
||||
}
|
||||
|
||||
@@ -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<RollData> {
|
||||
List<RollData> getList(String position,String type,String status);
|
||||
|
||||
List<ReadyRollDataVO> getReadyRollList(String position,String type,String status);
|
||||
|
||||
Map<String,ReadyRollDataVO> getAllReadyRollList();
|
||||
|
||||
List<OnlineRollDataVO> getOnlineRollList();
|
||||
|
||||
List<String> BackupRoll(List<ReadyRollDataVO> rollList);
|
||||
String BackupRoll(List<ReadyRollDataVO> rollList);
|
||||
|
||||
List<OnlineRollDataVO> onlineRoll();
|
||||
}
|
||||
|
||||
@@ -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<RollHistory> {
|
||||
|
||||
List<String> getRollIdList();
|
||||
|
||||
List<RollHistory> getRollHistory(RollHistoryForm rollHistoryForm);
|
||||
PageInfo<RollHistory> getRollHistory(RollHistoryForm rollHistoryForm);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,25 @@ public class RollDataServiceImpl extends ServiceImpl<RollDataMapper, RollData> i
|
||||
return readyRollDataVOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,ReadyRollDataVO> getAllReadyRollList() {
|
||||
List<ReadyRollDataVO> readyRollDataVOList = new ArrayList<>();
|
||||
List<RollData> 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<OnlineRollDataVO> getOnlineRollList() {
|
||||
Map<String, PlantConfig> plantConfigMap = plantConfigService.getAllConfig();
|
||||
@@ -124,9 +143,9 @@ public class RollDataServiceImpl extends ServiceImpl<RollDataMapper, RollData> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> BackupRoll(List<ReadyRollDataVO> rollList) {
|
||||
public String BackupRoll(List<ReadyRollDataVO> rollList) {
|
||||
if(ObjectUtil.isEmpty(rollList)){
|
||||
return Arrays.asList("轧辊数量为空,无法备辊");
|
||||
return "轧辊数量为空,无法备辊";
|
||||
}
|
||||
//统一检查所有轧辊状态
|
||||
List<String> rollidList = rollList.stream()
|
||||
@@ -136,7 +155,7 @@ public class RollDataServiceImpl extends ServiceImpl<RollDataMapper, RollData> i
|
||||
|
||||
if(rollDataList.stream()
|
||||
.anyMatch(item->item.getStatus().equals("ONLINE"))){
|
||||
return Arrays.asList("存在轧辊已在线,无法备辊");
|
||||
return "存在轧辊已在线,无法备辊";
|
||||
}
|
||||
Map<String, PlantConfig> plantConfigMap = plantConfigService.getAllConfig();
|
||||
//检查是否成对
|
||||
@@ -176,7 +195,7 @@ public class RollDataServiceImpl extends ServiceImpl<RollDataMapper, RollData> i
|
||||
this.saveOrUpdateBatch(newDataList);
|
||||
|
||||
}
|
||||
return result;
|
||||
return String.join(",",result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -248,13 +267,13 @@ public class RollDataServiceImpl extends ServiceImpl<RollDataMapper, RollData> 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<RollDataMapper, RollData> i
|
||||
}
|
||||
|
||||
List<ReadyRollDataVO> 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<RollDataMapper, RollData> 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<RollDataMapper, RollData> 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<RollDataMapper, RollData> 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(rollDia1<value||rollDia2<value){
|
||||
result.add(String.format("{0}径超限[min:{1}]",name,value));
|
||||
result.add(String.format("%s辊径超限[min:{1}]",name,value));
|
||||
}
|
||||
}
|
||||
//差值
|
||||
if(plantConfigMap.containsKey(diffValueKey)){
|
||||
double value = Double.parseDouble(plantConfigMap.get(diffValueKey).getValue());
|
||||
if(Math.abs(rollDia1-rollDia2)>value){
|
||||
result.add(String.format("{0}径超限[diff:{1}]",name,value));
|
||||
result.add(String.format("{%s辊径超限[diff:{1}]",name,value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<RollHistoryMapper, RollH
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RollHistory> getRollHistory(RollHistoryForm rollHistoryForm) {
|
||||
public PageInfo<RollHistory> getRollHistory(RollHistoryForm rollHistoryForm) {
|
||||
|
||||
// 调用分页查询方法,获取EventRecords的分页结果
|
||||
PageHelper.startPage(rollHistoryForm.getPageNum(), rollHistoryForm.getPageSize());
|
||||
|
||||
LambdaQueryWrapper<RollHistory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if(ObjectUtil.isNotEmpty(rollHistoryForm.getStartTime())){
|
||||
queryWrapper.ge(RollHistory::getChangeTime,rollHistoryForm.getStartTime());
|
||||
@@ -40,7 +46,11 @@ public class RollHistoryServiceImpl extends ServiceImpl<RollHistoryMapper, RollH
|
||||
queryWrapper.eq(RollHistory::getRollid,rollHistoryForm.getRollid());
|
||||
}
|
||||
queryWrapper.orderByDesc(RollHistory::getChangeTime);
|
||||
return this.list(queryWrapper);
|
||||
|
||||
List<RollHistory> list = this.list(queryWrapper);
|
||||
PageInfo<RollHistory> pageInfo = new PageInfo<>(list);
|
||||
|
||||
return pageInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<mapper namespace="com.fizz.business.mapper.RollHistoryMapper">
|
||||
<select id="getChangeIdList" resultType="String">
|
||||
select distinct change_id from roll_history
|
||||
select distinct changeid from roll_history
|
||||
</select>
|
||||
<select id="getRollIdList" resultType="String">
|
||||
select distinct rollid from roll_history
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<mapper namespace="com.fizz.business.mapper.RollHistoryMapper">
|
||||
<select id="getChangeIdList" resultType="String">
|
||||
select distinct change_id from roll_history
|
||||
select distinct changeid from roll_history
|
||||
</select>
|
||||
<select id="getRollIdList" resultType="String">
|
||||
select distinct rollid from roll_history
|
||||
|
||||
Reference in New Issue
Block a user