|
@@ -2,12 +2,16 @@ package com.ruoyi.web.work.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
+import com.ruoyi.common.constant.CacheConstants;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.web.work.api.util.AppUtil;
|
|
|
import com.ruoyi.web.work.domain.Contract;
|
|
|
import com.ruoyi.web.work.domain.ContractDetail;
|
|
|
+import com.ruoyi.web.work.domain.Platform;
|
|
|
import com.ruoyi.web.work.domain.User;
|
|
|
import com.ruoyi.web.work.domain.dto.ContractDto;
|
|
|
import com.ruoyi.web.work.mapper.ContractMapper;
|
|
@@ -45,6 +49,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
@Autowired
|
|
|
IUserService userService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
@Override
|
|
|
public List<Contract> selectList(Contract contract) {
|
|
|
return contractMapper.selectList(contract);
|
|
@@ -69,7 +76,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
detail = new ContractDetail();
|
|
|
detail.setUserId(AppUtil.getUser().getId());
|
|
|
detail.setContractId(contract.getId());
|
|
|
- detail.setContractUrl(contract.getUrl());
|
|
|
detail.setUrl(dto.getUrl());
|
|
|
detail.setState(1);
|
|
|
if (!detailService.save(detail)) {
|
|
@@ -84,16 +90,21 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void look(HttpServletResponse response,Long userId) throws IOException {
|
|
|
- User user=userService.getById(userId);
|
|
|
- if(user==null){
|
|
|
+ public void look(HttpServletResponse response, Long userId) throws IOException {
|
|
|
+ Platform platform = redisCache.getCacheObject(CacheConstants.APP_PLATFORM);
|
|
|
+ User user = userService.getById(userId);
|
|
|
+ if (user == null) {
|
|
|
throw new ServerException("用户信息不存在");
|
|
|
}
|
|
|
ContractDetail detail = detailService.selectByUserId(userId);
|
|
|
if (detail == null) {
|
|
|
throw new ServerException("你还未签约");
|
|
|
}
|
|
|
- String contractPath = RuoYiConfig.getProfile() + StringUtils.substringAfter(RuoYiConfig.getProfile() + detail.getContractUrl(), Constants.RESOURCE_PREFIX);
|
|
|
+ Contract contract = getById(detail.getContractId());
|
|
|
+ if (contract == null) {
|
|
|
+ throw new ServerException("合同不存在");
|
|
|
+ }
|
|
|
+ String contractPath = RuoYiConfig.getProfile() + StringUtils.substringAfter(RuoYiConfig.getProfile() + contract.getUrl(), Constants.RESOURCE_PREFIX);
|
|
|
String imgPath = RuoYiConfig.getProfile() + StringUtils.substringAfter(RuoYiConfig.getProfile() + detail.getUrl(), Constants.RESOURCE_PREFIX);
|
|
|
// 加载文档
|
|
|
Document doc = new Document();
|
|
@@ -105,10 +116,16 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
// 调整图片大小和旋转角度
|
|
|
picture.setWidth(80); // 设置图片宽度
|
|
|
picture.setHeight(30); // 设置图片高度
|
|
|
+
|
|
|
// 查找并替换占位符
|
|
|
- doc.replace("${sfz}", user.getIdCard(), true, true);
|
|
|
+ doc.replace("${serviceCompany}", platform.getServiceCompany(), true, true);
|
|
|
+ doc.replace("${director}", platform.getDirector(), true, true);
|
|
|
+ doc.replace("${address}", platform.getAddress(), true, true);
|
|
|
+ doc.replace("${name}", user.getName(), true, true);
|
|
|
+ doc.replace("${idCard}", user.getIdCard(), true, true);
|
|
|
doc.replace("${phone}", user.getPhone(), true, true);
|
|
|
-
|
|
|
+ doc.replace("${address2}", user.getAddress(), true, true);
|
|
|
+ doc.replace("${date}", DateUtils.getDate(), true, true);
|
|
|
// 查找并替换占位符
|
|
|
TextSelection[] selections = doc.findAllString("${jiaSign}", true, true);
|
|
|
for (TextSelection selection : selections) {
|