| | |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | |
| | | import com.example.jz.modle.entity.*; |
| | | import com.example.jz.modle.vo.CauseVo; |
| | | import com.example.jz.modle.vo.MemberVo; |
| | | import com.example.jz.modle.vo.ReportVo; |
| | | import com.example.jz.service.*; |
| | | import com.example.jz.utils.HttpUtil; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | |
| | | private final String wxApp_accessToken_verify_url = "https://api.weixin.qq.com/cgi-bin/token"; |
| | | |
| | | private final String appid = "wxebbb232d366dae09"; |
| | | @Value("${wx.appid}") |
| | | private String appid; |
| | | |
| | | private final String secret = "9a160c97c821eaa163240e8ec9185b77"; |
| | | @Value("${wx.secret}") |
| | | private String secret; |
| | | |
| | | private final String js_code = ""; |
| | | |
| | |
| | | MessageService messageService; |
| | | @Autowired |
| | | GroupUserService groupUserService; |
| | | @Autowired |
| | | PublicityService publicityService; |
| | | |
| | | @GetMapping("/login") |
| | | @SneakyThrows |
| | |
| | | role = user.getRole(); |
| | | id = user.getId(); |
| | | } |
| | | User user1 = userDao.selectOne(new QueryWrapper<User>().eq("user_mobile", phone_info.getPurePhoneNumber())); |
| | | HashMap<String, Object> loginMessage = new HashMap<>(); |
| | | loginMessage.put("id", id); |
| | | loginMessage.put("token", token); |
| | | loginMessage.put("role", role); |
| | | loginMessage.put("time", user1.getUserIdcard()); |
| | | return R.ok(loginMessage); |
| | | } |
| | | |
| | |
| | | report.setIsInGroup(0); |
| | | report.setCtime(new Date()); |
| | | report.setStatus(0); |
| | | report.setReportMethod("现场录入"); |
| | | report.setReportMethod("扫码报案"); |
| | | return R.ok(reportService.save(report)); |
| | | } |
| | | |
| | |
| | | @GetMapping("/manager/group/list") |
| | | public R getMessage(@RequestParam Integer id, @RequestParam String newDate, @RequestParam String lastDate) { |
| | | ArrayList<Map<String, Object>> list = new ArrayList<>(); |
| | | // List<GroupUser> groupUsers = groupUserService.list(new QueryWrapper<GroupUser>().eq("user_id", id)); |
| | | List<Group> groupUsers = groupService.list(new QueryWrapper<Group>().eq("user_id", id)); |
| | | if (groupUsers != null && groupUsers.size() != 0) { |
| | | if (!groupUsers.isEmpty()) { |
| | | groupUsers.forEach(item -> { |
| | | HashMap<String, Object> groupMap = new HashMap<>(); |
| | | List<Message> message = messageService.list(new QueryWrapper<Message>().eq("group_id", item.getId()).isNotNull("user_id").orderByDesc("ctime")); |
| | | List<Message> message = messageService.list(new QueryWrapper<Message>().eq("group_id", item.getId()).orderByDesc("ctime")); |
| | | groupMap.put("groupName", item.getGroupName()); |
| | | if (message != null && message.size() != 0) { |
| | | groupMap.put("message", message.get(0).getText()); |
| | | groupMap.put("name", message.get(0).getReportName()); |
| | | groupMap.put("time", message.get(0).getCtime()); |
| | | } |
| | | getMessage(groupMap, message); |
| | | if (StringUtils.isNotBlank(lastDate)) { |
| | | int count = messageService.count(new QueryWrapper<Message>().eq("group_id", item.getId()).between("ctime", lastDate, newDate)); |
| | | groupMap.put("count", count); |
| | |
| | | return R.ok(list); |
| | | } |
| | | |
| | | private void getMessage(HashMap<String, Object> groupMap, List<Message> message) { |
| | | if (!message.isEmpty()) { |
| | | groupMap.put("message", message.get(0).getText()); |
| | | if (message.get(0).getUserId() == null) { |
| | | groupMap.put("name", userDao.selectOne(new QueryWrapper<User>().eq("id", message.get(0).getCopId())).getRealName()); |
| | | } else { |
| | | groupMap.put("name", message.get(0).getReportName()); |
| | | } |
| | | groupMap.put("time", message.get(0).getCtime()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @GetMapping("/user/group/list") |
| | | public R getUserMessage(@RequestParam Integer id, @RequestParam String newDate, @RequestParam String lastDate) { |
| | | ArrayList<Map<String, Object>> list = new ArrayList<>(); |
| | | reportService.list((new QueryWrapper<Report>().eq("user_id", id))) |
| | | reportService.listGroup(id) |
| | | .forEach(item -> |
| | | { |
| | | GroupUser groupUser = groupUserService.getOne(new QueryWrapper<GroupUser>().eq("user_id", item.getId())); |
| | | if (groupUser != null) { |
| | | HashMap<String, Object> groupMap = new HashMap<>(); |
| | | List<Message> message = messageService.list(new QueryWrapper<Message>().eq("group_id", groupUser.getGroupId()).orderByDesc("ctime")); |
| | | if (message != null && message.size() != 0) { |
| | | groupMap.put("message", message.get(0).getText()); |
| | | groupMap.put("time", message.get(0).getCtime()); |
| | | } |
| | | getMessage(groupMap, message); |
| | | Group group = groupService.getOne(new QueryWrapper<Group>().eq("id", groupUser.getGroupId())); |
| | | groupMap.put("groupName", group.getGroupName()); |
| | | groupMap.put("id", group.getId()); |
| | |
| | | |
| | | @GetMapping("/group/user/sendMsg") |
| | | public R sendUserMsg(@RequestParam Integer id, @RequestParam Integer groupId, @RequestParam String msg) { |
| | | if (StringUtils.isBlank(msg)) { |
| | | return R.failed("msg is blank"); |
| | | } |
| | | Message message = new Message(); |
| | | message.setUserId(id); |
| | | message.setText(msg); |
| | |
| | | message.setReportName(userService.getOne(new QueryWrapper<User>().eq("id", reportService.getOne(new QueryWrapper<Report>().eq("id", id)).getUserId())).getRealName()); |
| | | return R.ok(messageService.save(message)); |
| | | } |
| | | |
| | | @GetMapping("/group/member/detail") |
| | | public R getMemberDetail(@RequestParam Integer id) { |
| | | Report report = reportService.getOne(new LambdaQueryWrapper<Report>().eq(Report::getId, id)); |
| | | ReportVo reportVo = new ReportVo(); |
| | | BeanUtils.copyProperties(report, reportVo); |
| | | User user = userDao.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, report.getUserId())); |
| | | reportVo.setReporterName(user.getRealName()); |
| | | reportVo.setMobile(user.getUserMobile()); |
| | | reportVo.setIdcard(user.getUserIdcard()); |
| | | return R.ok(reportVo); |
| | | } |
| | | |
| | | @GetMapping("/manager/report") |
| | | public R queryReport() { |
| | | return R.ok(reportService.list(new LambdaQueryWrapper<Report>().eq(Report::getStatus, 0)) |
| | | .stream() |
| | | .map(item -> { |
| | | ReportVo reportVo = new ReportVo(); |
| | | BeanUtils.copyProperties(item, reportVo); |
| | | User user = userDao.selectOne(new LambdaQueryWrapper<User>().eq(User::getId, item.getUserId())); |
| | | reportVo.setReporterName(user.getRealName()); |
| | | reportVo.setMobile(user.getUserMobile()); |
| | | reportVo.setIdcard(user.getUserIdcard()); |
| | | return reportVo; |
| | | }) |
| | | .collect(Collectors.toList())); |
| | | } |
| | | |
| | | @GetMapping("/publicity") |
| | | public R queryPublicity(@RequestParam(required = false) Integer size) { |
| | | List<Publicity> publicityList = publicityService.list(new LambdaQueryWrapper<Publicity>().eq(Publicity::getStatus, 1)); |
| | | if (size != null) { |
| | | return R.ok(publicityList.stream().limit(size)); |
| | | } |
| | | return R.ok(publicityList); |
| | | } |
| | | } |