|
@@ -14,10 +14,7 @@ import com.hssx.cloudmodel.entity.vo.UserVO;
|
|
import com.hssx.cloudmodel.mapper.*;
|
|
import com.hssx.cloudmodel.mapper.*;
|
|
import com.hssx.cloudmodel.service.MouldService;
|
|
import com.hssx.cloudmodel.service.MouldService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.hssx.cloudmodel.util.HttpKit;
|
|
|
|
-import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
|
|
-import com.hssx.cloudmodel.util.ListUtil;
|
|
|
|
-import com.hssx.cloudmodel.util.WechatTemplateMessage;
|
|
|
|
|
|
+import com.hssx.cloudmodel.util.*;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -105,7 +102,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
if (oldModelNo.indexOf("-") == -1) {
|
|
if (oldModelNo.indexOf("-") == -1) {
|
|
newMouldNo.append(oldModelNo).append("-").append("1");
|
|
newMouldNo.append(oldModelNo).append("-").append("1");
|
|
} else {
|
|
} else {
|
|
- int i = Integer.parseInt(oldModelNo.substring(oldModelNo.length()-1));
|
|
|
|
|
|
+ int i = Integer.parseInt(oldModelNo.substring(oldModelNo.length() - 1));
|
|
i++;
|
|
i++;
|
|
newMouldNo.append(oldModelNo.substring(0, oldModelNo.length() - 1)).append(i + "");
|
|
newMouldNo.append(oldModelNo.substring(0, oldModelNo.length() - 1)).append(i + "");
|
|
}
|
|
}
|
|
@@ -246,7 +243,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
map.put("download", 1);
|
|
map.put("download", 1);
|
|
map.put("view", 1);
|
|
map.put("view", 1);
|
|
map.put("approve", approve);
|
|
map.put("approve", approve);
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
//该项目的参与人
|
|
//该项目的参与人
|
|
Integer update = 0;
|
|
Integer update = 0;
|
|
Integer download = 0;
|
|
Integer download = 0;
|
|
@@ -282,6 +279,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
//查询所有被分配到项目的模具
|
|
//查询所有被分配到项目的模具
|
|
List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().isNotNull("project_id").isNotNull("maintain_count"));
|
|
List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().isNotNull("project_id").isNotNull("maintain_count"));
|
|
|
|
+ String token = GainTokenUtil.getToken();
|
|
for (Mould mould : moulds) {
|
|
for (Mould mould : moulds) {
|
|
List<Integer> counts = ListUtil.convertIntegerIdsArrayToList(mould.getMaintainCount());
|
|
List<Integer> counts = ListUtil.convertIntegerIdsArrayToList(mould.getMaintainCount());
|
|
Collections.sort(counts);
|
|
Collections.sort(counts);
|
|
@@ -293,6 +291,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ final Integer sumCount = noticeCount;
|
|
//添加通知消息
|
|
//添加通知消息
|
|
Project project = projectMapper.selectById(mould.getProjectId());
|
|
Project project = projectMapper.selectById(mould.getProjectId());
|
|
if (noticeCount != 0) {
|
|
if (noticeCount != 0) {
|
|
@@ -301,13 +300,19 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
m.setId(mould.getId());
|
|
m.setId(mould.getId());
|
|
m.setIsMaintain(1);
|
|
m.setIsMaintain(1);
|
|
mouldMapper.updateById(m);
|
|
mouldMapper.updateById(m);
|
|
-// //提示保养,向模具资产方人员公众号推送消息
|
|
|
|
-// User user = userMapper.selectOne(new QueryWrapper<User>().eq("parent_id", Constant.SYS_ID).eq("company_id", mould.getCompanyId()));
|
|
|
|
-// MouldEquipmentVO mouldEquipmentVO = new MouldEquipmentVO();
|
|
|
|
-// mouldEquipmentVO.setPlanType(Constant.PLAN_TYPE);
|
|
|
|
-// mouldEquipmentVO.setArea(mould.getArea());
|
|
|
|
-// mouldEquipmentVO.setName(mould.getModelName());
|
|
|
|
-// msg = sendMaintainTemplateMessage(Constant.MAINTAIN_NOTICE_TEMPLATE_ID, user.getOpenid(), Constant.WECHAT_APPID, Constant.WECHAT_SECRET, mouldEquipmentVO);
|
|
|
|
|
|
+ List<Integer> uids = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("project_id", project.getId())).stream().map(ProjectUser::getUserId).collect(Collectors.toList());
|
|
|
|
+ uids.add(project.getManagerId());
|
|
|
|
+ uids.add(project.getCreatorId());
|
|
|
|
+ uids.add(-1);
|
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", uids).isNotNull("openid").eq("is_disable", 1));
|
|
|
|
+ //公众号的推送to do
|
|
|
|
+ userList.forEach(u ->{
|
|
|
|
+ try {
|
|
|
|
+ WechatTemplateUtil.sendMaintainTemplateMessage(u.getOpenid(),mould.getModelNo()+"-"+mould.getModelName(),Constant.MAIN_TAIN_TYPE,Constant.MAIN_TAIN_CONTENT +sumCount+"次数",token);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
//添加通知消息
|
|
//添加通知消息
|
|
//查询到参与该项目的人
|
|
//查询到参与该项目的人
|
|
List<Integer> userIds = new ArrayList<>();
|
|
List<Integer> userIds = new ArrayList<>();
|
|
@@ -343,7 +348,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
} else {
|
|
} else {
|
|
newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
newsNotice.setProjectId(project.getId());
|
|
newsNotice.setProjectId(project.getId());
|
|
- newsNotice.setProjectName(project.getProjectName()+"-"+mould.getModelName());
|
|
|
|
|
|
+ newsNotice.setProjectName(project.getProjectName() + "-" + mould.getModelName());
|
|
newsNotice.setRefId(mould.getId());
|
|
newsNotice.setRefId(mould.getId());
|
|
newsNotice.setContent(Constant.MAIN_TAIN_NOTICE);
|
|
newsNotice.setContent(Constant.MAIN_TAIN_NOTICE);
|
|
newsNoticeMapper.insert(newsNotice);
|
|
newsNoticeMapper.insert(newsNotice);
|
|
@@ -389,7 +394,7 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
} else {
|
|
} else {
|
|
newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
newsNotice.setProjectId(project.getId());
|
|
newsNotice.setProjectId(project.getId());
|
|
- newsNotice.setProjectName(project.getProjectName()+"-"+mould.getModelName());
|
|
|
|
|
|
+ newsNotice.setProjectName(project.getProjectName() + "-" + mould.getModelName());
|
|
newsNotice.setRefId(mould.getId());
|
|
newsNotice.setRefId(mould.getId());
|
|
newsNotice.setContent(Constant.SCRAP_NOTICE);
|
|
newsNotice.setContent(Constant.SCRAP_NOTICE);
|
|
newsNoticeMapper.insert(newsNotice);
|
|
newsNoticeMapper.insert(newsNotice);
|
|
@@ -554,119 +559,4 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
-
|
|
|
|
- //告警模板推送通用接口
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * templateId 模板id,touserOpenId 被推送者的openId,appId微信公众号的appId
|
|
|
|
- * firstData 推送标题
|
|
|
|
- */
|
|
|
|
- public HttpRespMsg sendEmergencyTemplateMessage(String templateId, String touserOpenId, String appId, String
|
|
|
|
- secret, MouldEquipmentVO mouldEquipmentVO) throws Exception {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
|
- + appId + "&secret=" + secret;
|
|
|
|
- String resp;
|
|
|
|
- String resp1;
|
|
|
|
- resp1 = HttpKit.get(url, true);
|
|
|
|
- resp1 = StringEscapeUtils.unescapeJava(resp1);
|
|
|
|
- JSONObject json = (JSONObject) JSON.parse(resp1);
|
|
|
|
- // 获取值赋值给全局变量
|
|
|
|
- if (!json.containsKey("errcode")) {
|
|
|
|
- String newAccessToken = json.getString("access_token");
|
|
|
|
- String url1 = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="
|
|
|
|
- + newAccessToken;
|
|
|
|
- WechatTemplateMessage wechat = new WechatTemplateMessage();
|
|
|
|
- wechat.setTemplate_id(templateId);
|
|
|
|
- wechat.setTouser(touserOpenId);
|
|
|
|
- wechat.setAppid(appId);
|
|
|
|
- Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
- Map<String, String> first = new HashMap<>();
|
|
|
|
- Map<String, String> value1 = new HashMap<>();
|
|
|
|
- Map<String, String> value2 = new HashMap<>();
|
|
|
|
- Map<String, String> value3 = new HashMap<>();
|
|
|
|
- Map<String, String> value4 = new HashMap<>();
|
|
|
|
- Map<String, String> remark = new HashMap<>();
|
|
|
|
- // 推送信息主体
|
|
|
|
- first.put("value", "告警通知");//firstData推送标题
|
|
|
|
- data.put("first", first);
|
|
|
|
- value1.put("value", mouldEquipmentVO.getEquipmentName());
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
- data.put("keyword1", value1);
|
|
|
|
- value2.put("value", mouldEquipmentVO.getEmergencyType());
|
|
|
|
- data.put("keyword2", value2);
|
|
|
|
- value3.put("value", sdf.format(new Date()));
|
|
|
|
- data.put("keyword3", value3);
|
|
|
|
- value4.put("value", mouldEquipmentVO.getEmergencyContent());
|
|
|
|
- data.put("keyword4", value4);
|
|
|
|
- remark.put("value", "请尽快检查该设备");
|
|
|
|
- data.put("remark", remark);
|
|
|
|
- wechat.setData(data);
|
|
|
|
- String jsonString = JSONObject.toJSONString(wechat);
|
|
|
|
- // System.out.println("jsonString"+jsonString);
|
|
|
|
- resp = HttpKit.post(url1, jsonString);
|
|
|
|
- // System.out.println("resp0"+resp);
|
|
|
|
- resp = StringEscapeUtils.unescapeJava(resp);
|
|
|
|
- // System.out.println("resp"+resp);
|
|
|
|
- json = (JSONObject) JSON.parse(resp);
|
|
|
|
- }
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
- //保养
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * templateId 模板id,touserOpenId 被推送者的openId,appId微信公众号的appId
|
|
|
|
- * firstData 推送标题
|
|
|
|
- */
|
|
|
|
- public HttpRespMsg sendMaintainTemplateMessage(String templateId, String touserOpenId, String appId, String
|
|
|
|
- secret, MouldEquipmentVO mouldEquipmentVO) throws Exception {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
|
|
|
|
- + appId + "&secret=" + secret;
|
|
|
|
- String resp;
|
|
|
|
- String resp1;
|
|
|
|
- resp1 = HttpKit.get(url, true);
|
|
|
|
- resp1 = StringEscapeUtils.unescapeJava(resp1);
|
|
|
|
- JSONObject json = (JSONObject) JSON.parse(resp1);
|
|
|
|
- // 获取值赋值给全局变量
|
|
|
|
- if (!json.containsKey("errcode")) {
|
|
|
|
- String newAccessToken = json.getString("access_token");
|
|
|
|
- String url1 = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="
|
|
|
|
- + newAccessToken;
|
|
|
|
- WechatTemplateMessage wechat = new WechatTemplateMessage();
|
|
|
|
- wechat.setTemplate_id(templateId);
|
|
|
|
- wechat.setTouser(touserOpenId);
|
|
|
|
- wechat.setAppid(appId);
|
|
|
|
- Map<String, Map<String, String>> data = new HashMap<>();
|
|
|
|
- Map<String, String> first = new HashMap<>();
|
|
|
|
- Map<String, String> value1 = new HashMap<>();
|
|
|
|
- Map<String, String> value2 = new HashMap<>();
|
|
|
|
- Map<String, String> value3 = new HashMap<>();
|
|
|
|
- Map<String, String> value4 = new HashMap<>();
|
|
|
|
- Map<String, String> remark = new HashMap<>();
|
|
|
|
- // 推送信息主体
|
|
|
|
- first.put("value", "你好,你有新的保养通知");//firstData推送标题
|
|
|
|
- data.put("first", first);
|
|
|
|
- value1.put("value", mouldEquipmentVO.getEquipmentName());
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
|
|
|
- data.put("keyword1", value1);
|
|
|
|
- value2.put("value", mouldEquipmentVO.getArea());
|
|
|
|
- data.put("keyword2", value2);
|
|
|
|
- value3.put("value", sdf.format(new Date()));
|
|
|
|
- data.put("keyword3", value3);
|
|
|
|
- value4.put("value", mouldEquipmentVO.getPlanType());
|
|
|
|
- data.put("keyword4", value4);
|
|
|
|
- remark.put("value", "模具初始模次不满足运行了");
|
|
|
|
- data.put("remark", remark);
|
|
|
|
- wechat.setData(data);
|
|
|
|
- String jsonString = JSONObject.toJSONString(wechat);
|
|
|
|
- // System.out.println("jsonString"+jsonString);
|
|
|
|
- resp = HttpKit.post(url1, jsonString);
|
|
|
|
- // System.out.println("resp0"+resp);
|
|
|
|
- resp = StringEscapeUtils.unescapeJava(resp);
|
|
|
|
- // System.out.println("resp"+resp);
|
|
|
|
- json = (JSONObject) JSON.parse(resp);
|
|
|
|
- }
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|