贩卖机测试,测试日志
This commit is contained in:
1 parent
88cbffa5bc
commit
247d38b34b
13 files changed
+522
-18
No files matched your search
+4
@@ -69,5 +69,9 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CHANNEL_NOT_EXISTS = new ErrorCode(1_008_012_000, "货道不存在");
|
||||
ErrorCode CHANNEL_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_008_012_001, "导入货道数据不能为空!");
|
||||
ErrorCode CHANNEL_EXISTS = new ErrorCode(1_008_013_001, "货道已经存在");
|
||||
ErrorCode CHANNEL_ERROR = new ErrorCode(1_008_014_001, "请求出货响应为空");
|
||||
|
||||
// ========== 贩卖机测试日志 1-008-013-000 ==========
|
||||
ErrorCode DEVICE_LOG_NOT_EXISTS = new ErrorCode(1_008_013_000, "贩卖机测试日志不存在");
|
||||
|
||||
}
|
||||
+6
@@ -106,4 +106,10 @@ public class ChannelController {
|
||||
return success(channelService.importChannelList(list, updateSupport));
|
||||
}
|
||||
|
||||
@PostMapping("/channel-test")
|
||||
@Operation(summary = "测试货道")
|
||||
@PreAuthorize("@ss.hasPermission('product:channel:test')")
|
||||
public CommonResult<String> testChannel(@RequestParam("id") Long id) {
|
||||
return channelService.testChannel(id);
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.devicelog;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.devicelog.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.devicelog.ProductDeviceLogDO;
|
||||
import cn.iocoder.yudao.module.product.service.devicelog.ProductDeviceLogService;
|
||||
|
||||
@Tag(name = "管理后台 - 贩卖机测试日志")
|
||||
@RestController
|
||||
@RequestMapping("/product/device-log")
|
||||
@Validated
|
||||
public class ProductDeviceLogController {
|
||||
|
||||
@Resource
|
||||
private ProductDeviceLogService deviceLogService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建贩卖机测试日志")
|
||||
@PreAuthorize("@ss.hasPermission('product:device-log:create')")
|
||||
public CommonResult<Long> createDeviceLog(@Valid @RequestBody ProductDeviceLogSaveReqVO createReqVO) {
|
||||
return success(deviceLogService.createDeviceLog(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新贩卖机测试日志")
|
||||
@PreAuthorize("@ss.hasPermission('product:device-log:update')")
|
||||
public CommonResult<Boolean> updateDeviceLog(@Valid @RequestBody ProductDeviceLogSaveReqVO updateReqVO) {
|
||||
deviceLogService.updateDeviceLog(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除贩卖机测试日志")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('product:device-log:delete')")
|
||||
public CommonResult<Boolean> deleteDeviceLog(@RequestParam("id") Long id) {
|
||||
deviceLogService.deleteDeviceLog(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得贩卖机测试日志")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('product:device-log:query')")
|
||||
public CommonResult<ProductDeviceLogRespVO> getDeviceLog(@RequestParam("id") Long id) {
|
||||
ProductDeviceLogDO deviceLog = deviceLogService.getDeviceLog(id);
|
||||
return success(BeanUtils.toBean(deviceLog, ProductDeviceLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得贩卖机测试日志分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:device-log:query')")
|
||||
public CommonResult<PageResult<ProductDeviceLogRespVO>> getDeviceLogPage(@Valid ProductDeviceLogPageReqVO pageReqVO) {
|
||||
PageResult<ProductDeviceLogDO> pageResult = deviceLogService.getDeviceLogPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ProductDeviceLogRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出贩卖机测试日志 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('product:device-log:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDeviceLogExcel(@Valid ProductDeviceLogPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ProductDeviceLogDO> list = deviceLogService.getDeviceLogPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "贩卖机测试日志.xls", "数据", ProductDeviceLogRespVO.class,
|
||||
BeanUtils.toBean(list, ProductDeviceLogRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.devicelog.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 贩卖机测试日志分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductDeviceLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "设备IMEI", example = "4570")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "当前使用的货道或柜门编号")
|
||||
private String cabinetChannel;
|
||||
|
||||
@Schema(description = "出货状态", example = "2")
|
||||
private Integer deviceStatus;
|
||||
|
||||
@Schema(description = "内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.devicelog.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 贩卖机测试日志 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ProductDeviceLogRespVO {
|
||||
|
||||
@Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16469")
|
||||
@ExcelProperty("日志主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备IMEI", requiredMode = Schema.RequiredMode.REQUIRED, example = "4570")
|
||||
@ExcelProperty("设备IMEI")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "当前使用的货道或柜门编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("当前使用的货道或柜门编号")
|
||||
private String cabinetChannel;
|
||||
|
||||
@Schema(description = "出货状态", example = "2")
|
||||
@ExcelProperty("出货状态")
|
||||
private Integer deviceStatus;
|
||||
|
||||
@Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.devicelog.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 贩卖机测试日志新增/修改 Request VO")
|
||||
@Data
|
||||
public class ProductDeviceLogSaveReqVO {
|
||||
|
||||
@Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16469")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "设备IMEI", requiredMode = Schema.RequiredMode.REQUIRED, example = "4570")
|
||||
@NotEmpty(message = "设备IMEI不能为空")
|
||||
private String deviceId;
|
||||
|
||||
@Schema(description = "当前使用的货道或柜门编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "当前使用的货道或柜门编号不能为空")
|
||||
private String cabinetChannel;
|
||||
|
||||
@Schema(description = "出货状态", example = "2")
|
||||
private Integer deviceStatus;
|
||||
|
||||
@Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "内容不能为空")
|
||||
private String content;
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.product.dal.dataobject.devicelog;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 贩卖机测试日志 DO
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
@TableName("product_device_log")
|
||||
@KeySequence("product_device_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProductDeviceLogDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 日志主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceId;
|
||||
/**
|
||||
* 当前使用的货道或柜门编号
|
||||
*/
|
||||
private String cabinetChannel;
|
||||
/**
|
||||
* 出货状态
|
||||
*/
|
||||
private Integer deviceStatus;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.product.dal.mysql.devicelog;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.devicelog.ProductDeviceLogDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.devicelog.vo.*;
|
||||
|
||||
/**
|
||||
* 贩卖机测试日志 Mapper
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProductDeviceLogMapper extends BaseMapperX<ProductDeviceLogDO> {
|
||||
|
||||
default PageResult<ProductDeviceLogDO> selectPage(ProductDeviceLogPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ProductDeviceLogDO>()
|
||||
.eqIfPresent(ProductDeviceLogDO::getDeviceId, reqVO.getDeviceId())
|
||||
.eqIfPresent(ProductDeviceLogDO::getCabinetChannel, reqVO.getCabinetChannel())
|
||||
.eqIfPresent(ProductDeviceLogDO::getDeviceStatus, reqVO.getDeviceStatus())
|
||||
.eqIfPresent(ProductDeviceLogDO::getContent, reqVO.getContent())
|
||||
.betweenIfPresent(ProductDeviceLogDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ProductDeviceLogDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.product.service.channel;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.channel.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.channel.ChannelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@@ -53,4 +55,6 @@ public interface ChannelService {
|
||||
PageResult<ChannelDO> getChannelPage(ChannelPageReqVO pageReqVO);
|
||||
|
||||
ChannelImportRespVO importChannelList(List<ChannelImportExcelVO> list, Boolean updateSupport);
|
||||
|
||||
CommonResult<String> testChannel(Long id);
|
||||
}
|
||||
+102
-16
@@ -1,23 +1,33 @@
|
||||
package cn.iocoder.yudao.module.product.service.channel;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.channel.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.channel.ChannelDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.product.controller.admin.channel.vo.ChannelImportExcelVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.channel.vo.ChannelImportRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.channel.vo.ChannelPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.channel.vo.ChannelSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.devicelog.vo.ProductDeviceLogSaveReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.channel.ChannelDO;
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.channel.ChannelMapper;
|
||||
import cn.iocoder.yudao.module.product.service.device.bo.DispenseRequestBo;
|
||||
import cn.iocoder.yudao.module.product.service.device.bo.DispenseResponseBo;
|
||||
import cn.iocoder.yudao.module.product.service.devicelog.ProductDeviceLogService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_IMPORT_LIST_IS_EMPTY;
|
||||
|
||||
/**
|
||||
* 货道 Service 实现类
|
||||
@@ -31,10 +41,21 @@ public class ChannelServiceImpl implements ChannelService {
|
||||
@Resource
|
||||
private ChannelMapper channelMapper;
|
||||
|
||||
@Resource
|
||||
private ProductDeviceLogService productDeviceLogService;
|
||||
|
||||
// TOKEN
|
||||
@Value("${xr.cabinet.token}")
|
||||
private String token;
|
||||
|
||||
//API_URL
|
||||
@Value("${xr.cabinet.api_url}")
|
||||
private String api_url;
|
||||
|
||||
@Override
|
||||
public Long createChannel(ChannelSaveReqVO createReqVO) {
|
||||
ChannelDO dbChannel = channelMapper.selectByDeviceIdAndCabinetChannel(createReqVO.getDeviceId(),createReqVO.getCabinetChannel());
|
||||
if (dbChannel != null){
|
||||
ChannelDO dbChannel = channelMapper.selectByDeviceIdAndCabinetChannel(createReqVO.getDeviceId(), createReqVO.getCabinetChannel());
|
||||
if (dbChannel != null) {
|
||||
throw exception(CHANNEL_EXISTS);
|
||||
}
|
||||
// 插入
|
||||
@@ -89,13 +110,13 @@ public class ChannelServiceImpl implements ChannelService {
|
||||
.failureChannelnames(new LinkedHashMap<>())
|
||||
.build();
|
||||
importList.forEach(excelVO -> {
|
||||
ChannelDO dbChannel = channelMapper.selectByDeviceIdAndCabinetChannel(excelVO.getDeviceId(),excelVO.getCabinetChannel());
|
||||
if (dbChannel == null){
|
||||
ChannelDO dbChannel = channelMapper.selectByDeviceIdAndCabinetChannel(excelVO.getDeviceId(), excelVO.getCabinetChannel());
|
||||
if (dbChannel == null) {
|
||||
channelMapper.insert(BeanUtils.toBean(excelVO, ChannelDO.class));
|
||||
respVO.getCreateChannelnames().add(excelVO.getName());
|
||||
return;
|
||||
}
|
||||
if (!updateSupport){
|
||||
if (!updateSupport) {
|
||||
respVO.getFailureChannelnames().put(excelVO.getName(), CHANNEL_EXISTS.getMsg());
|
||||
return;
|
||||
}
|
||||
@@ -107,4 +128,69 @@ public class ChannelServiceImpl implements ChannelService {
|
||||
return respVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> testChannel(Long id) {
|
||||
// 校验存在
|
||||
ChannelDO channelDO = channelMapper.selectById(id);
|
||||
if (channelDO == null) {
|
||||
throw exception(CHANNEL_NOT_EXISTS);
|
||||
}
|
||||
DispenseRequestBo request = new DispenseRequestBo();
|
||||
request.setDeviceId(channelDO.getDeviceId());
|
||||
String message = "1," + channelDO.getCabinetChannel() + "&1";
|
||||
request.setMessage(message);
|
||||
// 设置请求头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.set("Authorization", token);
|
||||
|
||||
// 创建请求实体
|
||||
HttpEntity<DispenseRequestBo> requestEntity = new HttpEntity<>(request, headers);
|
||||
|
||||
// 创建RestTemplate
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
//测试日志
|
||||
ProductDeviceLogSaveReqVO deviceLog = new ProductDeviceLogSaveReqVO();
|
||||
deviceLog.setDeviceId(channelDO.getDeviceId());
|
||||
deviceLog.setCabinetChannel(channelDO.getCabinetChannel());
|
||||
try {
|
||||
// 发送请求并解析响应
|
||||
ResponseEntity<DispenseResponseBo> response = restTemplate.exchange(
|
||||
api_url,
|
||||
HttpMethod.POST,
|
||||
requestEntity,
|
||||
DispenseResponseBo.class
|
||||
);
|
||||
|
||||
DispenseResponseBo body = response.getBody();
|
||||
if (body != null) {
|
||||
System.out.println("响应结果: " + body);
|
||||
if (body.getCode() == 0) {
|
||||
System.out.println("出货成功!详情: " + body.getData());
|
||||
deviceLog.setDeviceStatus(body.getCode());
|
||||
deviceLog.setContent("出货成功!详情: " + body.getData());
|
||||
productDeviceLogService.createDeviceLog(deviceLog);
|
||||
return CommonResult.success("出货成功!详情: " + body.getData());
|
||||
} else {
|
||||
System.out.println("操作失败!原因: " + body.getMsg());
|
||||
deviceLog.setDeviceStatus(body.getCode());
|
||||
deviceLog.setContent("操作失败!原因: " + body.getMsg());
|
||||
productDeviceLogService.createDeviceLog(deviceLog);
|
||||
throw exception0(1_008_015_001, "操作失败!原因: " + body.getMsg());
|
||||
}
|
||||
} else {
|
||||
deviceLog.setDeviceStatus(501);
|
||||
deviceLog.setContent("操作失败!原因: 请求出货响应为空");
|
||||
productDeviceLogService.createDeviceLog(deviceLog);
|
||||
throw exception(CHANNEL_ERROR);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("请求异常: " + e.getMessage());
|
||||
deviceLog.setDeviceStatus(500);
|
||||
deviceLog.setContent("请求异常: " + e.getMessage());
|
||||
productDeviceLogService.createDeviceLog(deviceLog);
|
||||
throw exception0(1_008_016_001, "请求异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.product.service.devicelog;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.devicelog.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.devicelog.ProductDeviceLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 贩卖机测试日志 Service 接口
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
public interface ProductDeviceLogService {
|
||||
|
||||
/**
|
||||
* 创建贩卖机测试日志
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDeviceLog(@Valid ProductDeviceLogSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新贩卖机测试日志
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDeviceLog(@Valid ProductDeviceLogSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除贩卖机测试日志
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDeviceLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得贩卖机测试日志
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 贩卖机测试日志
|
||||
*/
|
||||
ProductDeviceLogDO getDeviceLog(Long id);
|
||||
|
||||
/**
|
||||
* 获得贩卖机测试日志分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 贩卖机测试日志分页
|
||||
*/
|
||||
PageResult<ProductDeviceLogDO> getDeviceLogPage(ProductDeviceLogPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.product.service.devicelog;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.devicelog.vo.*;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.devicelog.ProductDeviceLogDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.product.dal.mysql.devicelog.ProductDeviceLogMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 贩卖机测试日志 Service 实现类
|
||||
*
|
||||
* @author 小如之家
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ProductDeviceLogServiceImpl implements ProductDeviceLogService {
|
||||
|
||||
@Resource
|
||||
private ProductDeviceLogMapper deviceLogMapper;
|
||||
|
||||
@Override
|
||||
public Long createDeviceLog(ProductDeviceLogSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ProductDeviceLogDO deviceLog = BeanUtils.toBean(createReqVO, ProductDeviceLogDO.class);
|
||||
deviceLogMapper.insert(deviceLog);
|
||||
// 返回
|
||||
return deviceLog.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDeviceLog(ProductDeviceLogSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDeviceLogExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ProductDeviceLogDO updateObj = BeanUtils.toBean(updateReqVO, ProductDeviceLogDO.class);
|
||||
deviceLogMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDeviceLog(Long id) {
|
||||
// 校验存在
|
||||
validateDeviceLogExists(id);
|
||||
// 删除
|
||||
deviceLogMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDeviceLogExists(Long id) {
|
||||
if (deviceLogMapper.selectById(id) == null) {
|
||||
throw exception(DEVICE_LOG_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductDeviceLogDO getDeviceLog(Long id) {
|
||||
return deviceLogMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductDeviceLogDO> getDeviceLogPage(ProductDeviceLogPageReqVO pageReqVO) {
|
||||
return deviceLogMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -185,14 +185,14 @@ public class TradeDeviceOrderHandler implements TradeOrderHandler {
|
||||
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(body.getCode());
|
||||
deviceLogSaveReqVO.setContent(body.getData());
|
||||
deviceLogSaveReqVO.setContent("出货成功!详情: "+body.getData());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
} else {
|
||||
System.out.println("操作失败!原因: " + body.getMsg());
|
||||
log.error("订单--{}:[出货失败]:原因: {}",order.getNo(), body.getMsg());
|
||||
deviceLogSaveReqVO.setDeviceId(deviceId);
|
||||
deviceLogSaveReqVO.setDeviceStatus(body.getCode());
|
||||
deviceLogSaveReqVO.setContent(body.getData());
|
||||
deviceLogSaveReqVO.setContent("[出货失败]原因: "+body.getData());
|
||||
deviceLogService.createDeviceLog(deviceLogSaveReqVO);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user