|
@@ -0,0 +1,105 @@
|
|
|
+package com.rongwei.bscommon.sys.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.rongwei.bscommon.sys.service.EquMaintenanceTaskService;
|
|
|
+import com.rongwei.bscommon.sys.service.EquipmentSendNotifyService;
|
|
|
+import com.rongwei.bsentity.domain.EquMaintenanceTaskDo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.safecommon.fegin.CXCommonFeginClient;
|
|
|
+import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyContent.MAINTAIN_SYSTEM_CONTENT;
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyTitle.MAINTAIN_SYSTEM_TITLE;
|
|
|
+import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.MAINTAIN;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author shangmi
|
|
|
+ * @title EquipmentSendNotifyServiceImpl
|
|
|
+ * @date 2024/1/18 17:20
|
|
|
+ * @description 设备消息提醒业务实现类
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+public class EquipmentSendNotifyServiceImpl implements EquipmentSendNotifyService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EquMaintenanceTaskService maintenanceTaskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CXCommonFeginClient commonFeginClient;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据任务ID发送 提醒
|
|
|
+ *
|
|
|
+ * @param id 保养任务ID
|
|
|
+ * @return {@link R}
|
|
|
+ * @date 2024/1/18 17:16
|
|
|
+ * @author shangmi
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R maintainCreateTaskNotify(String id) {
|
|
|
+ if (StringUtils.isBlank(id)) {
|
|
|
+ log.info("任务ID为空");
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ EquMaintenanceTaskDo maintenanceTaskDo = maintenanceTaskService.getById(id);
|
|
|
+
|
|
|
+ if (null == maintenanceTaskDo) {
|
|
|
+ log.info("无法通过id:{}获取到任务列表", id);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发送人
|
|
|
+ List<String> userId = new ArrayList<>();
|
|
|
+ // 发送内容
|
|
|
+ String context = null;
|
|
|
+ // 发送标题
|
|
|
+ String title = null;
|
|
|
+ if (maintenanceTaskDo.getPrincipalid() != null){
|
|
|
+ userId.addAll(Arrays.asList(maintenanceTaskDo.getPrincipalid().split(",")));
|
|
|
+ }
|
|
|
+ if (maintenanceTaskDo.getOtherengineersid() != null){
|
|
|
+ userId.addAll(Arrays.asList(maintenanceTaskDo.getOtherengineersid().split(",")));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (userId.isEmpty()){
|
|
|
+ log.info("id为{}的任务无提醒人",id);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ title = MAINTAIN_SYSTEM_TITLE;
|
|
|
+ context = String.format(MAINTAIN_SYSTEM_CONTENT,
|
|
|
+ maintenanceTaskDo.getPlanyear()+"-"+maintenanceTaskDo.getMonth(),
|
|
|
+ maintenanceTaskDo.getWorkshop(),
|
|
|
+ maintenanceTaskDo.getEquipmentname(),
|
|
|
+ maintenanceTaskDo.getEquipmentnumber(),
|
|
|
+ maintenanceTaskDo.getMaintenancesite(),
|
|
|
+ maintenanceTaskDo.getPrincipal(),
|
|
|
+ maintenanceTaskDo.getOtherengineers()
|
|
|
+ );
|
|
|
+
|
|
|
+ JSONArray data = JSONUtil.parseArray( commonFeginClient.list(new HashMap<String, Object>() {{
|
|
|
+ this.put("NOTIFYTYPE", "maintain");
|
|
|
+ this.put("ROPTION", id);
|
|
|
+ }}).getData());
|
|
|
+ if (!data.isEmpty()){
|
|
|
+ List<String> ids = data.stream().map(info -> JSONUtil.parseObj(info).get("id").toString()).collect(Collectors.toList());
|
|
|
+ commonFeginClient.delete(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ CXCommonUtils.sendNotify(title,
|
|
|
+ context,null,userId.stream().distinct().collect(Collectors.toList()),maintenanceTaskDo.getId(),MAINTAIN);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|