Commit 4e9e5aee by levphon

用户数据检测

1 parent f8f6bedc
package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.modules.model.param.DataSniffBO;
import cn.com.glsx.admin.modules.service.VehicleService;
import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping(value = "/data")
@Api(value = "业务数据", tags = {"业务数据"})
public class BusinessDataController {
@Autowired
private VehicleService vehicleService;
@SysLog
@ApiOperation(value = "数据检测")
@PostMapping(value = "/sniff")
public R sniff(@RequestParam @Validated DataSniffBO sniffBO) {
boolean flag = vehicleService.dataSniff(sniffBO);
return R.ok().data(flag);
}
}
...@@ -26,7 +26,7 @@ import java.util.List; ...@@ -26,7 +26,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping(value = "/commonteardown") @RequestMapping(value = "/commonteardown")
@Api(value = "通用拆除报警", tags = {"通用拆除报警"}) @Api(value = "通用拆除报警", tags = {"通用拆除报警"})
public class ConmonTearDownAlarmController extends AbstractController { public class CommonTearDownAlarmController extends AbstractController {
@Autowired @Autowired
private TearDownAlarmSevice tearDownAlarmSevice; private TearDownAlarmSevice tearDownAlarmSevice;
......
...@@ -366,4 +366,6 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> { ...@@ -366,4 +366,6 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
*/ */
int updateSettleFlagById(@Param("id") Long id, @Param("settleFlag") Integer settleFlag); int updateSettleFlagById(@Param("id") Long id, @Param("settleFlag") Integer settleFlag);
int countByUserId(@Param("userId") Long userId);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.admin.modules.model.param;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class DataSniffBO {
@NotNull(message = "用户ID不能为空")
private Long userId;
/**
* 数据类型:1车辆
*/
private List<Integer> types;
}
...@@ -74,6 +74,7 @@ import org.springframework.util.StopWatch; ...@@ -74,6 +74,7 @@ import org.springframework.util.StopWatch;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -2384,4 +2385,23 @@ public class VehicleService extends AbstractCommonService { ...@@ -2384,4 +2385,23 @@ public class VehicleService extends AbstractCommonService {
} }
} }
/**
* 用户数据检测
*
* @param sniffBO
* @return
*/
public boolean dataSniff(DataSniffBO sniffBO) {
if (CollectionUtils.isNotEmpty(sniffBO.getTypes())) {
AtomicInteger vehicleCnt = new AtomicInteger();
sniffBO.getTypes().forEach(type -> {
if (type == 1) {//车辆
vehicleCnt.set(vehicleMapper.countByUserId(sniffBO.getUserId()));
}
});
return vehicleCnt.get() <= 0;
}
return false;
}
} }
...@@ -1361,6 +1361,13 @@ ...@@ -1361,6 +1361,13 @@
order by tv.created_date desc order by tv.created_date desc
</select> </select>
<select id="countByUserId" resultType="java.lang.Integer">
select count(*)
from t_vehicle tv
where tv.del_flag = 0
and tv.created_by = #{userId}
</select>
<update id="updateSettleFlagById"> <update id="updateSettleFlagById">
update t_vehicle update t_vehicle
set settle_flag = #{settleFlag} set settle_flag = #{settleFlag}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!