|
@@ -17,6 +17,7 @@ import org.jeecg.ctop.finance.settlement.mapper.SettlementInfoMapper;
|
|
|
import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
|
|
|
import org.jeecg.ctop.finance.settlement.service.ISettlementFileInfoService;
|
|
|
import org.jeecg.ctop.finance.utils.SettlementUtil;
|
|
|
+import org.jeecg.ctop.finance.utils.createExcelByTemplate;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -24,6 +25,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
@@ -163,21 +167,31 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Result insertAccountImages(CtopCwjsSettlementFileInfo settlementFileInfo) {
|
|
|
-
|
|
|
- for (CtopCwjsSettlementFileInfo settlement : settlementFileInfo.getSettlementList()) {
|
|
|
-
|
|
|
- settlement.setAccountId(SettlementUtil.subAccountName(settlement.getFileName()));
|
|
|
-
|
|
|
- /* Map<String,String> map = settlementFileInfoMapper.getSettlementAccount(settlement.getAccountId(),String.valueOf(settlementFileInfo.getMediaId()));
|
|
|
- if (Check.isNull(map)){
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- return Result.errorMsg("无法查询到账户【"+settlement.getAccountId()+"】信息,请到账户列表上传正确的账户信息");
|
|
|
- }*/
|
|
|
- BeanUtils.copyProperties(settlementFileInfo,settlement,SettlementUtil.getNullPropertyNames(settlementFileInfo));
|
|
|
- settlementFileInfoMapper.insert(settlement);
|
|
|
+ public Result insertAccountImages(CtopCwjsSettlementFileInfo settlementFileInfo){
|
|
|
+ try {
|
|
|
+ for (CtopCwjsSettlementFileInfo settlement : settlementFileInfo.getSettlementList()) {
|
|
|
+ settlement.setAccountId(SettlementUtil.subAccountName(settlement.getFileName()));
|
|
|
+
|
|
|
+ //TODO 上传图片判断 是否可以正常读取 width 和 high 如果不能读取 则上传失败 否则在下载结算单的时候会出错
|
|
|
+ InputStream is = createExcelByTemplate.getInputStreamByUrl(settlement.getFileUrl());
|
|
|
+ BufferedImage bufferImg = ImageIO.read(is);
|
|
|
+ if (Check.isNull(bufferImg) || bufferImg.getWidth() < 0 || bufferImg.getHeight() < 0){
|
|
|
+ return Result.errorMsg("【"+settlement.getFileName()+"】该文件不符合规范,请上传正确的账户截图文件。");
|
|
|
+ }
|
|
|
+ /* Map<String,String> map = settlementFileInfoMapper.getSettlementAccount(settlement.getAccountId(),String.valueOf(settlementFileInfo.getMediaId()));
|
|
|
+ if (Check.isNull(map)){
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return Result.errorMsg("无法查询到账户【"+settlement.getAccountId()+"】信息,请到账户列表上传正确的账户信息");
|
|
|
+ }*/
|
|
|
+
|
|
|
+ BeanUtils.copyProperties(settlementFileInfo,settlement,SettlementUtil.getNullPropertyNames(settlementFileInfo));
|
|
|
+ settlementFileInfoMapper.insert(settlement);
|
|
|
+ return Result.successMsg("账户截图上传成功",null);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- return Result.successMsg("账户截图上传成功",null);
|
|
|
+ return Result.errorMsg("上传失败。");
|
|
|
}
|
|
|
|
|
|
@Autowired
|