|
@@ -1,22 +1,31 @@
|
|
package com.om.service.impl;
|
|
package com.om.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
-import com.om.entity.dto.AppBaseDTO;
|
|
|
|
-import com.om.entity.dto.GuidDTO;
|
|
|
|
|
|
+import com.om.entity.dto.*;
|
|
|
|
+import com.om.entity.po.Client;
|
|
import com.om.entity.po.Manual;
|
|
import com.om.entity.po.Manual;
|
|
|
|
+import com.om.entity.po.Wxsc;
|
|
import com.om.entity.vo.AppManual;
|
|
import com.om.entity.vo.AppManual;
|
|
import com.om.exception.BadReqException;
|
|
import com.om.exception.BadReqException;
|
|
|
|
+import com.om.exception.BizException;
|
|
import com.om.mapper.ManualMapper;
|
|
import com.om.mapper.ManualMapper;
|
|
|
|
+import com.om.service.IClientService;
|
|
import com.om.service.IManualService;
|
|
import com.om.service.IManualService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.om.utils.AesUtil;
|
|
import com.om.utils.AesUtil;
|
|
import com.om.utils.JwtUtils;
|
|
import com.om.utils.JwtUtils;
|
|
|
|
+import com.om.utils.PushUtil;
|
|
import com.om.utils.Result;
|
|
import com.om.utils.Result;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.time.ZoneOffset;
|
|
import java.time.ZoneOffset;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -37,6 +46,12 @@ public class ManualServiceImpl extends ServiceImpl<ManualMapper, Manual> impleme
|
|
@Resource
|
|
@Resource
|
|
private JwtUtils jwtUtils;
|
|
private JwtUtils jwtUtils;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private IClientService clientService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private PushUtil pushUtil;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Page<Manual> findManual(Page<Manual> page, String code, String title) {
|
|
public Page<Manual> findManual(Page<Manual> page, String code, String title) {
|
|
return manualMapper.findManual(page, code, title);
|
|
return manualMapper.findManual(page, code, title);
|
|
@@ -61,4 +76,56 @@ public class ManualServiceImpl extends ServiceImpl<ManualMapper, Manual> impleme
|
|
vo.setCreateTime(one.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
vo.setCreateTime(one.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
return Result.ok(vo);
|
|
return Result.ok(vo);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result pushManual(Integer id) {
|
|
|
|
+ Manual manual = this.getById(id);
|
|
|
|
+ if (BeanUtil.isEmpty(manual)){
|
|
|
|
+ throw new BadReqException("该使用手册不存在");
|
|
|
|
+ }
|
|
|
|
+ PushInfo pushInfo = new PushInfo();
|
|
|
|
+ pushInfo.setPushInfoType(4);
|
|
|
|
+
|
|
|
|
+ MaintenanceManualInfo maintenanceManualInfo = new MaintenanceManualInfo();
|
|
|
|
+ maintenanceManualInfo.setType("1");
|
|
|
|
+ List<Describe> describeList = new ArrayList<>();
|
|
|
|
+ String title = manual.getTitle();
|
|
|
|
+ List<Manual> manuals = this.lambdaQuery()
|
|
|
|
+ .eq(Manual::getTitle, title)
|
|
|
|
+ .eq(Manual::getClientCode,manual.getClientCode())
|
|
|
|
+ .list();
|
|
|
|
+ if (CollectionUtil.isNotEmpty(manuals)){
|
|
|
|
+ for (Manual m : manuals) {
|
|
|
|
+ Describe describe = new Describe();
|
|
|
|
+ describe.setLanguage(m.getLang());
|
|
|
|
+ describe.setDescription(m.getFileName());
|
|
|
|
+ describeList.add(describe);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ maintenanceManualInfo.setDescribeList(describeList);
|
|
|
|
+ pushInfo.setJson(JSONUtil.parseObj(maintenanceManualInfo));
|
|
|
|
+
|
|
|
|
+ String clientCode = manual.getClientCode();
|
|
|
|
+ if (StringUtils.isNotBlank(clientCode)){
|
|
|
|
+
|
|
|
|
+ Client client = clientService.lambdaQuery()
|
|
|
|
+ .eq(Client::getNumber, clientCode)
|
|
|
|
+ .one();
|
|
|
|
+
|
|
|
|
+ if (BeanUtil.isEmpty(client)){
|
|
|
|
+ throw new BadReqException("该客户端编号不存在");
|
|
|
|
+ }
|
|
|
|
+ String deviceToken = client.getDeviceToken();
|
|
|
|
+ if (StringUtils.isNotBlank(deviceToken)){
|
|
|
|
+ String[] token = new String[]{deviceToken};
|
|
|
|
+ try {
|
|
|
|
+ pushUtil.sendAndroidListcastJSON(token,pushInfo);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new BizException("推送失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Result.ok();
|
|
|
|
+ }
|
|
}
|
|
}
|