feat(gongfu): 修改设备批量操作功能
- 将ChangeServiceAgentCodeQuery中的deviceId字段改为deviceIds列表 - 移除Controller中的@Valid注解并优化参数验证逻辑 - 实现设备批量修改代理商编码功能,支持多个设备同时处理 - 修复部署脚本中的文件路径处理逻辑 - 添加空值检查和业务逻辑优化
This commit is contained in:
parent
24dcb9df96
commit
8ba7ca24b1
|
|
@ -40,9 +40,9 @@ public class DeployTest {
|
|||
|
||||
private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception {
|
||||
printInfo("处理目录:" + dirName);
|
||||
List<Path> files = getFileList(localPath + "lib");
|
||||
List<Path> 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("处理目录完成");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ public class DeployTest {
|
|||
|
||||
private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception {
|
||||
printInfo("处理目录:" + dirName);
|
||||
List<Path> files = getFileList(localPath + "lib");
|
||||
List<Path> 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("处理目录完成");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ public class DeployTest {
|
|||
|
||||
private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception {
|
||||
printInfo("处理目录:" + dirName);
|
||||
List<Path> files = getFileList(localPath + "lib");
|
||||
List<Path> 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("处理目录完成");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Boolean> add(@Valid @RequestBody DeviceDTO deviceDTO) {
|
||||
public ApiResult<Boolean> 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<Boolean> update(@Valid @RequestBody DeviceDTO deviceDTO) {
|
||||
public ApiResult<Boolean> 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<Long> ids) throws Exception {
|
||||
public void exportSelect(HttpServletResponse response, @RequestBody @NotEmpty List<Long> ids) throws Exception {
|
||||
List<GongfuDevice> devices = deviceService.listByIds(ids);
|
||||
List<DictionaryItem> states = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_DEVICE_STATE);
|
||||
List<DeviceUpdateImportDTO> datas = devices.stream().map(d -> {
|
||||
|
|
@ -750,7 +749,7 @@ public class DeviceController extends ControllerBase {
|
|||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("getQRCode")
|
||||
public ApiResult<List<DeviceQRCodeVO>> getQRCode(@Valid @RequestBody IdPostRequest request) {
|
||||
public ApiResult<List<DeviceQRCodeVO>> getQRCode(@RequestBody IdPostRequest request) {
|
||||
List<GongfuDevice> devices = deviceService.listByIds(request.getIds());
|
||||
List<DeviceQRCodeVO> vos = new ArrayList<>();
|
||||
devices.forEach(device -> {
|
||||
|
|
@ -772,7 +771,7 @@ public class DeviceController extends ControllerBase {
|
|||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("exportImages")
|
||||
public ResponseEntity<byte[]> exportImages(@Valid @RequestBody IdPostRequest request) {
|
||||
public ResponseEntity<byte[]> exportImages(@RequestBody IdPostRequest request) {
|
||||
List<GongfuDevice> devices = deviceService.listByIds(request.getIds());
|
||||
if (CollUtil.isNotEmpty(devices)) {
|
||||
try {
|
||||
|
|
@ -825,29 +824,35 @@ public class DeviceController extends ControllerBase {
|
|||
@Transactional
|
||||
@PostMapping("changeServiceAgentCode")
|
||||
public ApiResult<Void> 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<GongfuDevice> 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("代理商公司不存在");
|
||||
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, query.getDeviceId())
|
||||
.eq(GongfuDevice::getId, device.getId())
|
||||
.update();
|
||||
gongfuDeviceAgentRecordService.save(new GongfuDeviceAgentRecord()
|
||||
.setDeviceId(query.getDeviceId())
|
||||
.setDeviceId(device.getId())
|
||||
.setAgentCode(query.getServiceAgentCode())
|
||||
.setAgentName(customer.getAgencyCompanyName())
|
||||
.setCreateById(AdminUserUtil.getUserId())
|
||||
.setCreateBy(AdminUserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
);
|
||||
}
|
||||
});
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Long> deviceIds;
|
||||
|
||||
/**
|
||||
* 服务代理商编码
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ public class DeployTest {
|
|||
|
||||
private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception {
|
||||
printInfo("处理目录:" + dirName);
|
||||
List<Path> files = getFileList(localPath + "lib");
|
||||
List<Path> 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("处理目录完成");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ public class DeployTest {
|
|||
|
||||
private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception {
|
||||
printInfo("处理目录:" + dirName);
|
||||
List<Path> files = getFileList(localPath + "lib");
|
||||
List<Path> 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("处理目录完成");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ public class DeployTest {
|
|||
|
||||
private void handleDir(SSHUtil sshUtil, String localPath, String remotePath, String dirName) throws Exception {
|
||||
printInfo("处理目录:" + dirName);
|
||||
List<Path> files = getFileList(localPath + "lib");
|
||||
List<Path> 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("处理目录完成");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue