From d5464eed6c5f1f849d594bcca3602d05c8a587af Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Thu, 3 Nov 2022 16:14:01 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E8=83=BD=E6=BA=90=E6=B6=88=E8=80=97?= =?UTF-8?q?=E6=AF=94=E8=BE=83=20=E7=94=9F=E6=88=90=E7=82=89=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mt/wms/core/MyGenerator.java | 6 +- .../com/mt/wms/core/dal/entity/CurrTask.java | 8 + .../com/mt/wms/core/dal/entity/TaskHis.java | 8 + .../wms/core/utils/CodeGeneratorHelper.java | 4 + .../empty/controller/CurrTaskController.java | 7 + .../empty/controller/EnergyController.java | 629 +++++++++--------- .../empty/controller/TaskHisController.java | 10 +- .../wms/empty/params/ElectricQueryParam.java | 3 +- .../wms/empty/params/TaskHisQueryParam.java | 10 +- .../mt/wms/empty/params/TestStoveCode.java | 20 + .../service/impl/TaskHisServiceImpl.java | 8 +- .../mt/wms/empty/task/AsynRunTaskService.java | 19 + .../com/mt/wms/empty/task/StoveCodeUtils.java | 18 + .../com/mt/wms/empty/vo/CurrTaskInfoVo.java | 5 + .../java/com/mt/wms/empty/vo/CurrTaskVo.java | 6 + .../com/mt/wms/empty/vo/TaskHisQueryVo.java | 6 + 16 files changed, 437 insertions(+), 330 deletions(-) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TestStoveCode.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/task/StoveCodeUtils.java diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java b/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java index f229ea6..d548250 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/MyGenerator.java @@ -21,9 +21,9 @@ public class MyGenerator { /** * 数据库地址 */ - static String dbUrl = "jdbc:mysql://mysql.picaiba.com:30307/mt_wms_qj"; + static String dbUrl = "jdbc:mysql://localhost:3306/mt_wms_qj"; static String userName = "root"; - static String password = "1qaz@WSX3edc$RFV"; + static String password = "123456"; /** * 是否去掉生成实体的属性名前缀 */ @@ -106,7 +106,7 @@ public class MyGenerator { @Test public void generateCodeWithInjectConfigForAllTable() { - generateByTablesWithInjectConfig(new String[]{"t_auto_exe_task"}); + generateByTablesWithInjectConfig(new String[]{"t_question_answer"}); } public static void main(String[] args) { diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/CurrTask.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/CurrTask.java index 8b5bf87..3cc4749 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/CurrTask.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/CurrTask.java @@ -228,6 +228,12 @@ public class CurrTask extends Model { @TableField("process_type") private Integer processType; + /** + * 炉号 + */ + @TableField("stove_code") + private String stoveCode; + public static final String ID = "id"; @@ -297,6 +303,8 @@ public class CurrTask extends Model { public static final String PROCESS_TYPE = "process_type"; + public static final String STOVE_CODE = "stove_code"; + @Override protected Serializable pkVal() { return this.id; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/TaskHis.java b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/TaskHis.java index 89fa791..e2fd209 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/TaskHis.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/dal/entity/TaskHis.java @@ -238,6 +238,12 @@ public class TaskHis extends Model { @TableField("task_id") private Long taskId; + /** + * 炉号 + */ + @TableField("stove_code") + private String stoveCode; + public static final String ID = "id"; public static final String VALID = "valid"; @@ -308,6 +314,8 @@ public class TaskHis extends Model { public static final String TASK_ID = "task_id"; + public static final String STOVE_CODE = "stove_code"; + @Override protected Serializable pkVal() { return this.id; diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java index af6ed22..8c6e317 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java @@ -50,6 +50,10 @@ public class CodeGeneratorHelper { public static String getStoveCode(String kilnNameAndCraft) { return IDGenerator.gen(kilnNameAndCraft, "yyMMdd", 2, STOVE_CODE); } + + public static String getStoveCode(String kilnName,String craft) { + return IDGenerator.gen(kilnName+"-"+craft+"-", "yyMMdd", 4,kilnName); + } /** * 生成自动任务编码 * diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index b9f6213..330d215 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -22,6 +22,7 @@ import com.mt.wms.empty.params.*; import com.mt.wms.empty.service.CurrTaskDetService; import com.mt.wms.empty.service.CurrTaskService; import com.mt.wms.empty.service.OrderInfoService; +import com.mt.wms.empty.task.StoveCodeUtils; import com.mt.wms.empty.task.TaskDistanceUtils; import com.mt.wms.empty.vo.*; import io.swagger.annotations.Api; @@ -347,4 +348,10 @@ public class CurrTaskController extends BaseController { JSONObject jsonObject = JSON.parseObject(result); return Integer.parseInt(String.valueOf(jsonObject.get("msg"))); } + + @PostMapping(value = "testStoveCode") + @ApiOperation(value = "测试炉号生成") + public String testStoveCode(@RequestBody TestStoveCode testStoveCode){ + return StoveCodeUtils.getStoveCode(testStoveCode.getKilnName(),testStoveCode.getCraft()); + } } 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 f427852..09a2794 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 @@ -44,30 +44,6 @@ import java.util.*; @Api(value = "电能消耗相关接口", tags = "电能消耗相关接口", hidden = false) public class EnergyController extends BaseController { - - //@PostConstruct - public void test(){ - LocalDateTime time=LocalDateTime.of(2021, 3, 31, 0, 0, 0); - Float f=29000F; - - LocalDate timeDate=time.toLocalDate(); - LocalDateTime timeEnd = LocalDateTime.of(timeDate, LocalTime.MAX).minus(5,ChronoUnit.SECONDS); - for (int i = 0; i < 10; i++) { - - ParEleValue parEleValue=new ParEleValue(); - parEleValue.setDateType(2); - parEleValue.setParId(1); - parEleValue.setKilnId(1L); - parEleValue.setTotalBat(Float.valueOf(String.valueOf(f+(Math.random()*24000)))); - parEleValue.setCreateTime(timeEnd); - timeEnd=timeEnd.plus(1,ChronoUnit.MONTHS); - f=parEleValue.getTotalBat(); - parEleValueServiceBiz.save(parEleValue); - System.out.println(parEleValue); - } - - } - @Autowired private ParEleValueServiceBiz parEleValueServiceBiz; @Autowired @@ -89,322 +65,351 @@ public class EnergyController extends BaseController { @PostMapping(value = "energyList") @ApiOperation(value = "根据加工炉id获取能源消耗情况") public R energyList(@Validated({Default.class}) @RequestBody ElectricQueryParam electricQueryParam){ - //TaskHis currTask = taskHisServiceBiz.getById(electricQueryParam.getTaskId()); - TaskHis currTask = taskHisServiceBiz.getOne(new QueryWrapper().eq(TaskHis.TASK_ID, electricQueryParam.getTaskId())); - Long kilnId = currTask.getKilnId(); - KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); - Integer kilnType = kilnInfo.getType(); - //传入任务号,工业炉号,查询消耗数据,返回json字符串 - JSONObject jsonObject=new JSONObject(); - ConsumeDataVo consumeDataVo=ConsumeDataVo.builder().build(); + List taskIds = electricQueryParam.getTaskIds(); + JSONObject json=new JSONObject(); + for (Long taskId:taskIds + ) { + //TaskHis currTask = taskHisServiceBiz.getById(electricQueryParam.getTaskId()); + TaskHis currTask = taskHisServiceBiz.getOne(new QueryWrapper().eq(TaskHis.TASK_ID, taskId)); + Long kilnId = currTask.getKilnId(); + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); + Integer kilnType = kilnInfo.getType(); + //传入任务号,工业炉号,查询消耗数据,返回json字符串 + JSONObject jsonObject=new JSONObject(); + ConsumeDataVo consumeDataVo=ConsumeDataVo.builder().build(); - Map map=new HashMap<>(); - //电能消耗 - List parEleValueList = parEleValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, kilnId) - .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); - if (parEleValueList.size()>0){ - List eleList=new ArrayList<>(); + Map map=new HashMap<>(); //电能消耗 - List eleConsume=new ArrayList<>(); - //A向电压 - List aVolConsume=new ArrayList<>(); - //B向电压 - List bVolConsume=new ArrayList<>(); - //C向电压 - List cVolConsume=new ArrayList<>(); - Float talBat=0F; - int i=0; - for (ParEleValue parEleValue:parEleValueList - ) { - //首位置为0 - if (i==0){ - talBat=parEleValue.getTotalBat(); - } - - i++; - map.put("time",parEleValue.getCreateTime()); - map.put("value",floatSubtract(parEleValue.getTotalBat(),talBat)); - map.put("name","耗电量"); - map.put("unit","KW"); - eleConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parEleValue.getCreateTime()); - map.put("value",parEleValue.getAVoltagevValue()); - map.put("name","A向电压"); - map.put("unit","V"); - aVolConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parEleValue.getCreateTime()); - map.put("value",parEleValue.getBVoltagevValue()); - map.put("name","B向电压"); - map.put("unit","V"); - bVolConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parEleValue.getCreateTime()); - map.put("value",parEleValue.getCVoltagevValue()); - map.put("name","C向电压"); - map.put("unit","V"); - cVolConsume.add(JSONObject.toJSON(map)); - map.clear(); - } - eleList.add(eleConsume); - eleList.add(aVolConsume); - eleList.add(bVolConsume); - eleList.add(cVolConsume); - jsonObject.put("ele",eleList); - } - //氮气、甲醇、丙烷、氨气消耗量 - List parGasValueList = parGasValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, kilnId) - .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); - if (parGasValueList.size()>0){ - if (kilnType==1){ - List gasList=new ArrayList<>(); - //氮气 - List nitConsume=new ArrayList<>(); - Float nit=0F; - //甲醇 - List metConsume=new ArrayList<>(); - Float met=0F; - //丙烷 - List propaneConsume=new ArrayList<>(); - Float propane=0F; - //氨气 - List ammoniaConsume=new ArrayList<>(); - Float ammonia=0F; + 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<>(); + Float talBat=0F; int i=0; - for (ParGasValue parGasValue:parGasValueList - ) { - //累计值的量首位置为0 + for (ParEleValue parEleValue:parEleValueList + ) { + //首位置为0 if (i==0){ - nit=parGasValue.getNitFlowValue(); - met=parGasValue.getMethanolFlow(); - propane=parGasValue.getPropaneFlow(); - ammonia=parGasValue.getAmmoniaFlowValue(); + talBat=parEleValue.getTotalBat(); } + i++; - map.put("time",parGasValue.getCreateTime()); - map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit)); - map.put("name","氮气"); - map.put("unit","m³"); - nitConsume.add(JSONObject.toJSON(map)); + map.put("time",parEleValue.getCreateTime()); + map.put("value",floatSubtract(parEleValue.getTotalBat(),talBat)); + map.put("name","耗电量"); + map.put("unit","KW"); + map.put("炉号",currTask.getSheetNo()); + eleConsume.add(JSONObject.toJSON(map)); map.clear(); - map.put("time",parGasValue.getCreateTime()); - map.put("value",floatSubtract(parGasValue.getMethanolFlow(),met)); - map.put("name","甲醇"); - map.put("unit","m³"); - metConsume.add(JSONObject.toJSON(map)); + map.put("time",parEleValue.getCreateTime()); + map.put("value",parEleValue.getAVoltagevValue()); + map.put("name","A向电压"); + map.put("unit","V"); + map.put("炉号",currTask.getSheetNo()); + aVolConsume.add(JSONObject.toJSON(map)); map.clear(); - map.put("time",parGasValue.getCreateTime()); - map.put("value",floatSubtract(parGasValue.getPropaneFlow(),propane)); - map.put("name","丙烷"); - map.put("unit","m³"); - propaneConsume.add(JSONObject.toJSON(map)); + map.put("time",parEleValue.getCreateTime()); + map.put("value",parEleValue.getBVoltagevValue()); + map.put("name","B向电压"); + map.put("unit","V"); + map.put("炉号",currTask.getSheetNo()); + bVolConsume.add(JSONObject.toJSON(map)); map.clear(); - map.put("time",parGasValue.getCreateTime()); - map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia)); - map.put("name","氨气"); - map.put("unit","m³"); - ammoniaConsume.add(JSONObject.toJSON(map)); + map.put("time",parEleValue.getCreateTime()); + map.put("value",parEleValue.getCVoltagevValue()); + map.put("name","C向电压"); + map.put("unit","V"); + map.put("炉号",currTask.getSheetNo()); + cVolConsume.add(JSONObject.toJSON(map)); map.clear(); } - gasList.add(nitConsume); - gasList.add(metConsume); - gasList.add(propaneConsume); - gasList.add(ammoniaConsume); - jsonObject.put("gas",gasList); + eleList.add(eleConsume); + eleList.add(aVolConsume); + eleList.add(bVolConsume); + eleList.add(cVolConsume); + jsonObject.put("ele",eleList); } - if (kilnType==3){ - List gasList=new ArrayList<>(); - //氮气 - List nitConsume=new ArrayList<>(); - Float nit=0F; - //二氧化碳 - List carbonConsume=new ArrayList<>(); - Float carbon=0F; - //氨气 - List ammoniaConsume=new ArrayList<>(); - Float ammonia=0F; - int i=0; - for (ParGasValue parGasValue:parGasValueList - ) { - //累计值的量首位置为0 - if (i==0){ - nit=parGasValue.getNitFlowValue(); - carbon=parGasValue.getCarDioxideFlowValue(); - ammonia=parGasValue.getAmmoniaFlowValue(); + //氮气、甲醇、丙烷、氨气消耗量 + List parGasValueList = parGasValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, kilnId) + .eq(ParEleValue.TASK_ID, taskId)); + if (parGasValueList.size()>0){ + if (kilnType==1){ + List gasList=new ArrayList<>(); + //氮气 + List nitConsume=new ArrayList<>(); + Float nit=0F; + //甲醇 + List metConsume=new ArrayList<>(); + Float met=0F; + //丙烷 + List propaneConsume=new ArrayList<>(); + Float propane=0F; + //氨气 + List ammoniaConsume=new ArrayList<>(); + Float ammonia=0F; + int i=0; + for (ParGasValue parGasValue:parGasValueList + ) { + //累计值的量首位置为0 + if (i==0){ + nit=parGasValue.getNitFlowValue(); + met=parGasValue.getMethanolFlow(); + propane=parGasValue.getPropaneFlow(); + ammonia=parGasValue.getAmmoniaFlowValue(); + } + i++; + map.put("time",parGasValue.getCreateTime()); + map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit)); + map.put("name","氮气"); + map.put("unit","m³"); + map.put("炉号",currTask.getSheetNo()); + nitConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",floatSubtract(parGasValue.getMethanolFlow(),met)); + map.put("name","甲醇"); + map.put("unit","m³"); + map.put("炉号",currTask.getSheetNo()); + metConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",floatSubtract(parGasValue.getPropaneFlow(),propane)); + map.put("name","丙烷"); + map.put("unit","m³"); + map.put("炉号",currTask.getSheetNo()); + propaneConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia)); + map.put("name","氨气"); + map.put("unit","m³"); + map.put("炉号",currTask.getSheetNo()); + ammoniaConsume.add(JSONObject.toJSON(map)); + map.clear(); } - i++; - map.put("time",parGasValue.getCreateTime()); - map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit)); - map.put("name","氮气"); - map.put("unit","m³"); - nitConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parGasValue.getCreateTime()); - map.put("value",floatSubtract(parGasValue.getCarDioxideFlowValue(),carbon)); - map.put("name","二氧化碳"); - map.put("unit","m³"); - carbonConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parGasValue.getCreateTime()); - map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia)); - map.put("name","氨气"); - map.put("unit","m³"); - ammoniaConsume.add(JSONObject.toJSON(map)); - map.clear(); + gasList.add(nitConsume); + gasList.add(metConsume); + gasList.add(propaneConsume); + gasList.add(ammoniaConsume); + jsonObject.put("gas",gasList); } - gasList.add(nitConsume); - gasList.add(carbonConsume); - gasList.add(ammoniaConsume); - jsonObject.put("gas",gasList); - } - } - //油搅拌转速趋势 - List parRotSpeedValueList = parRotSpeedValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, kilnId) - .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); - if (parRotSpeedValueList.size()>0){ - if (kilnType==1){ - List rotList=new ArrayList<>(); - List rot1Consume=new ArrayList<>(); - List rot2Consume=new ArrayList<>(); - for (ParRotSpeedValue parRotSpeedValue:parRotSpeedValueList - ) { - map.put("time",parRotSpeedValue.getCreateTime()); - map.put("value",parRotSpeedValue.getOilStiSpeedAValue()); - map.put("name","1号油搅拌转速"); - map.put("unit","转/min"); - rot1Consume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parRotSpeedValue.getCreateTime()); - map.put("value",parRotSpeedValue.getOilStiSpeedBValue()); - map.put("name","2号油搅拌转速"); - map.put("unit","转/min"); - rot2Consume.add(JSONObject.toJSON(map)); - map.clear(); + if (kilnType==3){ + List gasList=new ArrayList<>(); + //氮气 + List nitConsume=new ArrayList<>(); + Float nit=0F; + //二氧化碳 + List carbonConsume=new ArrayList<>(); + Float carbon=0F; + //氨气 + List ammoniaConsume=new ArrayList<>(); + Float ammonia=0F; + int i=0; + for (ParGasValue parGasValue:parGasValueList + ) { + //累计值的量首位置为0 + if (i==0){ + nit=parGasValue.getNitFlowValue(); + carbon=parGasValue.getCarDioxideFlowValue(); + ammonia=parGasValue.getAmmoniaFlowValue(); + } + i++; + map.put("time",parGasValue.getCreateTime()); + map.put("value",floatSubtract(parGasValue.getNitFlowValue(),nit)); + map.put("name","氮气"); + map.put("unit","m³"); + map.put("炉号",currTask.getSheetNo()); + nitConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",floatSubtract(parGasValue.getCarDioxideFlowValue(),carbon)); + map.put("name","二氧化碳"); + map.put("unit","m³"); + map.put("炉号",currTask.getSheetNo()); + carbonConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parGasValue.getCreateTime()); + map.put("value",floatSubtract(parGasValue.getAmmoniaFlowValue(),ammonia)); + map.put("name","氨气"); + map.put("unit","m³"); + map.put("炉号",currTask.getSheetNo()); + ammoniaConsume.add(JSONObject.toJSON(map)); + map.clear(); + } + gasList.add(nitConsume); + gasList.add(carbonConsume); + gasList.add(ammoniaConsume); + jsonObject.put("gas",gasList); } - rotList.add(rot1Consume); - rotList.add(rot2Consume); - jsonObject.put("rot",rotList); } - } - //温度趋势(实际温度、设定温度) - List parTemValueList = parTemValueServiceBiz.list(new QueryWrapper() - .eq(ParEleValue.KILN_ID, kilnId) - .eq(ParEleValue.TASK_ID, electricQueryParam.getTaskId())); - if (parTemValueList.size()>0){ - if (kilnType==1){ - List tempList=new ArrayList<>(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); - List actualOilTempConsume=new ArrayList<>(); - List setupOilTempConsume=new ArrayList<>(); - for (ParTemValue parTemValue:parTemValueList - ) { - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getActTemValue()); - map.put("name","实际温度"); - map.put("unit","℃"); - actualTempConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getSetTemValue()); - map.put("name","设定温度"); - map.put("unit","℃"); - setupTempConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getOilTankActTemValue()); - map.put("name","油槽实际温度"); - map.put("unit","℃"); - actualOilTempConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getOilTankSetTemValue()); - map.put("name","油槽设定温度"); - map.put("unit","℃"); - setupOilTempConsume.add(JSONObject.toJSON(map)); - map.clear(); + //油搅拌转速趋势 + List parRotSpeedValueList = parRotSpeedValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, kilnId) + .eq(ParEleValue.TASK_ID, taskId)); + if (parRotSpeedValueList.size()>0){ + if (kilnType==1){ + List rotList=new ArrayList<>(); + List rot1Consume=new ArrayList<>(); + List rot2Consume=new ArrayList<>(); + for (ParRotSpeedValue parRotSpeedValue:parRotSpeedValueList + ) { + map.put("time",parRotSpeedValue.getCreateTime()); + map.put("value",parRotSpeedValue.getOilStiSpeedAValue()); + map.put("name","1号油搅拌转速"); + map.put("unit","转/min"); + map.put("炉号",currTask.getSheetNo()); + rot1Consume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parRotSpeedValue.getCreateTime()); + map.put("value",parRotSpeedValue.getOilStiSpeedBValue()); + map.put("name","2号油搅拌转速"); + map.put("unit","转/min"); + map.put("炉号",currTask.getSheetNo()); + rot2Consume.add(JSONObject.toJSON(map)); + map.clear(); + } + rotList.add(rot1Consume); + rotList.add(rot2Consume); + jsonObject.put("rot",rotList); } - tempList.add(actualTempConsume); - tempList.add(setupTempConsume); - tempList.add(actualOilTempConsume); - tempList.add(setupOilTempConsume); - jsonObject.put("temp",tempList); } - if (kilnType==2){ - List tempList=new ArrayList<>(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); - for (ParTemValue parTemValue:parTemValueList - ) { - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getActTemValue()); - map.put("name","实际温度"); - map.put("unit","℃"); - actualTempConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getSetTemValue()); - map.put("name","设定温度"); - map.put("unit","℃"); - setupTempConsume.add(JSONObject.toJSON(map)); - map.clear(); + //温度趋势(实际温度、设定温度) + List parTemValueList = parTemValueServiceBiz.list(new QueryWrapper() + .eq(ParEleValue.KILN_ID, kilnId) + .eq(ParEleValue.TASK_ID, taskId)); + if (parTemValueList.size()>0){ + if (kilnType==1){ + List tempList=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List actualOilTempConsume=new ArrayList<>(); + List setupOilTempConsume=new ArrayList<>(); + for (ParTemValue parTemValue:parTemValueList + ) { + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getActTemValue()); + map.put("name","实际温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + actualTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getSetTemValue()); + map.put("name","设定温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + setupTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOilTankActTemValue()); + map.put("name","油槽实际温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + actualOilTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOilTankSetTemValue()); + map.put("name","油槽设定温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + setupOilTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + } + tempList.add(actualTempConsume); + tempList.add(setupTempConsume); + tempList.add(actualOilTempConsume); + tempList.add(setupOilTempConsume); + jsonObject.put("temp",tempList); } - tempList.add(actualTempConsume); - tempList.add(setupTempConsume); - jsonObject.put("temp",tempList); - } - if (kilnType==3){ + if (kilnType==2){ + List tempList=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + for (ParTemValue parTemValue:parTemValueList + ) { + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getActTemValue()); + map.put("name","实际温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + actualTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getSetTemValue()); + map.put("name","设定温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + setupTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + } + tempList.add(actualTempConsume); + tempList.add(setupTempConsume); + jsonObject.put("temp",tempList); + } + if (kilnType==3){ - List tempList=new ArrayList<>(); - List actualTempConsume=new ArrayList<>(); - List setupTempConsume=new ArrayList<>(); - List outerZone1TempConsume=new ArrayList<>(); - List outerZone2TempConsume=new ArrayList<>(); - for (ParTemValue parTemValue:parTemValueList - ) { - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getActTemValue()); - map.put("name","实际温度"); - map.put("unit","℃"); - actualTempConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getSetTemValue()); - map.put("name","设定温度"); - map.put("unit","℃"); - setupTempConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getOuterZone1Temp()); - map.put("name","外一区温度"); - map.put("unit","℃"); - outerZone1TempConsume.add(JSONObject.toJSON(map)); - map.clear(); - map.put("time",parTemValue.getCreateTime()); + List tempList=new ArrayList<>(); + List actualTempConsume=new ArrayList<>(); + List setupTempConsume=new ArrayList<>(); + List outerZone1TempConsume=new ArrayList<>(); + List outerZone2TempConsume=new ArrayList<>(); + for (ParTemValue parTemValue:parTemValueList + ) { + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getActTemValue()); + map.put("name","实际温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + actualTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getSetTemValue()); + map.put("name","设定温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + setupTempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); + map.put("value",parTemValue.getOuterZone1Temp()); + map.put("name","外一区温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + outerZone1TempConsume.add(JSONObject.toJSON(map)); + map.clear(); + map.put("time",parTemValue.getCreateTime()); - map.put("value",parTemValue.getOuterZone2Temp()); - map.put("name","外二区温度"); - map.put("unit","℃"); - outerZone2TempConsume.add(JSONObject.toJSON(map)); - map.clear(); + map.put("value",parTemValue.getOuterZone2Temp()); + map.put("name","外二区温度"); + map.put("unit","℃"); + map.put("炉号",currTask.getSheetNo()); + outerZone2TempConsume.add(JSONObject.toJSON(map)); + map.clear(); + } + tempList.add(actualTempConsume); + tempList.add(setupTempConsume); + tempList.add(outerZone1TempConsume); + tempList.add(outerZone2TempConsume); + jsonObject.put("temp",tempList); } - tempList.add(actualTempConsume); - tempList.add(setupTempConsume); - tempList.add(outerZone1TempConsume); - tempList.add(outerZone2TempConsume); - jsonObject.put("temp",tempList); } + json.put(String.valueOf(taskId),jsonObject); } - return R.ok(jsonObject.toJSONString()); + return R.ok(json.toJSONString()); } 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(); + return a1.floatValue(); } @PostMapping(value = "checkResultList") @ApiOperation(value = "根据生产单号获取apms检验结果") diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/TaskHisController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/TaskHisController.java index 6f6f2e5..059e67b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/TaskHisController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/TaskHisController.java @@ -34,16 +34,8 @@ public class TaskHisController extends BaseController { private TaskHisService taskHisService; @PostMapping(value = "taskHis") - @ApiOperation(value = "获取历史执行的任务 (车辆名称传id)") + @ApiOperation(value = "获取历史执行的任务") public R> currentTask(@Validated @RequestBody TaskHisQueryParam param) { - if (Objects.nonNull(param.getStartTime())) - { - param.setStartTime(LocalDateTimeUtils.getDayStart(param.getStartTime())); - } - if (Objects.nonNull(param.getEndTime())) - { - param.setEndTime(LocalDateTimeUtils.getDayEnd(param.getEndTime())); - } return taskHisService.taskHisPage(param); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java index 18edab4..90153f5 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ElectricQueryParam.java @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import java.time.LocalDateTime; +import java.util.List; /** * @Author: liguanghao @@ -26,7 +27,7 @@ public class ElectricQueryParam extends BaseParam { private Long kilnId; @ApiModelProperty(value = "任务id", required = true) - private Long taskId; + private List taskIds; @ApiModelProperty(value = "时间节点", required = false) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java index 9ff4817..d698139 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TaskHisQueryParam.java @@ -1,5 +1,6 @@ package com.mt.wms.empty.params; +import com.fasterxml.jackson.annotation.JsonFormat; import com.mt.wms.core.params.BasePageParam; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -22,12 +23,17 @@ public class TaskHisQueryParam extends BasePageParam { private static final long serialVersionUID = 1L; - @ApiModelProperty(value = "车辆id") - private String vehicleId; + @ApiModelProperty(value = "加工炉id") + private String kilnId; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @ApiModelProperty(value = "开始时间", example = "2021-11-20T12:05:20") private LocalDateTime startTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @ApiModelProperty(value = "结束时间", example = "2021-11-25T12:05:20") private LocalDateTime endTime; @ApiModelProperty(value = "生产单号", example = "1219391") private String sheetNo; + + @ApiModelProperty(value = "炉号", example = "BMA1-01-200011030001") + private String stoveCode; } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TestStoveCode.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TestStoveCode.java new file mode 100644 index 0000000..3411a0b --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/TestStoveCode.java @@ -0,0 +1,20 @@ +package com.mt.wms.empty.params; + +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: LGH + * @Date: 2022/8/3 + */ + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "测试stoveCode", description = "测试stoveCode") +public class TestStoveCode { + private String kilnName; + private Integer craft; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java index f14da71..da20bad 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/TaskHisServiceImpl.java @@ -54,9 +54,11 @@ public class TaskHisServiceImpl extends BaseService implements TaskHisService { @Override public R> taskHisPage(TaskHisQueryParam param) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq(StringUtils.isNotBlank(param.getSheetNo()),TaskHis.SHEET_NO,param.getSheetNo()); - queryWrapper.between(Objects.nonNull(param.getStartTime()) && Objects.nonNull(param.getEndTime()), TaskHis.CREATE_TIME, param.getStartTime(), param.getEndTime()) - .eq(TaskHis.VALID, 1).orderByDesc(TaskHis.CREATE_TIME); + queryWrapper.eq(StringUtils.isNotBlank(param.getKilnId()),TaskHis.KILN_ID,param.getKilnId()); + queryWrapper.like(StringUtils.isNotBlank(param.getSheetNo()),TaskHis.SHEET_NO,param.getSheetNo()); + queryWrapper.like(StringUtils.isNotBlank(param.getStoveCode()),TaskHis.STOVE_CODE,param.getStoveCode()); + queryWrapper.between(Objects.nonNull(param.getStartTime()) && Objects.nonNull(param.getEndTime()), TaskHis.BEGIN_TIME, param.getStartTime(), param.getEndTime()) + .eq(TaskHis.VALID, 1).orderByDesc(TaskHis.BEGIN_TIME); Page page = taskHisService.page(new Page<>(param.getCurrent(), param.getSize()), queryWrapper); return successful(new PageVo<>(page, TaskHisQueryVo.class)); } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index 07b421a..0fc7a26 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -123,6 +123,8 @@ public class AsynRunTaskService extends BaseService { currTask.setUpdateTime(LocalDateTime.now()); currTask.setBeginTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); + //生成炉号 + createStoveCode(currTask); //程序休眠10秒.防止进炉后允许入炉信号还没消失,就又发了下一个入炉任务. Thread.sleep(10000); //更新小车状态 @@ -227,6 +229,8 @@ public class AsynRunTaskService extends BaseService { currTask.setUpdateTime(LocalDateTime.now()); currTask.setBeginTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); + //生成炉号 + createStoveCode(currTask); //更新小车状态 vehicle.setStatus(0); vehicleInfoServiceBiz.updateById(vehicle); @@ -1205,6 +1209,21 @@ public class AsynRunTaskService extends BaseService { return Integer.parseInt(String.valueOf(jsonObject.get("msg"))); } + + /** + * 生成炉号 + * 多步骤任务除了第一步为清洗炉外,每步都生成炉号 + * 单步骤任务都生成炉号 + */ + private void createStoveCode(CurrTask currTask){ + if (!(isFirstTask(currTask)&&currTask.getKilnId()==3)) { + String stoveCode = CodeGeneratorHelper.getStoveCode(currTask.getKilnName(), currTask.getPlcValue().toString()); + currTask.setStoveCode(stoveCode); + currTaskServiceBiz.updateById(currTask); + }else { + logger.info(currTask.getId()+"任务为多步骤任务且第一步为清洗,不生产清洗炉炉号."); + } + } /** * 上报apms创建生产单并开始处理 * diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/StoveCodeUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/StoveCodeUtils.java new file mode 100644 index 0000000..4423566 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/StoveCodeUtils.java @@ -0,0 +1,18 @@ +package com.mt.wms.empty.task; + +import com.mt.wms.core.utils.CodeGeneratorHelper; + +import java.text.DecimalFormat; + +/** + * @Author: LGH + * @Date: 2022/11/2 + */ +public class StoveCodeUtils { + public static String getStoveCode(String kilnName,Integer craft){ + DecimalFormat df=new DecimalFormat(); + df.applyPattern("00"); + String craftCode = df.format(craft); + return CodeGeneratorHelper.getStoveCode(kilnName, craftCode); + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskInfoVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskInfoVo.java index 7aeaa86..6aca240 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskInfoVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskInfoVo.java @@ -34,6 +34,11 @@ public class CurrTaskInfoVo extends BaseVo implements PageVo.ConvertVo{ */ @ApiModelProperty("生产单号") private String sheetNo; + /** + * 炉号 + */ + @ApiModelProperty("炉号") + private String stoveCode; /** * auto_Curr_Task_id */ diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskVo.java index 5dd7841..4b0a8a1 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/CurrTaskVo.java @@ -153,4 +153,10 @@ public class CurrTaskVo extends BaseVo implements PageVo.ConvertVo { */ @ApiModelProperty("auto_exe_task_id") private Long craftCodeId; + + /** + * 炉号 + */ + @ApiModelProperty("stove_code") + private String stoveCode; } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/TaskHisQueryVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/TaskHisQueryVo.java index 33dcd67..2e76c86 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/TaskHisQueryVo.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/TaskHisQueryVo.java @@ -30,6 +30,12 @@ public class TaskHisQueryVo extends BaseVo implements PageVo.ConvertVo { */ @ApiModelProperty("任务编码") private String taskCode; + + /** + * 炉号 + */ + @ApiModelProperty("炉号") + private String stoveCode; /** * 发起任务时间 */