|
|
@@ -2,20 +2,34 @@ package com.template.controller;
|
|
|
|
|
|
|
|
|
import com.template.api.SmartVisitorControllerAPI;
|
|
|
+import com.template.common.utils.TimeExchange;
|
|
|
import com.template.common.utils.paramUtils;
|
|
|
+import com.template.model.enumModel.eApproveStatu;
|
|
|
+import com.template.model.enumModel.eVisitorType;
|
|
|
+import com.template.model.pojo.SmartUser;
|
|
|
import com.template.model.pojo.SmartVisitor;
|
|
|
+import com.template.model.request.otherAppointmentRequest;
|
|
|
+import com.template.model.request.parentsAppointmentRequest;
|
|
|
import com.template.model.result.CommonResult;
|
|
|
import com.template.model.result.PageUtils;
|
|
|
+import com.template.model.vo.AffiliateUserVo;
|
|
|
+import com.template.model.vo.VisitorPageVo;
|
|
|
+import com.template.services.SmartUserService;
|
|
|
import com.template.services.SmartVisitorService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 前端控制器
|
|
|
+ * 前端控制器
|
|
|
* </p>
|
|
|
*
|
|
|
* @author ceshi
|
|
|
@@ -27,9 +41,13 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
@Autowired
|
|
|
private SmartVisitorService smartVisitorService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SmartUserService smartUserService;
|
|
|
+
|
|
|
/**
|
|
|
* 新增访客预约
|
|
|
- * @param smartApply 访客预约数据
|
|
|
+ *
|
|
|
+ * @param smartApply 访客预约数据
|
|
|
* @param bindingResult
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -47,7 +65,8 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
|
|
|
/**
|
|
|
* 更新访客预约
|
|
|
- * @param sa 访客预约数据
|
|
|
+ *
|
|
|
+ * @param sa 访客预约数据
|
|
|
* @param bindingResult
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -64,9 +83,10 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
|
|
|
/**
|
|
|
* 访客预约分页数据查询
|
|
|
+ *
|
|
|
* @param currentPage 当前页数
|
|
|
- * @param pageCount 一页数据条数
|
|
|
- * @param name 查询名称
|
|
|
+ * @param pageCount 一页数据条数
|
|
|
+ * @param name 查询名称
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@@ -82,7 +102,7 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
|
|
|
SmartVisitor data = smartVisitorService.getSmartById(id);
|
|
|
|
|
|
- if(data == null){
|
|
|
+ if (data == null) {
|
|
|
return CommonResult.fail("当前数据不存在,删除失败!");
|
|
|
}
|
|
|
|
|
|
@@ -90,5 +110,90 @@ public class SmartVisitorController implements SmartVisitorControllerAPI {
|
|
|
|
|
|
return result > 0 ? CommonResult.ok("删除成功") : CommonResult.fail("删除失败");
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult parentsAppointment(parentsAppointmentRequest 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("当前用户信息不合法,无法进行预约!");
|
|
|
+ }
|
|
|
+
|
|
|
+ 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(par.getPeerNum());
|
|
|
+ sv.setCarNum(par.getCarNum());
|
|
|
+ sv.setVisitReason(par.getVisitReason());
|
|
|
+ sv.setStatu(eApproveStatu.Audit.getValue());
|
|
|
+ sv.setVisitorTime(TimeExchange.StringToDate(par.getVisitorTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ sv.setRespondent(student.getId());
|
|
|
+ //将第一个受访学生的部门ID带过去
|
|
|
+ sv.setDepartmentId(student.getDepartmentId());
|
|
|
+ sv.setVisitorType(eVisitorType.Parent.getValue());
|
|
|
+ svs.add(sv);
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean result = smartVisitorService.insertVisitorBatch(svs);
|
|
|
+
|
|
|
+ return result ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.fail("预约失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult otherAppointment(otherAppointmentRequest oar, BindingResult bindingResult) {
|
|
|
+ if (bindingResult.hasErrors()) {
|
|
|
+ String st = paramUtils.getParamError(bindingResult);
|
|
|
+ return CommonResult.fail(st);
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据用户ID查询相关信息
|
|
|
+ SmartUser su = smartUserService.getSmartById(oar.getUserId());
|
|
|
+ if (su == null) {
|
|
|
+ return CommonResult.fail("当前用户信息不合法,无法进行预约!");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartVisitor sv = new SmartVisitor();
|
|
|
+ sv.setUserId(oar.getUserId());
|
|
|
+ sv.setUserName(su.getName());
|
|
|
+ sv.setUserPhone(su.getPhone());
|
|
|
+ sv.setUserNumber(su.getIdCard());
|
|
|
+ sv.setPeerNum(oar.getPeerNum());
|
|
|
+ sv.setCarNum(oar.getCarNum());
|
|
|
+ sv.setVisitReason(oar.getVisitReason());
|
|
|
+ sv.setStatu(eApproveStatu.Audit.getValue());
|
|
|
+ sv.setVisitorTime(TimeExchange.StringToDate(oar.getVisitorTime(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ sv.setRespondentName(oar.getRespondentName());
|
|
|
+ sv.setRespondentPhone(oar.getRespondentPhone());
|
|
|
+ sv.setVisitorType(eVisitorType.Other.getValue());
|
|
|
+
|
|
|
+ int result = smartVisitorService.insertSmartVisitor(sv);
|
|
|
+
|
|
|
+ return result > 0 ? CommonResult.ok("预约成功,等待审批通过") : CommonResult.ok("预约失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CommonResult appointmentPageRecord(int currentPage,int pageCount, int userId, int type) {
|
|
|
+ PageUtils<VisitorPageVo> result = smartVisitorService.smartVisitorPageByUserId(currentPage, pageCount, userId, type);
|
|
|
+
|
|
|
+ return CommonResult.ok(result);
|
|
|
+ }
|
|
|
}
|
|
|
|