Merge remote-tracking branch 'origin/test' into test

release
yefei 2 years ago
commit a20854be7c
  1. 304
      dxhy-base/src/main/java/com/dxhy/base/controller/BaseInvoiceController.java
  2. 86
      dxhy-base/src/main/java/com/dxhy/base/controller/BaseRzTDxRecordInvoiceController.java
  3. 2
      dxhy-base/src/main/java/com/dxhy/base/dao/BaseTDxRecordInvoiceDao.java
  4. 16
      dxhy-base/src/main/java/com/dxhy/base/entity/BaseReturnData.java
  5. 22
      dxhy-base/src/main/java/com/dxhy/base/entity/BaseReturnEntity.java
  6. 1
      dxhy-base/src/main/java/com/dxhy/base/model/BaseSggxCxRespVO.java
  7. 206
      dxhy-base/src/main/java/com/dxhy/base/service/invoicecheck/BaseInvoiceManualCheckServiceImpl.java
  8. 15
      dxhy-base/src/main/java/com/dxhy/base/service/tdxrecordinvoice/BaseRzTDxRecordInvoiceServiceImpl.java
  9. 4
      dxhy-base/src/main/resources/mapper/BaseFpZhMapper.xml
  10. 386
      dxhy-base/src/main/resources/mapper/BaseSggxcxMapper.xml
  11. 1
      dxhy-common/src/main/java/com/dxhy/common/service/impl/DictdetaServciceImpl.java
  12. 2
      dxhy-core/pom.xml
  13. 2
      dxhy-customs/pom.xml
  14. 2
      dxhy-erp/pom.xml
  15. 9
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java
  16. 88
      dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java
  17. 7
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoiceAuthServiceImpl.java
  18. 39
      dxhy-extend/src/main/java/com/dxhy/extend/controller/ExtFpzhcxController.java
  19. 56
      dxhy-extend/src/main/resources/mapper/ExtBbfpzhMapper.xml
  20. 2
      dxhy-extend/src/main/resources/mapper/ExtBbycfpcxMapper.xml
  21. 22
      dxhy-extend/src/main/resources/mapper/ExtJxssbbMapper.xml
  22. 1
      dxhy-oss/README
  23. 132
      dxhy-oss/pom.xml
  24. 154
      dxhy-oss/src/main/java/com/dxhy/oss/config/OssConfig.java
  25. 27
      dxhy-oss/src/main/java/com/dxhy/oss/config/OssReturnConfig.java
  26. 19
      dxhy-oss/src/main/java/com/dxhy/oss/model/FileModel.java
  27. 41
      dxhy-oss/src/main/java/com/dxhy/oss/service/AliOssService.java
  28. 72
      dxhy-oss/src/main/java/com/dxhy/oss/service/FileService.java
  29. 275
      dxhy-oss/src/main/java/com/dxhy/oss/service/FtpService.java
  30. 46
      dxhy-oss/src/main/java/com/dxhy/oss/service/JdOssService.java
  31. 165
      dxhy-oss/src/main/java/com/dxhy/oss/service/SshService.java
  32. 186
      dxhy-oss/src/main/java/com/dxhy/oss/service/impl/AliOssServiceImpl.java
  33. 328
      dxhy-oss/src/main/java/com/dxhy/oss/service/impl/FileServiceImpl.java
  34. 213
      dxhy-oss/src/main/java/com/dxhy/oss/service/impl/JdOssServiceImpl.java
  35. 55
      dxhy-oss/src/main/java/com/dxhy/oss/service/impl/OssClientFactory.java
  36. 60
      dxhy-oss/src/main/java/com/dxhy/oss/utils/FileTypeUtils.java
  37. 32
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SftpConfig.java
  38. 67
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SftpFactory.java
  39. 41
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SftpPool.java
  40. 15
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SftpPoolException.java
  41. 61
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SftpProperties.java
  42. 31
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SshConfig.java
  43. 70
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SshFactory.java
  44. 41
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SshPool.java
  45. 61
      dxhy-oss/src/main/java/com/dxhy/oss/utils/SshProperties.java
  46. 13
      dxhy-oss/src/test/java/com/dxhy/DxhyOssApplication.java
  47. 40
      dxhy-oss/src/test/java/com/dxhy/OfdHandle.java
  48. 127
      dxhy-oss/src/test/java/com/dxhy/OssTest.java
  49. 43
      dxhy-oss/src/test/java/com/dxhy/SpringContextUtils.java
  50. 48
      dxhy-oss/src/test/resources/application.yml
  51. 2
      dxhy-portrait/pom.xml
  52. 2
      dxhy-sign/pom.xml
  53. 1
      pom.xml

