Commit 6458b900 authored by zhangzhenbang's avatar zhangzhenbang

suo

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