diff --git a/nflg-mobilebroken-admin/src/test/java/DeployTest.java b/nflg-mobilebroken-admin/src/test/java/DeployTest.java index cf547e9b..f30644b3 100644 --- a/nflg-mobilebroken-admin/src/test/java/DeployTest.java +++ b/nflg-mobilebroken-admin/src/test/java/DeployTest.java @@ -40,9 +40,9 @@ public class DeployTest { private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception { printInfo("处理目录:" + dirName); - List files = getFileList(localPath + "lib"); + List files = getFileList(localPath + dirName); for (Path file : files) { - handleFile(sshUtil, file.toString(), remotePath + "lib/" + file.getFileName().toString()); + handleFile(sshUtil, file.toString(), remotePath +dirName+ "/" + file.getFileName().toString()); } printInfo("处理目录完成"); } diff --git a/nflg-mobilebroken-auth/src/test/java/DeployTest.java b/nflg-mobilebroken-auth/src/test/java/DeployTest.java index c6732f1b..5eb5c56a 100644 --- a/nflg-mobilebroken-auth/src/test/java/DeployTest.java +++ b/nflg-mobilebroken-auth/src/test/java/DeployTest.java @@ -41,9 +41,9 @@ public class DeployTest { private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception { printInfo("处理目录:" + dirName); - List files = getFileList(localPath + "lib"); + List files = getFileList(localPath + dirName); for (Path file : files) { - handleFile(sshUtil, file.toString(), remotePath + "lib/" + file.getFileName().toString()); + handleFile(sshUtil, file.toString(), remotePath + dirName + "/" + file.getFileName().toString()); } printInfo("处理目录完成"); } diff --git a/nflg-mobilebroken-cfs-app/src/test/java/DeployTest.java b/nflg-mobilebroken-cfs-app/src/test/java/DeployTest.java index ec9cb380..be81ee9c 100644 --- a/nflg-mobilebroken-cfs-app/src/test/java/DeployTest.java +++ b/nflg-mobilebroken-cfs-app/src/test/java/DeployTest.java @@ -40,9 +40,9 @@ public class DeployTest { private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception { printInfo("处理目录:" + dirName); - List files = getFileList(localPath + "lib"); + List files = getFileList(localPath + dirName); for (Path file : files) { - handleFile(sshUtil, file.toString(), remotePath + "lib/" + file.getFileName().toString()); + handleFile(sshUtil, file.toString(), remotePath + dirName+ "/" + file.getFileName().toString()); } printInfo("处理目录完成"); } diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java index 1e7491e9..072ec5ed 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/controller/DeviceController.java @@ -31,6 +31,7 @@ import com.nflg.mobilebroken.repository.service.*; import com.nflg.mobilebroken.starter.annotation.MethodInfoMark; import com.nflg.mobilebroken.starter.service.FileUploadService; import lombok.extern.slf4j.Slf4j; +import org.hibernate.validator.constraints.NotEmpty; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -43,8 +44,6 @@ import org.ttzero.excel.entity.Workbook; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import javax.validation.constraints.NotEmpty; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; @@ -172,7 +171,7 @@ public class DeviceController extends ControllerBase { @PostMapping("add") @MethodInfoMark(value = "新增", menuName = "设备管理") @ApiMark(moduleName = "设备管理", apiName = "新增") - public ApiResult add(@Valid @RequestBody DeviceDTO deviceDTO) { + public ApiResult add(@RequestBody DeviceDTO deviceDTO) { VUtils.trueThrow(deviceService.lambdaQuery() .eq(GongfuDevice::getDeviceNo, deviceDTO.getDeviceNo()) .eq(GongfuDevice::getDeviceState, deviceDTO.getDeviceState()) @@ -187,7 +186,7 @@ public class DeviceController extends ControllerBase { @PostMapping("update") @MethodInfoMark(value = "编辑", menuName = "设备管理") @ApiMark(moduleName = "设备管理", apiName = "编辑") - public ApiResult update(@Valid @RequestBody DeviceDTO deviceDTO) { + public ApiResult update(@RequestBody DeviceDTO deviceDTO) { VUtils.trueThrow(deviceDTO.getId() <= 0).throwMessage(STATE.ParamErr, "编辑时ID参数不能<=0"); adminDeviceService.update(deviceDTO); return ApiResult.success(true); @@ -498,7 +497,7 @@ public class DeviceController extends ControllerBase { */ @PostMapping("exportSelect") @ApiMark(moduleName = "设备管理", apiName = "导出选中的设备") - public void exportSelect(HttpServletResponse response, @Valid @RequestBody @NotEmpty List ids) throws Exception { + public void exportSelect(HttpServletResponse response, @RequestBody @NotEmpty List ids) throws Exception { List devices = deviceService.listByIds(ids); List states = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE); List datas = devices.stream().map(d -> { @@ -750,7 +749,7 @@ public class DeviceController extends ControllerBase { * @param request 请求参数 */ @PostMapping("getQRCode") - public ApiResult> getQRCode(@Valid @RequestBody IdPostRequest request) { + public ApiResult> getQRCode(@RequestBody IdPostRequest request) { List devices = deviceService.listByIds(request.getIds()); List vos = new ArrayList<>(); devices.forEach(device -> { @@ -772,7 +771,7 @@ public class DeviceController extends ControllerBase { * @param request 请求参数 */ @PostMapping("exportImages") - public ResponseEntity exportImages(@Valid @RequestBody IdPostRequest request) { + public ResponseEntity exportImages(@RequestBody IdPostRequest request) { List devices = deviceService.listByIds(request.getIds()); if (CollUtil.isNotEmpty(devices)) { try { @@ -825,29 +824,35 @@ public class DeviceController extends ControllerBase { @Transactional @PostMapping("changeServiceAgentCode") public ApiResult changeServiceAgentCode(@RequestBody ChangeServiceAgentCodeQuery query) { - GongfuDevice device=deviceService.getById(query.getDeviceId()); - VUtils.trueThrowBusinessError(Objects.isNull(device)).throwMessage("设备不存在"); - VUtils.trueThrowBusinessError(StrUtil.equals(device.getServiceAgentCode(), query.getServiceAgentCode())) - .throwMessage("代理商未修改"); + List devices = deviceService.lambdaQuery() + .in(GongfuDevice::getId, query.getDeviceIds()) + .list(); + if (CollectionUtil.isEmpty(devices)){ + return ApiResult.error("没有需要修改的设备"); + } TBaseCustomer customer = customerService.lambdaQuery() .eq(TBaseCustomer::getDelIs, 0) .eq(TBaseCustomer::getEnableState, 1) .eq(TBaseCustomer::getAgencyCompanyCode, query.getServiceAgentCode()) .one(); VUtils.trueThrowBusinessError(Objects.isNull(customer)).throwMessage("代理商公司不存在"); - deviceService.lambdaUpdate() - .set(GongfuDevice::getServiceAgentCode, query.getServiceAgentCode()) - .set(GongfuDevice::getServiceAgentName, customer.getAgencyCompanyName()) - .eq(GongfuDevice::getId, query.getDeviceId()) - .update(); - gongfuDeviceAgentRecordService.save(new GongfuDeviceAgentRecord() - .setDeviceId(query.getDeviceId()) - .setAgentCode(query.getServiceAgentCode()) - .setAgentName(customer.getAgencyCompanyName()) - .setCreateById(AdminUserUtil.getUserId()) - .setCreateBy(AdminUserUtil.getUserName()) - .setCreateTime(LocalDateTime.now()) - ); + devices.forEach(device -> { + if (!StrUtil.equals(device.getServiceAgentCode(), query.getServiceAgentCode())){ + deviceService.lambdaUpdate() + .set(GongfuDevice::getServiceAgentCode, query.getServiceAgentCode()) + .set(GongfuDevice::getServiceAgentName, customer.getAgencyCompanyName()) + .eq(GongfuDevice::getId, device.getId()) + .update(); + gongfuDeviceAgentRecordService.save(new GongfuDeviceAgentRecord() + .setDeviceId(device.getId()) + .setAgentCode(query.getServiceAgentCode()) + .setAgentName(customer.getAgencyCompanyName()) + .setCreateById(AdminUserUtil.getUserId()) + .setCreateBy(AdminUserUtil.getUserName()) + .setCreateTime(LocalDateTime.now()) + ); + } + }); return ApiResult.success(); } diff --git a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/ChangeServiceAgentCodeQuery.java b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/ChangeServiceAgentCodeQuery.java index 254e24eb..8ce58c6d 100644 --- a/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/ChangeServiceAgentCodeQuery.java +++ b/nflg-mobilebroken-gongfu/src/main/java/com/nflg/mobilebroken/gongfu/pojo/query/ChangeServiceAgentCodeQuery.java @@ -4,6 +4,7 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import java.util.List; @Data public class ChangeServiceAgentCodeQuery { @@ -12,7 +13,7 @@ public class ChangeServiceAgentCodeQuery { * 设备ID */ @NotNull - private Long deviceId; + private List deviceIds; /** * 服务代理商编码 diff --git a/nflg-mobilebroken-gongfu/src/test/java/DeployTest.java b/nflg-mobilebroken-gongfu/src/test/java/DeployTest.java index 072bb26c..6eda7faf 100644 --- a/nflg-mobilebroken-gongfu/src/test/java/DeployTest.java +++ b/nflg-mobilebroken-gongfu/src/test/java/DeployTest.java @@ -40,9 +40,9 @@ public class DeployTest { private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception { printInfo("处理目录:" + dirName); - List files = getFileList(localPath + "lib"); + List files = getFileList(localPath + dirName); for (Path file : files) { - handleFile(sshUtil, file.toString(), remotePath + "lib/" + file.getFileName().toString()); + handleFile(sshUtil, file.toString(), remotePath + dirName + "/" + file.getFileName().toString()); } printInfo("处理目录完成"); } diff --git a/nflg-mobilebroken-product/src/test/java/DeployTest.java b/nflg-mobilebroken-product/src/test/java/DeployTest.java index 7496b555..e5aecf24 100644 --- a/nflg-mobilebroken-product/src/test/java/DeployTest.java +++ b/nflg-mobilebroken-product/src/test/java/DeployTest.java @@ -40,9 +40,9 @@ public class DeployTest { private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception { printInfo("处理目录:" + dirName); - List files = getFileList(localPath + "lib"); + List files = getFileList(localPath + dirName); for (Path file : files) { - handleFile(sshUtil, file.toString(), remotePath + "lib/" + file.getFileName().toString()); + handleFile(sshUtil, file.toString(), remotePath + dirName + "/" + file.getFileName().toString()); } printInfo("处理目录完成"); } diff --git a/nflg-mobilebroken-push/src/test/java/DeployTest.java b/nflg-mobilebroken-push/src/test/java/DeployTest.java index 0aa020dc..36e1f8e2 100644 --- a/nflg-mobilebroken-push/src/test/java/DeployTest.java +++ b/nflg-mobilebroken-push/src/test/java/DeployTest.java @@ -41,9 +41,9 @@ public class DeployTest { private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception { printInfo("处理目录:" + dirName); - List files = getFileList(localPath + "lib"); + List files = getFileList(localPath + dirName); for (Path file : files) { - handleFile(sshUtil, file.toString(), remotePath + "lib/" + file.getFileName().toString()); + handleFile(sshUtil, file.toString(), remotePath + dirName + "/" + file.getFileName().toString()); } printInfo("处理目录完成"); }