|
@@ -2,10 +2,28 @@ package com.qmth.sop.server.api;
|
|
|
|
|
|
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.sop.business.bean.params.TBDeviceDeliveryParam;
|
|
|
+import com.qmth.sop.business.entity.SysUser;
|
|
|
+import com.qmth.sop.business.entity.TBDeviceDelivery;
|
|
|
+import com.qmth.sop.business.service.TBDeviceDeliveryService;
|
|
|
+import com.qmth.sop.common.annotation.OperationLog;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.qmth.sop.common.enums.DeviceDeliveryStatusEnum;
|
|
|
+import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.sop.common.enums.LogTypeEnum;
|
|
|
+import com.qmth.sop.common.util.Result;
|
|
|
+import com.qmth.sop.common.util.ResultUtil;
|
|
|
+import com.qmth.sop.common.util.ServletUtil;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.validation.BindingResult;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -15,9 +33,56 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
* @author wangliang
|
|
|
* @since 2023-11-28
|
|
|
*/
|
|
|
-@Api(tags = "设备配置表 Controller")
|
|
|
+@Api(tags = "设备发货表Controller")
|
|
|
@RestController
|
|
|
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX+ SystemConstant.PREFIX_URL_DEVICE_DELIVERY)
|
|
|
+@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_DEVICE_DELIVERY)
|
|
|
public class TBDeviceDeliveryController {
|
|
|
|
|
|
+ @Resource
|
|
|
+ TBDeviceDeliveryService tbDeviceDeliveryService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "设备发货修改接口")
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
+ @OperationLog(logType = LogTypeEnum.EDIT)
|
|
|
+ public Result save(@Valid @ApiParam(value = "设备发货修改信息", required = true) @RequestBody TBDeviceDelivery tbDeviceDelivery, BindingResult bindingResult) throws Exception {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
+ }
|
|
|
+ return ResultUtil.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "设备发货状态修改接口")
|
|
|
+ @RequestMapping(value = "/status/update", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
+ @OperationLog(logType = LogTypeEnum.UPDATE)
|
|
|
+ @Transactional
|
|
|
+ public Result statusUpdate(@ApiParam(value = "设备发货表id", required = true) @RequestParam Long id,
|
|
|
+ @ApiParam(value = "设备发货状态", required = true) @RequestParam DeviceDeliveryStatusEnum status) {
|
|
|
+ TBDeviceDelivery tbDeviceDelivery = tbDeviceDeliveryService.getById(id);
|
|
|
+ Optional.ofNullable(tbDeviceDelivery).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到设备发货信息"));
|
|
|
+ tbDeviceDelivery.setStatus(status);
|
|
|
+ return ResultUtil.ok(tbDeviceDeliveryService.updateById(tbDeviceDelivery));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "设备发货状态批量修改接口")
|
|
|
+ @RequestMapping(value = "/status/batch/update", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
|
|
|
+ @OperationLog(logType = LogTypeEnum.UPDATE)
|
|
|
+ @Transactional
|
|
|
+ public Result statusBatchUpdate(@Valid @ApiParam(value = "设备发货修改信息", required = true) @RequestBody TBDeviceDeliveryParam tbDeviceDeliveryParam, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
+ }
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ List<TBDeviceDelivery> tbDeviceDeliveryList = tbDeviceDeliveryService.listByIds(tbDeviceDeliveryParam.getIds());
|
|
|
+ if (!CollectionUtils.isEmpty(tbDeviceDeliveryList)) {
|
|
|
+ for (TBDeviceDelivery t : tbDeviceDeliveryList) {
|
|
|
+ t.setStatus(tbDeviceDeliveryParam.getStatus());
|
|
|
+ t.updateInfo(sysUser.getId());
|
|
|
+ }
|
|
|
+ tbDeviceDeliveryService.saveOrUpdateBatch(tbDeviceDeliveryList);
|
|
|
+ }
|
|
|
+ return ResultUtil.ok();
|
|
|
+ }
|
|
|
}
|