Commit 6458b900 authored by zhangzhenbang's avatar zhangzhenbang

suo

parent ece384c1
......@@ -3,6 +3,8 @@ package com.yingxin.beijingvehicleflow.controller;
import com.yingxin.beijingvehicleflow.entity.FloatingPopulation;
import com.yingxin.beijingvehicleflow.response.Response;
import com.yingxin.beijingvehicleflow.service.FloatingPopulationServcie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -22,21 +24,19 @@ import java.util.Date;
@RequestMapping("/bjapi/v1")
public class FloatingPopulationController {
private static Logger LOGGER = LoggerFactory.getLogger(FloatingPopulationController.class);
@Autowired
private FloatingPopulationServcie populationServcie;
@PostMapping("/float-population")
public Response checkFloatingPopulation(@RequestBody FloatingPopulation floatingPopulation) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
floatingPopulation.setCheckTime(sdf.format(new Date()));
FloatingPopulation selectResult = populationServcie.selectOneByReservationId(floatingPopulation);
floatingPopulation.setAuthCoordinate(selectResult.getAuthCoordinate());
floatingPopulation.setAuthTime(selectResult.getAuthTime());
floatingPopulation.setSubmitCoordinate(selectResult.getSubmitCoordinate());
floatingPopulation.setSubmitTime(selectResult.getSubmitTime());
return populationServcie.isInsertFloatingPopulationSucc(floatingPopulation)?Response.succ():Response.fail();
try {
return populationServcie.checkFloatingPopulation(floatingPopulation);
} catch (Exception e) {
LOGGER.error("防疫人员扫码异常:", e);
return Response.fail("UNKNOWN-ERROR","服务繁忙,请稍后重试。");
}
}
......
......@@ -43,7 +43,10 @@ public interface ReservationMapper {
@Select("select * from reservation where verify_state=0 and identity_id=#{id}")
List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info);
@Update("update reservation set verify_state=1")
@Update("update reservation set verify_state=1 where verify_state=0")
int updateAllVerifyState();
@Update("update reservation set verify_state = 3 where id = #{id}")
int updateVerifyStateById(int id);
}
package com.yingxin.beijingvehicleflow.service;
import com.yingxin.beijingvehicleflow.entity.FloatingPopulation;
import com.yingxin.beijingvehicleflow.response.Response;
/**
* description //TODO
......@@ -11,6 +12,8 @@ import com.yingxin.beijingvehicleflow.entity.FloatingPopulation;
*/
public interface FloatingPopulationServcie {
Response checkFloatingPopulation(FloatingPopulation floatingPopulation) throws Exception;
boolean isInsertFloatingPopulationSucc(FloatingPopulation floatingPopulation);
FloatingPopulation selectOneByReservationId(FloatingPopulation floatingPopulation);
......
......@@ -25,4 +25,5 @@ public interface ReservationService {
List<Reservation> selectNotVerifyReservatinsByIdentityId(IdentityInformation info);
int updateAllVerifyState();
}
package com.yingxin.beijingvehicleflow.service.impl;
import com.yingxin.beijingvehicleflow.entity.FloatingPopulation;
import com.yingxin.beijingvehicleflow.entity.Reservation;
import com.yingxin.beijingvehicleflow.mapper.FloatingPopulationMapper;
import com.yingxin.beijingvehicleflow.mapper.ReservationMapper;
import com.yingxin.beijingvehicleflow.response.Response;
import com.yingxin.beijingvehicleflow.service.FloatingPopulationServcie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -28,11 +32,37 @@ public class FloatingPopulationServcieImpl implements FloatingPopulationServcie
@Autowired
private FloatingPopulationMapper populationMapper;
@Autowired
private ReservationMapper reservationMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Response checkFloatingPopulation(FloatingPopulation floatingPopulation) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
floatingPopulation.setCheckTime(sdf.format(new Date()));
FloatingPopulation selectResult = selectOneByReservationId(floatingPopulation);
floatingPopulation.setAuthCoordinate(selectResult.getAuthCoordinate());
floatingPopulation.setAuthTime(selectResult.getAuthTime());
floatingPopulation.setSubmitCoordinate(selectResult.getSubmitCoordinate());
floatingPopulation.setSubmitTime(selectResult.getSubmitTime());
if (populationMapper.insertFloatingPopulation(floatingPopulation) == 1) {
if (reservationMapper.updateVerifyStateById(floatingPopulation.getReservationId()) == 1) {
return Response.succ();
}
}
throw new Exception();
}
@Override
public boolean isInsertFloatingPopulationSucc(FloatingPopulation floatingPopulation) {
try {
return populationMapper.insertFloatingPopulation(floatingPopulation) == 1;
} catch (Exception e) {
LOGGER.error("流动人员数据库录入异常:", e);
return false;
}
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment