|
|
@@ -16,6 +16,7 @@ import com.template.common.utils.*;
|
|
|
import com.template.config.ControlConfig;
|
|
|
import com.template.config.ParkConfig;
|
|
|
import com.template.config.SeewoConfig;
|
|
|
+import com.template.model.dto.ParentsScreenDto;
|
|
|
import com.template.model.enumModel.*;
|
|
|
import com.template.model.pojo.*;
|
|
|
import com.template.model.request.otherAppointmentRequest;
|
|
|
@@ -40,6 +41,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -317,7 +320,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
|
|
|
boolean result = smartVisitorService.insertVisitorBatch(svs);
|
|
|
|
|
|
- return result ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.fail("预约失败");
|
|
|
+ return result ? CommonResult.ok("预约成功") : CommonResult.fail("预约失败");
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -823,6 +826,125 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
return CommonResult.ok("审核成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CommonResult parentsScreen(ParentsScreenDto par, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ String st = paramUtils.getParamError(bindingResult);
|
|
|
+ return CommonResult.fail(st);
|
|
|
+ }
|
|
|
+
|
|
|
+ //参数判断 判断受访学生信息是否为空
|
|
|
+ if (par.getStudents() == null) {
|
|
|
+ return CommonResult.fail("请选择受访学生");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (par.getStudents().size() <= 0) {
|
|
|
+ return CommonResult.fail("请选择受访学生");
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据用户ID查询相关信息
|
|
|
+ SmartUser su = smartUserService.getSmartById(par.getUserId());
|
|
|
+ if (su == null) {
|
|
|
+ return CommonResult.fail("当前用户信息不合法,无法进行预约!");
|
|
|
+ }
|
|
|
+ DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ LocalDateTime date = LocalDateTime.now();
|
|
|
+ String startTime = date.format(dateTimeFormatter1);
|
|
|
+
|
|
|
+ String endTime = TimeExchange.getEndOfDayStr(TimeExchange.StringToDate(startTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+
|
|
|
+ //要进行家长数据重复判断
|
|
|
+ //那是不是第二次预约的时间不能在那个可访问的时间段内
|
|
|
+ //例如:比如,第一次约了7:00-10:00;那第二次:6:00-7:30 或 8:11-13:00都不行
|
|
|
+ Integer count = smartVisitorService.queryVisitorCount(su.getIdCard(), startTime, endTime);
|
|
|
+ if (count > 0) {
|
|
|
+ return CommonResult.fail("该时间段已预约,请勿重复预约!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartVisitor> svs = new ArrayList<>();
|
|
|
+ for (AffiliateUserVo student : par.getStudents()) {
|
|
|
+ SmartVisitor sv = new SmartVisitor();
|
|
|
+ sv.setUserId(par.getUserId());
|
|
|
+ sv.setUserName(su.getName());
|
|
|
+ sv.setUserPhone(su.getPhone());
|
|
|
+ sv.setUserNumber(su.getIdCard());
|
|
|
+ sv.setPeerNum(0);
|
|
|
+ sv.setVisitReason(par.getVisitReason());
|
|
|
+// sv.setStatu(eApproveStatu.Audit.getValue());
|
|
|
+ sv.setVisitorTime(TimeExchange.StringToDate(startTime, "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ sv.setVisitorDeadline(TimeExchange.StringToDate(TimeExchange.AddTimeDesH(sv.getVisitorTime(), 4), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ sv.setRespondent(student.getId());
|
|
|
+ sv.setResponcode(student.getCardNo());
|
|
|
+ sv.setRespondentName(student.getName());
|
|
|
+ //将第一个受访学生的部门ID带过去
|
|
|
+ sv.setDepartmentId(student.getDepartmentId());
|
|
|
+ sv.setVisitorType(eVisitorType.Parent.getValue());
|
|
|
+
|
|
|
+ // 获取受访者id
|
|
|
+ Integer respondent = sv.getRespondent();
|
|
|
+ SmartUser smartUser = smartUserService.getById(respondent);
|
|
|
+ Integer schoolClass = smartUser.getSchoolClass();
|
|
|
+ SmartVisitorParentsConfig svpc = smartVisitorParentsConfigService.getById(schoolClass);
|
|
|
+ Integer screenAuditConfig = svpc.getScreenAuditConfig();
|
|
|
+ if (1 == screenAuditConfig) {//需要审核
|
|
|
+ sv.setStatu(1);
|
|
|
+ } else {//不需要审核
|
|
|
+ Integer screenPushConfig = svpc.getScreenPushConfig();
|
|
|
+// 判断是否需要推送
|
|
|
+ if (5 == screenPushConfig) {//需要推送
|
|
|
+ String content = sv.getRespondentName() + "你的家长将于" + TimeExchange.chineseDateTime(sv.getVisitorTime()) + "到校!";
|
|
|
+ //将预约信息推送到希沃班牌
|
|
|
+ CommonResult seewo = pushInfo(sv.getUserPhone(), sv.getResponcode(), content);
|
|
|
+ }
|
|
|
+// 核销
|
|
|
+ Integer screenCancelConfig = svpc.getScreenCancelConfig();
|
|
|
+ if (6 == screenCancelConfig) {//需要核销
|
|
|
+ sv.setStatu(7);
|
|
|
+ } else {//不需要核销
|
|
|
+ sv.setStatu(9);
|
|
|
+ }
|
|
|
+// 门禁配置
|
|
|
+ Integer accessConfig = svpc.getAccessConfig();
|
|
|
+ if (0 == accessConfig) {
|
|
|
+ try {
|
|
|
+ List<SmartDevice> devices = smartDeviceService.queryOnLineDevice();
|
|
|
+ String visitorNo = getUUIDBits(16);
|
|
|
+ //region 将访客数据下发到设备
|
|
|
+ for (SmartDevice device : devices) {
|
|
|
+ CommonResult<String> insertVisitor = bsInsertVisitor(su, TimeExchange.DateToString(sv.getVisitorTime()), TimeExchange.DateToString(sv.getVisitorDeadline()), device.getNum(), visitorNo);
|
|
|
+ if (!insertVisitor.isSuccess()) {
|
|
|
+ throw new Exception(insertVisitor.getMessage());
|
|
|
+ }
|
|
|
+ sv.setVisitorsync(sv.getVisitorsync() == null ? insertVisitor.getData() : (sv.getVisitorsync() + "," + insertVisitor.getData()));
|
|
|
+ sv.setDeviceNum(sv.getDeviceNum() == null ? device.getNum() : (sv.getDeviceNum() + "," + device.getNum()));
|
|
|
+ }
|
|
|
+ String code = GetVertifyCode.getRandomNumCode(6);
|
|
|
+ sv.setVisitorCode(code);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ svs.add(sv);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ boolean result = smartVisitorService.insertVisitorBatch(svs);
|
|
|
+
|
|
|
+ return result ? CommonResult.ok("预约成功") : CommonResult.fail("预约失败");
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult getScreenPage(int currentPage, int pageCount, String phone,String status) {
|
|
|
+ PageUtils<SmartVisitorScreenVo> page = smartVisitorService.getScreenPage(currentPage, pageCount,phone,status);
|
|
|
+
|
|
|
+ return CommonResult.ok(page);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 1、学生请假:
|
|
|
* 我们这边调用请假接口之后,把请假数据写到了百胜系统的"学生请假登记"页面中,那到时候学生是通过任意设备都能进出吗?
|