|
@@ -8,14 +8,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.bscommon.system.dao.QhseVisitorManagementDao;
|
|
|
import com.rongwei.bscommon.system.fegin.QhseAdminFeginService;
|
|
|
+import com.rongwei.bscommon.system.service.QhseVisitorManagementProcessService;
|
|
|
import com.rongwei.bscommon.system.service.QhseVisitorManagementService;
|
|
|
import com.rongwei.bscommon.system.utils.WordMergeHandler;
|
|
|
import com.rongwei.bscommon.system.utils.WordUtils;
|
|
|
import com.rongwei.bsentity.domain.QhseVisitorManagementDo;
|
|
|
+import com.rongwei.bsentity.dto.QhseVisitorManagementDto;
|
|
|
import com.rongwei.bsentity.vo.QhseVisitorManagementVo;
|
|
|
+import com.rongwei.rwadmincommon.system.domain.SysOrganizationDo;
|
|
|
+import com.rongwei.rwadmincommon.system.service.impl.SysOrganizationServiceImpl;
|
|
|
import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
-import com.rongwei.rwcommon.vo.generalsql.MasterSlaveInsertVo;
|
|
|
import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -28,9 +31,8 @@ import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.rongwei.bscommon.system.utils.QHSEConstant.FILE_SEPARATOR;
|
|
|
|
|
@@ -45,8 +47,6 @@ public class QhseVisitorManagementServiceImpl extends ServiceImpl<QhseVisitorMan
|
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
- @Autowired
|
|
|
- private QhseAdminFeginService qhseAdminFegin;
|
|
|
|
|
|
@Autowired
|
|
|
private QhseVisitorManagementDao qhseVisitorManagementDao;
|
|
@@ -54,22 +54,20 @@ public class QhseVisitorManagementServiceImpl extends ServiceImpl<QhseVisitorMan
|
|
|
@Autowired
|
|
|
private QhseVisitorManagementService qhseVisitorManagementService;
|
|
|
|
|
|
+
|
|
|
@Autowired
|
|
|
private FileFormatConversionServiceImpl fileFormatConversionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private QhseVisitorManagementProcessService qhseVisitorManagementProcessService;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private QHSEFileItemServiceImpl qhseFileItemServiceImpl;
|
|
|
|
|
|
- @Override
|
|
|
- public R generalMsInsert(MasterSlaveInsertVo masterSlaveInsert) {
|
|
|
- return qhseAdminFegin.generalMsInsert(masterSlaveInsert);
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ SysOrganizationServiceImpl sysOrganizationServicel;
|
|
|
|
|
|
- @Override
|
|
|
- public List<Map<String, String>> getUserByCodes(List<String> codes) {
|
|
|
- return qhseVisitorManagementDao.getUserByCodes(codes);
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 查询当天的手机号的访客纪录
|
|
@@ -83,37 +81,10 @@ public class QhseVisitorManagementServiceImpl extends ServiceImpl<QhseVisitorMan
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 根据身份证查询 改身份证是否在黑名单中
|
|
|
- * @param idNumber
|
|
|
- * @return
|
|
|
- */
|
|
|
- @Override
|
|
|
- public int getBlackListByIdNum(String idNumber) {
|
|
|
- return qhseVisitorManagementDao.getBlackListByIdNum(idNumber);
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void previewForAttachmentWithSignature(String signature, String fileId, String fileName,HttpServletResponse response) {
|
|
|
|
|
|
- SysFileItemDo tempDo = null;
|
|
|
- if(StringUtils.isBlank(fileId)){
|
|
|
- tempDo= qhseFileItemServiceImpl.getOne(new LambdaQueryWrapper<SysFileItemDo>().eq(SysFileItemDo::getFilename, fileName).eq(SysFileItemDo::getDeleted, "0"));
|
|
|
- }else {
|
|
|
- tempDo = fileFormatConversionService.fileCheck(fileId);
|
|
|
- }
|
|
|
-
|
|
|
- if (tempDo == null) {
|
|
|
- logger.error("无法根据id:{}获取到文件信息", fileId);
|
|
|
- throw new RuntimeException("无法获取到附件模板");
|
|
|
- }
|
|
|
-
|
|
|
- // 模板路径
|
|
|
- String tempFullpath = tempDo.getFullpath();
|
|
|
- if (StringUtils.isBlank(tempFullpath)) {
|
|
|
- logger.error("无法根据id:{}获取到文件信息", fileId);
|
|
|
- throw new RuntimeException("无法获取到附件模板");
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public void previewForAttachmentWithSignature(String signature, String url, HttpServletResponse response) {
|
|
|
|
|
|
String signatureId = signature.split(FILE_SEPARATOR)[1];
|
|
|
SysFileItemDo signatureDo = fileFormatConversionService.fileCheck(signatureId);
|
|
@@ -128,10 +99,10 @@ public class QhseVisitorManagementServiceImpl extends ServiceImpl<QhseVisitorMan
|
|
|
throw new RuntimeException("无法获取到签名");
|
|
|
}
|
|
|
|
|
|
- File file = new File(tempFullpath);
|
|
|
+ File file = new File(url);
|
|
|
|
|
|
|
|
|
- try (InputStream templateStream = Files.newInputStream(Paths.get(tempFullpath));
|
|
|
+ try (InputStream templateStream = Files.newInputStream(Paths.get(url));
|
|
|
OutputStream out = response.getOutputStream();) {
|
|
|
Document doc = new Document(templateStream);
|
|
|
// 设置邮件合并回调
|
|
@@ -149,7 +120,6 @@ public class QhseVisitorManagementServiceImpl extends ServiceImpl<QhseVisitorMan
|
|
|
// }
|
|
|
response.setContentType("application/pdf");
|
|
|
|
|
|
- response.setHeader("X-Content-Length", String.valueOf(tempDo.getFilesize()));
|
|
|
response.setHeader("X-Content-Length", String.valueOf( file.length()));
|
|
|
|
|
|
|
|
@@ -165,5 +135,91 @@ public class QhseVisitorManagementServiceImpl extends ServiceImpl<QhseVisitorMan
|
|
|
throw new RuntimeException("获取签名责任书失败!请联系系统管理员");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据身份证查询 改身份证是否在黑名单中
|
|
|
+ * @param idNumber
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int getBlackListByIdNum(String idNumber) {
|
|
|
+ return qhseVisitorManagementDao.getBlackListByIdNum(idNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 部门安全主管,部门经理,安监部抄送
|
|
|
+ */
|
|
|
+ private static final String[] CODES ={
|
|
|
+ "role103",
|
|
|
+ "role068",
|
|
|
+ "role084"
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据被访客部门 VISITEDDEPARTMENTID 查询对应的 部门安全主管,部门经理
|
|
|
+ * 查询安监部人员 塞入主表中
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R saveData(QhseVisitorManagementDto qhseVisitorManagementDto) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ QhseVisitorManagementDo qhseVisitorManagementDo = qhseVisitorManagementDto.getQhseVisitorManagementDo();
|
|
|
+ // //1.获取一级部门ID
|
|
|
+ String firstDeptId = getFitstDeptId(qhseVisitorManagementDo.getVisiteddepartmentid());
|
|
|
+
|
|
|
+ //2. 获取对应的部门安全主管,部门经理,安监部
|
|
|
+ List<Map<String, String>> userByCodes = qhseVisitorManagementDao.getUserByCodes(firstDeptId, CODES[0], CODES[1], CODES[2]);
|
|
|
+ userByCodes.forEach(map -> {
|
|
|
+ if ( map.get("code").equals(CODES[0])){
|
|
|
+ qhseVisitorManagementDo.setDepartmentsafesupervisorid( map.get("ids"));
|
|
|
+ qhseVisitorManagementDo.setDepartmentsafesupervisorname( map.get("names"));
|
|
|
+ };
|
|
|
+
|
|
|
+ if ( map.get("code").equals(CODES[1])){
|
|
|
+ qhseVisitorManagementDo.setDepartmentmanagerid( map.get("ids"));
|
|
|
+ qhseVisitorManagementDo.setDepartmentmanagername( map.get("names"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( map.get("code").equals(CODES[2])){
|
|
|
+ qhseVisitorManagementDo.setSafetysupervisiondepartmentid( map.get("ids"));
|
|
|
+ qhseVisitorManagementDo.setSafetysupervisiondepartmentname( map.get("names"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //4.保存
|
|
|
+ qhseVisitorManagementService.save(qhseVisitorManagementDo);
|
|
|
+ qhseVisitorManagementProcessService.saveBatch(qhseVisitorManagementDto.getProcessDos());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.error("保存失败原因: {} ", e.getMessage());
|
|
|
+ return R.error("保存失败,请联系管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取一级部门ID
|
|
|
+ * @param visiteddepartmentid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getFitstDeptId(String visiteddepartmentid){
|
|
|
+ SysOrganizationDo organizationDo = sysOrganizationServicel.getById(visiteddepartmentid);
|
|
|
+ if (organizationDo.getLevel() ==2 ){
|
|
|
+ return organizationDo.getId();
|
|
|
+ }else {
|
|
|
+ return organizationDo.getFullpid().split(",")[2];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|