@ -1,8 +1,12 @@
package com.dxhy.base.controller;
import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dxhy.base.entity.BaseReturnData;
import com.dxhy.base.entity.BaseReturnEntity;
import com.dxhy.base.entity.BaseTDxRecordInvoice;
import com.dxhy.base.model.BaseDrgxReqVO;
import com.dxhy.base.service.fpxxrz.BaseCxrzfpService;
@ -22,8 +26,7 @@ import com.dxhy.common.utils.R;
import com.dxhy.common.vo.Tax;
import com.dxhy.common.vo.TaxOrgCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -31,6 +34,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.xml.ws.Response;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Matcher;
@ -199,13 +203,6 @@ public class BaseInvoiceController extends AbstractController {
gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
}
pramsMap.put("gfsh", gfshList);
boolean flag = checkList(gfshList);
if (flag){
pramsMap.put("sign","88");
log.info("登陆账号无税号");
}
//所属组织
// List<String> companyCodeList = new ArrayList<>();
// if (StringUtils.isNotBlank(companyCode)){
@ -573,14 +570,6 @@ public class BaseInvoiceController extends AbstractController {
}
pramsMap.put("gfsh", gfshList);
boolean flag = checkList(gfshList);
log.info("gfshList.size(){}",gfshList.size());
if (flag){
pramsMap.put("sign","88");
log.info("登陆账号无税号");
}
//所属组织
// List<String> companyCodeList = new ArrayList<>();
// if (StringUtils.isNotBlank(companyCode) && !"99".equals(companyCode)){
@ -690,25 +679,6 @@ public class BaseInvoiceController extends AbstractController {
}
public boolean checkList(List<String> list) {
boolean flag =false;
if (list == null || list.isEmpty()){
flag = true;
}else {
String s = list.toString().replace("[","").replace("]","");
if (StringHelper.isBlank(s)){
flag = true;
}
if (StringHelper.isNotBlank(s) && s.contains(",")){
String replace = s.replace(",", "");
if (StringHelper.isBlank(replace)){
flag = true;
}
}
}
return flag;
}
/**
* 智能勾选查询 qsfs 默认传9
*
@ -850,31 +820,35 @@ public class BaseInvoiceController extends AbstractController {
@SysLog("调用智能勾选查询接口")
@ResponseBody
public Object sgrzzngxcx(@RequestBody Map<String, Object> map) {
// String gfsh = (String)map.get("gfsh");
// String invoiceType = (String)map.get("invoiceType");
// String invoiceSource = (String)map.get("invoiceSource");
// String kpksrq = (String)map.get("kpksrq");
// String kpjsrq = (String)map.get("kpjsrq");
// String qszt = (String)map.get("qszt");
// String qsfs = (String)map.get("qsfs");
// String businessCode = (String)map.get("businessCode");
// String invoiceNo = (String)map.get("invoiceNo");
// String qsksrq = (String)map.get("qsksrq");
// String qsjsrq = (String)map.get("qsjsrq");
// String xfmc = (String)map.get("xfmc");
// String position = (String)map.get("position");
// String fpzt = (String)map.get("invoiceStatus");
// String sfkrz = (String)map.get("sfkrz");
// String qsr = (String)map.get("qsr");
// String bzdh = (String) map.get("bzdh");
String inAccountStatus = (String) map.get("inAccountStatus");
String companyCode = (String) map.get("companyCode");
String gfsh = (String)map.get("gfsh");
String maxTax = (String) map.get("maxTax");
String menuId = (String)map.get("menuId");
String company = (String)map.get("company");
int curr = (int) map.get("curr");
int size = (int) map.get("size");
String isChooseAll = (String) map.get("isChooseAll");
if (org.apache.commons.lang3.StringUtils.isBlank(isChooseAll)){
isChooseAll = "N";
}
int curr = 0;
int size = 0;
if ("N".equalsIgnoreCase(isChooseAll)){
if (map.get("curr") != null){
curr = (int) map.get("curr");
}else {
ResponseEntity.ok(R.error("分页数据不能为空"));
}
if (map.get("size")!= null){
size = (int) map.get("size");
}else {
ResponseEntity.ok(R.error("分页大小不能为空"));
}
}
if (StringUtils.isBlank(inAccountStatus)){
return ResponseEntity.ok(R.error("入账状态不能为空"));
@ -887,45 +861,19 @@ public class BaseInvoiceController extends AbstractController {
try {
BigDecimal tax = new BigDecimal(maxTax);
} catch (NumberFormatException e) {
return ResponseEntity.ok(R.error("输入税额上线格式不对,请重新输入"));
return ResponseEntity.ok(R.error("输入税额上格式不对,请重新输入"));
}
Map<String, Object> pramsMap = new HashMap<>(16);
// pramsMap.put("bzdh", bzdh);
// pramsMap.put("payment", map.get("payment"));
// pramsMap.put("paymentStatus", map.get("paymentStatus"));
// pramsMap.put("paymentDateStart", map.get("paymentDateStart"));
// pramsMap.put("paymentDateEnd", map.get("paymentDateEnd"));
// pramsMap.put("settlementNo", map.get("settlementNo"));
// pramsMap.put("voucherNumber", map.get("voucherNumber"));
// pramsMap.put("snVoucherNumber", map.get("snVoucherNumber"));
// pramsMap.put("postingTimeEnd", map.get("postingTimeEnd"));
// pramsMap.put("postingTimeStart", map.get("postingTimeStart"));
// pramsMap.put("imageNumber", map.get("imageNumber"));
// if (map.get("accountPeriod") != null && !"".equals(map.get("accountPeriod"))) {
// String accountPeriod = map.get("accountPeriod").toString().substring(0,7);
// pramsMap.put("accountPeriod", accountPeriod);
// log.info("accountPeriod:{}",accountPeriod);
// }
//
// if (sfkrz != null) {
// if (!"99".equals(sfkrz)) {
// pramsMap.put("sfkrz", sfkrz);
// }
// }
// if (invoiceSource != null) {
// if (!"99".equals(invoiceSource)) {
// pramsMap.put("invoiceSource", invoiceSource);
// }
// }
pramsMap.put("inAccountStatus", inAccountStatus);
pramsMap.put("company", company);
pramsMap.put("company", "BIGB");
pramsMap.put("menuId", menuId);
pramsMap.put("menuId", "118061");
pramsMap.put("maxTax",maxTax);
pramsMap.put("curr",curr);
pramsMap.put("size",size);
pramsMap.put("isChooseAll",isChooseAll);
pramsMap.put("business", getUserInfo().getBusiness());
pramsMap.put("dbName", getUserInfo().getDbName());
List<Tax> taxList = getUserInfo().getOrg();
@ -937,101 +885,129 @@ public class BaseInvoiceController extends AbstractController {
} else {
gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
}
if (ObjectUtils.isNotEmpty(gfshList)){
pramsMap.put("gfsh", gfshList);
}else {
return ResponseEntity.ok(R.error("购方税号不能为空"));
}
//TODO 合并分支后把checkList加上可以让用户不使用上级权限就可以进行认证
pramsMap.put("gfsh",gfshList);
pramsMap.put("sign","99");
if (StringHelper.isNotBlank(companyCode) && "99".equals(companyCode)){
pramsMap.put("companyCodes",getUserInfo().getCompanyCodes());
log.info("组织机构====>{}",pramsMap.get("companyCodes"));
}
if (StringUtils.isNotBlank(companyCode)){
pramsMap.put("companyCode",companyCode);
}
// if (!StringUtils.isBlank(invoiceType)) {
// if (!"99".equals(invoiceType)) {
// pramsMap.put("invoiceType", invoiceType);
// }
// } else {
// return ResponseEntity.ok(R.error("发票类型不能为空!"));
// }
// if (StringUtils.isNotBlank(fpzt)) {
// pramsMap.put("fpzt", fpzt);
// } else {
// return ResponseEntity.ok(R.error("发票状态不能为空"));
// }
// pramsMap.put("businessCode", "99");
// if (!StringUtils.isBlank(qszt)) {
// if (!"99".equals(qszt)) {
// pramsMap.put("qszt", qszt);
// if ("1".equals(qszt)) {
// if (!StringUtils.isBlank(qsksrq)) {
// pramsMap.put("qsksrq", qsksrq);
// } else {
// return ResponseEntity.ok(R.error("签收开始日期不能为空!"));
// }
// if (!StringUtils.isBlank(qsjsrq)) {
// pramsMap.put("qsjsrq", qsjsrq);
// } else {
// return ResponseEntity.ok(R.error("签收结束日期不能为空!"));
// }
// if (!StringUtils.isBlank(qsfs)) {
// // 表示全部
// if (!"99".equals(qsfs)) {
// pramsMap.put("qsfs", qsfs);
// }
// } else {
// return ResponseEntity.ok(R.error("签收方式不能为空!"));
// }
// pramsMap.put("businessCode", businessCode);
// }
try {
return ResponseEntity
.ok(R.ok().put("data", baseInvoiceManualCheckService.inTellingCheck(pramsMap)));
} catch (Exception e) {
e.printStackTrace();
log.error("", e);
return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
}
}
@PostMapping("/sggx/afterInTellingCheck")
@SysLog("智能勾选后认证")
@ResponseBody
public Object afterInTellingCheck(@RequestBody Map<String, Object> map) {
String isChooseAll = (String) map.get("isChooseAll");
if (StringUtils.isBlank(isChooseAll)){
isChooseAll = "Y";
}
map.put("isChooseAll",isChooseAll);
int curr = 1;
int size = 10;
int count = 0;
Map<String, Object> pramsMap = new HashMap<>(16);
String companyCode = (String) map.get("companyCode");
String gfsh = (String)map.get("gfsh");
List<String> gfshList = new ArrayList<>();
if(StringUtils.isNotBlank(gfsh) && "99".equals(gfsh)){
gfshList=UserInfoUtil.getGfshAll(getUserInfo().getOrg());
}else {
gfshList.add(gfsh);
}
String gxType = (String) map.get("gxType");
if (StringUtils.isBlank(gxType)){
return ResponseEntity.ok(R.error("所选发票勾选类型不能为空"));
}
map.put("business", getUserInfo().getBusiness());
map.put("dbName", getUserInfo().getDbName());
List<Tax> taxList = getUserInfo().getOrg();
map.put("taxList", taxList);
map.put("gfsh",gfshList);
map.put("qsflag", getUserInfo().getQsStatus());
// List<String> gfshList = new ArrayList<>();
// if (!"99".equals(gfsh) && StringUtils.isNotBlank(gfsh)) {
// gfshList.add(gfsh);
// } else {
// gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
// }
// } else {
// return ResponseEntity.ok(R.error("签收状态不能为空!"));
// }
// String qsflag = getUserInfo().getQsStatus();
// if ("1".equals(qsflag)) {
// pramsMap.put("qszt", "1");
// }
// if (!StringUtils.isBlank(kpksrq)) {
// pramsMap.put("kpksrq", kpksrq);
// } else {
// return ResponseEntity.ok(R.error("开票开始日期不能为空!"));
// }
// if (!StringUtils.isBlank(kpjsrq)) {
// pramsMap.put("kpjsrq", kpjsrq);
// } else {
// return ResponseEntity.ok(R.error("开票结束日期不能为空!"));
// }
//
// if (!StringUtils.isBlank(position)) {
// pramsMap.put("username", getUserName());
// pramsMap.put("position", position);
// }
//
// //发票号码
// if (!StringUtils.isBlank(invoiceNo)) {
// if(invoiceNo.length()==8){
// pramsMap.put("invoiceNo", invoiceNo);
// }else {
// pramsMap.put("eleInvoiceNo", invoiceNo);
// }
// }
// //todo合并分支后把checkList加上可以让用户不使用上级权限就可以进行认证
//
// map.put("gfsh",gfshList);
//
// if (!StringUtils.isBlank(xfmc)) {
// pramsMap.put("xfmc", xfmc);
// }
// if (!StringUtils.isBlank(qsr)) {
// pramsMap.put("qsr", qsr);
// }
map.put("sign","99");
if (StringHelper.isNotBlank(companyCode) && "99".equals(companyCode)){
map.put("companyCodes",getUserInfo().getCompanyCodes());
log.info("组织机构====>{}",map.get("companyCodes"));
}
if (StringUtils.isNotBlank(companyCode)){
map.put("companyCode",companyCode);
}
String sgrzzngxcx = baseInvoiceManualCheckService.inTellingCheck(map);
log.info("sgrzzngxcx======={}",sgrzzngxcx);
String decodeStr = Base64.decodeStr(sgrzzngxcx);
BaseReturnEntity baseReturnEntity = JSON.parseObject(decodeStr, BaseReturnEntity.class);
List<BaseTDxRecordInvoice> dataList = baseReturnEntity.getDataList();
StringBuilder uuids = new StringBuilder();
StringBuilder dkses = new StringBuilder();
if (dataList != null && dataList.size() > 0){
for (int i = 0; i < dataList.size(); i++) {
uuids.append(dataList.get(i).getUuid());
dkses.append(dataList.get(i).getTaxAmount());
if (i<dataList.size()-1){
uuids.append(",");
dkses.append(",");
}
}
log.info("uuids====>{}",uuids);
log.info("dkses====>{}",dkses);
}else {
return ResponseEntity.ok(R.error("没有可操作的数据"));
}
pramsMap.put("uuids",uuids);
pramsMap.put("dkses",dkses);
pramsMap.put("name", getUserName());
pramsMap.put("dbName", getUserInfo().getDbName());
pramsMap.put("loginName", getLoginName());
pramsMap.put("userName", getUserName());
pramsMap.put("gxType", gxType);
pramsMap.put("gfsh", gfshList);
try {
return ResponseEntity
.ok(R.ok().put("data", baseInvoiceManualCheckService.inTellingCheck(pramsMap)));
.ok(R.ok().put("data", baseIRzTDxRecordInvoiceService.identifiByIds(pramsMap, curr, size, count)));
} catch (Exception e) {
e.printStackTrace();
log.error("", e);

@ -136,9 +136,37 @@ public class BaseRzTDxRecordInvoiceController extends AbstractController {
String xfmc = (String)map.get("xfmc");
String position = (String)map.get("position");
String fpzt = (String)map.get("invoiceStatus");
String companyCode = (String) map.get("companyCode");
String qsr = (String)map.get("qsr");
String bzdh = (String) map.get("bzdh");
String bzr = (String) map.get("bzr");
String inAccountStatus = (String) map.get("inAccountStatus");
String sfkrz = (String)map.get("sfkrz");
String suspendDate = (String) map.get("suspendDate");
if (org.apache.commons.lang3.StringUtils.isNotEmpty(suspendDate) && suspendDate.length() >7){
suspendDate = suspendDate.substring(0,7);
}
String suspendStatus = (String) map.get("suspendStastus");
Map<String, Object> pramsMap = new HashMap<>(20);
pramsMap.put("bzdh",bzdh);
pramsMap.put("bzr",bzr);
pramsMap.put("inAccountStatus",inAccountStatus);
pramsMap.put("suspendDate",suspendDate);
pramsMap.put("suspendStatus",suspendStatus);
if (sfkrz != null) {
if (!"99".equals(sfkrz)) {
pramsMap.put("sfkrz", sfkrz);
}
}
if(pramsMap.get("imageNumber") != null){
pramsMap.put("imageNumber",pramsMap.get("imageNumber"));
}
pramsMap.put("postingTimeEnd", map.get("postingTimeEnd"));
pramsMap.put("snVoucherNumber", map.get("snVoucherNumber"));
pramsMap.put("postingTimeStart", map.get("postingTimeStart"));
pramsMap.put("company", map.get("company"));
pramsMap.put("business", getUserInfo().getBusiness());
pramsMap.put("dbName", getUserInfo().getDbName());
pramsMap.put("name", getUserName());
@ -146,6 +174,13 @@ public class BaseRzTDxRecordInvoiceController extends AbstractController {
List<Tax> taxList = getUserInfo().getOrg();
pramsMap.put("taxList", taxList);
pramsMap.put("qsflag", getUserInfo().getQsStatus());
if (map.get("accountPeriod") != null && !"".equals(map.get("accountPeriod"))) {
String accountPeriod = map.get("accountPeriod").toString().substring(0,7);
pramsMap.put("accountPeriod", accountPeriod);
log.info("accountPeriod:{}",accountPeriod);
}
List<String> gfshList = new ArrayList<>();
if (!"99".equals(gfsh) && StringUtils.isNotBlank(gfsh)) {
@ -155,6 +190,14 @@ public class BaseRzTDxRecordInvoiceController extends AbstractController {
}
pramsMap.put("gfsh", gfshList);
if (StringHelper.isNotBlank(companyCode) && "99".equals(companyCode)){
pramsMap.put("companyCodes",getUserInfo().getCompanyCodes());
log.info("组织机构====>{}",pramsMap.get("companyCodes"));
}
if (org.apache.commons.lang3.StringUtils.isNotBlank(companyCode)){
pramsMap.put("companyCode",companyCode);
}
if (!StringUtils.isBlank(invoiceType)) {
if (!"99".equals(invoiceType)) {
pramsMap.put("invoiceType", invoiceType);
@ -272,15 +315,47 @@ public class BaseRzTDxRecordInvoiceController extends AbstractController {
String xfmc = (String)map.get("xfmc");
String position = (String)map.get("position");
String fpzt = (String)map.get("invoiceStatus");
String companyCode = (String) map.get("companyCode");
String qsr = (String)map.get("qsr");
String bzdh = (String) map.get("bzdh");
String bzr = (String) map.get("bzr");
String inAccountStatus = (String) map.get("inAccountStatus");
String sfkrz = (String)map.get("sfkrz");
String suspendDate = (String) map.get("suspendDate");
if (org.apache.commons.lang3.StringUtils.isNotEmpty(suspendDate) && suspendDate.length() >7){
suspendDate = suspendDate.substring(0,7);
}
String suspendStatus = (String) map.get("suspendStastus");
Map<String, Object> pramsMap = new HashMap<>(20);
pramsMap.put("bzdh",bzdh);
pramsMap.put("bzr",bzr);
pramsMap.put("inAccountStatus",inAccountStatus);
pramsMap.put("suspendDate",suspendDate);
pramsMap.put("suspendStatus",suspendStatus);
if (sfkrz != null) {
if (!"99".equals(sfkrz)) {
pramsMap.put("sfkrz", sfkrz);
}
}
if(pramsMap.get("imageNumber") != null){
pramsMap.put("imageNumber",pramsMap.get("imageNumber"));
}
pramsMap.put("business", getUserInfo().getBusiness());
pramsMap.put("dbName", getUserInfo().getDbName());
pramsMap.put("name", getUserName());
List<Tax> taxList = getUserInfo().getOrg();
pramsMap.put("taxList", taxList);
pramsMap.put("qsflag", getUserInfo().getQsStatus());
if (map.get("accountPeriod") != null && !"".equals(map.get("accountPeriod"))) {
String accountPeriod = map.get("accountPeriod").toString().substring(0,7);
pramsMap.put("accountPeriod", accountPeriod);
log.info("accountPeriod:{}",accountPeriod);
}
pramsMap.put("postingTimeEnd", map.get("postingTimeEnd"));
pramsMap.put("snVoucherNumber", map.get("snVoucherNumber"));
pramsMap.put("postingTimeStart", map.get("postingTimeStart"));
pramsMap.put("company", map.get("company"));
List<String> gfshList = new ArrayList<>();
if (!"99".equals(gfsh) && StringUtils.isNotBlank(gfsh)) {
@ -371,6 +446,13 @@ public class BaseRzTDxRecordInvoiceController extends AbstractController {
} else {
return ResponseEntity.ok(R.error("购方信息不能为空!"));
}
if (StringHelper.isNotBlank(companyCode) && "99".equals(companyCode)){
pramsMap.put("companyCodes",getUserInfo().getCompanyCodes());
log.info("组织机构====>{}",pramsMap.get("companyCodes"));
}
if (org.apache.commons.lang3.StringUtils.isNotBlank(companyCode)){
pramsMap.put("companyCode",companyCode);
}
String invoiceSource = (String)map.get("invoiceSource");
if (!StringUtils.isBlank(invoiceSource) && !"99".equals(invoiceSource)) {
pramsMap.put("invoiceSource", invoiceSource);

@ -218,4 +218,6 @@ public interface BaseTDxRecordInvoiceDao extends BaseMapper<BaseTDxRecordInvoice
void updateSuspendType(Map<String,Object> pramsMap);
List<String> findSuspendStatus(@Param("uuids") List<String> uuids);
List<BaseTDxRecordInvoice> selectChooseHj(Map<String,Object> pramsMap);
}

@ -0,0 +1,16 @@
package com.dxhy.base.entity;
import lombok.Data;
@Data
@SuppressWarnings("AlibabaClassNamingShouldBeCamel")
public class BaseReturnData {
private static final long serialVersionUID = -2166713217995969349L;
private String code;
private String data;
private String message;
}

@ -0,0 +1,22 @@
package com.dxhy.base.entity;
import lombok.Data;
import java.util.List;
@Data
@SuppressWarnings("AlibabaClassNamingShouldBeCamel")
public class BaseReturnEntity {
private static final long serialVersionUID = -2166713217995969349L;
private String hjse;
private List<BaseTDxRecordInvoice> dataList;
private String hjsl;
private String hjje;
private String total;
}

@ -165,4 +165,5 @@ public class BaseSggxCxRespVO {
private String bzr;
private String uuid;
}

@ -12,8 +12,8 @@ import javax.annotation.Resource;
import com.dxhy.common.constant.DictConstant;
import com.dxhy.common.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
@ -229,9 +229,9 @@ public class BaseInvoiceManualCheckServiceImpl extends MpBaseServiceImpl<BaseTDx
// String dkzt= dictdetaServcice.queryDictName(DictConstant.INACCOUNT_STATUS,pageList.get(i).getInAccountStatus());
// pageList.get(i).setInAccountStatus(dkzt);
// vo.setInAccountStatus(dkzt);
vo.setSelect(true);
if (!"1".equals(pageList.get(i).getAuthStatus())) {
vo.setSelect(false);
vo.setSelect(false);
if ("1".equals(pageList.get(i).getAuthStatus())) {
vo.setSelect(true);
}
log.info("手工勾选查询返回对象VO {}",vo);
@ -447,45 +447,89 @@ public class BaseInvoiceManualCheckServiceImpl extends MpBaseServiceImpl<BaseTDx
@Override
public String inTellingCheck(Map<String, Object> pramsMap) {
log.info("入参是:{}",pramsMap);
JSONObject json;
JSONObject json = new JSONObject();
DynamicContextHolder.push(pramsMap.get("dbName") + DbConstant.BUSINESS_READ);
try {
String company = (String)pramsMap.get("company");
String menuId = (String)pramsMap.get("menuId");
json = tabulateRedisService.getTabulateMenu(company, menuId);
if (StringUtils.isNotBlank(menuId)){
json = tabulateRedisService.getTabulateMenu(company, menuId);
}
List<String> gfshList = (List<String>)pramsMap.get("gfsh");
List<String> gfshList1 = new ArrayList<>();
if (gfshList.size() > 0) {
List<BaseTDxDkCount> curList = super.baseMapper.selectDksh(pramsMap);
for (BaseTDxDkCount cur : curList) {
String skssq = cur.getSkssq();
String year = skssq.substring(0, 4);
String mon = skssq.substring(4);
LocalDate localDate = LocalDate.of(Integer.parseInt(year), Integer.parseInt(mon), 1);
LocalDate localDate1 = localDate.plusMonths(1);
LocalDate localDate2 = LocalDate.now();
if ("0".equals(cur.getTjStatus()) || "3".equals(cur.getTjStatus())
|| localDate2.isBefore(localDate1)) {
gfshList1.add(cur.getTaxno());
String sign = (String) pramsMap.get("sign");
//如果有自己的税号则选择出在未申请抵扣的税号
if (!"88".equals(sign)){
List<String> gfshList1 = new ArrayList<>();
if (gfshList.size() > 0) {
List<BaseTDxDkCount> curList = super.baseMapper.selectDksh(pramsMap);
for (BaseTDxDkCount cur : curList) {
String skssq = cur.getSkssq();
String year = skssq.substring(0, 4);
String mon = skssq.substring(4);
LocalDate localDate = LocalDate.of(Integer.parseInt(year), Integer.parseInt(mon), 1);
LocalDate localDate1 = localDate.plusMonths(1);
LocalDate localDate2 = LocalDate.now();
if ("0".equals(cur.getTjStatus()) || "3".equals(cur.getTjStatus())
|| localDate2.isBefore(localDate1)) {
gfshList1.add(cur.getTaxno());
}
}
}
if(ObjectUtils.isEmpty(gfshList1)|| gfshList1.size()==0){
json.put("code","501");
json.put("message","税号已经申请抵扣");
if(ObjectUtils.isEmpty(gfshList1)|| gfshList1.size()==0){
json.put("code","501");
json.put("message","税号已经申请抵扣");
return super.responseResult(json);
}else {
pramsMap.put("gfsh",gfshList1);
}
} else {
json.put("code", "501");
json.put("message", "账号下无可用税号");
return super.responseResult(json);
}else {
pramsMap.put("gfsh",gfshList1);
}
} else {
}
String hjsl = "0";
String hjje = "0";
String hjse = "0";
List<BaseTDxRecordInvoice> hjList = super.baseMapper.selectChooseHj(pramsMap);
BaseTDxRecordInvoice hjxx = hjList.get(0);
hjsl = hjxx.getSfygx();
if (!"0".equals(hjsl)) {
hjje = AmountFormatUtil.fmtMicrometer(MathUtil.round(hjxx.getInvoiceAmount().toPlainString()));
hjse = AmountFormatUtil.fmtMicrometer(MathUtil.round(hjxx.getTaxAmount().toPlainString()));
}
json.put("hjsl", AmountFormatUtil.fmtMicrometer(hjsl));
json.put("hjje", hjje);
json.put("hjse", hjse);
if ("0".equals(hjsl)) {
json.put("message", "无可操作的数据");
json.put("code", "501");
json.put("message", "账号下无可用税号");
return super.responseResult(json);
}
String isChooseAll = (String) pramsMap.get("isChooseAll");
if ("N".equals(isChooseAll)){
int total = Integer.parseInt(hjsl);
int curr = (int) pramsMap.get("curr");
int size = (int) pramsMap.get("size");
int totalPage = total % size == 0?total/size:total/size+1;
if (curr<1){
curr =1;
}
if (curr>totalPage){
curr = totalPage;
}
curr = (curr -1)*size;
pramsMap.put("curr",curr);
}
PageHelper.startPage(1, 200);
List<BaseTDxRecordInvoice> pageList = super.baseMapper.selectInTellingCheck(pramsMap);
if (pageList == null || pageList.size() == 0){
@ -500,14 +544,8 @@ public class BaseInvoiceManualCheckServiceImpl extends MpBaseServiceImpl<BaseTDx
// 转化为页面展示对象
List<BaseSggxCxRespVO> returnList = new ArrayList<>();
//记录数量
int count = 0;
int count = 1;
//税额上限
BigDecimal maxTax = new BigDecimal((String)pramsMap.get("maxTax"));
//统计税额
BigDecimal currentTax = new BigDecimal("0");
//统计金额
BigDecimal hjje = new BigDecimal("0");
List<Business> businessList = (List<Business>)pramsMap.get("business");
if (pageList.size() > 0) {
@ -521,97 +559,18 @@ public class BaseInvoiceManualCheckServiceImpl extends MpBaseServiceImpl<BaseTDx
}
}
}
for (int i = 0; i < pageList.size(); i++) {
if(pageList.get(i).getTaxAmount().compareTo(new BigDecimal("0"))<1){
continue;
}
currentTax = currentTax.add(pageList.get(i).getTaxAmount());
hjje = hjje.add(pageList.get(i).getInvoiceAmount());
log.info("maxTax====>"+maxTax+",currentTax====>"+currentTax+",taxAmount===>"+pageList.get(i).getTaxAmount());
if (maxTax.compareTo(currentTax) >0){
count++;
log.info("count++{}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje);
//发票状态不能认证
// String invoiceStatus="07";
// if ( pageList.get(i).getInvoiceStatus() != null && !invoiceStatus.contains(pageList.get(i).getInvoiceStatus())
// || pageList.get(i).getInvoiceAmount() != null && pageList.get(i).getInvoiceAmount().compareTo(new BigDecimal(0)) < 0
// || pageList.get(i).getTaxAmount() != null && pageList.get(i).getTaxAmount().compareTo(new BigDecimal(0)) < 0) {
//
// currentTax = currentTax.subtract(pageList.get(i).getTaxAmount());
// hjje = hjje.subtract(pageList.get(i).getInvoiceAmount());
// count--;
// log.info("count--{}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje);
// continue;
// }
//发票税号一申请抵扣统计
// if (!gfshList1.contains(pageList.get(i).getGfTaxNo())) {
// //该发票税号已申请抵扣统计
// log.info("申请统计的购方税号为{}",pageList.get(i).getGfTaxNo());
// currentTax = currentTax.subtract(pageList.get(i).getTaxAmount());
// hjje = hjje.subtract(pageList.get(i).getInvoiceAmount());
// count--;
// log.info("已申请抵扣统计 count-- ==={}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje);
//
// continue;
// }
BaseSggxCxRespVO vo = getBaseSggxCxRespVO(pageList.get(i), count, taxnoList, businessList);
// log.info("智能勾选查询返回对象VO {}",vo);
log.info("returnList添加vo");
returnList.add(vo);
}else {
log.info("统计税额超出税额上限减去最后一个,并结束循环遍历");
currentTax = currentTax.subtract(pageList.get(i).getTaxAmount());
hjje = hjje.subtract(pageList.get(i).getInvoiceAmount());
if (i<pageList.size()-1){
List<BaseTDxRecordInvoice> collect = pageList.stream().skip(i + 1).sorted(Comparator.comparing(BaseTDxRecordInvoice::getTaxAmount)).collect(Collectors.toList());
log.info("collect====>{}",collect.stream().map(BaseTDxRecordInvoice::getTaxAmount).collect(Collectors.toList()));
if (collect != null && collect.size() > 0){
log.info("从小到大排序在进行添加");
for (int j = 0; j < collect.size(); j++) {
if (collect.get(j).getTaxAmount().compareTo(new BigDecimal("0"))<1){
continue;
}
currentTax = currentTax.add(collect.get(j).getTaxAmount());
hjje = hjje.add(collect.get(j).getInvoiceAmount());
log.info("maxTax====>"+maxTax+",currentTax====>"+currentTax);
if (maxTax.compareTo(currentTax)>0){
count++;
log.info("最小排序count++{}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje);
BaseSggxCxRespVO vo = getBaseSggxCxRespVO(collect.get(j), count, taxnoList, businessList);
log.info("returnList添加vo");
returnList.add(vo);
}else {
log.info("最小排序统计税额超出税额上限减去最后一个,并结束循环遍历");
currentTax = currentTax.subtract(collect.get(j).getTaxAmount());
hjje = hjje.subtract(collect.get(j).getInvoiceAmount());
break;
}
}
}
}
BaseSggxCxRespVO vo = getBaseSggxCxRespVO(pageList.get(i), count, taxnoList, businessList);
count++;
log.info("returnList添加vo");
returnList.add(vo);
}
break;
}
}
json.put("total", hjsl);
json.put("datalist", returnList);
}
}
if(returnList == null || returnList.size() == 0){
json.put("message","无可操作的数据");
json.put("code","501");
return super.responseResult(json);
}else {
json.put("hjje", hjje);
json.put("hjse", currentTax);
json.put("total", count);
json.put("datalist", returnList);
}
} catch (Exception e) {
// 统一设置操作异常标识
log.info("错误信息为:{}",e.getMessage());
@ -646,6 +605,7 @@ public class BaseInvoiceManualCheckServiceImpl extends MpBaseServiceImpl<BaseTDx
String businessName = this.getBusinessName(businessCode, businessList);
// log.info("businessName={}",businessName);
vo.setUuid(baseTDxRecordInvoice.getUuid());
vo.setVoucherNumber(baseTDxRecordInvoice.getVoucherNumber());
vo.setSnVoucherNumber(baseTDxRecordInvoice.getSnVoucherNumber());
vo.setImageNumber(baseTDxRecordInvoice.getImageNumber());

@ -7,6 +7,7 @@ import java.util.*;
import javax.annotation.Resource;
import cn.hutool.core.codec.Base64;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -46,6 +47,7 @@ import com.dxhy.common.vo.InvoiceLog;
@SuppressWarnings({"AlibabaUndefineMagicConstant", "AlibabaMethodTooLong", "AlibabaLowerCamelCaseVariableNaming",
"AlibabaClassNamingShouldBeCamel", "AlibabaCollectionInitShouldAssignCapacity"})
@Service("baseIRzTDxRecordInvoiceService")
@Slf4j
public class BaseRzTDxRecordInvoiceServiceImpl extends MpBaseServiceImpl<BaseTDxRecordInvoiceDao, BaseTDxRecordInvoice>
implements BaseIRzTDxRecordInvoiceService {
@ -401,6 +403,8 @@ public class BaseRzTDxRecordInvoiceServiceImpl extends MpBaseServiceImpl<BaseTDx
@Override
public String identifiAllCount(Map<String, Object> pramsMap) {
log.info("一键认证查询总数入参{}",pramsMap);
String hjsl = "0";
String hjje = "0";
String hjse = "0";
@ -412,8 +416,13 @@ public class BaseRzTDxRecordInvoiceServiceImpl extends MpBaseServiceImpl<BaseTDx
BaseTDxRecordInvoice hjxx = hjList.get(0);
hjsl = hjxx.getSfygx();
if (!"0".equals(hjsl)) {
hjje = AmountFormatUtil.fmtMicrometer(MathUtil.round(hjxx.getInvoiceAmount().toPlainString()));
hjse = AmountFormatUtil.fmtMicrometer(MathUtil.round(hjxx.getTaxAmount().toPlainString()));
if (hjxx.getInvoiceAmount() != null ){
hjje = AmountFormatUtil.fmtMicrometer(MathUtil.round(hjxx.getInvoiceAmount().toPlainString()));
}
if (hjxx.getTaxAmount() != null){
hjse = AmountFormatUtil.fmtMicrometer(MathUtil.round(hjxx.getTaxAmount().toPlainString()));
}
}
json.put("hjsl", AmountFormatUtil.fmtMicrometer(hjsl));
json.put("hjje", hjje);
@ -450,6 +459,8 @@ public class BaseRzTDxRecordInvoiceServiceImpl extends MpBaseServiceImpl<BaseTDx
@Override
public String identifiByAll(Map<String, Object> pramsMap) {
log.info("一键认证入参{}",pramsMap);
String rzts = "0";
String hjje = "0";
String hjse = "0";

@ -73,7 +73,7 @@
bdk_date,t.rzh_back_msg,t.in_account_status,t.payment_status,date_format(t.payment_date,'%Y-%m-%d')payment_date,
voucher_number,t.ele_invoice_no, sn_voucher_number, account_period, posting_time ,image_id
from t_dx_record_invoice t
WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
WHERE t.invoice_date between #{kpksrq} and #{kpjsrq}
and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
and t.bdk_status in ('1','2')
and t.export_mark = '0'
@ -353,7 +353,7 @@
resultMap="RzcxhjResultMap" databaseId="mysql">
select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.tax_amount)hjse
from t_dx_record_invoice t
WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
WHERE t.invoice_date between #{kpksrq} and #{kpjsrq}
and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
and t.auth_status != '0'
and t.bdk_status in ('1','2')

@ -35,6 +35,7 @@
<result column="suspend_status" property="suspendStatus"/>
<result column="suspend_date" property="suspendDate"/>
<result column="bzr" property="bzr"/>
<result column="uuid" property="uuid"/>
</resultMap>
<resultMap id="hjResultMap"
type="com.dxhy.base.entity.BaseTDxRecordInvoice">
@ -71,7 +72,7 @@
t.inaccount_status,t.payment_status,DATE_FORMAT(t.payment_date,'%Y-%m-%d')payment_date,t.settlement_no,t.ele_invoice_no
from t_dx_record_invoice t left join t_dx_tax_current c on t.gf_tax_no = c.taxno
left join t_dx_dk_count d on c.taxno = d.taxno and c.current_tax_period = d.skssq
WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
WHERE t.invoice_date between #{kpksrq} and #{kpjsrq}
and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
and t.rzh_yesorno = '0'
and t.auth_status in('0','5','6')
@ -81,14 +82,14 @@
and t.invoice_status in ('0','7')
and t.invoice_amount>0
and t.tax_amount>=0
and date_format(t.invoice_date,'%Y%m%d') between c.select_start_date and c.select_end_date
and t.invoice_date between c.select_start_date and c.select_end_date
and d.tj_status in('0','3')
</if>
<if test="sfkrz != '99' and sfkrz != null and sfkrz != '' and sfkrz != 'null' and sfkrz == '0'.toString()">
and (t.invoice_status in ('1','2','3','4','8','80') or t.invoice_amount &lt;0 or t.tax_amount &lt;0 or
date_format(t.invoice_date,'%Y%m%d') &lt;= c.select_start_date or
date_format(t.invoice_date,'%Y%m%d') &gt;=
t.invoice_date &lt;= c.select_start_date or
t.invoice_date &gt;=
c.select_end_date or d.tj_status in ('1','2'))
</if>
@ -395,7 +396,7 @@
select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.tax_amount)hjse
from t_dx_record_invoice t left join t_dx_tax_current c on t.gf_tax_no = c.taxno
left join t_dx_dk_count d on c.taxno = d.taxno and c.current_tax_period = d.skssq
WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
WHERE t.invoice_date between #{kpksrq} and #{kpjsrq}
and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
and t.rzh_yesorno = '0'
and t.auth_status in('0','5','6')
@ -408,14 +409,14 @@
and t.invoice_status in ('0','7')
and t.invoice_amount>0
and t.tax_amount>=0
and date_format(t.invoice_date,'%Y%m%d') between c.select_start_date and c.select_end_date
and t.invoice_date between c.select_start_date and c.select_end_date
and d.tj_status in('0','3')
</if>
<if test="sfkrz != '99' and sfkrz != null and sfkrz != '' and sfkrz != 'null' and sfkrz == '0'.toString()">
and (t.invoice_status in ('1','2','3','4','8','80') or t.invoice_amount &lt;0 or t.tax_amount &lt;0 or
date_format(t.invoice_date,'%Y%m%d') &lt;= c.select_start_date or
date_format(t.invoice_date,'%Y%m%d') &gt;=
t.invoice_date &lt;= c.select_start_date or
t.invoice_date &gt;=
c.select_end_date or d.tj_status in ('1','2'))
</if>
@ -1021,8 +1022,8 @@
,t.qs_type,t.qs_status,t.dk_tax_amount,t.qs_name
from t_dx_record_invoice t left join t_dx_tax_current c on t.gf_tax_no = c.taxno
left join t_dx_dk_count d on c.taxno = d.taxno and c.current_tax_period = d.skssq
WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
and t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08')
WHERE t.invoice_date between #{kpksrq} and #{kpjsrq}
and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
and t.rzh_yesorno = '0'
and t.invoice_status in ('0','7')
and t.auth_status in('0','5','6')
@ -1030,11 +1031,74 @@
and t.invoice_amount>0
and t.tax_amount>=0
and d.tj_status in('0','3')
and date_format(t.invoice_date,'%Y%m%d') between c.select_start_date and c.select_end_date
and invoice_date between c.select_start_date and c.select_end_date
and t.company = #{company}
and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="companyCode != null and companyCode != '' and companyCode != 'null' and companyCode == '99'">
and (t.comp_code in
<foreach collection="companyCodes" index="index" item="companyCode" separator="," open="(" close=")">
#{companyCode}
</foreach>
or t.comp_code is null or t.comp_code = ''
)
</if>
<if test="companyCode != null and companyCode != '99' and companyCode != '88' and companyCode != '' and companyCode != 'null'" >
and t.comp_code = #{companyCode}
</if>
<if test="companyCode != null and companyCode != '' and companyCode == '88'">
and (t.comp_code = '' or t.comp_code is null)
</if>
<if test="sfkrz != '99' and sfkrz != null and sfkrz != '' and sfkrz != 'null' and sfkrz == '1'.toString()">
and t.invoice_status in ('0','7')
and t.invoice_amount>0
and t.tax_amount>=0
and t.invoice_date between c.select_start_date and c.select_end_date
and d.tj_status in('0','3')
</if>
<if test="sfkrz != '99' and sfkrz != null and sfkrz != '' and sfkrz != 'null' and sfkrz == '0'.toString()">
and (t.invoice_status in ('1','2','3','4','8','80') or t.invoice_amount &lt;0 or t.tax_amount &lt;0 or
t.invoice_date &lt;= c.select_start_date or
t.invoice_date &gt;=
c.select_end_date or d.tj_status in ('1','2'))
</if>
<if test="suspendStatus != null and suspendStatus != '' and suspendStatus != 'null' and suspendStatus != '99' and suspendStatus == '1'.toString()">
and t.suspend_status = '1'
</if>
<if test="suspendStatus != null and suspendStatus != '' and suspendStatus != 'null' and suspendStatus != '99' and suspendStatus == '0'.toString()">
and (t.suspend_status = '' or t.suspend_status is null or t.suspend_status = '0')
</if>
<if test="suspendDate != null and suspendDate != '' and suspendDate != 'null' ">
and t.suspend_date = #{suspendDate}
</if>
<if test="bzr != null and bzr != '' and bzr != 'null'">
and t.bzr like concat('%',#{bzr},'%')
</if>
<if test="bzdh != null and bzdh != '' and bzdh != 'null' and bzdh != '99'">
and t.bzdh = #{bzdh}
</if>
<if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' and inAccountStatus == '1'.toString()">
and t.inaccount_status = #{inAccountStatus}
</if>
<if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' and inAccountStatus == '0'.toString()">
and (t.inaccount_status = '0' or t.inaccount_status = '' or t.inaccount_status is null)
</if>
<if test="snVoucherNumber != null and snVoucherNumber != '' and snVoucherNumber != 'null' and snVoucherNumber != '99'">
and t.sn_voucher_number = #{snVoucherNumber}
</if>
<if test="postingTimeStart != null and postingTimeStart != '' and postingTimeStart != 'null' and postingTimeStart != '99' and postingTimeEnd != null and postingTimeEnd != '' and postingTimeEnd != 'null' and postingTimeEnd != '99'">
and t.posting_time between #{postingTimeStart} and #{postingTimeEnd}
</if>
<if test="imageNumber != null and imageNumber != '' and imageNumber != 'null' and imageNumber != '99'">
and t.image_id = #{imageNumber}
</if>
<if test="accountPeriod != null and accountPeriod != '' and accountPeriod != 'null' and accountPeriod != '99'">
and t.account_period = #{accountPeriod}
</if>
<if test="qszt != null and qszt != '' and qszt != 'null' ">
and t.qs_status = #{qszt}
</if>
@ -1187,11 +1251,14 @@
</select>
<select id="selectRzhAllHj" parameterType="java.util.Map"
resultMap="hjResultMap" databaseId="mysql">
select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.dk_tax_amount)hjse
select count(1) hjsl,sum(t.invoice_amount)hjje,sum(
case
when t.dk_tax_amount is null then t.tax_amount
else t.dk_tax_amount end )hjse
from t_dx_record_invoice t left join t_dx_tax_current c on t.gf_tax_no = c.taxno
left join t_dx_dk_count d on c.taxno = d.taxno and c.current_tax_period = d.skssq
WHERE date_format(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
and t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08')
WHERE t.invoice_date between #{kpksrq} and #{kpjsrq}
and (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
and t.rzh_yesorno = '0'
and t.invoice_status in ('0','7')
and t.auth_status in('0','5','6')
@ -1199,11 +1266,74 @@
and t.invoice_amount>0
and t.tax_amount>=0
and d.tj_status in('0','3')
and date_format(t.invoice_date,'%Y%m%d') between c.select_start_date and c.select_end_date
and t.invoice_date between c.select_start_date and c.select_end_date
and t.company = #{company}
and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="companyCode != null and companyCode != '' and companyCode != 'null' and companyCode == '99'">
and (t.comp_code in
<foreach collection="companyCodes" index="index" item="companyCode" separator="," open="(" close=")">
#{companyCode}
</foreach>
or t.comp_code is null or t.comp_code = ''
)
</if>
<if test="companyCode != null and companyCode != '99' and companyCode != '88' and companyCode != '' and companyCode != 'null'" >
and t.comp_code = #{companyCode}
</if>
<if test="companyCode != null and companyCode != '' and companyCode == '88'">
and (t.comp_code = '' or t.comp_code is null)
</if>
<if test="sfkrz != '99' and sfkrz != null and sfkrz != '' and sfkrz != 'null' and sfkrz == '1'.toString()">
and t.invoice_status in ('0','7')
and t.invoice_amount>0
and t.tax_amount>=0
and t.invoice_date between c.select_start_date and c.select_end_date
and d.tj_status in('0','3')
</if>
<if test="sfkrz != '99' and sfkrz != null and sfkrz != '' and sfkrz != 'null' and sfkrz == '0'.toString()">
and (t.invoice_status in ('1','2','3','4','8','80') or t.invoice_amount &lt;0 or t.tax_amount &lt;0 or
t.invoice_date &lt;= c.select_start_date or
t.invoice_date &gt;=
c.select_end_date or d.tj_status in ('1','2'))
</if>
<if test="suspendStatus != null and suspendStatus != '' and suspendStatus != 'null' and suspendStatus != '99' and suspendStatus == '1'.toString()">
and t.suspend_status = '1'
</if>
<if test="suspendStatus != null and suspendStatus != '' and suspendStatus != 'null' and suspendStatus != '99' and suspendStatus == '0'.toString()">
and (t.suspend_status = '' or t.suspend_status is null or t.suspend_status = '0')
</if>
<if test="suspendDate != null and suspendDate != '' and suspendDate != 'null' ">
and t.suspend_date = #{suspendDate}
</if>
<if test="bzr != null and bzr != '' and bzr != 'null'">
and t.bzr like concat('%',#{bzr},'%')
</if>
<if test="bzdh != null and bzdh != '' and bzdh != 'null' and bzdh != '99'">
and t.bzdh = #{bzdh}
</if>
<if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' and inAccountStatus == '1'.toString()">
and t.inaccount_status = #{inAccountStatus}
</if>
<if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' and inAccountStatus == '0'.toString()">
and (t.inaccount_status = '0' or t.inaccount_status = '' or t.inaccount_status is null)
</if>
<if test="snVoucherNumber != null and snVoucherNumber != '' and snVoucherNumber != 'null' and snVoucherNumber != '99'">
and t.sn_voucher_number = #{snVoucherNumber}
</if>
<if test="postingTimeStart != null and postingTimeStart != '' and postingTimeStart != 'null' and postingTimeStart != '99' and postingTimeEnd != null and postingTimeEnd != '' and postingTimeEnd != 'null' and postingTimeEnd != '99'">
and t.posting_time between #{postingTimeStart} and #{postingTimeEnd}
</if>
<if test="imageNumber != null and imageNumber != '' and imageNumber != 'null' and imageNumber != '99'">
and t.image_id = #{imageNumber}
</if>
<if test="accountPeriod != null and accountPeriod != '' and accountPeriod != 'null' and accountPeriod != '99'">
and t.account_period = #{accountPeriod}
</if>
<if test="qszt != null and qszt != '' and qszt != 'null' ">
and t.qs_status = #{qszt}
</if>
@ -1337,121 +1467,141 @@
<select id="selectInTellingCheck" parameterType="java.util.Map"
resultMap="SggxcxResultMap" databaseId="mysql">
select t.invoice_type,t.dept_id,t.dept_name,t.comp_code
,t.id,t.invoice_code,t.invoice_no,t.gf_name,t.gf_tax_no,t.xf_name,
DATE_FORMAT(t.invoice_date,'%Y-%m-%d')invoice_date,t.invoice_amount,t.tax_amount,t.invoice_status,DATE_FORMAT(t.qs_date,'%Y-%m-%d')qs_date
,t.qs_type,t.qs_status,t.dk_tax_amount,t.qs_name,t.sn_voucher_number,t.posting_time,t.image_id,t.account_period,
case date_format(t.invoice_date,'%Y%m%d') between c.select_start_date and c.select_end_date when
true then 1
else 2 end authStatus,t.bzdh,t.bzr,t.suspend_status,t.suspend_date,
t.inaccount_status,t.payment_status,DATE_FORMAT(t.payment_date,'%Y-%m-%d')payment_date,t.settlement_no,t.ele_invoice_no
from t_dx_record_invoice t left join t_dx_tax_current c on t.gf_tax_no = c.taxno
left join t_dx_dk_count d on c.taxno = d.taxno and c.current_tax_period = d.skssq
WHERE (t.invoice_type in('01','03','08','14','31','283','161','183','185') or (t.invoice_type ='32' and t.lq_tdyslxDm='08'))
and t.rzh_yesorno = '0'
and t.auth_status in('0','5','6')
and t.export_mark = '0'
and t.company = #{company}
and t.invoice_status = '0'
and t.tax_amount > 0
and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<if test="companyCode != null and companyCode != '99' and companyCode != '88' and companyCode != '' and companyCode != 'null'" >
and t.comp_code = #{companyCode}
</if>
<if test="companyCode != null and companyCode != '' and companyCode == '88'">
and (t.comp_code = '' or t.comp_code is null)
SELECT *
FROM (
SELECT tax_amount,
(@total := @total + tax_amount) AS max_tax,
invoice_type,
comp_code,
uuid,
invoice_code,
invoice_no,
gf_name,
gf_tax_no,
xf_name,
DATE_FORMAT(invoice_date,'%Y-%m-%d')invoice_date,
invoice_amount,
invoice_status,
DATE_FORMAT(qs_date,'%Y-%m-%d')qs_date,
qs_type,
qs_status,
dk_tax_amount,
qs_name,
sn_voucher_number,
posting_time,
image_id,
account_period,
bzdh,
bzr,
suspend_status,
suspend_date,
inaccount_status,
payment_status,
DATE_FORMAT(payment_date,'%Y-%m-%d')payment_date,
settlement_no,
ele_invoice_no
FROM t_dx_record_invoice, (SELECT @total := 0) AS t
WHERE tax_amount != ''
and tax_amount > 0
and (invoice_type in('01','03','08','14','31','283','161','183','185') or (invoice_type ='32' and lq_tdyslxDm='08'))
and rzh_yesorno = '0'
and auth_status in('0','5','6')
and export_mark = '0'
and invoice_status = '0'
and company = #{company}
<if test="sign !='88'">
and gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="companyCode != null and companyCode != '' and companyCode != 'null' and companyCode == '99'">
and (comp_code in
<foreach collection="companyCodes" index="index" item="companyCode" separator="," open="(" close=")">
#{companyCode}
</foreach>
or comp_code is null or comp_code = ''
)
</if>
<if test="companyCode != null and companyCode != '99' and companyCode != '88' and companyCode != '' and companyCode != 'null'" >
and comp_code = #{companyCode}
</if>
<if test="companyCode != null and companyCode != '' and companyCode == '88'">
and (comp_code = '' or comp_code is null)
</if>
<if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' and inAccountStatus == '0'.toString()">
and inaccount_status = '1'
</if>
<if test="qsflag != null and qsflag != '' and qsflag != 'null' and qsflag == '1'.toString()">
and qs_status = '1'
</if>
ORDER BY tax_amount
) AS subquery
WHERE <![CDATA[ max_tax <= #{maxTax} ]]>
<if test="isChooseAll != null and isChooseAll != '' and isChooseAll == 'N'.toString()">
limit #{curr},#{size}
</if>
<if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus == '0'.toString()">
and t.inaccount_status = '1'
</if>
</select>
<if test="qsksrq != null and qsksrq != '' and qsksrq != 'null' and qsjsrq != null and qsjsrq != '' and qsjsrq != 'null'">
and date_format(t.qs_date,'%Y-%m-%d') between #{qsksrq} and #{qsjsrq}
</if>
<if test="voucherNumber != null and voucherNumber != ''">
and t.voucher_number like concat('%',concat(#{voucherNumber},'%'))
</if>
<if test="paymentDateStart != null and paymentDateStart != '' and paymentDateStart != 'null' ">
<![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d') >= #{paymentDateStart} ]]>
</if>
<if test="paymentDateEnd != null and paymentDateEnd != '' and paymentDateEnd != 'null' ">
<![CDATA[ AND date_format(t.payment_date,'%Y-%m-%d') <= #{paymentDateEnd} ]]>
</if>
<if test="paymentStatus != null and paymentStatus != '' and paymentStatus != '99'">
and t.payment_status = #{paymentStatus}
</if>
<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType == '14' ">
and t.invoice_type = '14' or (t.invoice_type = '32' and t.lq_tdyslxDm='08')
</if>
<if test="invoiceType != null and invoiceType != '' and invoiceType != 'null' and invoiceType != '14' ">
and t.invoice_type = #{invoiceType}
</if>
<if test="invoiceSource!=null and invoiceSource!='' and invoiceSource!='null' and invoiceSource!='99'">
and t.invoice_source = #{invoiceSource}
</if>
<if test="fpzt != null and fpzt != '' and fpzt != 'null'">
and t.invoice_status = #{fpzt}
</if>
<if test="qsfs != null and qsfs != '' and qsfs != 'null' ">
and t.qs_type = #{qsfs}
</if>
<if test="xfmc != null and xfmc != '' and xfmc != 'null' ">
and t.xf_name like concat(#{xfmc},'%')
</if>
<if test="qsr != null and qsr != '' and qsr != 'null' ">
and t.qs_name = #{qsr}
</if>
<if test="settlementNo != null and settlementNo != ''">
and t.settlement_no like concat(#{settlementNo},'%')
</if>
<if test="invoiceNo != null and invoiceNo != '' and invoiceNo != 'null' ">
and t.invoice_no = #{invoiceNo}
</if>
<!-- 按签收人查询 -->
<if test="position != null and position != '' and position != 'null' and position == '1'.toString()">
and t.qs_name = #{username}
<resultMap id="chooseResultMap"
type="com.dxhy.base.entity.BaseTDxRecordInvoice">
<result column="hjsl" property="sfygx"/>
<result column="hjje" property="invoiceAmount"/>
<result column="hjse" property="taxAmount"/>
</resultMap>
<select id="selectChooseHj" parameterType="java.util.Map" databaseId="mysql" resultMap="chooseResultMap">
SELECT count(1) hjsl,sum(subquery.invoice_amount)hjje,sum(subquery.tax_amount)hjse
FROM (
SELECT tax_amount,
(@total := @total + tax_amount) AS max_tax,
invoice_amount
FROM t_dx_record_invoice, (SELECT @total := 0) AS t
WHERE tax_amount != ''
and tax_amount > 0
and (invoice_type in('01','03','08','14','31','283','161','183','185') or (invoice_type ='32' and lq_tdyslxDm='08'))
and rzh_yesorno = '0'
and auth_status in('0','5','6')
and export_mark = '0'
and invoice_status = '0'
and company = #{company}
<if test="sign !='88'">
and gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="businessCode != '99' and businessCode != null and businessCode != '' and businessCode != 'null' ">
and t.dept_id = #{businessCode}
</if>
<if test="businessCode==''">
and (t.dept_id is null or t.dept_id='' or t.dept_id='99')
</if>
<if test='businessCode == "99" and business != null and business.size()>0'>
and (t.dept_id in
<foreach collection="business" index="index" item="item" open="(" separator="," close="">
#{item.businessCode}
<if test="companyCode != null and companyCode != '' and companyCode != 'null' and companyCode == '99'">
and (comp_code in
<foreach collection="companyCodes" index="index" item="companyCode" separator="," open="(" close=")">
#{companyCode}
</foreach>
) or (t.dept_id is null or t.dept_id='' or t.dept_id='99'))
</if>
<if test="eleInvoiceNo!=null and eleInvoiceNo!='' and eleInvoiceNo!='null'">
and t.ele_invoice_no = #{eleInvoiceNo}
</if>
<if test="snVoucherNumber != null and snVoucherNumber != '' and snVoucherNumber != 'null' and snVoucherNumber != '99'">
and t.sn_voucher_number = #{snVoucherNumber}
</if>
<if test="postingTimeStart != null and postingTimeStart != '' and postingTimeStart != 'null' and postingTimeStart != '99' and postingTimeEnd != null and postingTimeEnd != '' and postingTimeEnd != 'null' and postingTimeEnd != '99'">
and t.posting_time between #{postingTimeStart} and #{postingTimeEnd}
or comp_code is null or comp_code = ''
)
</if>
<if test="imageNumber != null and imageNumber != '' and imageNumber != 'null' and imageNumber != '99'">
and t.image_id = #{imageNumber}
<if test="companyCode != null and companyCode != '99' and companyCode != '88' and companyCode != '' and companyCode != 'null'" >
and comp_code = #{companyCode}
</if>
<if test="accountPeriod != null and accountPeriod != '' and accountPeriod != 'null' and accountPeriod != '99'">
and t.account_period = #{accountPeriod}
<if test="companyCode != null and companyCode != '' and companyCode == '88'">
and (comp_code = '' or comp_code is null)
</if>
<if test="qsksrq != null and qsksrq != '' and qsksrq != 'null' and qsjsrq != null and qsjsrq != '' and qsjsrq != 'null'">
order by t.qs_date desc,t.invoice_date desc
<if test="inAccountStatus != null and inAccountStatus != '' and inAccountStatus != 'null' and inAccountStatus != '99' and inAccountStatus == '0'.toString()">
and inaccount_status = '1'
</if>
<if test="qsksrq==null or qsksrq=='' or qsjsrq==null or qsjsrq==''">
order by t.invoice_date desc
<if test="qsflag != null and qsflag != '' and qsflag != 'null' and qsflag == '1'.toString()">
and qs_status = '1'
</if>
ORDER BY tax_amount
) AS subquery
WHERE <![CDATA[ max_tax <= #{maxTax} ]]>
</select>
<update id="updateSuspendType" parameterType="java.util.Map" databaseId="mysql">

@ -34,7 +34,6 @@ public class DictdetaServciceImpl implements DictdetaServcice {
@Override
public String queryDictName(String type,String code) {
log.info("type={},code={}",type,code);
String dictJson = redisUtils.get(RedisConstant.KEY_DICT + type);
List<DictdetaModel> dictdetaModels = JSON.parseArray(dictJson, DictdetaModel.class);
Map<String, String> collect = dictdetaModels.stream().collect(Collectors.toMap(DictdetaModel::getDictcode, DictdetaModel::getDictname));

@ -150,7 +150,7 @@
<dependency>
<groupId>com.dxhy.jxpt</groupId>
<artifactId>dxhy-oss</artifactId>
<version>3.2.9</version>
<version>3.3.3</version>
</dependency>
<!-- itext pdf相关 -->
<dependency>

@ -111,7 +111,7 @@
<dependency>
<groupId>com.dxhy.jxpt</groupId>
<artifactId>dxhy-oss</artifactId>
<version>3.2.9</version>
<version>3.3.3</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>

@ -107,7 +107,7 @@
<dependency>
<groupId>com.dxhy.jxpt</groupId>
<artifactId>dxhy-oss</artifactId>
<version>3.2.9</version>
<version>3.3.3</version>
</dependency>
<dependency>
<groupId>com.twelvemonkeys.imageio</groupId>

@ -606,18 +606,13 @@ public class SDNYMainProcessController extends AbstractController {
} else {
object.setZFILED5(environment);
}
// object.setZFILED5(environment);
List<SAPInvoiceInfo> sapInvoiceInfos = new ArrayList<>();
if (invoiceInfoList != null && invoiceInfoList.size() > 0) {
for (SNInvoice invoice : invoiceInfoList) {
String fplxdm = "";
String snFplx = "";
// if (invoice.getPurchaserTaxNo() == null || "".equals(invoice.getPurchaserTaxNo())){
// invoice.setPurchaserTaxNo(taxno);
// }
// if (invoice.getPurchaserName() == null || "".equals(invoice.getPurchaserName())){
// invoice.setPurchaserName(taxname);
// }
result = snPushCheckRecordService.updateInvoicePoll(company, taxno, reimburse, invoice, fplxdm, imageId, compCode);
//价税分离判断

@ -11,6 +11,7 @@ import com.dxhy.common.enums.FplxEnum;
import com.dxhy.common.enums.SNFplxEnum;
import com.dxhy.common.util.InvoiceUtil;
import com.dxhy.common.util.StringHelper;
import com.dxhy.common.utils.R;
import com.dxhy.common.vo.UserInfo;
import com.dxhy.erp.dao.*;
import com.dxhy.erp.entity.*;
@ -30,6 +31,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -95,6 +97,12 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
@Resource
private SysDeptDao sysDeptDao;
@Resource
private SNPushCheckRecordService snPushCheckRecordService;
@Resource
private SignSaveInvoiceInfoService signSaveInvoiceInfoService;
@Resource
private TdxPlatformCheckLogService platformCheckLogService;
@ -451,8 +459,8 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
jsonObject.put("tonnage", invoiceData.get("dw"));
jsonObject.put("limitPeople", invoiceData.get("xcrs"));
String taxRate = "";
if (invoiceData.get("sl")==null||StringUtils.isBlank(invoiceData.get("sl").toString())||
"免税".equals(invoiceData.get("sl").toString())|| "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) {
if (invoiceData.get("sl") == null || StringUtils.isBlank(invoiceData.get("sl").toString()) ||
"免税".equals(invoiceData.get("sl").toString()) || "不征税".equals(invoiceData.get("sl").toString()) || "***".equals(invoiceData.get("sl").toString())) {
taxRate = "0";
jsonObject.put("taxRate", taxRate);
} else {
@ -615,14 +623,19 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
InvoiceInfo invoiceInfo = convertToInvoiceInfo(invoice);
log.info("进行价税分离的发票信息为:{}", invoiceInfo);
ServiceResult<InvoiceInfo> invoiceResult = new ServiceResult<>();
boolean flag = false;
//0523晚成伟提出新需求,客运汽车票必须实名才可以进行价税分离
if(SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)){
if(StringUtils.isEmpty(invoice.getRiderName()) || StringUtils.isEmpty(invoice.getIdcardNo())){
if (SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)) {
if (StringUtils.isEmpty(invoice.getRiderName()) || StringUtils.isEmpty(invoice.getIdcardNo())) {
log.info("非实名的实名客票 不需要做价税分离");
flag = true;
invoiceResult.setMsg("ok");
invoiceResult.setResult(true);
}
invoiceResult.setMsg("ok");
invoiceResult.setResult(true);
}else {
}
if(!flag) {
invoiceResult = this.valoremTaxCount(invoiceInfo, "Y");
InvoiceInfo data = invoiceResult.getData();
if (data != null) {
@ -637,6 +650,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
}
}
if (!"ok".equals(invoiceResult.getMsg()) && !"0000".equals(invoiceResult.getMsg())) {
log.info("价税分离失败:{}", invoiceResult.getMsg());
return invoiceResult.getMsg();
@ -675,6 +689,62 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
if ("01".equals(fplxdm) || "02".equals(fplxdm) || "03".equals(fplxdm) || "04".equals(fplxdm)
|| "08".equals(fplxdm) || "10".equals(fplxdm) || "11".equals(fplxdm) || "14".equals(fplxdm)
|| "15".equals(fplxdm) || "31".equals(fplxdm) || "32".equals(fplxdm)) {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
String fpdm = invoice.getInvoiceCode();
String fphm = invoice.getInvoiceNumber();
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>();
if (StringUtils.isEmpty(fpdm)) {
recordWrapper.eq("uuid", fphm);
} else {
recordWrapper.eq("uuid", fpdm + fphm);
}
BaseTDxRecordInvoice update = baseTDxRecordInvoiceDao.selectOne(recordWrapper);
Map<String, String> pramsMap = new HashMap<>();
JSONObject checkInvoiceResult = null;
//如果提交的发票信息在底账库不存在,则重新补充查验,插入数据库中.
if (update == null) {
try {
//传入的参数为:{billingDate=2023-04-24, totalAmount=9708.74, purchaserTaxNo=91370000MA3RD38A9Q, invoiceNumber=02014197, invoiceType=10100,
// invoiceCode=3700222130, checkCode=}
pramsMap.put("invoiceCode", fpdm);
pramsMap.put("invoiceNumber", fphm);
if (StringUtils.isNotEmpty(invoice.getBillingDate())) {
String billingDate = invoice.getBillingDate().replaceAll("-", "");
pramsMap.put("billingDate", billingDate);
}
if("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())){
pramsMap.put("totalAmount", invoice.getAmountTax());
}else{
pramsMap.put("totalAmount", invoice.getTotalAmount());
}
pramsMap.put("purchaserTaxNo", invoice.getPurchaserTaxNo());
if("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())){
pramsMap.put("invoiceType", "21");
}else {
pramsMap.put("invoiceType", invoice.getInvoiceType());
}
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap);
log.info("补充查验结果为:{}", checkInvoiceResult);
} catch (Exception e) {
e.printStackTrace();
log.error("补充查验失败,errormsg:{}", e.getMessage());
}
if (!checkInvoiceResult.containsKey("code")) {
if (!checkInvoiceResult.containsKey("cyjg")) {
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber"));
log.info("补充查验的结果为:{}", checkInvoiceResult);
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, "", "1", "business");
}
}
}
DynamicContextHolder.push(DbConstant.BASICS_WRITE);
//可查验发票,已入库,更新票池
Integer integer = this.pushInvoiceToRecordInvoice2(invoice, imageId, compCode);
log.info("可查验发票,更新底账库完成");
@ -720,10 +790,10 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
log.info("uuid={}", uuid);
reimburse.setSelectId(uuid);
if (StringHelper.isNotBlank(invoice.getTaxRate())){
if (StringHelper.isNotBlank(invoice.getTaxRate())) {
reimburse.setTaxRate(invoice.getTaxRate());
reimburse.setTaxCode(getTaxCode(invoice.getTaxRate()));
}else {
} else {
reimburse.setTaxRate("0%");
reimburse.setTaxCode(getTaxCode(reimburse.getTaxRate()));
}

@ -19,7 +19,6 @@ import com.dxhy.erp.model.auth.InterfaceCode;
import com.dxhy.erp.service.InvoiceAuthService;
import com.dxhy.erp.service.TDxInvoiceReimburseService;
import com.dxhy.erp.utils.CheckUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
@ -35,7 +34,6 @@ import java.util.*;
*/
@SuppressWarnings({"AlibabaMethodTooLong", "AlibabaUndefineMagicConstant"})
@Service
@Slf4j
public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao, RecordInvoice>
implements InvoiceAuthService {
@ -366,9 +364,8 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao,
String uuid = zdata1.getZFPDM()+zdata1.getZFPHM();
//销项标识
String xxbs = zdata1.getXXBS();
log.info("xxbs==>{}",xxbs);
DynamicContextHolder.push("business"+DbConstant.BUSINESS_READ);
if(fplxList.contains(zdata1.getZFPLX()) && !"X".equals(xxbs)){
if(fplxList.contains(zdata1.getZFPLX()) && !"X".equalsIgnoreCase(xxbs)){
TdxRecordInvoice recordInvoiceByUuid = tDxrecordInvoiceDao.getRecordInvoiceByUuid(uuid);
if(recordInvoiceByUuid!=null){
UpdateWrapper updateWrapper = new UpdateWrapper();
@ -424,7 +421,7 @@ public class InvoiceAuthServiceImpl extends MpBaseServiceImpl<RecordInvoiceDao,
DynamicContextHolder.push("business"+DbConstant.BUSINESS_WRITE);
tDxInvoiceReimburseService.getBaseMapper().update(null,updateWrapper);
}
if ("X".equals(xxbs)){
if ("X".equalsIgnoreCase(xxbs)){
DynamicContextHolder.push("business"+DbConstant.BUSINESS_WRITE);
UpdateWrapper updateWrapper = new UpdateWrapper();
updateWrapper.set("sn_voucher_number",zdata1.getBELNR());

@ -3,6 +3,7 @@ package com.dxhy.extend.controller;
import com.dxhy.common.aspect.SysLog;
import com.dxhy.common.constant.CommonConstants;
import com.dxhy.common.controller.AbstractController;
import com.dxhy.common.util.StringHelper;
import com.dxhy.common.util.UserInfoUtil;
import com.dxhy.common.utils.DateUtils;
import com.dxhy.common.utils.R;
@ -115,6 +116,25 @@ public class ExtFpzhcxController extends AbstractController {
}
pramsMap.put("gfsh", gfshList);
boolean flag = checkList(gfshList);
if (flag){
pramsMap.put("sign","88");
}else {
pramsMap.put("sign","99");
}
String companyCode = (String) pramsMap.get("companyCode");
if (org.apache.commons.lang3.StringUtils.isNotBlank(companyCode) && "99".equals(companyCode)){
pramsMap.put("companyCodes",getUserInfo().getCompanyCodes());
log.info("组织机构====>{}",pramsMap.get("companyCodes"));
}
if (StringUtils.isNotBlank(companyCode)){
pramsMap.put("companyCode",companyCode);
}else {
return ResponseEntity.ok(R.error("所属组织不能为空"));
}
if (pramsMap.get("kpksrq") != null && !"".equals(pramsMap.get("kpksrq"))) {
pramsMap.put("kpksrq", DateUtils.getMorning(DateUtils.strToDate(pramsMap.get("kpksrq").toString())));
}
@ -199,6 +219,25 @@ public class ExtFpzhcxController extends AbstractController {
}
public boolean checkList(List<String> list) {
boolean flag =false;
if (list == null || list.isEmpty()){
flag = true;
}else {
String s = list.toString().replace("[","").replace("]","");
if (StringHelper.isBlank(s)){
flag = true;
}
if (StringHelper.isNotBlank(s) && s.contains(",")){
String replace = s.replace(",", "");
if (StringHelper.isBlank(replace)){
flag = true;
}
}
}
return flag;
}
/**
* 报表异常发票查询
*

@ -69,11 +69,30 @@
t.settlement_no,t.inaccount_status,t.bzdh,
t.settlement_status,t.voucher_number,t.total_amount,t.sn_voucher_number,t.posting_time,t.image_id,t.account_period
from t_dx_record_invoice t
WHERE t.company = #{company} and t.invoice_date between #{kpksrq} and #{kpjsrq}
and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
WHERE t.company = #{company}
and t.invoice_date between #{kpksrq} and #{kpjsrq}
<if test="sign != '88'">
and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="companyCode != null and companyCode != '' and companyCode != 'null' and companyCode == '99'">
and (t.comp_code in
<foreach collection="companyCodes" index="index" item="companyCode" separator="," open="(" close=")">
#{companyCode}
</foreach>
or t.comp_code is null or t.comp_code = ''
)
</if>
<if test="companyCode != null and companyCode != '99' and companyCode != '88' and companyCode != '' and companyCode != 'null'" >
and t.comp_code = #{companyCode}
</if>
<if test="companyCode != null and companyCode != '' and companyCode == '88'">
and (t.comp_code = '' or t.comp_code is null)
</if>
<if test="bzdh != null and bzdh != '' and bzdh != 'null'">
and t.bzdh = #{bzdh}
</if>
@ -331,10 +350,29 @@
select count(1) hjsl,sum(t.invoice_amount)hjje,sum(t.tax_amount)hjse
from t_dx_record_invoice t
where t.invoice_date between #{kpksrq} and #{kpjsrq}
and t.company = #{company} and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and t.company = #{company}
<if test="sign != '88'">
and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="companyCode != null and companyCode != '' and companyCode != 'null' and companyCode == '99'">
and (t.comp_code in
<foreach collection="companyCodes" index="index" item="companyCode" separator="," open="(" close=")">
#{companyCode}
</foreach>
or t.comp_code is null or t.comp_code = ''
)
</if>
<if test="companyCode != null and companyCode != '99' and companyCode != '88' and companyCode != '' and companyCode != 'null'" >
and t.comp_code = #{companyCode}
</if>
<if test="companyCode != null and companyCode != '' and companyCode == '88'">
and (t.comp_code = '' or t.comp_code is null)
</if>
<if
test="invoiceStatus != null and invoiceStatus != '' and invoiceStatus != 'null' and invoiceStatus != '99'">
and t.invoice_status = #{invoiceStatus}

@ -182,7 +182,7 @@
where t.invoice_status != '0'
and t.invoice_type in ('01','03','08','14','31')
and t.company = #{company}
and DATE_FORMAT(t.invoice_date,'%Y-%m-%d') between #{kpksrq} and #{kpjsrq}
and t.invoice_date between #{kpksrq} and #{kpjsrq}
and t.gf_tax_no in
<foreach collection="gfsh" index="index" item="item" open="(" separator="," close=")">
#{item}

@ -13,8 +13,10 @@
select count(1) totalCount, ifnull(sum(invoice_amount), 0) totalAmount,
ifnull(sum(dk_tax_amount), 0) totalTax
FROM t_dx_record_invoice
WHERE valid='1' and invoice_type in ('01','03','08','14','31') AND invoice_status='0' AND
rzh_yesorno='1'
WHERE valid='1'
and (invoice_type in('01','03','08','14','31','283','161','183','185') or (invoice_type ='32' and t.lq_tdyslxDm='08'))
AND invoice_status='0'
AND rzh_yesorno='1'
<if test="skssq !=null and skssq != ''">
and rzh_belong_date = #{skssq}
</if>
@ -54,9 +56,11 @@
<select id="getTotalOutTax" resultType="Double" databaseId="mysql">
SELECT ifnull(sum(out_tax_amount), 0) FROM t_dx_record_invoice
WHERE valid='1' and invoice_type in ('01','03','08','14','31') AND invoice_status='0' AND
rzh_yesorno='1' AND
out_status in ('1','2')
WHERE valid='1'
and (invoice_type in('01','03','08','14','31','283','161','183','185') or (invoice_type ='32' and t.lq_tdyslxDm='08'))
AND invoice_status='0'
AND rzh_yesorno='1'
AND out_status in ('1','2')
<if test="skssq !=null and skssq != ''">
and out_belong_date = #{skssq}
</if>
@ -69,9 +73,11 @@
out_reason rzhDate,
ifnull(sum(out_tax_amount), 0) tax
FROM t_dx_record_invoice
WHERE valid='1' and invoice_type in ('01','03','08','14','31') AND invoice_status='0' AND
rzh_yesorno='1' AND
out_status in ('1','2')
WHERE valid='1'
and (invoice_type in('01','03','08','14','31','283','161','183','185') or (invoice_type ='32' and t.lq_tdyslxDm='08'))
AND invoice_status='0'
AND rzh_yesorno='1'
AND out_status in ('1','2')
<if test="skssq !=null and skssq != ''">
and out_belong_date = #{skssq}
</if>

@ -0,0 +1 @@
README

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.dxhy</groupId>
<artifactId>ofd</artifactId>
<version>3.2.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dxhy.jxpt</groupId>
<artifactId>dxhy-oss</artifactId>
<version>3.3.3</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.13.2</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.131</version>
</dependency>
<!-- ftp -->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<!-- 使用commons-pool2 实现ftp连接池 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.7.0</version>
</dependency>
<!-- minio 存储依赖 -->
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
<version>8.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>releases</id>
<name>releases</name>
<url>http://10.1.20.6:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>snapshots</name>
<url>http://10.1.20.6:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>大象慧云</id>
<name>Public Repositories</name>
<url>http://10.1.20.6:8081/nexus/content/groups/public/</url>
</repository>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,154 @@
package com.dxhy.oss.config;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.jcraft.jsch.ChannelSftp;
import lombok.Data;
/**
* @author jiaohongyang
*/
@Component
@Data
public class OssConfig {
/**
* oss 服务类型 JD AL FTP
*/
@Value("${oss.ossType:FTP}")
public String ossType;
/**
* 阿里请求地址
*/
@Value("${oss.endpointUrl:}")
public String endpointUrl;
/**
* 访问密钥
*/
@Value("${oss.accessKeyId:}")
public String accessKeyId;
/**
* 访问密钥
*/
@Value("${oss.accessKeySecret:}")
public String accessKeySecret;
/**
* 京东云地域
*/
@Value("${oss.region:}")
public String region;
/**
* 实例
*/
@Value("${oss.bucketName:}")
public String bucketName;
/**
* ftp上传的根路径
*/
@Value("${ftp.connection.pathPrefix:}")
public String pathPrefix;
/**
* ftp服务器地址
*/
@Value("${ftp.connection.hostname:}")
public String hostname;
/**
* ftp服务器端口
*/
@Value("${ftp.connection.port:62236}")
public String port;
/**
* ftp登录密码
*/
@Value("${ftp.connection.password:}")
public String password;
@Value("${ftp.connection.timeout:6000}")
public String timeout;
/**
* ftp登录账号
*/
@Value("${ftp.connection.username:}")
public String username;
@Value("${ftp.connection.localPathDefault:}")
public String localPathDefault;
/**
* 临时路径
*/
@Value("${ftp.connection.tempPath:}")
public String tempPath;
/**
* ftp配置信息
*/
@Value("${ftp.connection.size:2}")
public String pdfSize;
/**
* 图片的最大大小
*/
@Value("${oss.imageSize:10485760}")
public long imageSize;
/**
* 其他文件的最大大小
*/
@Value("${oss.fileSize:1073741824}")
public long fileSize;
private Pool pool = new Pool();
public static class Pool extends GenericObjectPoolConfig<ChannelSftp> {
private int maxTotal = DEFAULT_MAX_TOTAL;
private int maxIdle = DEFAULT_MAX_IDLE;
private int minIdle = DEFAULT_MIN_IDLE;
public Pool() {
super();
}
@Override
public int getMaxTotal() {
return maxTotal;
}
@Override
public void setMaxTotal(int maxTotal) {
this.maxTotal = maxTotal;
}
@Override
public int getMaxIdle() {
return maxIdle;
}
@Override
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
@Override
public int getMinIdle() {
return minIdle;
}
@Override
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
}
}

@ -0,0 +1,27 @@
package com.dxhy.oss.config;
/**
* @author jiaohongyang焦红阳
* @date 2020-09-30
*/
public interface OssReturnConfig {
String SUCCESS = "000000";
String ERROR_01 = "000001";
String ERROR_09 = "999999";
String JD = "JD";
String AL = "AL";
String FTP = "FTP";
String SSH = "SSH";
String LOCAL = "LOCAL";
String TOS = "TOS";
String MINIO = "MINIO";
}

@ -0,0 +1,19 @@
package com.dxhy.oss.model;
import lombok.Data;
/**
* @author jiaohongyang焦红阳
* @date 2020-10-17
*/
@Data
public class FileModel {
/**
* 编码
*/
private String code;
/**
* 文件地址
*/
private String filePath;
}

@ -0,0 +1,41 @@
package com.dxhy.oss.service;
import com.dxhy.oss.model.FileModel;
/**
* @author jiaohongyang
*/
public interface AliOssService {
/**
* 阿里云OSS文件存储
*
* @param file 文件
* @return 返回
*/
FileModel uploadFile(String fileName, String file);
/**
* 下载
*
* @param fileName 文件名称
* @param filePath 本地文件存储地址
* @return 返回
*/
FileModel downloadFile(String fileName, String filePath);
/**
* 删除文件
*
* @param file 文件名
* @return 返回
*/
FileModel deleteFile(String file);
/**
* 生产文件下载地址
*
* @param key 文件传输路径加名称
* @return 返回下载地址
*/
FileModel getUrl(String key);
}

@ -0,0 +1,72 @@
package com.dxhy.oss.service;
import com.dxhy.oss.model.FileModel;
/**
* @author jiaohongyang
*/
public interface FileService {
/**
* 文件上传
*
* @param fileName 文件 ftp名称
* @param originFileName 本地文件地址
* @return 返回
* @throws Exception 异常
*/
FileModel uploadFile(String fileName, String originFileName) throws Exception;
/**
* 文件下载
*
* @param downloadFile 下载文件
* @param saveFile 保存文件地址
* @return 返回
* @throws Exception 异常
*/
FileModel downFile(String downloadFile, String saveFile) throws Exception;
/**
* 生成文件下载地址
*
* @param key 文件传输路径加名称
* @return 返回文件下载地址
*/
FileModel getUrl(String key);
/**
* 删除文件
*
* @param file 文件地址
* @return 返回
*/
FileModel deleteFile(String file);
/**
* 获取ftp 上传地址
*
* @return 返回
*/
String getPathPrefix();
/**
* 图片本地地址
*
* @return 返回
*/
String getLocalPathDefault();
/**
* 临时路径
*/
String getTempPath();
/**
* PDF 上传文件大小
*/
String getFtpPdfSize();
}

@ -0,0 +1,275 @@
package com.dxhy.oss.service;
import com.dxhy.oss.utils.SftpPool;
import com.dxhy.oss.utils.SftpPoolException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.springframework.stereotype.Service;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class FtpService {
private final SftpPool pool;
public FtpService(SftpPool pool) {
this.pool = pool;
}
/**
* ftp上传文件
*
* @param serviceDec
* @param fileName
* @param localDec 本地目录
* @return
*/
public boolean uploadFile( String serviceDec, String fileName, String localDec) throws InterruptedException {
FTPClient ftpClient = null;
InputStream inputStream = null;
boolean result =true;
try {
inputStream = new FileInputStream(new File(localDec));
log.info("开始上传文件");
ftpClient = pool.borrowObject();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
createDirecroty(ftpClient, serviceDec);
ftpClient.makeDirectory(serviceDec);
ftpClient.changeWorkingDirectory(serviceDec);
ftpClient.storeFile(fileName, inputStream);
inputStream.close();
ftpClient.logout();
log.info("上传文件成功");
} catch (Exception e) {
e.printStackTrace();
log.error("上传文件失败" + e);
result =false;
} finally {
try {
log.info("回收线程");
pool.returnObject(ftpClient);
if (null != inputStream) {
inputStream.close();
}
} catch (IOException e) {
log.error("上传文件失败" + e);
result =false;
}
}
return result;
}
public boolean deleteFile(String directory, String deleteFile) {
FTPClient ftpClient = null;
try {
ftpClient = pool.borrowObject();
return ftpClient.deleteFile(directory + File.separator + deleteFile);
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (ftpClient != null) {
log.info("回收线程");
pool.returnObject(ftpClient);
}
}
}
private static boolean createDirecroty(FTPClient ftpClient, String remote) throws IOException {
boolean success = true;
String directory = remote + "/";
// 如果远程目录不存在,则递归创建远程服务器目录
if (!directory.equalsIgnoreCase("/") && !changeWorkingDirectory(ftpClient, new String(directory))) {
int start = 0;
int end = 0;
if (directory.startsWith("/")) {
start = 1;
} else {
start = 0;
}
end = directory.indexOf("/", start);
String path = "";
String paths = "";
while (true) {
String subDirectory = new String(remote.substring(start, end).getBytes("GBK"), "iso-8859-1");
path = path + "/" + subDirectory;
if (!existFile(ftpClient, path)) {
if (makeDirectory(ftpClient, subDirectory)) {
changeWorkingDirectory(ftpClient, subDirectory);
} else {
log.info("创建目录[" + subDirectory + "]失败");
changeWorkingDirectory(ftpClient, subDirectory);
}
} else {
changeWorkingDirectory(ftpClient, subDirectory);
}
paths = paths + "/" + subDirectory;
start = end + 1;
end = directory.indexOf("/", start);
// 检查所有目录是否创建完毕
if (end <= start) {
break;
}
}
}
return success;
}
//改变目录路径
private static boolean changeWorkingDirectory(FTPClient ftpClient, String directory) {
boolean flag = true;
try {
flag = ftpClient.changeWorkingDirectory(directory);
if (flag) {
log.info("进入文件夹" + directory + " 成功!");
} else {
log.info("进入文件夹" + directory + " 失败!开始创建文件夹");
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
return flag;
}
//判断ftp服务器文件是否存在
private static boolean existFile(FTPClient ftpClient, String path) throws IOException {
boolean flag = false;
FTPFile[] ftpFileArr = ftpClient.listFiles(path);
if (ftpFileArr.length > 0) {
flag = true;
}
return flag;
}
//创建目录
private static boolean makeDirectory(FTPClient ftpClient, String dir) {
boolean flag = true;
try {
flag = ftpClient.makeDirectory(dir);
if (flag) {
log.info("创建文件夹" + dir + " 成功!");
} else {
log.info("创建文件夹" + dir + " 失败!");
}
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
/**
* 获取FTP某一特定目录下的所有文件名称
*
* @param ftpClient 已经登陆成功的FTPClient
* @param ftpDirPath FTP上的目标文件路径
*/
public static List getFileNameList(FTPClient ftpClient, String ftpDirPath) {
List list = new ArrayList();
try {
if (ftpDirPath.startsWith("/") && ftpDirPath.endsWith("/")) {
// 通过提供的文件路径获取FTPFile对象列表
FTPFile[] files = ftpClient.listFiles(ftpDirPath);
// 遍历文件列表,打印出文件名称
for (int i = 0; i < files.length; i++) {
FTPFile ftpFile = files[i];
// 此处只打印文件,未遍历子目录(如果需要遍历,加上递归逻辑即可)
if (ftpFile.isFile()) {
// log.info(ftpDirPath + ftpFile.getName());
list.add(ftpFile.getName());
}
}
log.info("当前FTP路径可用");
} else {
log.info("当前FTP路径不可用");
}
} catch (IOException e) {
log.error("错误" + e);
}
return list;
}
/**
* @param servicePath ftp的路径
* @param fileName 文件名称
* @param localFilePath 下载到本地的文件夹
* @return
*/
public boolean downloadFile(String servicePath, String fileName, String localFilePath) {
FTPClient ftpClient;
try {
ftpClient = pool.borrowObject();
String name = dowFile(ftpClient, servicePath, fileName, localFilePath);
if (name != null && !name.equals("")){
return true;
}
} catch (SftpPoolException e) {
e.printStackTrace();
}
return false;
}
/**
*
* @param ftpClient
* @param servicePath ftp的路径
* @param fileName 文件名称
* @param localFilePath 下载到本地的文件夹
* @return
*/
private static String dowFile(FTPClient ftpClient, String servicePath, String fileName, String localFilePath) {
InputStream is = null;
FileOutputStream fos = null;
try {
ftpClient.enterLocalPassiveMode();
is = ftpClient.retrieveFileStream(servicePath + fileName);// 获取ftp上的文件
directoryIsExists(localFilePath);
fos = new FileOutputStream(new File(localFilePath + fileName));
// 文件读取方式一
int i;
byte[] bytes = new byte[1024];
while ((i = is.read(bytes)) != -1) {
fos.write(bytes, 0, i);
}
ftpClient.completePendingCommand();
log.info("FTP文件下载成功!");
} catch (Exception e) {
log.error("FTP文件下载失败!" + e);
} finally {
try {
if (fos != null) {fos.close();}
if (is != null) {is.close();}
} catch (IOException e) {
log.error("下载流关闭失败" + e);
return null;
}
}
return localFilePath + fileName;
}
public static void directoryIsExists(String path) {
File directory = new File(path);
if (directory.exists()) {
return;
}
if (!directory.mkdir()) {
return;
}
if (directory.canWrite()) {
return;
}
boolean setWritable = directory.setWritable(true);
log.info("是否创建文件 directoryIsExists :{} ", setWritable);
}
}

@ -0,0 +1,46 @@
package com.dxhy.oss.service;
import com.dxhy.oss.model.FileModel;
/**
* @author jiaohongyang
*/
public interface JdOssService {
/**
* 阿里云OSS文件存储
*
* @param file
* 文件
* @return 返回
*/
FileModel uploadFile(String fileName, String file);
/**
* 下载
*
* @param fileName
* 文件名称
* @param filePath
* 本地文件存储地址
* @return 返回
*/
FileModel downloadFile(String fileName, String filePath);
/**
* 生成文件下载地址
*
* @param key
* 文件传输路径加名称
* @return 返回文件下载地址
*/
FileModel getUrl(String key);
/**
* 删除文件
*
* @param file
* 文件信息
* @return 返回
*/
FileModel deleteFile(String file);
}

@ -0,0 +1,165 @@
package com.dxhy.oss.service;
import cn.hutool.core.io.FileUtil;
import com.dxhy.oss.utils.SshPool;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.SftpException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
/**
* @author jiaohongyang
*/
@Slf4j
public class SshService {
private final SshPool pool;
public SshService(SshPool pool) {
this.pool = pool;
}
/**
* 将输入流的数据上传到sftp作为文件文件完整路径 = basePath+directory
*
* @param pathName ftp服务保存地址完整路径
* @param fileName 上传到ftp的文件名
* @param originFileName 待上传文件的名称绝对地址
*/
public boolean uploadFile(String pathName, String fileName, String originFileName) {
log.info("开始上传文件");
ChannelSftp sftp = null;
InputStream inputStream;
try {
sftp = pool.borrowObject();
try {
sftp.cd(pathName);
} catch (SftpException e) {
// 目录不存在,则创建文件夹
String[] dirs = pathName.split("/");
String tempPath = "";
for (String dir : dirs) {
if (null == dir || "".equals(dir)) {
continue;
}
tempPath += "/" + dir;
try {
sftp.cd(tempPath);
} catch (SftpException ex) {
try {
sftp.mkdir(tempPath);
sftp.cd(tempPath);
} catch (SftpException e1) {
e1.printStackTrace();
}
}
}
}
File orgFile = new File(originFileName);
inputStream = Files.newInputStream(orgFile.toPath());
sftp.put(inputStream, fileName);
inputStream.close();
// 删除本地文件,防止服务器空间不足
FileUtil.del(orgFile);
log.info("上传文件成功");
return true;
} catch (Exception e) {
e.printStackTrace();
log.info("上传文件失败");
return false;
} finally {
if (sftp != null) {
log.info("回收线程");
pool.returnObject(sftp);
}
}
}
public boolean downloadFile(String directory, String downloadFile, String saveFile) {
log.info("开始下载文件!");
ChannelSftp sftp = null;
try {
sftp = pool.borrowObject();
if (directory != null && !"".equals(directory)) {
sftp.cd(directory);
}
String file = saveFile + "/" + downloadFile;
File fileLocal = new File(file);
if (fileLocal.exists()) {
boolean delete = fileLocal.delete();
log.info("删除本地路径文件:{}", delete);
}
this.directoryIsExists(saveFile);
sftp.get(downloadFile, file);
log.info("下载文件成功!");
return true;
} catch (Exception e) {
e.printStackTrace();
log.info("下载文件失败!");
return false;
} finally {
if (sftp != null) {
log.info("回收线程");
pool.returnObject(sftp);
}
}
}
/**
* 删除文件
*
* @param directory 要删除文件所在目录
* @param deleteFile 要删除的文件
* @return 返回是否删除成功
*/
public boolean deleteFile(String directory, String deleteFile) {
ChannelSftp sftp = null;
try {
sftp = pool.borrowObject();
sftp.cd(directory);
sftp.rm(deleteFile);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
if (sftp != null) {
log.info("回收线程");
pool.returnObject(sftp);
}
}
}
public void directoryIsExists(String path) {
File directory = new File(path);
if (directory.exists()) {
return;
}
if (!directory.mkdir()) {
return;
}
if (directory.canWrite()) {
return;
}
boolean setWritable = directory.setWritable(true);
log.info("是否创建文件 directoryIsExists :{} ", setWritable);
}
}

@ -0,0 +1,186 @@
package com.dxhy.oss.service.impl;
import cn.hutool.core.io.FileUtil;
import com.aliyun.oss.OSS;
import com.aliyun.oss.model.GetObjectRequest;
import com.dxhy.oss.config.OssConfig;
import com.dxhy.oss.config.OssReturnConfig;
import com.dxhy.oss.model.FileModel;
import com.dxhy.oss.service.AliOssService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.net.URL;
import java.util.Date;
/**
* @author jiaohongyang
*/
@Service("aliOssService")
@Slf4j
public class AliOssServiceImpl implements AliOssService {
private final OssConfig ossConfig;
@Autowired
public AliOssServiceImpl(OssConfig ossConfig) {
this.ossConfig = ossConfig;
}
/**
* 阿里云OSS文件存储
*
* @param filePath 文件
* @return 返回
*/
@Override
public FileModel uploadFile(String fileName, String filePath) {
OSS ossClient = null;
FileModel fileModel;
log.info("文件存储阿里OSS,存储目录:{} , 存储文件名:{} ", ossConfig.getBucketName(), fileName);
try {
// 创建连接
ossClient =
OssClientFactory.getInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
if (ossClient == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
// 进行文件上传
ossClient.putObject(ossConfig.getBucketName(), fileName, new File(filePath));
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
fileModel.setFilePath(fileName);
return fileModel;
} catch (Exception e) {
log.error("文件存储阿里OSS失败,异常:{}", e.getMessage());
e.printStackTrace();
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
FileUtil.del(filePath);
}
}
@Override
public FileModel getUrl(String key) {
OSS ossClient = null;
FileModel fileModel;
try {
ossClient =
OssClientFactory.getInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
if (ossClient == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
// 设置URL过期时间为10年 3600l* 1000*24*365*10
Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000 * 24);
// 生成URL
URL url = ossClient.generatePresignedUrl(ossConfig.getBucketName(), key, expiration);
if (url != null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
fileModel.setFilePath(url.toString());
return fileModel;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
/**
* 下载
*
* @param fileName 文件名称
* @param filePath 本地文件存储地址
* @return 返回
*/
@Override
public FileModel downloadFile(String fileName, String filePath) {
log.info("下载文件阿里OSS,存储目录:{} , 存储文件名:{} ", ossConfig.getBucketName(), fileName);
OSS ossClient = null;
FileModel fileModel;
try {
// 创建连接
ossClient =
OssClientFactory.getInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
if (ossClient == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
// 下载OSS文件到本地文件。如果指定的本地文件存在会覆盖,不存在则新建。
ossClient.getObject(new GetObjectRequest(ossConfig.getBucketName(), fileName), new File(filePath));
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
fileModel.setFilePath(filePath);
return fileModel;
} catch (Exception e) {
log.error("文件下载阿里OSS失败,异常:{}", e.getMessage());
e.printStackTrace();
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
}
/**
* 删除文件
*
* @param file 文件名
* @return 返回
*/
@Override
public FileModel deleteFile(String file) {
log.info("文件删除阿里OSS,存储目录:{} , 存储文件名:{} ", ossConfig.getBucketName(), file);
OSS ossClient = null;
FileModel fileModel;
try {
// 创建连接
ossClient =
OssClientFactory.getInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
if (ossClient == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
ossClient.deleteObject(ossConfig.getBucketName(), file);
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
return fileModel;
} catch (Exception e) {
log.error("文件删除阿里OSS失败,异常:{}", e.getMessage());
e.printStackTrace();
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
}
}

@ -0,0 +1,328 @@
package com.dxhy.oss.service.impl;
import cn.hutool.core.io.FileUtil;
import com.dxhy.oss.config.OssConfig;
import com.dxhy.oss.config.OssReturnConfig;
import com.dxhy.oss.model.FileModel;
import com.dxhy.oss.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @author jiaohongyang
*/
@Slf4j
@Service("fileService")
public class FileServiceImpl implements FileService {
private final OssConfig ossConfig;
private final AliOssService aliOssService;
private final JdOssService jdOssService;
private final FtpService ftpService;
private final SshService sshService;
@Autowired
public FileServiceImpl(OssConfig ossConfig, AliOssService aliOssService, JdOssService jdOssService, FtpService ftpService, SshService sshService) {
this.ossConfig = ossConfig;
this.aliOssService = aliOssService;
this.jdOssService = jdOssService;
this.ftpService = ftpService;
this.sshService = sshService;
}
/**
* 文件上传
*
* @param fileName 上传文件路径+ 名称
* @param originFileName 本地文件地址
* @return 返回
* @throws Exception 异常
*/
@Override
public FileModel uploadFile(String fileName, String originFileName) {
log.info("上传文件地址:{} , 本地存储文件地址:{}", fileName, originFileName);
FileModel fileModel;
if (OssReturnConfig.AL.equals(ossConfig.getOssType())) {
if (fileName.startsWith("/")) {
fileName = fileName.substring(1);
}
fileModel = aliOssService.uploadFile(fileName, originFileName);
} else if (OssReturnConfig.JD.equals(ossConfig.getOssType())) {
if (fileName.startsWith("/")) {
fileName = fileName.substring(1);
}
fileModel = jdOssService.uploadFile(fileName, originFileName);
} else if (OssReturnConfig.SSH.equals(ossConfig.getOssType())){
if (!fileName.startsWith("/")) {
fileName = "/" + fileName;
}
String directory = fileName.substring(0, fileName.lastIndexOf("/"));
File directoryFile = new File(fileName);
String downloadFileName = directoryFile.getName();
boolean b = sshService.uploadFile(directory, downloadFileName, originFileName);
fileModel = new FileModel();
fileModel.setFilePath(fileName);
if (b) {
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel.setCode(OssReturnConfig.ERROR_09);
}
}else if (OssReturnConfig.FTP.equals(ossConfig.getOssType())) {
if (!fileName.startsWith("/")) {
fileName = "/" + fileName;
}
String directory = fileName.substring(0, fileName.lastIndexOf("/"));
File directoryFile = new File(fileName);
String downloadFileName = directoryFile.getName();
boolean b = false;
try {
b = ftpService.uploadFile(directory, downloadFileName, originFileName);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
fileModel = new FileModel();
fileModel.setFilePath(fileName);
if (b) {
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel.setCode(OssReturnConfig.ERROR_09);
}
} else if(OssReturnConfig.LOCAL.equals(ossConfig.getOssType())){
//创建目录
boolean b = false;
FileInputStream fis = null;
FileOutputStream fos = null;
try {
File directory = new File(fileName.substring(0, fileName.lastIndexOf("/")));
if(!directory.exists()){
directory.mkdirs();
}
File sourceFile = new File(originFileName);
File file = new File(fileName);
if(!file.exists()){
file.createNewFile();
}
fis = new FileInputStream(sourceFile);
fos = new FileOutputStream(file);
//复制文件
byte[] bytes = new byte[1024];
while (fis.read(bytes) != -1){
fos.write(bytes);
}
fos.flush();
b = true;
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if(fis != null){fis.close();}
if(fos != null){fos.close();}
} catch (IOException e) {
log.error("上传文件关闭文件流异常:{}",e.getMessage());
}
}
fileModel = new FileModel();
fileModel.setFilePath(fileName);
if (b) {
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel.setCode(OssReturnConfig.ERROR_09);
}
} else {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
}
log.info("文件上传结果编码:{},地址信息返回:{}", fileModel.getCode(), fileModel.getFilePath());
return fileModel;
}
/**
*
* @param downloadFile 下载文件 服务器路径
* @param saveFile 保存文件地址 本地路劲
* @return
*/
@Override
public FileModel downFile(String downloadFile, String saveFile) {
log.info("下载文件地址:{} , 本地存储文件地址:{}", downloadFile, saveFile);
// 获取下载文件存储路径 ,路径不存在则创建路径
File file = new File(saveFile);
String path = file.getParent();
FileUtil.mkdir(path);
FileModel fileModel;
if (OssReturnConfig.AL.equals(ossConfig.getOssType())) {
if (downloadFile.startsWith("/")) {
downloadFile = downloadFile.substring(1);
}
fileModel = aliOssService.downloadFile(downloadFile, saveFile);
} else if (OssReturnConfig.JD.equals(ossConfig.getOssType())) {
if (downloadFile.startsWith("/")) {
downloadFile = downloadFile.substring(1);
}
fileModel = jdOssService.downloadFile(downloadFile, saveFile);
} else if(OssReturnConfig.SSH.equals(ossConfig.getOssType())){
String directory = downloadFile.substring(0, downloadFile.lastIndexOf("/"));
String downloadFileName = downloadFile.substring(downloadFile.lastIndexOf("/") + 1);
boolean b = sshService.downloadFile(directory, downloadFileName, path);
fileModel = new FileModel();
fileModel.setFilePath(saveFile);
if (b) {
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel.setCode(OssReturnConfig.ERROR_09);
}
}else if (OssReturnConfig.FTP.equals(ossConfig.getOssType())) {
String directory = downloadFile.substring(0, downloadFile.lastIndexOf("/"));
File directoryFile = new File(downloadFile);
String downloadFileName = directoryFile.getName();
boolean b = ftpService.downloadFile(directory, downloadFileName, path);
fileModel = new FileModel();
fileModel.setFilePath(saveFile);
if (b) {
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel.setCode(OssReturnConfig.ERROR_09);
}
} else if(OssReturnConfig.LOCAL.equals(ossConfig.getOssType())){
//创建目录
boolean b = false;
FileInputStream fis = null;
FileOutputStream fos = null;
try {
File download = new File(downloadFile);
fis = new FileInputStream(download);
fos = new FileOutputStream(file);
//复制文件
byte[] bytes = new byte[1024];
while (fis.read(bytes) != -1){
fos.write(bytes);
}
fos.flush();
b = true;
} catch (IOException e) {
log.error("本地导出异常:{}",e);
}finally {
try {
if(fis != null){fis.close();}
if(fos != null){fos.close();}
} catch (IOException e) {
log.error("上传文件关闭文件流异常:{}",e.getMessage());
}
}
fileModel = new FileModel();
fileModel.setFilePath(saveFile);
if (b) {
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel.setCode(OssReturnConfig.ERROR_09);
}
} else {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
}
log.info("文件下载结果编码:{},地址信息返回:{}", fileModel.getCode(), fileModel.getFilePath());
return fileModel;
}
@Override
public FileModel getUrl(String key) {
FileModel fileModel;
log.info("生成文件下载地址:{} ", key);
if (OssReturnConfig.AL.equals(ossConfig.getOssType())) {
fileModel = aliOssService.getUrl(key);
} else if (OssReturnConfig.JD.equals(ossConfig.getOssType())) {
fileModel = jdOssService.getUrl(key);
} else {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
}
log.info("生成文件下载地址结果编码:{},地址链接返回:{}", fileModel.getCode(), fileModel.getFilePath());
return fileModel;
}
@Override
public FileModel deleteFile(String path) {
log.info("删除文件信息:{} ", path);
FileModel fileModel;
if (OssReturnConfig.AL.equals(ossConfig.getOssType())) {
if (path.startsWith("/")) {
path = path.substring(1);
}
fileModel = aliOssService.deleteFile(path);
} else if (OssReturnConfig.JD.equals(ossConfig.getOssType())) {
if (path.startsWith("/")) {
path = path.substring(1);
}
fileModel = jdOssService.deleteFile(path);
} else if(OssReturnConfig.SSH.equals(ossConfig.getOssType())){
File file = new File(path);
boolean b = sshService.deleteFile(file.getParent(), file.getName());
if (b) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_01);
}
}else if (OssReturnConfig.FTP.equals(ossConfig.getOssType())) {
File file = new File(path);
boolean b = ftpService.deleteFile(file.getParent(), file.getName());
if (b) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_01);
}
} else if(OssReturnConfig.LOCAL.equals(ossConfig.getOssType())){
File file = new File(path);
boolean b = file.delete();
if (b) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
} else {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_01);
}
}else{
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
}
log.info("删除文件信息返回结果编码:{}", fileModel.getCode());
return fileModel;
}
@Override
public String getPathPrefix() {
return ossConfig.getPathPrefix();
}
@Override
public String getLocalPathDefault() {
return ossConfig.getLocalPathDefault();
}
@Override
public String getTempPath() {
return ossConfig.getTempPath();
}
/**
* PDF 上传文件大小
*/
@Override
public String getFtpPdfSize() {
return ossConfig.getPdfSize();
}
}

@ -0,0 +1,213 @@
package com.dxhy.oss.service.impl;
import cn.hutool.core.io.FileUtil;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectInputStream;
import com.dxhy.oss.config.OssConfig;
import com.dxhy.oss.config.OssReturnConfig;
import com.dxhy.oss.model.FileModel;
import com.dxhy.oss.service.JdOssService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
/**
* @author jiaohongyang
*/
@Service("jdOssService")
@Slf4j
public class JdOssServiceImpl implements JdOssService {
private final OssConfig ossConfig;
@Autowired
public JdOssServiceImpl(OssConfig ossConfig) {
this.ossConfig = ossConfig;
}
/**
* 京东云OSS文件存储
*
* @param filePath 文件
* @return 返回
*/
@Override
public FileModel uploadFile(String fileName, String filePath) {
FileModel fileModel;
AmazonS3 jdInstance = null;
log.info("文件存储京东OSS,存储目录:{} , 存储文件名:{} ", ossConfig.getBucketName(), fileName);
try {
// 创建连接
jdInstance = OssClientFactory.getJdInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(),
ossConfig.getAccessKeySecret(), ossConfig.getRegion());
if (jdInstance == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
// 进行文件上传
jdInstance.putObject(ossConfig.getBucketName(), fileName, new File(filePath));
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
fileModel.setFilePath(fileName);
return fileModel;
} catch (Exception e) {
log.error("文件存储京东OSS失败,异常:{}", e.getMessage());
e.printStackTrace();
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
} finally {
if (jdInstance != null) {
jdInstance.shutdown();
}
FileUtil.del(filePath);
}
}
/**
* 下载
*
* @param fileName 文件名称
* @param filePath 本地文件存储地址
* @return 返回
*/
@Override
public FileModel downloadFile(String fileName, String filePath) {
log.info("下载文件京东OSS,存储目录:{} , 存储文件名:{} ", ossConfig.getBucketName(), fileName);
AmazonS3 jdInstance = null;
S3ObjectInputStream s3is = null;
FileOutputStream fos = null;
FileModel fileModel;
try {
// 创建连接
jdInstance = OssClientFactory.getJdInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(),
ossConfig.getAccessKeySecret(), ossConfig.getRegion());
if (jdInstance == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
// 下载OSS文件到本地文件。如果指定的本地文件存在会覆盖,不存在则新建。
S3Object object = jdInstance.getObject(ossConfig.getBucketName(), fileName);
s3is = object.getObjectContent();
fos = new FileOutputStream(filePath);
byte[] readBuf = new byte[1024];
int readLen = 0;
while ((readLen = s3is.read(readBuf)) > 0) {
fos.write(readBuf, 0, readLen);
}
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
fileModel.setFilePath(filePath);
return fileModel;
} catch (Exception e) {
e.printStackTrace();
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
} finally {
try {
if (s3is != null) {
s3is.close();
}
if (fos != null) {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
if (jdInstance != null) {
jdInstance.shutdown();
}
}
}
@Override
public FileModel getUrl(String key) {
log.info("生成文件下载地址京东OSS,存储目录:{} , 存储文件名:{} ", ossConfig.getBucketName(), key);
AmazonS3 jdInstance = null;
FileModel fileModel;
try {
// 创建连接
jdInstance = OssClientFactory.getJdInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(),
ossConfig.getAccessKeySecret(), ossConfig.getRegion());
if (jdInstance == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
// 设置URL过期时间为10年 3600l* 1000*24*365*10
Date expiration = new Date(System.currentTimeMillis() + 3600L * 1000 * 24 * 365 * 2);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(ossConfig.getBucketName(), key);
request.setExpiration(expiration);
URL url = jdInstance.generatePresignedUrl(request);
if (url != null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
fileModel.setFilePath(url.toString());
return fileModel;
}
} catch (Exception e) {
e.printStackTrace();
log.error("文件下载京东OSS失败,异常:{}", e.getMessage());
} finally {
if (jdInstance != null) {
jdInstance.shutdown();
}
}
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
/**
* 删除文件
*
* @param file 文件名
* @return 返回
*/
@Override
public FileModel deleteFile(String file) {
log.info("文件删除京东云OSS,存储目录:{} , 存储文件名:{} ", ossConfig.getBucketName(), file);
AmazonS3 jdInstance = null;
FileModel fileModel;
try {
// 创建连接
// 创建连接
jdInstance = OssClientFactory.getJdInstance(ossConfig.getEndpointUrl(), ossConfig.getAccessKeyId(),
ossConfig.getAccessKeySecret(), ossConfig.getRegion());
if (jdInstance == null) {
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
}
jdInstance.deleteObject(ossConfig.getBucketName(), file);
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.SUCCESS);
return fileModel;
} catch (Exception e) {
log.error("文件删除京东云OSS失败,异常:{}", e.getMessage());
e.printStackTrace();
fileModel = new FileModel();
fileModel.setCode(OssReturnConfig.ERROR_09);
return fileModel;
} finally {
if (jdInstance != null) {
jdInstance.shutdown();
}
}
}
}

@ -0,0 +1,55 @@
package com.dxhy.oss.service.impl;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
/**
* @author jiaohongyang
*/
@Slf4j
public class OssClientFactory {
private OssClientFactory() {
}
/**
* 创建连接
*/
@Bean
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static OSS getInstance(String endpointUrl, String accessKeyId, String accessKeySecret) {
return new OSSClientBuilder().build(endpointUrl, accessKeyId, accessKeySecret);
}
@Bean
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public static AmazonS3 getJdInstance(String endpointUrl, String accessKeyId, String accessKeySecret,
String region) {
ClientConfiguration config = new ClientConfiguration();
AwsClientBuilder.EndpointConfiguration endpointConfig =
new AwsClientBuilder.EndpointConfiguration(endpointUrl, region);
AWSCredentials awsCredentials = new BasicAWSCredentials(accessKeyId, accessKeySecret);
AWSCredentialsProvider awsCredentialsProvider = new AWSStaticCredentialsProvider(awsCredentials);
return AmazonS3Client.builder().withEndpointConfiguration(endpointConfig).withClientConfiguration(config)
.withCredentials(awsCredentialsProvider).disableChunkedEncoding().withPathStyleAccessEnabled(true)
.build();
}
}

@ -0,0 +1,60 @@
package com.dxhy.oss.utils;
import cn.hutool.core.io.FileTypeUtil;
import java.io.InputStream;
/**
* 文件类型工具类
* TODO 其中只是定义了部分文件格式有缺失的自己添加
*/
public class FileTypeUtils {
private final static String IMAGE_TYPE = "image/";
private final static String AUDIO_TYPE = "audio/";
private final static String VIDEO_TYPE = "video/";
private final static String APPLICATION_TYPE = "application/";
private final static String TXT_TYPE = "text/";
public static String getFileType(InputStream fileInputStream) {
String type = null;
try {
type = FileTypeUtil.getType(fileInputStream);
if (type.equalsIgnoreCase("JPG") || type.equalsIgnoreCase("JPEG")
|| type.equalsIgnoreCase("GIF") || type.equalsIgnoreCase("PNG")
|| type.equalsIgnoreCase("BMP") || type.equalsIgnoreCase("PCX")
|| type.equalsIgnoreCase("TGA") || type.equalsIgnoreCase("PSD")
|| type.equalsIgnoreCase("TIFF")) {
return IMAGE_TYPE + type;
}
if (type.equalsIgnoreCase("mp3") || type.equalsIgnoreCase("OGG")
|| type.equalsIgnoreCase("WAV") || type.equalsIgnoreCase("REAL")
|| type.equalsIgnoreCase("APE") || type.equalsIgnoreCase("MODULE")
|| type.equalsIgnoreCase("MIDI") || type.equalsIgnoreCase("VQF")
|| type.equalsIgnoreCase("CD")) {
return AUDIO_TYPE + type;
}
if (type.equalsIgnoreCase("mp4") || type.equalsIgnoreCase("avi")
|| type.equalsIgnoreCase("MPEG-1") || type.equalsIgnoreCase("RM")
|| type.equalsIgnoreCase("ASF") || type.equalsIgnoreCase("WMV")
|| type.equalsIgnoreCase("qlv") || type.equalsIgnoreCase("MPEG-2")
|| type.equalsIgnoreCase("MPEG4") || type.equalsIgnoreCase("mov")
|| type.equalsIgnoreCase("3gp")) {
return VIDEO_TYPE + type;
}
if (type.equalsIgnoreCase("doc") || type.equalsIgnoreCase("docx")
|| type.equalsIgnoreCase("ppt") || type.equalsIgnoreCase("pptx")
|| type.equalsIgnoreCase("xls") || type.equalsIgnoreCase("xlsx")
|| type.equalsIgnoreCase("zip") || type.equalsIgnoreCase("jar")) {
return APPLICATION_TYPE + type;
}
if (type.equalsIgnoreCase("txt")) {
return TXT_TYPE + type;
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

@ -0,0 +1,32 @@
package com.dxhy.oss.utils;
import com.dxhy.oss.service.FtpService;
import com.dxhy.oss.service.SshService;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
// ftp配置
@Configuration
@EnableConfigurationProperties(SftpProperties.class)
public class SftpConfig {
// 工厂
@Bean
public SftpFactory sftpFactory(SftpProperties properties) {
return new SftpFactory(properties);
}
// 连接池
@Bean
public SftpPool sftpPool(SftpFactory sftpFactory) {
return new SftpPool(sftpFactory);
}
// 辅助类
@Bean
public FtpService ftpService(SftpPool sftpPool) {
return new FtpService(sftpPool);
}
}

@ -0,0 +1,67 @@
package com.dxhy.oss.utils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import java.io.IOException;
@EqualsAndHashCode(callSuper = true)
@Data
@Slf4j
public class SftpFactory extends BasePooledObjectFactory<FTPClient> {
private SftpProperties ossConfig;
public SftpFactory(SftpProperties ossConfig) {
this.ossConfig = ossConfig;
}
@Override
public FTPClient create() throws Exception{
FTPClient ftpClient = null;
try {
ftpClient = new FTPClient();
ftpClient.setControlEncoding("UTF-8");// 中文支持
ftpClient.setConnectTimeout(1000 * 30);//设置连接超时时间
ftpClient.connect(ossConfig.getHostname(), Integer.valueOf(ossConfig.getPort()));// 连接FTP服务器
ftpClient.login(ossConfig.getUsername(), ossConfig.getPassword());// 登陆FTP服务器
// 设置文件类型为二进制(如果从FTP下载或上传的文件是压缩文件的时候,不进行该设置可能会导致获取的压缩文件解压失败)
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// ftpClient.enterLocalPassiveMode();//开启被动模式,否则文件上传不成功,也不报错
if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
log.info("连接FTP失败,用户名或密码错误。");
ftpClient.disconnect();
} else {
log.info("FTP连接成功!");
}
} catch (Exception e) {
log.info("登陆FTP失败,请检查FTP相关配置信息是否正确!" + e);
return null;
}
return ftpClient;
}
@Override
public PooledObject<FTPClient> wrap(FTPClient channelSftp) {
return new DefaultPooledObject<>(channelSftp);
}
// 销毁对象
@Override
public void destroyObject(PooledObject<FTPClient> p) {
FTPClient ftpClient = p.getObject();
try {
ftpClient.disconnect();
} catch (IOException e) {
log.error("登出ftp失败,请检查FTP相关配置信息是否正确!" + e);
}
}
}

@ -0,0 +1,41 @@
package com.dxhy.oss.utils;
import lombok.Data;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.pool2.impl.GenericObjectPool;
@Data
public class SftpPool {
private GenericObjectPool<FTPClient> pool;
public SftpPool(SftpFactory factory) {
this.pool = new GenericObjectPool<>(factory, factory.getOssConfig().getPool());
}
/**
* 获取一个sftp连接对象
*
* @return sftp连接对象
*/
public FTPClient borrowObject() throws SftpPoolException {
try {
return pool.borrowObject();
} catch (Exception e) {
e.printStackTrace();
throw new SftpPoolException("获取ftp连接失败", e);
}
}
/**
* 归还一个sftp连接对象
*
* @param ftpClient sftp连接对象
*/
public void returnObject(FTPClient ftpClient) {
if (ftpClient != null) {
pool.returnObject(ftpClient);
}
}
}

@ -0,0 +1,15 @@
package com.dxhy.oss.utils;
/**
* @author jiaohongyang
* @date 2019年3月26日 下午5:57:26
*/
public class SftpPoolException extends Exception {
public SftpPoolException(String message, Exception e) {
super(message, e);
}
}

@ -0,0 +1,61 @@
package com.dxhy.oss.utils;
import lombok.Data;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties(prefix = "ftp.connection")
public class SftpProperties {
private String hostname;
private String port;
private String username;
private String password;
private String timeout;
private Pool pool = new Pool();
public static class Pool extends GenericObjectPoolConfig<FTPClient> {
private int maxTotal = DEFAULT_MAX_TOTAL;
private int maxIdle = DEFAULT_MAX_IDLE;
private int minIdle = DEFAULT_MIN_IDLE;
public Pool() {
super();
}
@Override
public int getMaxTotal() {
return maxTotal;
}
@Override
public void setMaxTotal(int maxTotal) {
this.maxTotal = maxTotal;
}
@Override
public int getMaxIdle() {
return maxIdle;
}
@Override
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
@Override
public int getMinIdle() {
return minIdle;
}
@Override
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
}
}

@ -0,0 +1,31 @@
package com.dxhy.oss.utils;
import com.dxhy.oss.service.FtpService;
import com.dxhy.oss.service.SshService;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
// ftp配置
@Configuration
@EnableConfigurationProperties(SshProperties.class)
public class SshConfig {
// 工厂
@Bean
public SshFactory sshFactory(SshProperties properties) {
return new SshFactory(properties);
}
// 连接池
@Bean
public SshPool sshPool(SshFactory sshFactory) {
return new SshPool(sshFactory);
}
// 辅助类
@Bean
public SshService sshService(SshPool sftpPool) {
return new SshService(sftpPool);
}
}

@ -0,0 +1,70 @@
package com.dxhy.oss.utils;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import java.util.Properties;
@EqualsAndHashCode(callSuper = true)
@Data
@Slf4j
public class SshFactory extends BasePooledObjectFactory<ChannelSftp> {
private SshProperties ossConfig;
public SshFactory(SshProperties ossConfig) {
this.ossConfig = ossConfig;
}
@Override
public ChannelSftp create() throws SftpPoolException {
try {
JSch jsch = new JSch();
Session session = jsch.getSession(ossConfig.getUsername(), ossConfig.getHostname(), Integer.parseInt(ossConfig.getPort()));
// 设置密码
if (ossConfig.getPassword() != null) {
session.setPassword(ossConfig.getPassword());
}
// 设置密码
if (ossConfig.getPassword() != null) {
session.setPassword(ossConfig.getPassword());
}
// 为Session对象设置properties
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
// 设置超时时间
session.setTimeout(Integer.parseInt(ossConfig.getTimeout()));
// 建立链接
session.connect();
// 打开SFTP通道
ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
// 建立SFTP通道的连接
channel.connect();
return channel;
} catch (JSchException e) {
throw new SftpPoolException("获取ftp连接失败", e);
}
}
@Override
public PooledObject<ChannelSftp> wrap(ChannelSftp channelSftp) {
return new DefaultPooledObject<>(channelSftp);
}
// 销毁对象
@Override
public void destroyObject(PooledObject<ChannelSftp> p) {
ChannelSftp channelSftp = p.getObject();
channelSftp.disconnect();
}
}

@ -0,0 +1,41 @@
package com.dxhy.oss.utils;
import com.jcraft.jsch.ChannelSftp;
import lombok.Data;
import org.apache.commons.pool2.impl.GenericObjectPool;
@Data
public class SshPool {
private GenericObjectPool<ChannelSftp> pool;
public SshPool(SshFactory factory) {
this.pool = new GenericObjectPool<>(factory, factory.getOssConfig().getPool());
}
/**
* 获取一个sftp连接对象
*
* @return sftp连接对象
*/
public ChannelSftp borrowObject() throws SftpPoolException {
try {
return pool.borrowObject();
} catch (Exception e) {
e.printStackTrace();
throw new SftpPoolException("获取ftp连接失败", e);
}
}
/**
* 归还一个sftp连接对象
*
* @param channelSftp sftp连接对象
*/
public void returnObject(ChannelSftp channelSftp) {
if (channelSftp != null) {
pool.returnObject(channelSftp);
}
}
}

@ -0,0 +1,61 @@
package com.dxhy.oss.utils;
import com.jcraft.jsch.ChannelSftp;
import lombok.Data;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties(prefix = "ftp.connection")
public class SshProperties {
private String hostname;
private String port = "22";
private String username;
private String password;
private String timeout;
private Pool pool = new Pool();
public static class Pool extends GenericObjectPoolConfig<ChannelSftp> {
private int maxTotal = DEFAULT_MAX_TOTAL;
private int maxIdle = DEFAULT_MAX_IDLE;
private int minIdle = DEFAULT_MIN_IDLE;
public Pool() {
super();
}
@Override
public int getMaxTotal() {
return maxTotal;
}
@Override
public void setMaxTotal(int maxTotal) {
this.maxTotal = maxTotal;
}
@Override
public int getMaxIdle() {
return maxIdle;
}
@Override
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
@Override
public int getMinIdle() {
return minIdle;
}
@Override
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
}
}

@ -0,0 +1,13 @@
package com.dxhy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan("com.dxhy.*")
public class DxhyOssApplication {
public static void main(String[] args) {
SpringApplication.run(DxhyOssApplication.class, args);
}
}

@ -0,0 +1,40 @@
package com.dxhy;
import com.dxhy.oss.model.FileModel;
import com.dxhy.oss.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
/**
* @author user
*/
@SuppressWarnings("FieldCanBeLocal")
@Slf4j
public class OfdHandle extends Thread {
private final File file;
@Autowired
private FileService fileService;
public OfdHandle(File file) {
this.file = file;
}
@Override
public void run() {
fileService = (FileService) SpringContextUtils.getBean("fileService");
FileModel fileModel = new FileModel();
try {
fileModel = fileService.uploadFile(file.getPath(), file.getPath());
} catch (Exception e) {
e.printStackTrace();
}
log.info("文件上传返回结果:" + fileModel.getCode() + " " + fileModel.getFilePath());
}
}

@ -0,0 +1,127 @@
package com.dxhy;
import java.io.File;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.dxhy.oss.model.FileModel;
import com.dxhy.oss.service.FileService;
import cn.hutool.core.io.FileUtil;
/**
* @author jiaohongyang焦红阳
* @date 2020-09-30
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DxhyOssApplication.class)
public class OssTest {
@Resource
private FileService fileService;
@Test
public void ossUploadTest() {
String fileName = "/GYL/YONGHUI/2022/09/08/update.zip";
String originFileName = "/Users/jiaohongyang/product/project/project/jxpt/ofd/pdf/update.zip";
FileModel fileModel = new FileModel();
try {
fileModel = fileService.uploadFile(fileName, originFileName);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("文件上传返回结果:" + fileModel.getCode() + " " + fileModel.getFilePath());
}
@Test
public void ossGylUploadTest() {
String fileName = "/GYL/DUODIAN/2022/12/07/update.zip";
String originFileName = "/Users/jiaohongyang/product/project/project/jxpt/ofd/pdf/update.zip";
FileModel fileModel = new FileModel();
try {
fileModel = fileService.uploadFile(fileName, originFileName);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("文件上传返回结果:" + fileModel.getCode() + " " + fileModel.getFilePath());
}
@Test
public void ossGylSdlpUploadTest() {
String fileName = "/GYL/SDLP/2022/09/20/51发票助手_local_J_1.4.8.exe";
String originFileName = "/Users/jiaohongyang/product/project/project/jxpt/ofd/pdf/51发票助手_local_J_1.4.8.exe";
FileModel fileModel = new FileModel();
try {
fileModel = fileService.uploadFile(fileName, originFileName);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("文件上传返回结果:" + fileModel.getCode() + " " + fileModel.getFilePath());
}
@Test
public void ossDownloadTest() {
String downloadFile = "/jxfp/pdf/2022/1111/dxhy-admin.jar";
// String downloadFile = "/jxfp/excel/2020/10/12/1282510566564315137_进项票据采集_2020-10-12_1602489969696.xlsx";
String saveFile = "/Users/jiaohongyang/product/project/project/jxpt/ofd/pdf/dxhy-admin.jar";
FileModel fileModel = new FileModel();
try {
fileModel = fileService.downFile(downloadFile, saveFile);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("文件下载返回结果" + fileModel.getCode() + " " + fileModel.getFilePath());
}
@Test
public void ossgetUrlTest() {
String key = "/GYL/SDLP/2022/09/14/供应链协同开票助手-v1.1.0.1.20220914-x86_Setup.zip";
FileModel fileModel = fileService.getUrl(key);
System.out.println(fileModel.getCode() + " " + fileModel.getFilePath());
}
@Test
public void ossDeleteTest() {
String downloadFile = "GYL/DUODIAN/2022/12/01/20221201(1.1.0.2).zip";
FileModel fileModel = new FileModel();
try {
fileModel = fileService.deleteFile(downloadFile);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("文件删除返回结果" + fileModel.getCode());
}
@Test
public void ossPush() {
String path = "/Volumes/product/PDF/";
try {
File[] ls = FileUtil.ls(path);
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2000, 10000, 60L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(ls.length), r -> new Thread(r, "oss推送-" + r.hashCode()));
for (File file : ls) {
if (!threadPoolExecutor.isShutdown()) {
threadPoolExecutor.execute(new OfdHandle(file));
}
}
threadPoolExecutor.shutdown();
threadPoolExecutor.awaitTermination(60, TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,43 @@
package com.dxhy;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* Spring Context 工具类
*
* @author jiaohongyang
*/
@Component
public class SpringContextUtils implements ApplicationContextAware {
public static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContextUtils.applicationContext = applicationContext;
}
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static <T> T getBean(String name, Class<T> requiredType) {
return applicationContext.getBean(name, requiredType);
}
public static boolean containsBean(String name) {
return applicationContext.containsBean(name);
}
public static boolean isSingleton(String name) {
return applicationContext.isSingleton(name);
}
public static Class<?> getType(String name) {
return applicationContext.getType(name);
}
}

@ -0,0 +1,48 @@
#oss:
# ossType: AL
# endpointUrl: http://oss-accelerate.aliyuncs.com
# accessKeyId: LTAI4G6XxTTwUzcY3ByWa6Yb
# accessKeySecret: kkgPJ4DIvkOcvfZPl4BE1FVqyQlPiq
# region:
# bucketName: jiaohongyang
#oss:
# ossType: JD
# endpointUrl: https://storage.jd.local
# accessKeyId: bfac05320eaf11cc80cf1823e4fb87d98523fc94
# accessKeySecret: 70ec454ffb302043a7837417e0909e12d1288d0b
# region: cn-north-1
# bucketName: input-tax-invoice
#oss:
# ossType: AL
# endpointUrl: http://oss-cn-beijing-internal.aliyuncs.com
# accessKeyId: LTAI4GHGCEiWsXxTZ651wV22
# accessKeySecret: hTXim31f5JmIMz3rcj7WIopKAUscsE
# region:
# bucketName: guowangtest
#oss:
# ossType: MINIO
# endpointUrl: http://10.1.2.107:9000
# accessKeyId: minioadmin
# accessKeySecret: minioadmin
# region:
# bucketName: jxpt
oss:
ossType: JD
endpointUrl: https://s3.cn-north-1.jdcloud-oss.com
accessKeyId: 4B2A089EA1C8F776357A15948DBCA363
accessKeySecret: 570296481BA33BFC4A8C9EEB5E00652A
region: cn-north-1
bucketName: jxdownload
ftp:
connection:
hostname: 10.1.2.87
username: dxhy1
password: dxhy
port: 62236
timeout: 60000
pathPrefix: /jxfp/excel/
# 连接池参数
pool:
max-total: 10
max-idle: 10
min-idle: 5

@ -106,7 +106,7 @@
<dependency>
<groupId>com.dxhy.jxpt</groupId>
<artifactId>dxhy-oss</artifactId>
<version>3.2.9</version>
<version>3.3.3</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>

@ -118,7 +118,7 @@
<dependency>
<groupId>com.dxhy.jxpt</groupId>
<artifactId>dxhy-oss</artifactId>
<version>3.2.9</version>
<version>3.3.3</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>

@ -21,6 +21,7 @@
<module>dxhy-admin</module>
<module>dxhy-gateway</module>
<module>dxhy-base</module>
<module>dxhy-oss</module>
<module>dxhy-core</module>
<module>dxhy-erp</module>
<module>dxhy-extend</module>

Loading…
Cancel
Save