Selaa lähdekoodia

车辆日志功能

xiao547607 4 vuotta sitten
vanhempi
commit
5d715f3bd6

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/VehicleInfoDAO.java

@@ -19,4 +19,6 @@ public interface VehicleInfoDAO {
     VehicleInfo findByCodeAndCarNum(String activationCode, String carNum);
 	VehicleInfo findByGpsDeviceNo(String gpsDeviceNo);
 	int updateGps(VehicleInfo entity);
+
+	VehicleInfo findByCarNum(String carNum);
 }

+ 3 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/VehicleInfoService.java

@@ -18,5 +18,8 @@ public interface VehicleInfoService {
     VehicleInfo findByCodeAndCarNum(String activationCode, String carNum);
 
 	VehicleInfo findByGpsDeviceNo(String deviceNo);
+
+	VehicleInfo findByCarNum(String carNum);
+
 	void updateGps(VehicleInfo v);
 }

+ 5 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/VehicleInfoServiceImpl.java

@@ -81,4 +81,9 @@ public class VehicleInfoServiceImpl implements VehicleInfoService {
 	public void updateGps(VehicleInfo v) {
 		vehicleInfoDAO.updateGps(v);
 	}
+
+	@Override
+	public VehicleInfo findByCarNum(String carNum){
+		return vehicleInfoDAO.findByCarNum(carNum);
+	}
 }

+ 6 - 0
common/src/main/resources/mapper/bus/VehicleInfo.xml

@@ -199,4 +199,10 @@
 		</set>
 		where id_=#{id}
 	</update>
+
+	<select id="findByCarNum" resultMap="VehicleInfoMap">
+		select * from bus_vehicle_info where del_flag=0 and license_plate_number=#{carNum}
+		order by create_time desc limit 1
+	</select>
+
 </mapper>

+ 1 - 1
common/src/main/resources/mapper/sys/SysLog.xml

@@ -58,7 +58,7 @@
         </set>
         where id_=#{id}
     </update>
-    <select id="get" parameterType="string" resultMap="SysLogMap">
+    <select id="get" parameterType="Long" resultMap="SysLogMap">
         select * from sys_log where id_=#{0}
     </select>
     <select id="exist" parameterType="string" resultType="int">

+ 65 - 0
web/src/main/java/com/jpsoft/bus/modules/bus/controller/VehicleInfoController.java

@@ -13,10 +13,13 @@ import com.jpsoft.bus.modules.bus.service.VehicleInfoService;
 import com.jpsoft.bus.modules.common.utils.OSSUtil;
 import com.jpsoft.bus.modules.common.utils.POIUtils;
 import com.jpsoft.bus.modules.common.utils.PojoUtils;
+import com.jpsoft.bus.modules.sys.entity.SysLog;
+import com.jpsoft.bus.modules.sys.service.SysLogService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -39,6 +42,7 @@ import java.util.*;
 @RestController
 @RequestMapping("/bus/vehicleInfo")
 @Api(description = "vehicleInfo")
+@Slf4j
 public class VehicleInfoController {
     private Logger logger = LoggerFactory.getLogger(getClass());
 
@@ -54,6 +58,9 @@ public class VehicleInfoController {
     @Autowired
     private GpsDataInfoService gpsDataInfoService;
 
+    @Autowired
+    private SysLogService sysLogService;
+
     @ApiOperation(value="创建空记录")
     @GetMapping("create")
     public MessageResult<VehicleInfo> create(){
@@ -408,4 +415,62 @@ public class VehicleInfoController {
 
         return messageResult;
     }
+
+    @ApiOperation(value="车辆信息一键绑定")
+    @RequestMapping(value = "bindBus",method = RequestMethod.POST)
+    public MessageResult<Map> bindBus(
+            @RequestParam(value="logId",defaultValue="") String logId,
+            @RequestAttribute String subject)throws Exception{
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+        try {
+
+            if (StringUtils.isEmpty(logId)) {
+                throw new Exception("未查到日志信息");
+            }
+
+            SysLog sysLog = sysLogService.get(Long.valueOf(logId));
+
+            if (sysLog == null) {
+                throw new Exception("未查到日志信息");
+            }
+
+
+            String sysData = sysLog.getData();
+            String[] data = sysData.split(",");
+            if (data.length > 2) {
+                //车牌号
+                String carNum = data[0];
+                //平板设备编号
+                String activationCode = data[1];
+                //设备编号
+                String deviceNo = data[2];
+                VehicleInfo vehicleInfo = vehicleInfoService.findByCarNum(carNum);
+                if (vehicleInfo == null) {
+                    throw new Exception("未查到车辆信息");
+                }
+
+                vehicleInfo.setActivationCode(activationCode);
+                vehicleInfo.setDeviceNo(deviceNo);
+                vehicleInfo.setUpdateBy(subject);
+                vehicleInfo.setUpdateTime(new Date());
+
+                vehicleInfoService.update(vehicleInfo);
+                msgResult.setResult(true);
+                msgResult.setMessage("绑定成功");
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("绑定失败");
+            }
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }

+ 77 - 0
web/src/main/java/com/jpsoft/bus/modules/sys/controller/LogController.java

@@ -126,4 +126,81 @@ public class LogController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="车辆日志列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId",value = "用户编号", paramType = "form"),
+            @ApiImplicitParam(name = "url",value = "url",  paramType = "form"),
+            @ApiImplicitParam(name = "remoteIP",value = "远程IP", paramType="form"),
+            @ApiImplicitParam(name = "startTime",value = "开始时间", paramType="form"),
+            @ApiImplicitParam(name = "endTime",value = "结束时间", paramType="form"),
+            @ApiImplicitParam(name = "elapseMin",value = "耗时大于(毫秒)", paramType="form"),
+            @ApiImplicitParam(name = "elapseMax",value = "耗时小于(毫秒)", paramType="form"),
+            @ApiImplicitParam(name = "pointcut",value = "切入口", paramType="form"),
+            @ApiImplicitParam(name = "remoteIP",value = "远程IP", paramType="form"),
+            @ApiImplicitParam(name = "remark",value = "备注", paramType="form")
+    })
+    @RequestMapping(value = "busList",method = RequestMethod.POST)
+    public MessageResult<Map> busList(
+            String userId,
+            String url,
+            String remoteIP,
+            Long elapseMin,
+            Long elapseMax,
+            String pointcut,
+            String remark,
+            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") Date startTime,
+            @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") Date endTime,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize){
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("create_time","desc"));
+
+        if (StringUtils.isNotEmpty(userId)) {
+            searchParams.put("userId",userId);
+        }
+
+        if (StringUtils.isNotEmpty(url)) {
+            searchParams.put("url",url + "%");
+        }
+
+        if (StringUtils.isNotEmpty(remoteIP)) {
+            searchParams.put("remoteIP",remoteIP + "%");
+        }
+
+        if (StringUtils.isNotEmpty(pointcut)) {
+            searchParams.put("pointcut",pointcut + "%");
+        }
+
+        if (startTime!=null) {
+            searchParams.put("startTime",startTime);
+        }
+
+        if (endTime!=null) {
+            searchParams.put("endTime",endTime);
+        }
+
+        if (elapseMin!=null){
+            searchParams.put("elapseMin",elapseMin);
+        }
+
+        if (elapseMax!=null){
+            searchParams.put("elapseMax",elapseMax);
+        }
+
+        if (StringUtils.isNotEmpty(remark)) {
+            searchParams.put("remark","%" + remark + "%");
+        }
+
+        Page<SysLog> page = sysLogService.pageSearch(searchParams,pageIndex,pageSize,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
 }