| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | //String serid2 = list.get(0).getSerid(); |
| | | //String substring = serid2.substring(0, serid.length() - 1); |
| | | //String s = serid + substring; |
| | | System.out.println("用户id:" + serid); |
| | | taskqdService.updatet(taskqd.getId(), i, serid, null, null); |
| | | return R.success("抢单成功"); |
| | | } else { |
| | | String ser = taskqd.getSerid(); |
| | | String ser2 = list.get(0).getSerid(); |
| | | String sub = ser.substring(0, serid.length() - 1); |
| | | String ss = ser2 + sub; |
| | | //String sub = ser.substring(0, serid.length() - 1); |
| | | String ss = ser2 + ser; |
| | | |
| | | String team = taskqd.getCaptain(); |
| | | boolean isteam = StringUtil.isEmpty(list.get(0).getTeam()); |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping("/selectLi") |
| | | public R selectLi(String type, String serid, String jurisdiction) { |
| | | List<TaskqdVO> list = taskqdService.selectLi(type, serid, jurisdiction); |
| | | public R selectLi(String type, String serid, String jurisdiction, String workjurisdiction, String tasktype) { |
| | | List<TaskqdVO> list = taskqdService.selectLi(type, serid, jurisdiction, workjurisdiction, tasktype); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Integer nums = list.get(i).getNums(); |
| | | |
| | |
| | | |
| | | /** |
| | | * 查询可参与任务 |
| | | * |
| | | * @param serid |
| | | * @param jurisdiction |
| | | * @return |
| | | */ |
| | | @GetMapping("/selectNum") |
| | | public R selectNum(String serid,String jurisdiction,String workjurisdiction) { |
| | | return R.data(taskqdService.selectNum(serid, jurisdiction,workjurisdiction)); |
| | | public R selectNum(String serid, String jurisdiction, String workjurisdiction) { |
| | | List<Map<String, Object>> maps = taskqdService.selectNum(serid, jurisdiction, workjurisdiction); |
| | | //0:治安巡查 |
| | | Map map = new HashMap(); |
| | | int a = 0; |
| | | int b = 0; |
| | | int c = 0; |
| | | for (int i = 0; i < maps.size(); i++) { |
| | | String tasktype = maps.get(i).get("tasktype").toString(); |
| | | if (tasktype.equals("0")) { |
| | | map.put("xcha", maps.get(i).get("num")); |
| | | a = 1; |
| | | } else if (tasktype.equals("1")) { |
| | | map.put("xchuan", maps.get(i).get("num")); |
| | | b = 1; |
| | | } else if (tasktype.equals("2")) { |
| | | map.put("px", maps.get(i).get("num")); |
| | | c = 1; |
| | | } |
| | | } |
| | | if (a == 0) { |
| | | map.put("xcha", 0); |
| | | } |
| | | if (b == 0) { |
| | | map.put("xchuan", 0); |
| | | } |
| | | if (c == 0) { |
| | | map.put("px", 0); |
| | | } |
| | | return R.data(map); |
| | | } |
| | | |
| | | @GetMapping("/startTask") |
| | | public R<Map> startTask(String rid, String serid,String type,String data) { |
| | | public R<Map> startTask(String rid, String serid, String type, String data) { |
| | | //获取组员id并进行通知 |
| | | Map<String, Object> map = new HashMap<>(); |
| | | |
| | | serid = taskqdService.querySerid(rid); |
| | | |
| | | int msg = pushMsgService.startTask(serid, rid,type,data); |
| | | int msg = pushMsgService.startTask(serid, rid, type, data); |
| | | map.put("res", msg); |
| | | map.put("type", type); |
| | | map.put("data",data); |
| | | if (!type.equals("stop")){ |
| | | taskqdService.updateRtype("0",rid); |
| | | map.put("data", data); |
| | | if (!type.equals("stop")) { |
| | | taskqdService.updateRtype("0", rid); |
| | | } |
| | | return R.data(map); |
| | | } |
| | | |
| | | @GetMapping("/cancelTask") |
| | | public R cancelTask(String rid, String serid, String name) { |
| | | //任务查询 |
| | | //String id = taskqdService.querySerid(rid); |
| | | List<Taskqd> list = taskqdService.selectList(Integer.valueOf(rid)); |
| | | |
| | | //获取参与者id |
| | | String id = list.get(0).getSerid(); |
| | | |
| | | String captain[] = id.split(","); |
| | | if (captain[0].equals(serid)) { |
| | | return R.status(taskqdService.removeByIds(Func.toLongList(rid))); |
| | | } |
| | | |
| | | //获取参与者名称 |
| | | String[] nameList = list.get(0).getTeam().split(","); |
| | | //创建新的参与者 |
| | | String newteam = ""; |
| | | //设置标识防止删除同名人员 |
| | | boolean flage = true; |
| | | for (int i = 0; i < nameList.length; i++) { |
| | | if (flage) { |
| | | if (!name.equals(nameList[i])) { |
| | | newteam += nameList[i] + ","; |
| | | }else{ |
| | | flage = false; |
| | | } |
| | | } else { |
| | | newteam += nameList[i] + ","; |
| | | } |
| | | |
| | | } |
| | | //去除最后的逗号 |
| | | if (newteam.length() != 0) { |
| | | newteam = newteam.substring(0, newteam.length() - 1); |
| | | } |
| | | |
| | | //扣去人数 |
| | | int newnum = list.get(0).getNum() - 1; |
| | | |
| | | //成员id拼接逗号方便删除 |
| | | String delid = "," + serid; |
| | | //将指定成员删除 |
| | | String resid = id.replaceAll(delid, ""); |
| | | |
| | | return R.status(taskqdService.updateSerid(rid, resid, newteam, newnum)); |
| | | } |
| | | |
| | | @GetMapping("/taskCount") |
| | | public R cancelTask(String id,String type) { |
| | | List<Map<String,Object>> cout = taskqdService.taskCount(id,type); |
| | | List<TaskqdVO> list = taskqdService.getlist(id,type); |
| | | Map<String,Object> res = new HashMap<>(); |
| | | res.put("ywc",cout.get(0).get("count")); |
| | | res.put("wwc",cout.get(1).get("count")); |
| | | res.put("data",list); |
| | | return R.data(res); |
| | | } |
| | | |
| | | } |