Merge pull request '临时身份证自助补办机接口' (#5) from zzw-one into master

Reviewed-on: #5
This commit is contained in:
root 2024-08-19 15:40:59 +08:00
commit 03d8f3134e
6 changed files with 104 additions and 0 deletions

View File

@ -41,4 +41,6 @@ public class AssetRespVO {
@ExcelProperty("最后一次反馈时间") @ExcelProperty("最后一次反馈时间")
private Long lastfeedbacktime; private Long lastfeedbacktime;
private Long personCount;
} }

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.datacenter.controller.admin.ticssrMachine;
import cn.iocoder.yudao.module.datacenter.controller.admin.asset.vo.AssetRespVO;
import cn.iocoder.yudao.module.datacenter.service.asset.AssetService;
import cn.iocoder.yudao.module.datacenter.service.passengerInformation.PassengerInformationService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Description 临时身份证自助补办机
*/
@Tag(name = "大屏服务 - 临时身份证自助补办机")
@RestController
@RequestMapping("/datacenter/ticssrMachine")
@Validated
public class TicssrMachineApi {
@Autowired
private AssetService assetService;
@Autowired
private PassengerInformationService passengerInformationService;
@GetMapping("/temporaryIDCardMessage")
public List<AssetRespVO> temporaryIDCardMessage(){
List<AssetRespVO> list = assetService.nameAsset("临时身份证补办机");
for (AssetRespVO assetRespVO : list) {
Long personCount = passengerInformationService.personCount(assetRespVO.getDataId());
assetRespVO.setPersonCount(personCount);
}
return list;
}
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.datacenter.dal.dataobject.passengerInformation;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
@Document("passengerInformation")
@Data
public class PassengerInformation {
//编号
private String id;
//设备id
private String deviceId;
//旅客姓名
private String name;
//旅客身份证
private String idCard;
//提交时间
private String commitTime;
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.datacenter.dal.mongodb.passengerInformation;
import cn.iocoder.yudao.module.datacenter.dal.dataobject.passengerInformation.PassengerInformation;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface PassengerInformationRepository extends MongoRepository<PassengerInformation,String> {
@Query("{ 'commitTime': { $regex: ?0 }, 'deviceId': ?1 }")
List countAllByDeviceId(String regex, String deviceId);
}

View File

@ -0,0 +1,5 @@
package cn.iocoder.yudao.module.datacenter.service.passengerInformation;
public interface PassengerInformationService {
public Long personCount(String deviceId);
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.datacenter.service.passengerInformation;
import cn.iocoder.yudao.module.datacenter.dal.mongodb.passengerInformation.PassengerInformationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@Service
@Validated
public class PassengerInformationServiceImpl implements PassengerInformationService{
@Autowired
private PassengerInformationRepository passengerInformationRepository;
@Override
public Long personCount(String deviceId) {
// 获取今天的日期字符串格式为 "yyyy-MM-dd"
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
String todayDate = dateFormat.format(calendar.getTime());
// 构造正则表达式以匹配今天的日期
String regex = "^" + todayDate;
return Long.parseLong(passengerInformationRepository.countAllByDeviceId(regex,deviceId).size()+"");
}
}