From 7d64716cb0d406f21cde03976fd273bd07fdc06f Mon Sep 17 00:00:00 2001 From: whycxzp <perryhsu@163.com> Date: 星期二, 28 九月 2021 11:44:28 +0800 Subject: [PATCH] 更新用户-角色-菜单-权限 --- src/main/java/com/whyc/controller/TestConfigController.java | 79 +++++++++++++++++++++++++++++++-------- 1 files changed, 62 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/whyc/controller/TestConfigController.java b/src/main/java/com/whyc/controller/TestConfigController.java index 9227e34..72e3cab 100644 --- a/src/main/java/com/whyc/controller/TestConfigController.java +++ b/src/main/java/com/whyc/controller/TestConfigController.java @@ -5,16 +5,20 @@ import com.whyc.dto.Response; import com.whyc.pojo.DeviceInf; import com.whyc.pojo.DeviceType; +import com.whyc.pojo.TestPlan; import com.whyc.service.DeviceInfService; import com.whyc.service.DeviceTypeService; +import com.whyc.service.TestPlanService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; @RestController @RequestMapping("testConfig") @@ -22,24 +26,65 @@ @Api(tags = "璇曢獙閰嶇疆") public class TestConfigController { @Autowired + @Qualifier("deviceInfService") private DeviceInfService deviceInfService; - @Autowired + @Resource(name = "deviceTypeService") private DeviceTypeService deviceTypeService; + @Resource(name = "testPlanService") + private TestPlanService testPlanService; - @PutMapping - @ApiOperation("鍔犺浇榛樿閰嶇疆鍙傛暟") - public Response setDefautlTestConfig(@RequestParam Integer deviceId){ + @PutMapping("updateConfig") + @ApiOperation("鏇存柊閰嶇疆鍙傛暟") + public Response setDefautlTestConfig(@RequestBody List<DeviceInf> deviceInfList){ + for (DeviceInf deviceInf: deviceInfList) { + deviceInfService.update(deviceInf); + } + return new Response().setMsg(1,"鏇存柊鎴愬姛"); + + } + + @GetMapping("defaultConfig") + @ApiOperation("榛樿鍙傛暟閰嶇疆") + public Response getDefaultTestConfig(@RequestParam Integer num){ + TestPlan testPlan = testPlanService.getOneById(num); + String devices = testPlan.getDevices(); + String[] deviceIds = devices.split(","); + List<DeviceInf> deviceInfList = new ArrayList<>(); + for (String deviceId : deviceIds) { + DeviceInf deviceInf = getDefaultConfig(Integer.valueOf(deviceId)); + deviceInfList.add(deviceInf); + } + return new Response().set(1,deviceInfList); + } + //璁惧id鑾峰彇璁惧绫诲瀷id锛屽鏋滆澶囨湁鍙傛暟鏄剧ず鏈韩鍙傛暟锛屽鏋滄病鏈夊皢璁惧绫诲瀷鐨勯粯璁ゅ弬鏁板鍒跺埌璁惧绫昏繑鍥� + public DeviceInf getDefaultConfig(Integer deviceId){ DeviceInf deviceInf = deviceInfService.getOneByDeviceId(deviceId); DeviceType deviceType = deviceTypeService.getOneByDeviceTypeId(deviceInf.getSystemId()); - deviceInf.setLoadStartType(deviceType.getLoadStartType()); - deviceInf.setLoadRuntimeHour(deviceType.getLoadRuntimeHour()); - deviceInf.setLoadRuntimeMin(deviceType.getLoadRuntimeMin()); - deviceInf.setLoadCurrStd(deviceType.getLoadCurrStd()); - deviceInf.setLoadVolStd(deviceType.getLoadVolStd()); - deviceInf.setLoadRpm(deviceType.getLoadRpm()); - deviceInf.setLoadTorque(deviceType.getLoadTorque()); - deviceInf.setLoadPropulsionShaft(deviceType.getLoadPropulsionShaft()); - return deviceInfService.update(deviceInf); + if (deviceInf.getLoadStartType() == null) { + deviceInf.setLoadStartType(deviceType.getLoadStartType()); + } + if (deviceInf.getLoadRuntimeHour() == null) { + deviceInf.setLoadRuntimeHour(deviceType.getLoadRuntimeHour()); + } + if (deviceInf.getLoadRuntimeMin() == null) { + deviceInf.setLoadRuntimeMin(deviceType.getLoadRuntimeMin()); + } + if (deviceInf.getLoadCurrStd() == null) { + deviceInf.setLoadCurrStd(deviceType.getLoadCurrStd()); + } + if (deviceInf.getLoadVolStd() == null) { + deviceInf.setLoadVolStd(deviceType.getLoadVolStd()); + } + if (deviceInf.getLoadRpm() == null) { + deviceInf.setLoadRpm(deviceType.getLoadRpm()); + } + if (deviceInf.getLoadTorque() == null) { + deviceInf.setLoadTorque(deviceType.getLoadTorque()); + } + if (deviceInf.getLoadPropulsionShaft() == null) { + deviceInf.setLoadPropulsionShaft(deviceType.getLoadPropulsionShaft()); + } + return deviceInf; } -- Gitblit v1.9.1