From b0540ce4dc43979763e74586d59c0ffbe067074c Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Tue, 27 Dec 2022 18:02:13 +0800 Subject: [PATCH] update: --- .../empty/controller/EnergyController.java | 1 + .../empty/controller/ScreenController.java | 657 ++++++++++++++++++ .../com/mt/wms/empty/mapper/EleMapper.java | 17 + .../com/mt/wms/empty/service/EleService.java | 11 + .../empty/service/impl/EleServiceImpl.java | 25 + .../java/com/mt/wms/empty/vo/CountEleVo.java | 38 + .../com/mt/wms/empty/vo/NowCurrTaskDetVo.java | 30 +- .../src/main/resources/mapper/EleMapper.xml | 39 ++ 8 files changed, 808 insertions(+), 10 deletions(-) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ScreenController.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/mapper/EleMapper.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/service/EleService.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/EleServiceImpl.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CountEleVo.java create mode 100644 6.program/wms-empty/src/main/resources/mapper/EleMapper.xml diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index 7aa5d58..7dd8315 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -677,6 +677,7 @@ public class EnergyController extends BaseController { carbonSetVo.setValue(parGasValue.getSetNitPotValue()); carbonSet.add(carbonSetVo); EnergyVo carbonActVo = EnergyVo.builder().build(); + carbonActVo.setTime(parGasValue.getCreateTime()); carbonActVo.setValue(parGasValue.getActualNitPotValue()); carbonActVo.setUnit("%"); carbonActVo.setName("碳/氮势"); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ScreenController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ScreenController.java new file mode 100644 index 0000000..faf690a --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ScreenController.java @@ -0,0 +1,657 @@ +package com.mt.wms.empty.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.dal.entity.*; +import com.mt.wms.core.dal.service.*; +import com.mt.wms.core.params.IdParam; +import com.mt.wms.core.utils.BeanUtils; +import com.mt.wms.core.utils.HttpClient; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.ElectricQueryParam; +import com.mt.wms.empty.service.EleService; +import com.mt.wms.empty.task.ScheduledTask; +import com.mt.wms.empty.vo.ApmsCheckResultVo; +import com.mt.wms.empty.vo.CurrTaskDetVo; +import com.mt.wms.empty.vo.EnergyVo; +import com.mt.wms.empty.vo.NowCurrTaskDetVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.xmlbeans.impl.xb.xsdschema.Public; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.groups.Default; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: LGH + * @Date: 2022/12/27 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_BASE + "screenInfo") +@Slf4j +@Api(value = "大屏信息相关接口", tags = "大屏信息相关接口", hidden = false) +public class ScreenController extends BaseController { + + private final static Logger logger = LoggerFactory.getLogger(ScreenController.class); + @Autowired + private PlcNameSpaceServiceBiz plcNameSpaceServiceBiz; + @Autowired + private CurrTaskDetServiceBiz currTaskDetServiceBiz; + @Autowired + private OrderInfoServiceBiz orderInfoServiceBiz; + @Autowired + private CurrTaskServiceBiz currTaskServiceBiz; + @Autowired + private KilnInfoServiceBiz kilnInfoServiceBiz; + @Autowired + private ParEleValueServiceBiz parEleValueServiceBiz; + @Autowired + private ParGasValueServiceBiz parGasValueServiceBiz; + @Autowired + private ParRotSpeedValueServiceBiz parRotSpeedValueServiceBiz; + @Autowired + private ParTemValueServiceBiz parTemValueServiceBiz; + @Autowired + private EleService eleService; + + @PostMapping(value = "getKilnList") + @ApiOperation(value = "获取加工炉信息") + public R> getKilnList() { + List kilnInfoList = kilnInfoServiceBiz.list(); + for (KilnInfo kilnInfo : kilnInfoList + ) { + Boolean kilnWorking = kilnWorking(kilnInfo.getId()); + if (kilnWorking) { + kilnInfo.setStatus(2); + } + Boolean kilnOnline = kilnOnline(kilnInfo.getId()); + if (!kilnOnline) { + //不在线视为损坏 + kilnInfo.setStatus(1); + } + } + return successful(kilnInfoList); + } + + public R countEleByKiln(@Validated @RequestBody IdParam idParam) { + return eleService.list(idParam.getId()); + } + + @PostMapping(value = "CurrTaskInfo") + @ApiOperation(value = "获取当前加工任务基础信息") + public R> CurrTaskInfo() { + //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 + List currTaskList = currTaskServiceBiz.list(new QueryWrapper() + .eq(CurrTask.IS_IN, 1) + .eq(CurrTask.STATUS, 1)); + if (currTaskList.size() == 0) { + return failed(""); + } + List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); + for (NowCurrTaskDetVo nowCurrTask : nowCurrTaskDetVoList + ) { + Long kilnId = nowCurrTask.getKilnId(); + Boolean kilnWorking = kilnWorking(kilnId); + //查询对应炉号是否Working + if (kilnWorking) { + String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId)).getName(); + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + nowCurrTask.setTaskCode(nowCurrTask.getSheetNo()); + nowCurrTask.setKilnCode(kilnInfo.getCode()); + nowCurrTask.setTaskId(nowCurrTask.getId()); + //设定时间 + Integer setupTime = 1; + //剩余时间 + Integer remainingTime = 0; + if (kilnInfo.getType() != 4) { + if (kilnInfo.getType() == 3) { + remainingTime = readPlc(nameSpace, "ProgramTimeRemaining").intValue(); + } else { + remainingTime = readPlc(nameSpace, "ProgramTimeRemain").intValue(); + } + + } + if (kilnInfo.getType() == 1 || kilnInfo.getType() == 3) { + //运行时间 + Integer runTime = readPlc(nameSpace, "ProgramRunTime").intValue(); + setupTime = runTime + remainingTime; + } + if (kilnInfo.getType() == 2) { + setupTime = readPlc(nameSpace, "SetTime").intValue(); + } + nowCurrTask.setSetupTime(setupTime); + nowCurrTask.setRemainingTime(remainingTime); + int completeness = (int) (((float) remainingTime / (float) setupTime) * 100); + nowCurrTask.setCompleteness(completeness); + nowCurrTask.setKilnCode(kilnInfo.getCode()); + //标识卡详情 + List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper() + .eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId())); + List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class); + for (CurrTaskDetVo currTaskDetVo : currTaskDetVoList + ) { + String customerName = orderInfoServiceBiz.getOne(new QueryWrapper().eq(OrderInfo.IDEN_CARD_NUM, currTaskDetVo.getIdenCardNum())).getCustomerName(); + currTaskDetVo.setCustomer(customerName); + } + nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList); + } + } + return successful(nowCurrTaskDetVoList); + } + + @PostMapping(value = "energyInfo") + @ApiOperation(value = "获取当前加工任务能源消耗信息") + public R list(@Validated @RequestBody IdParam idParam) { + Long taskId = idParam.getId(); + Map map = new HashMap<>(); + //电度值 + List> eleConsumeList = new ArrayList<>(); + //A向电压 + List> aVolConsumeList = new ArrayList<>(); + //B向电压 + List> bVolConsumeList = new ArrayList<>(); + //C向电压 + List> cVolConsumeList = new ArrayList<>(); + //A向电流 + List> aCurrentList = new ArrayList<>(); + //B向电流 + List> bCurrentList = new ArrayList<>(); + //C向电流 + List> cCurrentList = new ArrayList<>(); + //氮气 + List> nitConsumeList = new ArrayList<>(); + //甲醇 + List> metConsumeList = new ArrayList<>(); + //丙烷 + List> propaneConsumeList = new ArrayList<>(); + //氨气 + List> ammoniaConsumeList = new ArrayList<>(); + //二氧化碳 + List> carbonConsumeList = new ArrayList<>(); + //1号油搅拌转速 + List> rot1ConsumeList = new ArrayList<>(); + //2号油搅拌转速 + List> rot2ConsumeList = new ArrayList<>(); + //温度 + List> tempConsumeList = new ArrayList<>(); + //油槽温度 + List> oilTempConsumeList = new ArrayList<>(); + //外一区温度 + List> outerZone1TempConsumeList = new ArrayList<>(); + //外二区温度 + List> outerZone2TempConsumeList = new ArrayList<>(); + //碳/氮势 + List> carbonList = new ArrayList<>(); + List> checkResultList = new ArrayList<>(); + CurrTask currTask = currTaskServiceBiz.getById(taskId); + //防止早期没有炉号的报错 + if (currTask.getStoveCode() == null) { + currTask.setStoveCode(currTask.getSheetNo()); + } + + Long kilnId = currTask.getKilnId(); + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + Integer kilnType = kilnInfo.getType(); + //电能消耗 + List parEleValueList = parEleValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, kilnId) + .eq(ParEleValue.TASK_ID, taskId)); + if (parEleValueList.size() > 0) { + List eleList = new ArrayList<>(); + //电能消耗 + List eleConsume = new ArrayList<>(); + //A向电压 + List aVolConsume = new ArrayList<>(); + //B向电压 + List bVolConsume = new ArrayList<>(); + //C向电压 + List cVolConsume = new ArrayList<>(); + //A向电流 + List aCurrentConsume = new ArrayList<>(); + //B向电流 + List bCurrentConsume = new ArrayList<>(); + //C向电流 + List cCurrentConsume = new ArrayList<>(); + Float talBat = 0F; + int i = 0; + for (ParEleValue parEleValue : parEleValueList + ) { + //首位置为0 + if (i == 0) { + talBat = parEleValue.getTotalBat(); + } + i++; + EnergyVo eleVo = EnergyVo.builder().build(); + eleVo.setCode(currTask.getStoveCode()); + eleVo.setName("耗电量"); + eleVo.setUnit("KW"); + eleVo.setTime(parEleValue.getCreateTime()); + eleVo.setValue(floatSubtract(parEleValue.getTotalBat(), talBat)); + eleConsume.add(eleVo); + + EnergyVo aVolVo = EnergyVo.builder().build(); + aVolVo.setCode(currTask.getStoveCode()); + aVolVo.setName("A向电压"); + aVolVo.setUnit("V"); + aVolVo.setTime(parEleValue.getCreateTime()); + aVolVo.setValue(parEleValue.getAVoltagevValue()); + aVolConsume.add(aVolVo); + + EnergyVo bVolVo = EnergyVo.builder().build(); + bVolVo.setCode(currTask.getStoveCode()); + bVolVo.setName("B向电压"); + bVolVo.setUnit("V"); + bVolVo.setTime(parEleValue.getCreateTime()); + bVolVo.setValue(parEleValue.getBVoltagevValue()); + bVolConsume.add(bVolVo); + + EnergyVo cVolVo = EnergyVo.builder().build(); + cVolVo.setCode(currTask.getStoveCode()); + cVolVo.setName("C向电压"); + cVolVo.setUnit("V"); + cVolVo.setTime(parEleValue.getCreateTime()); + cVolVo.setValue(parEleValue.getCVoltagevValue()); + cVolConsume.add(cVolVo); + + EnergyVo aCurrVo = EnergyVo.builder().build(); + aCurrVo.setCode(currTask.getStoveCode()); + aCurrVo.setName("A向电流"); + aCurrVo.setUnit("A"); + aCurrVo.setTime(parEleValue.getCreateTime()); + aCurrVo.setValue(parEleValue.getACurrentValue()); + aCurrentConsume.add(aCurrVo); + + EnergyVo bCurrVo = EnergyVo.builder().build(); + bCurrVo.setCode(currTask.getStoveCode()); + bCurrVo.setName("B向电流"); + bCurrVo.setUnit("A"); + bCurrVo.setTime(parEleValue.getCreateTime()); + bCurrVo.setValue(parEleValue.getBCurrentValue()); + bCurrentConsume.add(bCurrVo); + + EnergyVo cCurrVo = EnergyVo.builder().build(); + cCurrVo.setCode(currTask.getStoveCode()); + cCurrVo.setName("C向电流"); + cCurrVo.setUnit("A"); + cCurrVo.setTime(parEleValue.getCreateTime()); + cCurrVo.setValue(parEleValue.getCCurrentValue()); + cCurrentConsume.add(cCurrVo); + } + eleConsumeList.add(eleConsume); + aVolConsumeList.add(aVolConsume); + bVolConsumeList.add(bVolConsume); + cVolConsumeList.add(cVolConsume); + aCurrentList.add(aCurrentConsume); + bCurrentList.add(bCurrentConsume); + cCurrentList.add(cCurrentConsume); + + } + //氮气、甲醇、丙烷、氨气二氧化碳消耗量碳势 + List parGasValueList = parGasValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, kilnId) + .eq(ParEleValue.TASK_ID, taskId)); + if (parGasValueList.size() > 0) { + if (kilnType == 1) { + //碳/氮势 + List carbon = new ArrayList<>(); + //碳/氮势-设定 + List carbonSet = new ArrayList<>(); + //氮气 + List nitConsume = new ArrayList<>(); + //甲醇 + List metConsume = new ArrayList<>(); + //丙烷 + List propaneConsume = new ArrayList<>(); + //氨气 + List ammoniaConsume = new ArrayList<>(); + for (ParGasValue parGasValue : parGasValueList + ) { + EnergyVo carbonSetVo = EnergyVo.builder().build(); + carbonSetVo.setTime(parGasValue.getCreateTime()); + carbonSetVo.setCode(currTask.getStoveCode().concat("-设定")); + carbonSetVo.setUnit("%"); + carbonSetVo.setName("碳/氮势"); + carbonSetVo.setValue(parGasValue.getSetNitPotValue()); + carbonSet.add(carbonSetVo); + EnergyVo carbonActVo = EnergyVo.builder().build(); + carbonActVo.setValue(parGasValue.getActualNitPotValue()); + carbonActVo.setUnit("%"); + carbonActVo.setName("碳/氮势"); + carbonActVo.setCode(currTask.getStoveCode()); + carbon.add(carbonActVo); + + EnergyVo nitVo = EnergyVo.builder().build(); + nitVo.setTime(parGasValue.getCreateTime()); + nitVo.setUnit("m³/h"); + nitVo.setValue(parGasValue.getNitFlowValue()); + nitVo.setName("氮气"); + nitVo.setCode(currTask.getStoveCode()); + nitConsume.add(nitVo); + + EnergyVo metVo = EnergyVo.builder().build(); + metVo.setCode(currTask.getStoveCode()); + metVo.setValue(parGasValue.getMethanolFlow()); + metVo.setName("甲醇"); + metVo.setUnit("m³/h"); + metVo.setTime(parGasValue.getCreateTime()); + metConsume.add(metVo); + + EnergyVo propaneVo = EnergyVo.builder().build(); + propaneVo.setTime(parGasValue.getCreateTime()); + propaneVo.setCode(currTask.getStoveCode()); + propaneVo.setUnit("m³/h"); + propaneVo.setValue(parGasValue.getPropaneFlow()); + propaneVo.setName("丙烷"); + propaneConsume.add(propaneVo); + + EnergyVo ammoniaVo = EnergyVo.builder().build(); + ammoniaVo.setName("氨气"); + ammoniaVo.setCode(currTask.getStoveCode()); + ammoniaVo.setValue(parGasValue.getAmmoniaFlowValue()); + ammoniaVo.setUnit("m³/h"); + ammoniaVo.setTime(parGasValue.getCreateTime()); + ammoniaConsume.add(ammoniaVo); + } + carbonList.add(carbon); + carbonList.add(carbonSet); + nitConsumeList.add(nitConsume); + metConsumeList.add(metConsume); + propaneConsumeList.add(propaneConsume); + ammoniaConsumeList.add(ammoniaConsume); + } + if (kilnType == 3) { + //碳/氮势 + List carbon = new ArrayList<>(); + //碳/氮势-设定 + List carbonSet = new ArrayList<>(); + //氮气 + List nitConsume = new ArrayList<>(); + //二氧化碳 + List carbonConsume = new ArrayList<>(); + //氨气 + List ammoniaConsume = new ArrayList<>(); + for (ParGasValue parGasValue : parGasValueList + ) { + EnergyVo carbonSetVo = EnergyVo.builder().build(); + carbonSetVo.setTime(parGasValue.getCreateTime()); + carbonSetVo.setCode(currTask.getStoveCode().concat("-设定")); + carbonSetVo.setUnit("%"); + carbonSetVo.setName("碳/氮势"); + carbonSetVo.setValue(parGasValue.getSetNitPotValue()); + carbonSet.add(carbonSetVo); + EnergyVo carbonActVo = EnergyVo.builder().build(); + carbonActVo.setTime(parGasValue.getCreateTime()); + carbonActVo.setValue(parGasValue.getActualNitPotValue()); + carbonActVo.setUnit("%"); + carbonActVo.setName("碳/氮势"); + carbonActVo.setCode(currTask.getStoveCode()); + carbon.add(carbonActVo); + + EnergyVo nitVo = EnergyVo.builder().build(); + nitVo.setTime(parGasValue.getCreateTime()); + nitVo.setUnit("m³/h"); + nitVo.setValue(parGasValue.getNitFlowValue()); + nitVo.setName("氮气"); + nitVo.setCode(currTask.getStoveCode()); + nitConsume.add(nitVo); + + EnergyVo carbonVo = EnergyVo.builder().build(); + carbonVo.setTime(parGasValue.getCreateTime()); + carbonVo.setCode(currTask.getStoveCode()); + carbonVo.setUnit("m³/h"); + carbonVo.setValue(parGasValue.getCarDioxideFlowValue()); + carbonVo.setName("二氧化碳"); + carbonConsume.add(carbonVo); + + EnergyVo ammoniaVo = EnergyVo.builder().build(); + ammoniaVo.setName("氨气"); + ammoniaVo.setCode(currTask.getStoveCode()); + ammoniaVo.setValue(parGasValue.getAmmoniaFlowValue()); + ammoniaVo.setUnit("m³/h"); + ammoniaVo.setTime(parGasValue.getCreateTime()); + ammoniaConsume.add(ammoniaVo); + } + carbonList.add(carbon); + carbonList.add(carbonSet); + carbonConsumeList.add(carbonConsume); + nitConsumeList.add(nitConsume); + ammoniaConsumeList.add(ammoniaConsume); + } + } + //油搅拌转速趋势 + List parRotSpeedValueList = parRotSpeedValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, kilnId) + .eq(ParEleValue.TASK_ID, taskId)); + if (parRotSpeedValueList.size() > 0) { + if (kilnType == 1) { + List rot1Consume = new ArrayList<>(); + for (ParRotSpeedValue parRotSpeedValue : parRotSpeedValueList + ) { + EnergyVo rot1Vo = EnergyVo.builder().build(); + rot1Vo.setCode(currTask.getStoveCode()); + rot1Vo.setUnit("转/min"); + rot1Vo.setName("1号油搅拌转速"); + rot1Vo.setValue(parRotSpeedValue.getOilStiSpeedAValue()); + rot1Vo.setTime(parRotSpeedValue.getCreateTime()); + rot1Consume.add(rot1Vo); + } + rot1ConsumeList.add(rot1Consume); + } + } + //温度趋势(实际温度、设定温度)油槽温度外区温度 + List parTemValueList = parTemValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, kilnId) + .eq(ParEleValue.TASK_ID, taskId)); + if (parTemValueList.size() > 0) { + if (kilnType == 1) { + List actualTempConsume = new ArrayList<>(); + List setupTempConsume = new ArrayList<>(); + List actualOilTempConsume = new ArrayList<>(); + List setupOilTempConsume = new ArrayList<>(); + for (ParTemValue parTemValue : parTemValueList + ) { + EnergyVo actTempVo = EnergyVo.builder().build(); + actTempVo.setTime(parTemValue.getCreateTime()); + actTempVo.setCode(currTask.getStoveCode()); + actTempVo.setUnit("℃"); + actTempVo.setValue(parTemValue.getActTemValue()); + actTempVo.setName("实际温度"); + actualTempConsume.add(actTempVo); + + EnergyVo setTempVo = EnergyVo.builder().build(); + setTempVo.setTime(parTemValue.getCreateTime()); + setTempVo.setCode(currTask.getStoveCode().concat("-设定")); + setTempVo.setUnit("℃"); + setTempVo.setValue(parTemValue.getSetTemValue()); + setTempVo.setName("设定温度"); + setupTempConsume.add(setTempVo); + + EnergyVo oilSetTempVo = EnergyVo.builder().build(); + oilSetTempVo.setTime(parTemValue.getCreateTime()); + oilSetTempVo.setCode(currTask.getStoveCode().concat("-设定")); + oilSetTempVo.setUnit("℃"); + oilSetTempVo.setValue(parTemValue.getOilTankSetTemValue()); + oilSetTempVo.setName("油槽设定温度"); + setupOilTempConsume.add(oilSetTempVo); + + EnergyVo oilActTempVo = EnergyVo.builder().build(); + oilActTempVo.setTime(parTemValue.getCreateTime()); + oilActTempVo.setCode(currTask.getStoveCode()); + oilActTempVo.setUnit("℃"); + oilActTempVo.setValue(parTemValue.getOilTankActTemValue()); + oilActTempVo.setName("油槽实际温度"); + actualOilTempConsume.add(oilActTempVo); + + } + tempConsumeList.add(actualTempConsume); + tempConsumeList.add(setupTempConsume); + oilTempConsumeList.add(actualOilTempConsume); + oilTempConsumeList.add(setupOilTempConsume); + } + if (kilnType == 2) { + List actualTempConsume = new ArrayList<>(); + List setupTempConsume = new ArrayList<>(); + for (ParTemValue parTemValue : parTemValueList + ) { + EnergyVo actTempVo = EnergyVo.builder().build(); + actTempVo.setTime(parTemValue.getCreateTime()); + actTempVo.setCode(currTask.getStoveCode()); + actTempVo.setUnit("℃"); + actTempVo.setValue(parTemValue.getActTemValue()); + actTempVo.setName("实际温度"); + actualTempConsume.add(actTempVo); + + EnergyVo setTempVo = EnergyVo.builder().build(); + setTempVo.setTime(parTemValue.getCreateTime()); + setTempVo.setCode(currTask.getStoveCode().concat("-设定")); + setTempVo.setUnit("℃"); + setTempVo.setValue(parTemValue.getSetTemValue()); + setTempVo.setName("设定温度"); + setupTempConsume.add(setTempVo); + } + tempConsumeList.add(actualTempConsume); + tempConsumeList.add(setupTempConsume); + ; + } + if (kilnType == 3) { + + List actualTempConsume = new ArrayList<>(); + List setupTempConsume = new ArrayList<>(); + List outerZone1TempConsume = new ArrayList<>(); + List outerZone2TempConsume = new ArrayList<>(); + for (ParTemValue parTemValue : parTemValueList + ) { + EnergyVo actTempVo = EnergyVo.builder().build(); + actTempVo.setTime(parTemValue.getCreateTime()); + actTempVo.setCode(currTask.getStoveCode()); + actTempVo.setUnit("℃"); + actTempVo.setValue(parTemValue.getActTemValue()); + actTempVo.setName("实际温度"); + actualTempConsume.add(actTempVo); + + EnergyVo setTempVo = EnergyVo.builder().build(); + setTempVo.setTime(parTemValue.getCreateTime()); + setTempVo.setCode(currTask.getStoveCode().concat("-设定")); + setTempVo.setUnit("℃"); + setTempVo.setValue(parTemValue.getSetTemValue()); + setTempVo.setName("设定温度"); + setupTempConsume.add(setTempVo); + + } + tempConsumeList.add(actualTempConsume); + tempConsumeList.add(setupTempConsume); + } + } + map.put("checkResult", checkResultList); + map.put("ele", eleConsumeList); + map.put("aVol", aVolConsumeList); + map.put("bVol", bVolConsumeList); + map.put("cVol", cVolConsumeList); + map.put("aCurr", aCurrentList); + map.put("bCurr", bCurrentList); + map.put("cCurr", cCurrentList); + map.put("carbon", carbonList); + map.put("nit", nitConsumeList); + map.put("met", metConsumeList); + map.put("propane", propaneConsumeList); + map.put("ammon", ammoniaConsumeList); + map.put("car", carbonConsumeList); + map.put("rot1", rot1ConsumeList); + map.put("temp", tempConsumeList); + map.put("oilTemp", oilTempConsumeList); + return successful(JSONObject.parseObject(JSON.toJSONString(map))); + } + + private Boolean kilnWorking(Long kilnId) { + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId) + .eq(PlcNameSpace.TYPE, 0)); + String nameSpaceNote = nameSpace.getName(); + String result = readPlcToString(nameSpaceNote, "Working"); + return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + } + + private Boolean kilnOnline(Long kilnId) { + PlcNameSpace nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper() + .eq(PlcNameSpace.EQ_TYPE, 0) + .eq(PlcNameSpace.EQ_ID, kilnId) + .eq(PlcNameSpace.TYPE, 0)); + String nameSpaceNote = nameSpace.getName(); + String result = readPlcToString(nameSpaceNote, "ManualAutomatic"); + return Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + } + + /** + * 获取变量值 + * + * @param nameSpace nameSpace前缀 + * @param variableName 变量名称 + * @return 变量值 + */ + private Double readPlc(String nameSpace, String variableName) { + String identifier = nameSpace.concat(variableName); + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier", identifier); + String result = null; + try { + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("能源消耗统计:获取 " + identifier + " 的值失败"); + } + return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); + } + + /** + * 获取变量值 + * + * @param nameSpace nameSpace前缀 + * @param variableName 变量名称 + * @return result字符串 + */ + private String readPlcToString(String nameSpace, String variableName) { + String identifier = nameSpace.concat(variableName); + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier", identifier); + String result = null; + try { + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("readPLC: " + identifier + " 的值失败"); + } + return result; + } + + private Float floatSubtract(Float a, Float b) { + BigDecimal a1 = new BigDecimal(Float.toString(a)); + BigDecimal b1 = new BigDecimal(Float.toString(b)); + return a1.subtract(b1).floatValue(); + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/mapper/EleMapper.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/mapper/EleMapper.java new file mode 100644 index 0000000..0cf767a --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/mapper/EleMapper.java @@ -0,0 +1,17 @@ +package com.mt.wms.empty.mapper; + +import com.mt.wms.empty.vo.CountEleVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Author: LGH + * @Date: 2022/12/27 + */ +public interface EleMapper { + /** + * 获取最近十条电能统计值 + */ + List list(@Param("kilnId") Long kilnId); +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/EleService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/EleService.java new file mode 100644 index 0000000..da67d3e --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/EleService.java @@ -0,0 +1,11 @@ +package com.mt.wms.empty.service; + +import com.mt.wms.core.vo.R; + +/** + * @Author: LGH + * @Date: 2022/12/27 + */ +public interface EleService { + R list(Long kilnId); +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/EleServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/EleServiceImpl.java new file mode 100644 index 0000000..978f078 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/EleServiceImpl.java @@ -0,0 +1,25 @@ +package com.mt.wms.empty.service.impl; + +import com.mt.wms.core.base.BaseService; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.mapper.EleMapper; +import com.mt.wms.empty.service.EleService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @Author: LGH + * @Date: 2022/12/27 + */ +@Service +public class EleServiceImpl extends BaseService implements EleService { + + @Resource + EleMapper eleMapper; + + @Override + public R list(Long kilnId) { + return successful(eleMapper.list(kilnId)); + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CountEleVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CountEleVo.java new file mode 100644 index 0000000..4d16970 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CountEleVo.java @@ -0,0 +1,38 @@ +package com.mt.wms.empty.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.time.LocalDateTime; + +/** + * @Author: LGH + * @Date: 2022/12/27 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@Builder +@ApiModel(value = "消耗数据视图对象", description = "用于查询消耗数据") +public class CountEleVo { + /** + * 时间 + */ + @ApiModelProperty(value = "时间", example = "0") + private LocalDateTime createTime; + /** + * 消耗值 + */ + @ApiModelProperty(value = "消耗值", example = "0.0") + private Float value; + + /** + * 名称 + */ + @ApiModelProperty(value = "任务id", example = "0.0") + private Long taskId; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java index 56faf69..1609eb9 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java @@ -20,59 +20,69 @@ import java.util.List; @Accessors(chain = true) @Builder @ApiModel(value = "当前正在加工炉任务详情视图对象", description = "用于查询当前正在加工炉任务详情") -public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo{ +public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo { /** * 主键,自增 */ @ApiModelProperty(value = "主键", example = "1") private Long id; + /** + * currtask任务id + */ + @ApiModelProperty(value = "currtask任务id", example = "0") + private Long taskId; /** * currtask任务code */ - @ApiModelProperty(value = "currtask任务code",example = "0") + @ApiModelProperty(value = "currtask任务code", example = "0") private String taskCode; + /** + * 炉号 + */ + @ApiModelProperty(value = "炉号", example = "0") + private String stoveCode; /** * 生产单号 */ - @ApiModelProperty(value = "生产单号",example = "0") + @ApiModelProperty(value = "生产单号", example = "0") private String sheetNo; /** * 炉子id */ - @ApiModelProperty(value = "炉子id",example = "0") + @ApiModelProperty(value = "炉子id", example = "0") private Long kilnId; /** * 炉子code */ - @ApiModelProperty(value = "炉子code",example = "0") + @ApiModelProperty(value = "炉子code", example = "0") private String kilnCode; /** * 工艺plc值 */ - @ApiModelProperty(value = "工艺plc值",example = "0") + @ApiModelProperty(value = "工艺plc值", example = "0") private Integer plcValue; /** * 工艺设定时间 */ - @ApiModelProperty(value = "工艺设定时间",example = "0") + @ApiModelProperty(value = "工艺设定时间", example = "0") private Integer setupTime; /** * 工艺剩余时间 */ - @ApiModelProperty(value = "工艺剩余时间",example = "0") + @ApiModelProperty(value = "工艺剩余时间", example = "0") private Integer remainingTime; /** * 工艺进度 */ - @ApiModelProperty(value = "工艺进度",example = "0") + @ApiModelProperty(value = "工艺进度", example = "0") private Integer completeness; /** * 标识卡list */ - @ApiModelProperty(value = "标识卡list",example = "0") + @ApiModelProperty(value = "标识卡list", example = "0") private List currTaskDetVoList; } diff --git a/6.program/wms-empty/src/main/resources/mapper/EleMapper.xml b/6.program/wms-empty/src/main/resources/mapper/EleMapper.xml new file mode 100644 index 0000000..22756b2 --- /dev/null +++ b/6.program/wms-empty/src/main/resources/mapper/EleMapper.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file