|
@@ -1,10 +1,31 @@
|
|
|
package com.yx.face.service.impl;
|
|
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.yx.face.boot.restful.RestDTO;
|
|
|
+import com.yx.face.boot.restful.RestResponse;
|
|
|
+import com.yx.face.boot.restful.RestResult;
|
|
|
+import com.yx.face.boot.restful.ServiceException;
|
|
|
+import com.yx.face.boot.uitls.SMSOrIdCardUtils;
|
|
|
import com.yx.face.dao.UserControlEarlyWarningListDao;
|
|
|
+import com.yx.face.model.dto.UserControlEarlyWarningDTO;
|
|
|
+import com.yx.face.model.dto.UserWhitelistDTO;
|
|
|
import com.yx.face.model.entity.UserControlEarlyWarningList;
|
|
|
+import com.yx.face.model.excel.UserControlEarlyWarningExcel;
|
|
|
+import com.yx.face.model.excel.UserWhitelistExcel;
|
|
|
+import com.yx.face.model.search.UserControlEarlyWarningSearch;
|
|
|
+import com.yx.face.model.vo.AdminVO;
|
|
|
+import com.yx.face.model.vo.FaceLogVO;
|
|
|
+import com.yx.face.model.vo.UserControlEarlyWarningVO;
|
|
|
+import com.yx.face.service.AdminService;
|
|
|
import com.yx.face.service.UserControlEarlyWarningListService;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 预警人员 服务实现类
|
|
@@ -16,4 +37,78 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class UserControlEarlyWarningListServiceImpl implements UserControlEarlyWarningListService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private UserControlEarlyWarningListDao userControlEarlyWarningListDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AdminService adminService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer addOrUpdate(UserControlEarlyWarningDTO userControlEarlyWarningDTO) {
|
|
|
+ if(!SMSOrIdCardUtils.isIdCard(userControlEarlyWarningDTO.getEarlyWarningIdNumber()))
|
|
|
+ throw new ServiceException("请输入正确的预警人员身份证号");
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ UserControlEarlyWarningList ucewl = new UserControlEarlyWarningList();
|
|
|
+ BeanUtils.copyProperties(userControlEarlyWarningDTO,ucewl);
|
|
|
+ ucewl.setUpdateTime(date);
|
|
|
+ if(userControlEarlyWarningDTO.getId() == null){
|
|
|
+ UserControlEarlyWarningList u = new UserControlEarlyWarningList();
|
|
|
+ u.setEarlyWarningIdNumber(userControlEarlyWarningDTO.getEarlyWarningIdNumber());
|
|
|
+ u.setAdminId(userControlEarlyWarningDTO.getAdminId());
|
|
|
+ UserControlEarlyWarningList userControlEarlyWarningList = userControlEarlyWarningListDao.selectOne(u);
|
|
|
+ if(userControlEarlyWarningList != null)throw new ServiceException("该预警人员已经添加到该账号下了");
|
|
|
+
|
|
|
+ ucewl.setCreateTime(date);
|
|
|
+ return userControlEarlyWarningListDao.insertSelective(ucewl);
|
|
|
+ }else {
|
|
|
+ UserControlEarlyWarningList userControlEarlyWarningList = userControlEarlyWarningListDao.selectByPrimaryKey(userControlEarlyWarningDTO.getId());
|
|
|
+ if(!userControlEarlyWarningList.getEarlyWarningIdNumber().equals(userControlEarlyWarningDTO.getEarlyWarningIdNumber()))
|
|
|
+ throw new ServiceException("预警人员身份照号不可修改");
|
|
|
+ ucewl.setId(userControlEarlyWarningDTO.getId());
|
|
|
+ return userControlEarlyWarningListDao.updateByPrimaryKeySelective(ucewl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RestResult<List<String>> userControlEarlyWarningListExcel(List<Object> datas,Integer adminId) {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ try {
|
|
|
+ UserControlEarlyWarningExcel ucewe = (UserControlEarlyWarningExcel) datas.get(i);
|
|
|
+ if (ucewe.getEarlyWarningIdNumber() == null) throw new ServiceException("第" + (i + 2) + "行,预警人员身份证号不能为空");
|
|
|
+
|
|
|
+ UserControlEarlyWarningDTO userControlEarlyWarningDTO = new UserControlEarlyWarningDTO();
|
|
|
+ BeanUtils.copyProperties(ucewe,userControlEarlyWarningDTO);
|
|
|
+ userControlEarlyWarningDTO.setAdminId(adminId);
|
|
|
+ try {
|
|
|
+ this.addOrUpdate(userControlEarlyWarningDTO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("第" + (i + 2) + "行," + e.getMessage());
|
|
|
+ }
|
|
|
+ } catch (ServiceException e) {
|
|
|
+ list.add(e.getMessage());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ datas.clear();//结束后销毁不用的资源
|
|
|
+ return RestResponse.ok(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer delete(Integer controlEarlyWarningId) {
|
|
|
+ return userControlEarlyWarningListDao.deleteByPrimaryKey(controlEarlyWarningId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<UserControlEarlyWarningVO> getPageList(RestDTO<UserControlEarlyWarningSearch> dto) {
|
|
|
+ AdminVO info = adminService.getInfo();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("adminVO", info);
|
|
|
+ map.put("query", dto.getData());
|
|
|
+
|
|
|
+ PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
|
|
+ List<UserControlEarlyWarningVO> list = userControlEarlyWarningListDao.getPageList(map);
|
|
|
+ return new PageInfo<>(list);
|
|
|
+ }
|
|
|
}
|