WxscServiceImpl.java 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. package com.om.service.impl;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import cn.hutool.core.util.PageUtil;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.om.entity.dto.*;
  6. import com.om.entity.po.Wxsc;
  7. import com.om.entity.vo.AppWxscQueryPageVO;
  8. import com.om.entity.vo.AppWxscVO;
  9. import com.om.exception.BadReqException;
  10. import com.om.mapper.WxscMapper;
  11. import com.om.service.IWxscService;
  12. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  13. import com.om.utils.AesUtil;
  14. import com.om.utils.HuaweiObsUtil;
  15. import com.om.utils.Result;
  16. import com.om.utils.ResultCode;
  17. import org.apache.commons.lang3.StringUtils;
  18. import org.springframework.context.annotation.Bean;
  19. import org.springframework.stereotype.Service;
  20. import javax.annotation.Resource;
  21. import java.time.ZoneOffset;
  22. import java.util.ArrayList;
  23. import java.util.List;
  24. /**
  25. * <p>
  26. * 服务实现类
  27. * </p>
  28. *
  29. * @author henry-ong
  30. * @since 2024-03-09
  31. */
  32. @Service
  33. public class WxscServiceImpl extends ServiceImpl<WxscMapper, Wxsc> implements IWxscService {
  34. private final WxscMapper wxscMapper;
  35. public WxscServiceImpl(WxscMapper wxscMapper) {
  36. this.wxscMapper = wxscMapper;
  37. }
  38. @Resource
  39. private HuaweiObsUtil obsUtil;
  40. @Override
  41. public Page<Wxsc> findManual(Page<Wxsc> page, String code, String title) {
  42. return wxscMapper.findManual(page, code, title);
  43. }
  44. @Override
  45. public Result appGetPageList(AppWxscQueryPageDTO dto) {
  46. if (BeanUtil.isEmpty(dto)){
  47. return Result.fail("未获取到数据").result(ResultCode.NO_DATA);
  48. }
  49. String guid = dto.getGuid();
  50. GuidDTO guidDTO = AesUtil.getGuidDTOFromGuid(guid);
  51. String clientNum = guidDTO.getClientNum();
  52. String language = dto.getLanguage();
  53. Integer pageIndex = dto.getPageIndex();
  54. Integer pageSize = dto.getPageSize();
  55. Page<Wxsc> page = this.lambdaQuery()
  56. .orderByDesc(Wxsc::getCreateTime)
  57. .eq(Wxsc::getClientCode,clientNum)
  58. .eq(Wxsc::getLang,language)
  59. .page(new Page<>(pageIndex, pageSize));
  60. if (BeanUtil.isEmpty(page)){
  61. return Result.ok();
  62. }
  63. AppWxscQueryPageVO vo = new AppWxscQueryPageVO();
  64. vo.setCurrent((int) page.getCurrent());
  65. vo.setTotal((int) page.getTotal());
  66. vo.setPages((int) page.getPages());
  67. vo.setSize((int) page.getSize());
  68. List<AppWxscVO> appWxscVOS = new ArrayList<>();
  69. List<Wxsc> records = page.getRecords();
  70. for (Wxsc record : records) {
  71. AppWxscVO appWxscVO = new AppWxscVO();
  72. appWxscVO.setMaintenanceManualId(record.getId());
  73. appWxscVO.setMaintenanceManualName(record.getScName());
  74. appWxscVO.setCreateTime(record.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
  75. appWxscVOS.add(appWxscVO);
  76. }
  77. vo.setMaintenanceManualLis(appWxscVOS);
  78. return Result.ok(vo);
  79. }
  80. @Override
  81. public Result<Wxsc> appGetById(AppWxscDTO dto) {
  82. Integer id = dto.getId();
  83. String language = dto.getLanguage();
  84. //根据id查询
  85. Wxsc wxsc = this.lambdaQuery()
  86. .eq(Wxsc::getId, id)
  87. .eq(Wxsc::getLang, language)
  88. .one();
  89. if (BeanUtil.isEmpty(wxsc)){
  90. throw new BadReqException("该维修资料不存在!");
  91. }
  92. return Result.ok(wxsc);
  93. }
  94. @Override
  95. public Result deleteById(Integer id) {
  96. Wxsc byId = this.getById(id);
  97. if (BeanUtil.isEmpty(byId)){
  98. throw new BadReqException("该维修手册不存在");
  99. }
  100. this.removeById(id);
  101. return Result.ok();
  102. }
  103. @Override
  104. public Result pushWxzl(Integer id) {
  105. Wxsc wxsc = this.getById(id);
  106. if (BeanUtil.isEmpty(wxsc)){
  107. throw new BadReqException("该维修手册不存在");
  108. }
  109. PushInfo pushInfo = new PushInfo();
  110. pushInfo.setPushInfoType(4);
  111. MaintenanceManualInfo maintenanceManualInfo = new MaintenanceManualInfo();
  112. maintenanceManualInfo.setType("0");
  113. List<Describe> describeList = new ArrayList<>();
  114. return null;
  115. }
  116. }