|
@@ -80,122 +80,141 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- //查询当前模具编号的模具是否存在
|
|
|
|
- Integer count = mouldMapper.selectCount(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
|
|
|
|
- if (count > 0) {
|
|
|
|
- msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
|
|
- } else {
|
|
|
|
- if (mould.getProduceCompanyId() != null) {
|
|
|
|
- Company company = companyMapper.selectById(mould.getProduceCompanyId());
|
|
|
|
- mould.setArea(company.getCompanyAddress());
|
|
|
|
|
|
+ if (null != mould.getPreUpdateId()) {
|
|
|
|
+ //更新模具操作
|
|
|
|
+ //查询当前模具编号的模具是否存在
|
|
|
|
+ Integer count = mouldMapper.selectCount(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
|
|
+ return msg;
|
|
|
|
+ } else {
|
|
|
|
+ if (mould.getProduceCompanyId() != null) {
|
|
|
|
+ Company company = companyMapper.selectById(mould.getProduceCompanyId());
|
|
|
|
+ mould.setArea(company.getCompanyAddress());
|
|
|
|
+ }
|
|
|
|
+ mould.setCreatorId(user.getId());
|
|
|
|
+ mould.setCompanyId(user.getCompanyId());
|
|
|
|
+ mouldMapper.insert(mould);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ //查询当前模具编号的模具是否存在
|
|
|
|
+ Integer count = mouldMapper.selectCount(new QueryWrapper<Mould>().eq("model_no", mould.getModelNo()));
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ msg.setError("当前模具编号已存在,请重新输入其他模具编号");
|
|
|
|
+ return msg;
|
|
|
|
+ } else {
|
|
|
|
+ if (mould.getProduceCompanyId() != null) {
|
|
|
|
+ Company company = companyMapper.selectById(mould.getProduceCompanyId());
|
|
|
|
+ mould.setArea(company.getCompanyAddress());
|
|
|
|
+ }
|
|
|
|
+ mould.setCreatorId(user.getId());
|
|
|
|
+ mould.setCompanyId(user.getCompanyId());
|
|
|
|
+ mouldMapper.insert(mould);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- mould.setCreatorId(user.getId());
|
|
|
|
- mould.setCompanyId(user.getCompanyId());
|
|
|
|
- mouldMapper.insert(mould);
|
|
|
|
}
|
|
}
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg getMoildDetail(MouldVO mouldVO) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- MouldVO mould = mouldMapper.getDetailById(mouldVO);
|
|
|
|
- map.put("vo", mould);
|
|
|
|
- ProjectVO vo = projectMapper.getProjectById(mould.getProjectId());
|
|
|
|
- User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", mouldVO.getToken()));
|
|
|
|
- if (null == mould.getProjectId()) {
|
|
|
|
- map.put("update", 0);
|
|
|
|
- map.put("download", 0);
|
|
|
|
- map.put("view", 0);
|
|
|
|
- map.put("approve", 0);
|
|
|
|
- } else {
|
|
|
|
- List<CustomCompany> list = customCompanyMapper.selectList(new QueryWrapper<CustomCompany>().eq("project_id", mould.getProjectId()));
|
|
|
|
- map.put("customCompany", list);
|
|
|
|
- if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
|
|
|
|
- //当前人超级管理员 ,对项目只可以浏览
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getMoildDetail (MouldVO mouldVO){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ MouldVO mould = mouldMapper.getDetailById(mouldVO);
|
|
|
|
+ map.put("vo", mould);
|
|
|
|
+ ProjectVO vo = projectMapper.getProjectById(mould.getProjectId());
|
|
|
|
+ User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", mouldVO.getToken()));
|
|
|
|
+ if (null == mould.getProjectId()) {
|
|
map.put("update", 0);
|
|
map.put("update", 0);
|
|
map.put("download", 0);
|
|
map.put("download", 0);
|
|
- map.put("view", 1);
|
|
|
|
- map.put("approve", 0);
|
|
|
|
- } else if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
- //当前为系统管理员
|
|
|
|
- map.put("update", 1);
|
|
|
|
- map.put("download", 1);
|
|
|
|
- map.put("view", 1);
|
|
|
|
|
|
+ map.put("view", 0);
|
|
map.put("approve", 0);
|
|
map.put("approve", 0);
|
|
- } else if (vo.getManagerId() == currentUser.getId()) {
|
|
|
|
- //当前人是该项目的项目经理
|
|
|
|
- Integer approve = 0;
|
|
|
|
- if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId())) > 0) {
|
|
|
|
- //查看当前项目经理是否为审批人
|
|
|
|
- approve = 1;
|
|
|
|
- }
|
|
|
|
- map.put("update", 1);
|
|
|
|
- map.put("download", 1);
|
|
|
|
- map.put("view", 1);
|
|
|
|
- map.put("approve", approve);
|
|
|
|
- } else if(projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId())) > 0){
|
|
|
|
- //是否为审批人
|
|
|
|
- map.put("update", 0);
|
|
|
|
- map.put("download", 1);
|
|
|
|
- map.put("view", 1);
|
|
|
|
- map.put("approve", 1);
|
|
|
|
- }else{
|
|
|
|
- //该项目的参与人
|
|
|
|
- Integer update = 0;
|
|
|
|
- Integer download = 0;
|
|
|
|
- Integer view = 0;
|
|
|
|
- Integer approve = 0;
|
|
|
|
- List<Power> powers = powerMapper.selectList(new QueryWrapper<Power>().eq("project_id", mould.getProjectId()).eq("user_id", currentUser.getId()));
|
|
|
|
- if (powers.size() > 0) {
|
|
|
|
- for (Power power : powers) {
|
|
|
|
- if (power.getPowerType() == 0) {
|
|
|
|
- update = 1;
|
|
|
|
- } else if (power.getPowerType() == 1) {
|
|
|
|
- download = 1;
|
|
|
|
- } else if (power.getPowerType() == 2) {
|
|
|
|
- view = 1;
|
|
|
|
- } else {
|
|
|
|
- approve = 1;
|
|
|
|
|
|
+ } else {
|
|
|
|
+ List<CustomCompany> list = customCompanyMapper.selectList(new QueryWrapper<CustomCompany>().eq("project_id", mould.getProjectId()));
|
|
|
|
+ map.put("customCompany", list);
|
|
|
|
+ if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
|
|
|
|
+ //当前人超级管理员 ,对项目只可以浏览
|
|
|
|
+ map.put("update", 0);
|
|
|
|
+ map.put("download", 0);
|
|
|
|
+ map.put("view", 1);
|
|
|
|
+ map.put("approve", 0);
|
|
|
|
+ } else if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
+ //当前为系统管理员
|
|
|
|
+ map.put("update", 1);
|
|
|
|
+ map.put("download", 1);
|
|
|
|
+ map.put("view", 1);
|
|
|
|
+ map.put("approve", 0);
|
|
|
|
+ } else if (vo.getManagerId() == currentUser.getId()) {
|
|
|
|
+ //当前人是该项目的项目经理
|
|
|
|
+ Integer approve = 0;
|
|
|
|
+ if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId())) > 0) {
|
|
|
|
+ //查看当前项目经理是否为审批人
|
|
|
|
+ approve = 1;
|
|
|
|
+ }
|
|
|
|
+ map.put("update", 1);
|
|
|
|
+ map.put("download", 1);
|
|
|
|
+ map.put("view", 1);
|
|
|
|
+ map.put("approve", approve);
|
|
|
|
+ } else if (projectApproveMapper.selectCount(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId())) > 0) {
|
|
|
|
+ //是否为审批人
|
|
|
|
+ map.put("update", 0);
|
|
|
|
+ map.put("download", 1);
|
|
|
|
+ map.put("view", 1);
|
|
|
|
+ map.put("approve", 1);
|
|
|
|
+ } else {
|
|
|
|
+ //该项目的参与人
|
|
|
|
+ Integer update = 0;
|
|
|
|
+ Integer download = 0;
|
|
|
|
+ Integer view = 0;
|
|
|
|
+ Integer approve = 0;
|
|
|
|
+ List<Power> powers = powerMapper.selectList(new QueryWrapper<Power>().eq("project_id", mould.getProjectId()).eq("user_id", currentUser.getId()));
|
|
|
|
+ if (powers.size() > 0) {
|
|
|
|
+ for (Power power : powers) {
|
|
|
|
+ if (power.getPowerType() == 0) {
|
|
|
|
+ update = 1;
|
|
|
|
+ } else if (power.getPowerType() == 1) {
|
|
|
|
+ download = 1;
|
|
|
|
+ } else if (power.getPowerType() == 2) {
|
|
|
|
+ view = 1;
|
|
|
|
+ } else {
|
|
|
|
+ approve = 1;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ map.put("update", update);
|
|
|
|
+ map.put("download", download);
|
|
|
|
+ map.put("view", view);
|
|
|
|
+ map.put("approve", approve);
|
|
}
|
|
}
|
|
- map.put("update", update);
|
|
|
|
- map.put("download", download);
|
|
|
|
- map.put("view", view);
|
|
|
|
- map.put("approve", approve);
|
|
|
|
}
|
|
}
|
|
|
|
+ msg.data = map;
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- msg.data = map;
|
|
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg maintenanceReminder() throws Exception {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- //查询所有被分配到项目的模具
|
|
|
|
- List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().isNotNull("project_id").isNotNull("maintain_count"));
|
|
|
|
- for (Mould mould : moulds) {
|
|
|
|
- List<Integer> counts = ListUtil.convertIntegerIdsArrayToList(mould.getMaintainCount());
|
|
|
|
- Collections.sort(counts);
|
|
|
|
- Integer noticeCount = 0;
|
|
|
|
- if (counts.size() > 0) {
|
|
|
|
- for (Integer count : counts) {
|
|
|
|
- if (count <= mould.getRunTimes()) {
|
|
|
|
- noticeCount = count;
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg maintenanceReminder () throws Exception {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ //查询所有被分配到项目的模具
|
|
|
|
+ List<Mould> moulds = mouldMapper.selectList(new QueryWrapper<Mould>().isNotNull("project_id").isNotNull("maintain_count"));
|
|
|
|
+ for (Mould mould : moulds) {
|
|
|
|
+ List<Integer> counts = ListUtil.convertIntegerIdsArrayToList(mould.getMaintainCount());
|
|
|
|
+ Collections.sort(counts);
|
|
|
|
+ Integer noticeCount = 0;
|
|
|
|
+ if (counts.size() > 0) {
|
|
|
|
+ for (Integer count : counts) {
|
|
|
|
+ if (count <= mould.getRunTimes()) {
|
|
|
|
+ noticeCount = count;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //添加通知消息
|
|
|
|
- Project project = projectMapper.selectById(mould.getProjectId());
|
|
|
|
- if (noticeCount != 0) {
|
|
|
|
- //需要保养
|
|
|
|
- Mould m = new Mould();
|
|
|
|
- m.setId(mould.getId());
|
|
|
|
- m.setIsMaintain(1);
|
|
|
|
- mouldMapper.updateById(m);
|
|
|
|
|
|
+ //添加通知消息
|
|
|
|
+ Project project = projectMapper.selectById(mould.getProjectId());
|
|
|
|
+ if (noticeCount != 0) {
|
|
|
|
+ //需要保养
|
|
|
|
+ Mould m = new Mould();
|
|
|
|
+ m.setId(mould.getId());
|
|
|
|
+ m.setIsMaintain(1);
|
|
|
|
+ mouldMapper.updateById(m);
|
|
// //提示保养,向模具资产方人员公众号推送消息
|
|
// //提示保养,向模具资产方人员公众号推送消息
|
|
// User user = userMapper.selectOne(new QueryWrapper<User>().eq("parent_id", Constant.SYS_ID).eq("company_id", mould.getCompanyId()));
|
|
// User user = userMapper.selectOne(new QueryWrapper<User>().eq("parent_id", Constant.SYS_ID).eq("company_id", mould.getCompanyId()));
|
|
// MouldEquipmentVO mouldEquipmentVO = new MouldEquipmentVO();
|
|
// MouldEquipmentVO mouldEquipmentVO = new MouldEquipmentVO();
|
|
@@ -203,29 +222,29 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
// mouldEquipmentVO.setArea(mould.getArea());
|
|
// mouldEquipmentVO.setArea(mould.getArea());
|
|
// mouldEquipmentVO.setName(mould.getModelName());
|
|
// mouldEquipmentVO.setName(mould.getModelName());
|
|
// msg = sendMaintainTemplateMessage(Constant.MAINTAIN_NOTICE_TEMPLATE_ID, user.getOpenid(), Constant.WECHAT_APPID, Constant.WECHAT_SECRET, mouldEquipmentVO);
|
|
// msg = sendMaintainTemplateMessage(Constant.MAINTAIN_NOTICE_TEMPLATE_ID, user.getOpenid(), Constant.WECHAT_APPID, Constant.WECHAT_SECRET, mouldEquipmentVO);
|
|
- //添加通知消息
|
|
|
|
- //查询到参与该项目的人
|
|
|
|
- List<Integer> userIds = new ArrayList<>();
|
|
|
|
- userIds.add(project.getCreatorId());
|
|
|
|
- userIds.add(project.getManagerId());
|
|
|
|
- List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("project_id", project.getId()));
|
|
|
|
- for (ProjectUser projectUser : projectUsers) {
|
|
|
|
- userIds.add(projectUser.getUserId());
|
|
|
|
- }
|
|
|
|
- List<ProjectApprove> projectApproves = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("project_id", project.getId()));
|
|
|
|
- for (ProjectApprove projectApprove : projectApproves) {
|
|
|
|
- userIds.add(projectApprove.getApproverId());
|
|
|
|
- }
|
|
|
|
- List<User> users = userMapper.selectList(new QueryWrapper<User>().in("id", userIds));
|
|
|
|
- //查询到之前模具保养的消息
|
|
|
|
- NewsNotice oldNews = newsNoticeMapper.selectOne(new QueryWrapper<NewsNotice>().eq("ref_id", mould.getId()).eq("notice_type", 1));
|
|
|
|
- NewsNotice newsNotice = new NewsNotice();
|
|
|
|
- if (oldNews != null) {
|
|
|
|
- NewsNotice newNews = new NewsNotice();
|
|
|
|
- newNews.setId(oldNews.getId());
|
|
|
|
- oldNews.setIndate(LocalDateTime.now());
|
|
|
|
- newsNoticeMapper.updateById(oldNews);
|
|
|
|
- newsNoticeUserMapper.updateNewsNoticeUserByNewsNoticeId(oldNews.getId());
|
|
|
|
|
|
+ //添加通知消息
|
|
|
|
+ //查询到参与该项目的人
|
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
|
+ userIds.add(project.getCreatorId());
|
|
|
|
+ userIds.add(project.getManagerId());
|
|
|
|
+ List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("project_id", project.getId()));
|
|
|
|
+ for (ProjectUser projectUser : projectUsers) {
|
|
|
|
+ userIds.add(projectUser.getUserId());
|
|
|
|
+ }
|
|
|
|
+ List<ProjectApprove> projectApproves = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("project_id", project.getId()));
|
|
|
|
+ for (ProjectApprove projectApprove : projectApproves) {
|
|
|
|
+ userIds.add(projectApprove.getApproverId());
|
|
|
|
+ }
|
|
|
|
+ List<User> users = userMapper.selectList(new QueryWrapper<User>().in("id", userIds));
|
|
|
|
+ //查询到之前模具保养的消息
|
|
|
|
+ NewsNotice oldNews = newsNoticeMapper.selectOne(new QueryWrapper<NewsNotice>().eq("ref_id", mould.getId()).eq("notice_type", 1));
|
|
|
|
+ NewsNotice newsNotice = new NewsNotice();
|
|
|
|
+ if (oldNews != null) {
|
|
|
|
+ NewsNotice newNews = new NewsNotice();
|
|
|
|
+ newNews.setId(oldNews.getId());
|
|
|
|
+ oldNews.setIndate(LocalDateTime.now());
|
|
|
|
+ newsNoticeMapper.updateById(oldNews);
|
|
|
|
+ newsNoticeUserMapper.updateNewsNoticeUserByNewsNoticeId(oldNews.getId());
|
|
// for (User u : users) {
|
|
// for (User u : users) {
|
|
// //添加通知的消息
|
|
// //添加通知的消息
|
|
// NewsNoticeUser newsNoticeUser = new NewsNoticeUser();
|
|
// NewsNoticeUser newsNoticeUser = new NewsNoticeUser();
|
|
@@ -234,324 +253,326 @@ public class MouldServiceImpl extends ServiceImpl<MouldMapper, Mould> implements
|
|
// newsNoticeUser.setIsRead(0);
|
|
// newsNoticeUser.setIsRead(0);
|
|
// newsNoticeUserMapper.updateById(newsNoticeUser);
|
|
// newsNoticeUserMapper.updateById(newsNoticeUser);
|
|
// }
|
|
// }
|
|
- } else {
|
|
|
|
- newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
|
|
- newsNotice.setProjectId(project.getId());
|
|
|
|
- newsNotice.setProjectName(project.getProjectName());
|
|
|
|
- newsNotice.setRefId(mould.getId());
|
|
|
|
- newsNotice.setContent(Constant.MAIN_TAIN_NOTICE);
|
|
|
|
- newsNoticeMapper.insert(newsNotice);
|
|
|
|
- for (User u : users) {
|
|
|
|
- //添加通知的消息
|
|
|
|
- NewsNoticeUser newsNoticeUser = new NewsNoticeUser();
|
|
|
|
- newsNoticeUser.setNewsId(newsNotice.getId());
|
|
|
|
- newsNoticeUser.setUserId(u.getId());
|
|
|
|
- newsNoticeUserMapper.insert(newsNoticeUser);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
|
|
+ newsNotice.setProjectId(project.getId());
|
|
|
|
+ newsNotice.setProjectName(project.getProjectName());
|
|
|
|
+ newsNotice.setRefId(mould.getId());
|
|
|
|
+ newsNotice.setContent(Constant.MAIN_TAIN_NOTICE);
|
|
|
|
+ newsNoticeMapper.insert(newsNotice);
|
|
|
|
+ for (User u : users) {
|
|
|
|
+ //添加通知的消息
|
|
|
|
+ NewsNoticeUser newsNoticeUser = new NewsNoticeUser();
|
|
|
|
+ newsNoticeUser.setNewsId(newsNotice.getId());
|
|
|
|
+ newsNoticeUser.setUserId(u.getId());
|
|
|
|
+ newsNoticeUserMapper.insert(newsNoticeUser);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //待报废消息通知
|
|
|
|
- if (mould.getRunTimes() > mould.getSettingLife()) {
|
|
|
|
- //修改模具成待报废状态
|
|
|
|
- Mould m = new Mould();
|
|
|
|
- m.setId(mould.getId());
|
|
|
|
- m.setState(3 + "");//3-待报废状态
|
|
|
|
- mouldMapper.updateById(m);
|
|
|
|
- NewsNotice oldNews = newsNoticeMapper.selectOne(new QueryWrapper<NewsNotice>().eq("ref_id", mould.getId()).eq("notice_type", 3));
|
|
|
|
- NewsNotice newsNotice = new NewsNotice();
|
|
|
|
- //添加通知消息
|
|
|
|
- //查询到参与该项目的人
|
|
|
|
- List<Integer> userIds = new ArrayList<>();
|
|
|
|
- userIds.add(project.getCreatorId());
|
|
|
|
- userIds.add(project.getManagerId());
|
|
|
|
- List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("project_id", project.getId()));
|
|
|
|
- for (ProjectUser projectUser : projectUsers) {
|
|
|
|
- userIds.add(projectUser.getUserId());
|
|
|
|
- }
|
|
|
|
- List<ProjectApprove> projectApproves = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("project_id", project.getId()));
|
|
|
|
- for (ProjectApprove projectApprove : projectApproves) {
|
|
|
|
- userIds.add(projectApprove.getApproverId());
|
|
|
|
- }
|
|
|
|
- List<User> users = userMapper.selectList(new QueryWrapper<User>().in("id", userIds));
|
|
|
|
- if (oldNews != null) {
|
|
|
|
- NewsNotice newNews = new NewsNotice();
|
|
|
|
- newNews.setId(oldNews.getId());
|
|
|
|
- oldNews.setIndate(LocalDateTime.now());
|
|
|
|
- newsNoticeMapper.updateById(oldNews);
|
|
|
|
- newsNoticeUserMapper.updateNewsNoticeUserByNewsNoticeId(oldNews.getId());
|
|
|
|
- } else {
|
|
|
|
- newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
|
|
- newsNotice.setProjectId(project.getId());
|
|
|
|
- newsNotice.setProjectName(project.getProjectName());
|
|
|
|
- newsNotice.setRefId(mould.getId());
|
|
|
|
- newsNotice.setContent(Constant.SCRAP_NOTICE);
|
|
|
|
- newsNoticeMapper.insert(newsNotice);
|
|
|
|
- for (User u : users) {
|
|
|
|
- //添加通知的消息
|
|
|
|
- NewsNoticeUser newsNoticeUser = new NewsNoticeUser();
|
|
|
|
- newsNoticeUser.setNewsId(newsNotice.getId());
|
|
|
|
- newsNoticeUser.setUserId(u.getId());
|
|
|
|
- newsNoticeUserMapper.insert(newsNoticeUser);
|
|
|
|
|
|
+ //待报废消息通知
|
|
|
|
+ if (mould.getRunTimes() > mould.getSettingLife()) {
|
|
|
|
+ //修改模具成待报废状态
|
|
|
|
+ Mould m = new Mould();
|
|
|
|
+ m.setId(mould.getId());
|
|
|
|
+ m.setState(3 + "");//3-待报废状态
|
|
|
|
+ mouldMapper.updateById(m);
|
|
|
|
+ NewsNotice oldNews = newsNoticeMapper.selectOne(new QueryWrapper<NewsNotice>().eq("ref_id", mould.getId()).eq("notice_type", 3));
|
|
|
|
+ NewsNotice newsNotice = new NewsNotice();
|
|
|
|
+ //添加通知消息
|
|
|
|
+ //查询到参与该项目的人
|
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
|
+ userIds.add(project.getCreatorId());
|
|
|
|
+ userIds.add(project.getManagerId());
|
|
|
|
+ List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("project_id", project.getId()));
|
|
|
|
+ for (ProjectUser projectUser : projectUsers) {
|
|
|
|
+ userIds.add(projectUser.getUserId());
|
|
|
|
+ }
|
|
|
|
+ List<ProjectApprove> projectApproves = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("project_id", project.getId()));
|
|
|
|
+ for (ProjectApprove projectApprove : projectApproves) {
|
|
|
|
+ userIds.add(projectApprove.getApproverId());
|
|
|
|
+ }
|
|
|
|
+ List<User> users = userMapper.selectList(new QueryWrapper<User>().in("id", userIds));
|
|
|
|
+ if (oldNews != null) {
|
|
|
|
+ NewsNotice newNews = new NewsNotice();
|
|
|
|
+ newNews.setId(oldNews.getId());
|
|
|
|
+ oldNews.setIndate(LocalDateTime.now());
|
|
|
|
+ newsNoticeMapper.updateById(oldNews);
|
|
|
|
+ newsNoticeUserMapper.updateNewsNoticeUserByNewsNoticeId(oldNews.getId());
|
|
|
|
+ } else {
|
|
|
|
+ newsNotice.setNoticeType(Constant.MAINTAIN_TYPE);
|
|
|
|
+ newsNotice.setProjectId(project.getId());
|
|
|
|
+ newsNotice.setProjectName(project.getProjectName());
|
|
|
|
+ newsNotice.setRefId(mould.getId());
|
|
|
|
+ newsNotice.setContent(Constant.SCRAP_NOTICE);
|
|
|
|
+ newsNoticeMapper.insert(newsNotice);
|
|
|
|
+ for (User u : users) {
|
|
|
|
+ //添加通知的消息
|
|
|
|
+ NewsNoticeUser newsNoticeUser = new NewsNoticeUser();
|
|
|
|
+ newsNoticeUser.setNewsId(newsNotice.getId());
|
|
|
|
+ newsNoticeUser.setUserId(u.getId());
|
|
|
|
+ newsNoticeUserMapper.insert(newsNoticeUser);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg delMoule(Mould mould) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- Mould newMould = mouldMapper.selectById(mould.getId());
|
|
|
|
- if (null != mould.getProjectId()) {
|
|
|
|
- msg.setError("该模具已被应用到项目,不提供删除操作");
|
|
|
|
- } else {
|
|
|
|
- mouldMapper.deleteById(newMould.getId());
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg delMoule (Mould mould){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ Mould newMould = mouldMapper.selectById(mould.getId());
|
|
|
|
+ if (null != mould.getProjectId()) {
|
|
|
|
+ msg.setError("该模具已被应用到项目,不提供删除操作");
|
|
|
|
+ } else {
|
|
|
|
+ mouldMapper.deleteById(newMould.getId());
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg isMaintain(Mould mould) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- if (mould.getId() != null) {
|
|
|
|
- mouldMapper.updateById(mould);
|
|
|
|
- } else {
|
|
|
|
- msg.setError("模具id不存在");
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg isMaintain (Mould mould){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ if (mould.getId() != null) {
|
|
|
|
+ mouldMapper.updateById(mould);
|
|
|
|
+ } else {
|
|
|
|
+ msg.setError("模具id不存在");
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg maintainMouldList(UserVO userVO) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
|
|
|
|
- List<Integer> set = new ArrayList<>();
|
|
|
|
- set.add(-1);
|
|
|
|
- List<Mould> moulds = new ArrayList<>();
|
|
|
|
- if (currentUser.getId() != null) {
|
|
|
|
- //资产方管理员,获取他公司下的所有模具
|
|
|
|
- if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
- List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>().eq("creator_id", currentUser.getId()));
|
|
|
|
- for (Project project : projects) {
|
|
|
|
- set.add(project.getId());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- //普通用户或者项目经理
|
|
|
|
- //充当项目经理参与的项目
|
|
|
|
- QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
- qw.eq("manager_id", currentUser.getId());
|
|
|
|
- List<Project> projects = projectMapper.selectList(qw);
|
|
|
|
- if (projects.size() > 0) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg maintainMouldList (UserVO userVO){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
|
|
|
|
+ List<Integer> set = new ArrayList<>();
|
|
|
|
+ set.add(-1);
|
|
|
|
+ List<Mould> moulds = new ArrayList<>();
|
|
|
|
+ if (currentUser.getId() != null) {
|
|
|
|
+ //资产方管理员,获取他公司下的所有模具
|
|
|
|
+ if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
+ List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>().eq("creator_id", currentUser.getId()));
|
|
for (Project project : projects) {
|
|
for (Project project : projects) {
|
|
set.add(project.getId());
|
|
set.add(project.getId());
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ //普通用户或者项目经理
|
|
|
|
+ //充当项目经理参与的项目
|
|
|
|
+ QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("manager_id", currentUser.getId());
|
|
|
|
+ List<Project> projects = projectMapper.selectList(qw);
|
|
|
|
+ if (projects.size() > 0) {
|
|
|
|
+ for (Project project : projects) {
|
|
|
|
+ set.add(project.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// //充当普通人员参与的项目
|
|
// //充当普通人员参与的项目
|
|
- List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id", currentUser.getId()));
|
|
|
|
- if (projectUsers.size() > 0) {
|
|
|
|
- for (ProjectUser projectUser : projectUsers) {
|
|
|
|
- set.add(projectUser.getProjectId());
|
|
|
|
|
|
+ List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id", currentUser.getId()));
|
|
|
|
+ if (projectUsers.size() > 0) {
|
|
|
|
+ for (ProjectUser projectUser : projectUsers) {
|
|
|
|
+ set.add(projectUser.getProjectId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
// //充当审批人员参与的项目
|
|
// //充当审批人员参与的项目
|
|
- List<ProjectApprove> projectss = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId()));
|
|
|
|
- if (projectss.size() > 0) {
|
|
|
|
- for (ProjectApprove projectUser : projectss) {
|
|
|
|
- set.add(projectUser.getProjectId());
|
|
|
|
|
|
+ List<ProjectApprove> projectss = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId()));
|
|
|
|
+ if (projectss.size() > 0) {
|
|
|
|
+ for (ProjectApprove projectUser : projectss) {
|
|
|
|
+ set.add(projectUser.getProjectId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id", set).eq("is_maintain", 1));
|
|
|
|
+ msg.data = moulds;
|
|
|
|
+ } else {
|
|
|
|
+ msg.setError("用户不存在,或者未登录!");
|
|
}
|
|
}
|
|
- moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id", set).eq("is_maintain", 1));
|
|
|
|
- msg.data = moulds;
|
|
|
|
- } else {
|
|
|
|
- msg.setError("用户不存在,或者未登录!");
|
|
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg scrapMouldList(UserVO userVO) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
|
|
|
|
- List<Integer> set = new ArrayList<>();
|
|
|
|
- set.add(-1);
|
|
|
|
- List<Mould> moulds = new ArrayList<>();
|
|
|
|
- if (currentUser.getId() != null) {
|
|
|
|
- //资产方管理员,获取他公司下的所有模具
|
|
|
|
- if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
- List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>().eq("creator_id", currentUser.getId()));
|
|
|
|
- for (Project project : projects) {
|
|
|
|
- set.add(project.getId());
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- //普通用户或者项目经理
|
|
|
|
- //充当项目经理参与的项目
|
|
|
|
- QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
- qw.eq("manager_id", currentUser.getId());
|
|
|
|
- List<Project> projects = projectMapper.selectList(qw);
|
|
|
|
- if (projects.size() > 0) {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg scrapMouldList (UserVO userVO){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
|
|
|
|
+ List<Integer> set = new ArrayList<>();
|
|
|
|
+ set.add(-1);
|
|
|
|
+ List<Mould> moulds = new ArrayList<>();
|
|
|
|
+ if (currentUser.getId() != null) {
|
|
|
|
+ //资产方管理员,获取他公司下的所有模具
|
|
|
|
+ if (Constant.SYS_ID == currentUser.getParentId()) {
|
|
|
|
+ List<Project> projects = projectMapper.selectList(new QueryWrapper<Project>().eq("creator_id", currentUser.getId()));
|
|
for (Project project : projects) {
|
|
for (Project project : projects) {
|
|
set.add(project.getId());
|
|
set.add(project.getId());
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ //普通用户或者项目经理
|
|
|
|
+ //充当项目经理参与的项目
|
|
|
|
+ QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("manager_id", currentUser.getId());
|
|
|
|
+ List<Project> projects = projectMapper.selectList(qw);
|
|
|
|
+ if (projects.size() > 0) {
|
|
|
|
+ for (Project project : projects) {
|
|
|
|
+ set.add(project.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// //充当普通人员参与的项目
|
|
// //充当普通人员参与的项目
|
|
- List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id", currentUser.getId()));
|
|
|
|
- if (projectUsers.size() > 0) {
|
|
|
|
- for (ProjectUser projectUser : projectUsers) {
|
|
|
|
- set.add(projectUser.getProjectId());
|
|
|
|
|
|
+ List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id", currentUser.getId()));
|
|
|
|
+ if (projectUsers.size() > 0) {
|
|
|
|
+ for (ProjectUser projectUser : projectUsers) {
|
|
|
|
+ set.add(projectUser.getProjectId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
// //充当审批人员参与的项目
|
|
// //充当审批人员参与的项目
|
|
- List<ProjectApprove> projectss = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId()));
|
|
|
|
- if (projectss.size() > 0) {
|
|
|
|
- for (ProjectApprove projectUser : projectss) {
|
|
|
|
- set.add(projectUser.getProjectId());
|
|
|
|
|
|
+ List<ProjectApprove> projectss = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId()));
|
|
|
|
+ if (projectss.size() > 0) {
|
|
|
|
+ for (ProjectApprove projectUser : projectss) {
|
|
|
|
+ set.add(projectUser.getProjectId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id", set).eq("state", 3));
|
|
|
|
+ msg.data = moulds;
|
|
|
|
+ } else {
|
|
|
|
+ msg.setError("用户不存在,或者未登录!");
|
|
}
|
|
}
|
|
- moulds = mouldMapper.selectList(new QueryWrapper<Mould>().in("project_id", set).eq("state", 3));
|
|
|
|
- msg.data = moulds;
|
|
|
|
- } else {
|
|
|
|
- msg.setError("用户不存在,或者未登录!");
|
|
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- return msg;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
- public HttpRespMsg changeMouldEquipment(Mould mould, String token) {
|
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
- User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
|
|
|
|
- if (currentUser != null) {
|
|
|
|
- if(Constant.SYS_PARENT_ID == currentUser.getParentId()){
|
|
|
|
- Mould m = new Mould();
|
|
|
|
- m.setId(mould.getId());
|
|
|
|
- m.setEquipmentId(mould.getEquipmentId());
|
|
|
|
- mouldMapper.updateById(m);
|
|
|
|
- //通知资产方管理员
|
|
|
|
-
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg changeMouldEquipment (Mould mould, String token){
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
|
|
|
|
+ if (currentUser != null) {
|
|
|
|
+ if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
|
|
|
|
+ Mould m = new Mould();
|
|
|
|
+ m.setId(mould.getId());
|
|
|
|
+ m.setEquipmentId(mould.getEquipmentId());
|
|
|
|
+ mouldMapper.updateById(m);
|
|
|
|
+ //通知资产方管理员
|
|
|
|
+
|
|
|
|
|
|
- }else{
|
|
|
|
- msg.setError("您没有该项权限");
|
|
|
|
|
|
+ } else {
|
|
|
|
+ msg.setError("您没有该项权限");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ msg.setError("用户不存在或未登录");
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- msg.setError("用户不存在或未登录");
|
|
|
|
|
|
+ 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);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 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;
|
|
}
|
|
}
|
|
- 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);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 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;
|
|
}
|
|
}
|
|
- return msg;
|
|
|
|
}
|
|
}
|
|
-}
|
|
|