| | |
| | | package com.ruoyi.app.application.service.impl; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import java.util.ArrayList; |
| | | import java.util.Map; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | |
| | | public class ArdAppApplicationServiceImpl implements IArdAppApplicationService { |
| | | @Resource |
| | | private ArdAppApplicationMapper ardAppApplicationMapper; |
| | | |
| | | private Map<String,Thread> threadMap = new HashMap(); |
| | | |
| | | /** |
| | | * 查询单兵端申请查看指挥端位置或三一车辆位置 |
| | |
| | | result.put("SYCars",resultSYCarsPosition); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public int approvalCheckPosition(String commanderId, Map<String, String> para) { |
| | | String applicationType = para.get("applicationType"); |
| | | String soilderId = para.get("soilderId"); |
| | | String state = para.get("state"); |
| | | String begin = ""; |
| | | if(state.equals("1")){//state为1,即同意 |
| | | begin = String.valueOf(new Date().getTime());//设置开始时间 |
| | | int result = ardAppApplicationMapper.updateArdAppApplicationBeginByCommanderIdAndSoilderIdAndType(commanderId,soilderId,applicationType,begin,state); |
| | | String key = commanderId + "," + soilderId + "," + applicationType; |
| | | Thread thread = new Thread(key){//创建线程计时24小时 |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | Thread.sleep(24*60*60*1000); |
| | | //Thread.sleep(3*60*1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | return; |
| | | } |
| | | Thread currentThread = Thread.currentThread(); |
| | | String state = "000";//state为000,即超时 |
| | | String commanderId = currentThread.getName().split(",")[0]; |
| | | String soilderId = currentThread.getName().split(",")[1]; |
| | | String applicationType = currentThread.getName().split(",")[2]; |
| | | int result = ardAppApplicationMapper.updateArdAppApplicationBeginByCommanderIdAndSoilderIdAndType(commanderId,soilderId,applicationType,"",state); |
| | | threadMap.remove(currentThread.getName()); |
| | | } |
| | | }; |
| | | thread.start(); |
| | | this.threadMap.put(key,thread); |
| | | return result; |
| | | }else if(state.equals("-1")){//state为1,即驳回 |
| | | int result = ardAppApplicationMapper.updateArdAppApplicationBeginByCommanderIdAndSoilderIdAndType(commanderId,soilderId,applicationType,"",state); |
| | | return result; |
| | | }else if(state.equals("00")){//state为00,即撤销 |
| | | String key = commanderId + "," + soilderId + "," + applicationType; |
| | | try{ |
| | | this.threadMap.get(key).interrupt();//撤销后线程销毁 |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | this.threadMap.remove(key); |
| | | int result = ardAppApplicationMapper.updateArdAppApplicationBeginByCommanderIdAndSoilderIdAndType(commanderId,soilderId,applicationType,"",state); |
| | | return result; |
| | | } |
| | | return 0; |
| | | } |
| | | } |