Commit c66fbaf2 by huluobin

update

parent 4fbcd402
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
<commons.fileupload>1.3.1</commons.fileupload> <commons.fileupload>1.3.1</commons.fileupload>
<commons.io>2.4</commons.io> <commons.io>2.4</commons.io>
<commons-lang3.verson>3.10</commons-lang3.verson> <commons-lang3.verson>3.10</commons-lang3.verson>
<qiniu-java-sdk.version>[7.2.0, 7.2.99]</qiniu-java-sdk.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -140,19 +142,19 @@ ...@@ -140,19 +142,19 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<!-- <exclusions>--> <!-- <exclusions>-->
<!-- <exclusion>--> <!-- <exclusion>-->
<!-- <groupId>org.springframework.boot</groupId>--> <!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>--> <!-- <artifactId>spring-boot-starter-tomcat</artifactId>-->
<!-- </exclusion>--> <!-- </exclusion>-->
<!-- </exclusions>--> <!-- </exclusions>-->
</dependency> </dependency>
<!-- &lt;!&ndash;undertow servlet 容器&ndash;&gt;--> <!-- &lt;!&ndash;undertow servlet 容器&ndash;&gt;-->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>--> <!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-undertow</artifactId>--> <!-- <artifactId>spring-boot-starter-undertow</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<!--mp 增加Mybatis--> <!--mp 增加Mybatis-->
<dependency> <dependency>
...@@ -166,6 +168,13 @@ ...@@ -166,6 +168,13 @@
<artifactId>mybatis-plus-generator</artifactId> <artifactId>mybatis-plus-generator</artifactId>
</dependency> </dependency>
<!--七牛云文档-->
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>${qiniu-java-sdk.version}</version>
</dependency>
<!--freemarker作为模板--> <!--freemarker作为模板-->
<dependency> <dependency>
<groupId>org.freemarker</groupId> <groupId>org.freemarker</groupId>
......
...@@ -325,26 +325,25 @@ public abstract class AbstractCostService implements CostService { ...@@ -325,26 +325,25 @@ public abstract class AbstractCostService implements CostService {
// 费用单状态改为审核驳回,添加驳回理由 // 费用单状态改为审核驳回,添加驳回理由
// 修复驳回后提交出现费用单已存在的问题 // 修复驳回后提交出现费用单已存在的问题
// 将后缀添加到 detail_key 字段 // 将后缀添加到 detail_key 字段
CostDomain oldCost = this.getCostByCostNo(costCashiercallbackDomain.getCostNo()); CostDomain cost = this.getCostByCostNo(costCashiercallbackDomain.getCostNo());
String oldDetailKey = oldCost.getDetailKey(); String oldDetailKey = cost.getDetailKey();
CostDomain costDomain = new CostDomain();
costDomain.setId(oldCost.getId());
if (null != oldDetailKey && oldDetailKey.contains("-")) { if (null != oldDetailKey && oldDetailKey.contains("-")) {
String[] split = oldDetailKey.split("-"); String[] split = oldDetailKey.split("-");
if (split.length > 1) { if (split.length > 1) {
int i = Integer.parseInt(split[1]) + 1; int i = Integer.parseInt(split[1]) + 1;
costDomain.setDetailKey(split[0] + "-" + i); cost.setDetailKey(split[0] + "-" + i);
} }
} else { } else {
costDomain.setDetailKey(oldCost.getCostNo() + "-" + 1); cost.setDetailKey(cost.getCostNo() + "-" + 1);
} }
costDomain.setRejectReason(costCashiercallbackDomain.getPaynote()); cost.setRejectReason(costCashiercallbackDomain.getPaynote());
costDomain.setCostStatus(3); cost.setCostStatus(3);
costDomain.setRejectType(2); cost.setRejectType(2);
this.updateById(costDomain); this.updateById(cost);
log.info("出纳驳回,费用单状态更改成功" + costCashiercallbackDomain); log.info("出纳驳回,费用单状态更改成功" + costCashiercallbackDomain);
costLogService.save(costDomain.getCostNo(), costCashiercallbackDomain.getPayuserid(), "被出纳驳回:" + costCashiercallbackDomain.getPaynote()); costLogService.save(cost.getCostNo(), costCashiercallbackDomain.getPayuserid(), "被出纳驳回:" + costCashiercallbackDomain.getPaynote());
} }
void cashierCallbackPass(CostCashiercallbackDomain costCashiercallbackDomain) { void cashierCallbackPass(CostCashiercallbackDomain costCashiercallbackDomain) {
......
package com.blt.other.module.cost.utils; package com.blt.other.module.cost.utils;
import com.bailuntec.common.JsonUtilByFsJson;
import com.bailuntec.common.StringUtils;
import com.bailuntec.common.exception.BizException;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.blt.other.common.util.PathUtil;
import com.qiniu.common.QiniuException;
import com.qiniu.common.Zone;
import com.qiniu.http.Response;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.UploadManager;
import com.qiniu.storage.model.DefaultPutRet;
import com.qiniu.util.Auth;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.UUID; import java.util.UUID;
/** /**
...@@ -48,7 +63,7 @@ public class CostFileUtil { ...@@ -48,7 +63,7 @@ public class CostFileUtil {
File dest = new File(fileName); File dest = new File(fileName);
// 创建路径 // 创建路径
if (!dest.exists()) { //文件不存在则创建文件,先创建目录 if (!dest.exists()) { //文件不存在则创建文件,先创建目录
File dir = new File(dest.getParent()); File dir = new File(dest.getParent());
dir.mkdirs(); dir.mkdirs();
dest.createNewFile(); dest.createNewFile();
...@@ -63,4 +78,58 @@ public class CostFileUtil { ...@@ -63,4 +78,58 @@ public class CostFileUtil {
} }
public String saveImage(MultipartFile multipartFile) throws IOException {
//临时文件地址
String basePath = PathUtil.getBasePath() + PathUtil.getPath("cost/");
//文件名
String fileName = multipartFile.getOriginalFilename();
if (StringUtils.isEmpty(fileName)) {
throw new BizException("上传文件为空,请重新上传");
}
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
String localFileName = IdWorker.getId() + fileSuffix;
String filePath = basePath + File.separator + localFileName;
File localFile = new File(filePath);
File imagePath = new File(basePath);
if (!imagePath.exists()) {
boolean ignore = imagePath.mkdirs();
}
multipartFile.transferTo(localFile);
return qiniuUpload(localFile);
}
public String qiniuUpload(File localFilePath) {
//1、构造一个带指定Zone对象的配置类
Configuration cfg = new Configuration(Zone.zone2());
//2、其他参数参考类注释
UploadManager uploadManager = new UploadManager(cfg);
//3、生成上传凭证,然后准备上传
String accessKey = "RWQXlbVA7oe3BxnPuFtqkAJocQZkWTwrwYyldklr";
String secretKey = "tS2gxsQO26mGoFZJI-x8WSH9X5aPgYMJcyoJdak5";
String bucket = "begogirls";
//默认不指定key的情况下,以文件内容的hash值作为文件名
String key = null;
Auth auth = Auth.create(accessKey, secretKey);
String upToken = auth.uploadToken(bucket);
try {
Response response = uploadManager.put(localFilePath, key, upToken);
//4、解析上传成功的结果
DefaultPutRet putRet = JsonUtilByFsJson.jsonToBean(response.bodyString(), DefaultPutRet.class);
System.out.println(putRet.key);
System.out.println(putRet.hash);
return putRet.key;
} catch (QiniuException ex) {
Response r = ex.response;
System.err.println(r.toString());
try {
System.err.println(r.bodyString());
} catch (QiniuException ex2) {
//ignore
}
return null;
}
}
} }
...@@ -5,6 +5,7 @@ import com.bailuntec.api.bailuntec.oa.OaApi; ...@@ -5,6 +5,7 @@ import com.bailuntec.api.bailuntec.oa.OaApi;
import com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp; import com.bailuntec.api.bailuntec.oa.response.OaDepartmentResp;
import com.bailuntec.api.bailuntec.oa.response.OaUserResp; import com.bailuntec.api.bailuntec.oa.response.OaUserResp;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.blt.other.module.auth.dao.OaDepartmentMapper;
import com.blt.other.module.auth.model.OaDepartment; import com.blt.other.module.auth.model.OaDepartment;
import com.blt.other.module.auth.model.OaUser; import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.auth.service.IOaDepartmentService; import com.blt.other.module.auth.service.IOaDepartmentService;
...@@ -25,7 +26,7 @@ import java.util.stream.Collectors; ...@@ -25,7 +26,7 @@ import java.util.stream.Collectors;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = OtherApplication.class) @SpringBootTest(classes = OtherApplication.class)
@ActiveProfiles("test") @ActiveProfiles("prod")
public class OtherApplicationTests { public class OtherApplicationTests {
@Autowired @Autowired
...@@ -34,6 +35,8 @@ public class OtherApplicationTests { ...@@ -34,6 +35,8 @@ public class OtherApplicationTests {
private IOaUserService oaUserService; private IOaUserService oaUserService;
@Autowired @Autowired
private IOaDepartmentService oaDepartmentService; private IOaDepartmentService oaDepartmentService;
@Resource
OaDepartmentMapper oaDepartmentMapper;
// @Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
@Test @Test
...@@ -77,7 +80,13 @@ public class OtherApplicationTests { ...@@ -77,7 +80,13 @@ public class OtherApplicationTests {
oaUserService.remove(new LambdaQueryWrapper<>()); oaUserService.remove(new LambdaQueryWrapper<>());
oaUserService.saveBatch(oaUserList); oaUserService.saveBatch(oaUserList);
// oaDepartmentService.saveBatch(oaDepartmentList);
oaDepartmentList.forEach(oaDepartment -> {
if (oaDepartmentMapper.selectByDepartmentId(oaDepartment.getDepartmentId())==null){
oaDepartment.setUpdateUserId(0);
oaDepartmentService.save(oaDepartment);
}
});
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment