diff --git a/beneficiation/src/main/java/com/ccsens/beneficiation/api/ParameterController.java b/beneficiation/src/main/java/com/ccsens/beneficiation/api/ParameterController.java new file mode 100644 index 00000000..163654aa --- /dev/null +++ b/beneficiation/src/main/java/com/ccsens/beneficiation/api/ParameterController.java @@ -0,0 +1,53 @@ +package com.ccsens.beneficiation.api; + +import com.ccsens.beneficiation.bean.dto.ParameterDto; +import com.ccsens.beneficiation.bean.dto.WeightDto; +import com.ccsens.beneficiation.bean.vo.ParameterVo; +import com.ccsens.beneficiation.bean.vo.WeightVo; +import com.ccsens.beneficiation.service.IParameterService; +import com.ccsens.cloudutil.annotation.MustLogin; +import com.ccsens.util.JsonResponse; +import com.ccsens.util.bean.dto.QueryDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author 逗 + */ +@Slf4j +@Api(tags = "皮带秤每天上传的重量统计相关" , description = "") +@RestController +@RequestMapping("/parameter") +public class ParameterController { + @Resource + private IParameterService parameterService; + + @MustLogin + @ApiOperation(value = "查看各个设备的参数", notes = "") + @RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse queryParameter(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("查看各个设备的参数:{}",params); + ParameterVo.ParameterInfo parameterInfo = parameterService.queryParameter(params.getParam()); + log.info("各个设备的参数:{}",parameterInfo); + return JsonResponse.newInstance().ok(parameterInfo); + } + + @MustLogin + @ApiOperation(value = "修改设备的参数", notes = "") + @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) + public JsonResponse updateParameter(@ApiParam @Validated @RequestBody QueryDto params) { + log.info("修改设备的参数:{}",params); + parameterService.updateParameter(params.getParam()); + log.info("修改设备的参数成功"); + return JsonResponse.newInstance().ok(); + } +} diff --git a/beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/ParameterDto.java b/beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/ParameterDto.java new file mode 100644 index 00000000..08bf6857 --- /dev/null +++ b/beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/ParameterDto.java @@ -0,0 +1,69 @@ +package com.ccsens.beneficiation.bean.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; + +/** + * @author 逗 + */ +@Data +public class ParameterDto { + @Data + @ApiModel("修改仪器的参数") + public static class ParameterInfo{ + @ApiModelProperty("电耳1") + private ParameterThreshold electricEar1; + @ApiModelProperty("电耳2") + private ParameterThreshold electricEar2; + @ApiModelProperty("电磁阀1") + private Parameter solenoidValue1; + @ApiModelProperty("电磁阀2") + private Parameter solenoidValue2; + @ApiModelProperty("变频器1") + private Parameter transducer1; + @ApiModelProperty("变频器2") + private Parameter transducer2; + @ApiModelProperty("变频器3") + private Parameter transducer3; + @ApiModelProperty("变频器4") + private Parameter transducer4; + } + + @Data + @ApiModel("单个仪器的参数") + public static class Parameter{ + @NotNull + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("设置值") + private BigDecimal settingValue; + } + + @Data + @ApiModel("电耳的阀值") + public static class ParameterThreshold{ + @NotNull + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("阀值1") + private Threshold thresholdValue1; + @ApiModelProperty("阀值2") + private Threshold thresholdValue2; + @ApiModelProperty("阀值3") + private Threshold thresholdValue3; + + } + @Data + @ApiModel("阀值的最大最小值") + public static class Threshold{ + @ApiModelProperty("最小") + private BigDecimal minValue; + @ApiModelProperty("最打") + private BigDecimal maxValue; + } + +} diff --git a/beneficiation/src/main/java/com/ccsens/beneficiation/bean/vo/ParameterVo.java b/beneficiation/src/main/java/com/ccsens/beneficiation/bean/vo/ParameterVo.java new file mode 100644 index 00000000..db76720f --- /dev/null +++ b/beneficiation/src/main/java/com/ccsens/beneficiation/bean/vo/ParameterVo.java @@ -0,0 +1,109 @@ +package com.ccsens.beneficiation.bean.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * @author 逗 + */ +@Data +public class ParameterVo { + @Data + @ApiModel("查看每个仪器的参数") + public static class ParameterInfo{ + @ApiModelProperty("皮带秤") + private Parameter beltWeigher; + @ApiModelProperty("电耳1") + private ParameterThreshold electricEar1; + @ApiModelProperty("电耳2") + private ParameterThreshold electricEar2; + @ApiModelProperty("电磁阀1") + private Parameter solenoidValue1; + @ApiModelProperty("电磁阀2") + private Parameter solenoidValue2; + @ApiModelProperty("流量计1") + private Parameter flowmeter1; + @ApiModelProperty("流量计1") + private Parameter flowmeter2; + @ApiModelProperty("变频器1") + private Parameter transducer1; + @ApiModelProperty("变频器2") + private Parameter transducer2; + @ApiModelProperty("变频器3") + private Parameter transducer3; + @ApiModelProperty("变频器4") + private Parameter transducer4; + } + + @Data + @ApiModel("单个仪器的参数") + public static class Parameter{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("名字") + private String name; + @ApiModelProperty("实时值") + private BigDecimal currentTimeValue; + @ApiModelProperty("累计值") + private BigDecimal totalValue; + + public Parameter(Long id, String name, BigDecimal currentTimeValue, BigDecimal totalValue) { + this.id = id; + this.name = name; + this.currentTimeValue = currentTimeValue; + this.totalValue = totalValue; + } + + public Parameter() { + } + } + + @Data + @ApiModel("单个仪器的参数带阀值") + public static class ParameterThreshold{ + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("名字") + private String name; + @ApiModelProperty("实时值") + private BigDecimal currentTimeValue; + @ApiModelProperty("阀值1") + private Threshold thresholdValue1; + @ApiModelProperty("阀值2") + private Threshold thresholdValue2; + @ApiModelProperty("阀值3") + private Threshold thresholdValue3; + + public ParameterThreshold(Long id, String name, BigDecimal currentTimeValue, Threshold thresholdValue1, Threshold thresholdValue2, Threshold thresholdValue3) { + this.id = id; + this.name = name; + this.currentTimeValue = currentTimeValue; + this.thresholdValue1 = thresholdValue1; + this.thresholdValue2 = thresholdValue2; + this.thresholdValue3 = thresholdValue3; + } + + public ParameterThreshold() { + } + } + @Data + @ApiModel("阀值") + public static class Threshold{ + @ApiModelProperty("最小") + private BigDecimal minValue; + @ApiModelProperty("最打") + private BigDecimal maxValue; + + public Threshold(BigDecimal minValue, BigDecimal maxValue) { + this.minValue = minValue; + this.maxValue = maxValue; + } + + public Threshold() { + } + } + +} diff --git a/beneficiation/src/main/java/com/ccsens/beneficiation/service/IParameterService.java b/beneficiation/src/main/java/com/ccsens/beneficiation/service/IParameterService.java new file mode 100644 index 00000000..de8ba1c8 --- /dev/null +++ b/beneficiation/src/main/java/com/ccsens/beneficiation/service/IParameterService.java @@ -0,0 +1,22 @@ +package com.ccsens.beneficiation.service; + +import com.ccsens.beneficiation.bean.dto.ParameterDto; +import com.ccsens.beneficiation.bean.vo.ParameterVo; + +/** + * @author 逗 + */ +public interface IParameterService { + /** + * 查询每个设备的参数 + * @param param 没有参数 + * @return 返回每个设备的数据 + */ + ParameterVo.ParameterInfo queryParameter(Object param); + + /** + * 修改一起的参数 + * @param param 参数 + */ + void updateParameter(ParameterDto.ParameterInfo param); +} diff --git a/beneficiation/src/main/java/com/ccsens/beneficiation/service/ParameterService.java b/beneficiation/src/main/java/com/ccsens/beneficiation/service/ParameterService.java new file mode 100644 index 00000000..998660ef --- /dev/null +++ b/beneficiation/src/main/java/com/ccsens/beneficiation/service/ParameterService.java @@ -0,0 +1,50 @@ +package com.ccsens.beneficiation.service; + +import com.ccsens.beneficiation.bean.dto.ParameterDto; +import com.ccsens.beneficiation.bean.vo.ParameterVo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; + +/** + * @author 逗 + */ +@Slf4j +@Service +@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +public class ParameterService implements IParameterService{ + + @Override + public ParameterVo.ParameterInfo queryParameter(Object param) { + ParameterVo.ParameterInfo parameterInfo = new ParameterVo.ParameterInfo(); + parameterInfo.setBeltWeigher(new ParameterVo.Parameter(1L,"皮带秤", BigDecimal.valueOf(12),BigDecimal.valueOf(1212))); + parameterInfo.setFlowmeter1(new ParameterVo.Parameter(2L,"流量计1", BigDecimal.valueOf(16),BigDecimal.valueOf(1524))); + parameterInfo.setFlowmeter2(new ParameterVo.Parameter(3L,"流量计2", BigDecimal.valueOf(5),BigDecimal.valueOf(232))); + parameterInfo.setSolenoidValue1(new ParameterVo.Parameter(4L,"电磁阀1", BigDecimal.valueOf(84),null)); + parameterInfo.setSolenoidValue2(new ParameterVo.Parameter(5L,"电磁阀2", BigDecimal.valueOf(95),null)); + parameterInfo.setTransducer1(new ParameterVo.Parameter(6L,"变频器1", BigDecimal.valueOf(45),null)); + parameterInfo.setTransducer2(new ParameterVo.Parameter(7L,"变频器2", BigDecimal.valueOf(8),null)); + parameterInfo.setTransducer3(new ParameterVo.Parameter(8L,"变频器3", BigDecimal.valueOf(67),null)); + parameterInfo.setTransducer4(new ParameterVo.Parameter(10L,"变频器4", BigDecimal.valueOf(75),null)); + + parameterInfo.setElectricEar1(new ParameterVo.ParameterThreshold(11L,"电耳1",BigDecimal.valueOf(60), + new ParameterVo.Threshold(BigDecimal.valueOf(20),BigDecimal.valueOf(60)), + new ParameterVo.Threshold(BigDecimal.valueOf(30),BigDecimal.valueOf(70)), + new ParameterVo.Threshold(BigDecimal.valueOf(40),BigDecimal.valueOf(80)))); + + parameterInfo.setElectricEar1(new ParameterVo.ParameterThreshold(12L,"电耳2",BigDecimal.valueOf(65), + new ParameterVo.Threshold(BigDecimal.valueOf(30),BigDecimal.valueOf(70)), + new ParameterVo.Threshold(BigDecimal.valueOf(40),BigDecimal.valueOf(80)), + new ParameterVo.Threshold(BigDecimal.valueOf(50),BigDecimal.valueOf(90)))); + + return parameterInfo; + } + + @Override + public void updateParameter(ParameterDto.ParameterInfo param) { + + } +} diff --git a/beneficiation/src/main/resources/application.yml b/beneficiation/src/main/resources/application.yml index 1ac895fc..ac92adb9 100644 --- a/beneficiation/src/main/resources/application.yml +++ b/beneficiation/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: prod - include: common, util-prod + active: test + include: common, util-test diff --git a/tall/src/main/java/com/ccsens/tall/service/ITaskPluginService.java b/tall/src/main/java/com/ccsens/tall/service/ITaskPluginService.java index c1f0c71b..061496f2 100644 --- a/tall/src/main/java/com/ccsens/tall/service/ITaskPluginService.java +++ b/tall/src/main/java/com/ccsens/tall/service/ITaskPluginService.java @@ -6,6 +6,7 @@ import com.ccsens.tall.bean.vo.PluginVo; import com.ccsens.tall.bean.vo.TaskVo; import java.io.FileNotFoundException; +import java.io.IOException; import java.util.List; /** @@ -93,5 +94,5 @@ public interface ITaskPluginService { * @param currentUserId userId * @return 返回excel路径 */ - String openExcel(Long taskId, String token, Long currentUserId); + PluginVo.MinutesInfo openExcel(Long taskId, String token, Long currentUserId) throws IOException, Exception; } diff --git a/tall/src/main/java/com/ccsens/tall/service/TaskPluginService.java b/tall/src/main/java/com/ccsens/tall/service/TaskPluginService.java index eb3d2a2d..bef931ae 100644 --- a/tall/src/main/java/com/ccsens/tall/service/TaskPluginService.java +++ b/tall/src/main/java/com/ccsens/tall/service/TaskPluginService.java @@ -985,13 +985,41 @@ public class TaskPluginService implements ITaskPluginService{ } @Override - public String openExcel(Long taskId, String token, Long currentUserId) { + public PluginVo.MinutesInfo openExcel(Long taskId, String token, Long currentUserId) throws Exception { //查询此任务是否有关联的excel,有直接返回 - + List minutesInfoList = new ArrayList<>(); + List wpsPath = wpsService.queryVisitUrls(taskId,(byte) 11,token,null); + if(CollectionUtil.isNotEmpty(wpsPath)){ + minutesInfo(taskId, minutesInfoList, wpsPath); + return minutesInfoList.get(0); + } //没有则新建一个空白excel + Workbook wb = new XSSFWorkbook(); + //生成文件 + String name = System.currentTimeMillis() + ".xlsx"; + String fileName = "excel/" + DateUtil.today() + "/" + System.currentTimeMillis() + ".xlsx"; + File tmpFile = saveFile(wb, fileName); //关联wps - //查询wps路径并返回 - - return null; + WpsDto.Business business = new WpsDto.Business(); + business.setBusinessId(taskId); + business.setBusinessType((byte) 11); + business.setUserId(currentUserId); + business.setFileName(name); + business.setFilePath(fileName); + business.setRealFilePath(PropUtil.path + File.separator + fileName); + business.setFileSize(tmpFile.length()); + business.setOperation(WebConstant.Wps.USER_OPERATION_NEW); + business.setPrivilege(WebConstant.Wps.PROJECT_PRIVILEGE_WRITE); + business.setPrivilegeQueryUrl(PropUtil.domain + "v1/3rd/wpsPower"); + wpsService.saveFile(business); + //获取wps文件的路径并返回 + wpsPath = wpsService.queryVisitUrls(taskId,(byte) 11,token,null); + if(CollectionUtil.isNotEmpty(wpsPath)){ + minutesInfo(taskId, minutesInfoList, wpsPath); + } + if(CollectionUtil.isEmpty(minutesInfoList)) { + return null; + } + return minutesInfoList.get(0); } } diff --git a/tall/src/main/java/com/ccsens/tall/web/PluginController.java b/tall/src/main/java/com/ccsens/tall/web/PluginController.java index 9759c2e9..51c54e2f 100644 --- a/tall/src/main/java/com/ccsens/tall/web/PluginController.java +++ b/tall/src/main/java/com/ccsens/tall/web/PluginController.java @@ -229,12 +229,12 @@ public class PluginController { @ApiImplicitParams({ }) @RequestMapping(value = "/openExcel", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) - public JsonResponse openExcel(HttpServletRequest request,@RequestParam(required = true) Long taskId) throws Exception { + public JsonResponse openExcel(HttpServletRequest request,@RequestParam(required = true) Long taskId) throws Exception { log.info("打开excel:{}",taskId); Long currentUserId = Long.valueOf(((Claims) request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS)).getSubject()); String authHeader = request.getHeader(WebConstant.HEADER_KEY_TOKEN); String token = authHeader.substring(WebConstant.HEADER_KEY_TOKEN_PREFIX.length()); - String path = taskPluginService.openExcel(taskId,token,currentUserId); + PluginVo.MinutesInfo path = taskPluginService.openExcel(taskId,token,currentUserId); log.info("excel的路径:{}",path); return JsonResponse.newInstance().ok(path); } diff --git a/tall/src/main/resources/application.yml b/tall/src/main/resources/application.yml index ebc544af..b5408a3a 100644 --- a/tall/src/main/resources/application.yml +++ b/tall/src/main/resources/application.yml @@ -1,5 +1,5 @@ spring: profiles: - active: test - include: util-test,common + active: dev + include: util-dev,common diff --git a/tcm/src/main/resources/application.yml b/tcm/src/main/resources/application.yml index f59084b0..4ecd13fd 100644 --- a/tcm/src/main/resources/application.yml +++ b/tcm/src/main/resources/application.yml @@ -1,5 +1,5 @@ spring: profiles: - active: test - include: common, util-test + active: dev + include: common, util-dev