Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -145,8 +145,8 @@ public class ContractController implements BusinessControllerMarker {
|
||||
@PostMapping("/submit/erp")
|
||||
@Operation(summary = "提交ERP")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
|
||||
public CommonResult<List<String>> submitErp(@RequestBody List<Long> ids) {
|
||||
return success(contractService.submitErp(ids));
|
||||
public CommonResult<JSONObject> submitErp(@RequestParam("id") Long id) {
|
||||
return success(contractService.submitErp(id));
|
||||
}
|
||||
|
||||
@GetMapping("/list/up-not-relation")
|
||||
|
||||
@@ -38,4 +38,7 @@ public class ContractPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "本币金额;与ERP(HTBWBZJE)对应")
|
||||
private BigDecimal basicAmount;
|
||||
|
||||
@Schema(description = "合同分类(字典:SPLY_BSN_TP)")
|
||||
private String businessType;
|
||||
}
|
||||
@@ -31,10 +31,10 @@ public class DeductRespVO {
|
||||
private String rangeWay;
|
||||
|
||||
@Schema(description = "上限")
|
||||
private String up;
|
||||
private BigDecimal up;
|
||||
|
||||
@Schema(description = "下限")
|
||||
private String down;
|
||||
private BigDecimal down;
|
||||
|
||||
@Schema(description = "类型(字典:STLM_COEF)")
|
||||
private String type;
|
||||
|
||||
@@ -31,10 +31,10 @@ public class DeductSaveReqVO {
|
||||
private String rangeWay;
|
||||
|
||||
@Schema(description = "上限")
|
||||
private String up;
|
||||
private BigDecimal up;
|
||||
|
||||
@Schema(description = "下限")
|
||||
private String down;
|
||||
private BigDecimal down;
|
||||
|
||||
@Schema(description = "类型(字典:STLM_COEF)")
|
||||
private String type;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.zt.plat.module.contractorder.controller.admin.contract.vo.contract;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 合同关联 Response VO")
|
||||
@Data
|
||||
public class RelationRespVO {
|
||||
|
||||
@Schema(description = "上游主键")
|
||||
private Long upId;
|
||||
|
||||
@Schema(description = "下游主键")
|
||||
private Long downId;
|
||||
}
|
||||
@@ -63,12 +63,12 @@ public class ContractDeductDO extends BusinessBaseDO {
|
||||
* 上限
|
||||
*/
|
||||
@TableField("UP")
|
||||
private String up;
|
||||
private BigDecimal up;
|
||||
/**
|
||||
* 下限
|
||||
*/
|
||||
@TableField("DOWN")
|
||||
private String down;
|
||||
private BigDecimal down;
|
||||
/**
|
||||
* 类型(字典:STLM_COEF)
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@ public interface ContractMainMapper extends BaseMapperX<ContractMainDO> {
|
||||
.likeIfPresent(ContractMainDO::getPurchaseCompanyName, reqVO.getPurchaseCompanyName())
|
||||
.eqIfPresent(ContractMainDO::getBasicAmount, reqVO.getBasicAmount())
|
||||
.eqIfPresent(ContractMainDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ContractMainDO::getBusinessType, reqVO.getBusinessType())
|
||||
.orderByDesc(ContractMainDO::getCreateTime));
|
||||
}
|
||||
}
|
||||
@@ -102,10 +102,10 @@ public interface ContractService {
|
||||
/**
|
||||
* 提交ERP
|
||||
*
|
||||
* @param ids 合同ID集合
|
||||
* @return
|
||||
* @param id 合同ID
|
||||
* @return 提交结果
|
||||
*/
|
||||
List<String> submitErp(List<Long> ids);
|
||||
JSONObject submitErp(Long id);
|
||||
|
||||
/**
|
||||
* 删除合同
|
||||
@@ -163,6 +163,14 @@ public interface ContractService {
|
||||
*/
|
||||
Boolean relation(RelationReqVo reqVo);
|
||||
|
||||
/**
|
||||
* 根据合同ID获得关联合同
|
||||
*
|
||||
* @param id 合同ID
|
||||
* @return 上下游合同ID
|
||||
*/
|
||||
RelationRespVO getRelation(Long id);
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
@@ -171,7 +172,11 @@ public class ContractServiceImpl implements ContractService {
|
||||
// 合同状态保存为草稿
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_DRAFT.getCode());
|
||||
// 生成系统合同编号
|
||||
contractMainDO.setSystemContractNumber(generateSystemContractNumber(reqVO.getCategory()));
|
||||
contractMainDO.setSystemContractNumber(generateSystemContractNumber(reqVO.getBusinessType()));
|
||||
// 原币金额-变更后
|
||||
if (contractMainDO.getChangeCooAmount() == null) contractMainDO.setChangeCooAmount(new BigDecimal(0));
|
||||
// 本币金额-变更后
|
||||
if (contractMainDO.getChangeBasicAmount() == null) contractMainDO.setChangeBasicAmount(new BigDecimal(0));
|
||||
|
||||
// 保存合同主信息
|
||||
contractMainMapper.insert(contractMainDO);
|
||||
@@ -1312,62 +1317,65 @@ public class ContractServiceImpl implements ContractService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> submitErp(List<Long> ids) {
|
||||
public JSONObject submitErp(Long id) {
|
||||
|
||||
List<String> results = new ArrayList<>();
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
// 遍历合同ID集合
|
||||
ids.forEach(id -> {
|
||||
// 查询合同信息
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
|
||||
// 查询合同信息
|
||||
ContractMainDO contractMainDO = contractMainMapper.selectById(id);
|
||||
// 合同数据不存在
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
if (contractMainDO != null) {
|
||||
// 合同状态校验
|
||||
if (!(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_VOID.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus()))) {
|
||||
|
||||
// 合同状态校验
|
||||
if (!(DictEnum.BSE_CTRT_STS_WAIT_PUSH.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_VOID.getCode().equals(contractMainDO.getStatus())
|
||||
|| DictEnum.BSE_CTRT_STS_TERMINATED.getCode().equals(contractMainDO.getStatus()))) {
|
||||
throw exception(CONTRACT_STATUS_NOT_SUBMIT_ERP,
|
||||
DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
|
||||
throw exception(CONTRACT_STATUS_NOT_SUBMIT_ERP,
|
||||
DictEnum.getByCodeAndType(contractMainDO.getStatus(), DictTypeConstants.BSE_CTRT_STS).getLabel());
|
||||
}
|
||||
// 生成ERP合同映射表
|
||||
ErpContractSaveReqVO erpContractVO = getErpContract(contractMainDO);
|
||||
|
||||
// 生成ERP合同映射表
|
||||
ErpContractSaveReqVO erpContractVO = getErpContract(contractMainDO);
|
||||
// 调用ERP模块
|
||||
JSONObject erpResult = sendToErp(erpContractVO);
|
||||
log.info("合同提交ERP结果:{}", erpResult);
|
||||
result.putOnce("success", erpResult.getBool("success"));
|
||||
|
||||
// 调用ERP模块
|
||||
JSONObject erpResult = sendToErp(erpContractVO);
|
||||
log.info("合同提交ERP结果:{}", erpResult);
|
||||
String result = id
|
||||
+"-"+erpResult.getBool("success")
|
||||
+(erpResult.getBool("success") ? "" : "-" + erpResult.getStr("errMsg"));
|
||||
results.add(result);
|
||||
// 更新合同状态
|
||||
if (erpResult.getBool("success")) {
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode());
|
||||
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_FIND.getCode());
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
|
||||
// 更新合同状态
|
||||
if (erpResult.getBool("success")) {
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_IN_PROGRESS.getCode());
|
||||
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_FIND.getCode());
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
} else {
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_PUSH_ERROR.getCode());
|
||||
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_RLBK.getCode());
|
||||
// contractMainDO.setCause(erpResult.getStr("errMsg"));
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
}
|
||||
} else {
|
||||
results.add(id+"-"+"false"+"-"+CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
});
|
||||
result.putOnce("data", erpResult.getStr("data"));
|
||||
} else {
|
||||
contractMainDO.setStatus(DictEnum.BSE_CTRT_STS_PUSH_ERROR.getCode());
|
||||
contractMainDO.setErpStatus(DictEnum.ERP_REQ_STS_RLBK.getCode());
|
||||
contractMainDO.setCause(erpResult.getStr("errMsg"));
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
|
||||
return results;
|
||||
result.putOnce("data", erpResult.getStr("errMsg"));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private JSONObject sendToErp(ErpContractSaveReqVO erpContractVO) {
|
||||
JSONObject erpResult = new JSONObject();
|
||||
try {
|
||||
String result = erpContractService.submitErp(erpContractVO);
|
||||
erpResult.putOnce("success", true);
|
||||
HashMap<String, String> result = erpContractService.submitErp(erpContractVO);
|
||||
if ("E".equals(result.get("flag"))) {
|
||||
erpResult.putOnce("success", false);
|
||||
erpResult.putOnce("errMsg", result.get("resStr")+":"+result.get("E_RESP"));
|
||||
} else {
|
||||
erpResult.putOnce("success", true);
|
||||
erpResult.putOnce("data", result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
erpResult.putOnce("success", false);
|
||||
erpResult.putOnce("errMsg", e.getMessage());
|
||||
@@ -1386,6 +1394,32 @@ public class ContractServiceImpl implements ContractService {
|
||||
return insert > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelationRespVO getRelation(Long id) {
|
||||
|
||||
// 返回结果
|
||||
RelationRespVO resp = new RelationRespVO();
|
||||
|
||||
// 获得上游合同关联
|
||||
SystemRelativityDO upSystemRelativityDO = systemRelativityMapper
|
||||
.selectOne(new LambdaQueryWrapperX<SystemRelativityDO>()
|
||||
.eq(SystemRelativityDO::getDownId, id)
|
||||
);
|
||||
|
||||
// 获得下游合同关联
|
||||
SystemRelativityDO downSystemRelativityDO = systemRelativityMapper
|
||||
.selectOne(new LambdaQueryWrapperX<SystemRelativityDO>()
|
||||
.eq(SystemRelativityDO::getUpId, id)
|
||||
);
|
||||
|
||||
// 上游合同ID
|
||||
if (upSystemRelativityDO != null) resp.setUpId(upSystemRelativityDO.getId());
|
||||
// 下游合同ID
|
||||
if (downSystemRelativityDO != null) resp.setDownId(downSystemRelativityDO.getId());
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<ByteArrayResource> download(List<Long> ids) {
|
||||
try {
|
||||
@@ -1517,10 +1551,10 @@ public class ContractServiceImpl implements ContractService {
|
||||
|
||||
// 更新合同
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
});
|
||||
|
||||
// 重新提交erp
|
||||
submitErp(ids);
|
||||
// 重新提交erp
|
||||
submitErp(id);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1548,10 +1582,10 @@ public class ContractServiceImpl implements ContractService {
|
||||
|
||||
// 更新合同
|
||||
contractMainMapper.updateById(contractMainDO);
|
||||
});
|
||||
|
||||
// 重新提交erp
|
||||
submitErp(ids);
|
||||
// 重新提交erp
|
||||
submitErp(id);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<configuration>
|
||||
<!-- 引用 Spring Boot 的 logback 基础配置 -->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
<!-- 变量 cloud.info.base-package,基础业务包 -->
|
||||
<springProperty scope="context" name="cloud.info.base-package" source="cloud.info.base-package"/>
|
||||
<!-- 格式化输出:%d 表示日期,%X{tid} SkWalking 链路追踪编号,%thread 表示线程名,%-5level:级别从左显示 5 个字符宽度,%msg:日志消息,%n是换行符 -->
|
||||
<property name="PATTERN_DEFAULT" value="%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd HH:mm:ss.SSS}} | %highlight(${LOG_LEVEL_PATTERN:-%5p} ${PID:- }) | %boldYellow(%thread [%tid]) %boldGreen(%-40.40logger{39}) | %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
|
||||
|
||||
<!-- 控制台 Appender -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 文件 Appender -->
|
||||
<!-- 参考 Spring Boot 的 file-appender.xml 编写 -->
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
<!-- 日志文件名 -->
|
||||
<file>${LOG_FILE}</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- 滚动后的日志文件名 -->
|
||||
<fileNamePattern>${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz}</fileNamePattern>
|
||||
<!-- 启动服务时,是否清理历史日志,一般不建议清理 -->
|
||||
<cleanHistoryOnStart>${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false}</cleanHistoryOnStart>
|
||||
<!-- 日志文件,到达多少容量,进行滚动 -->
|
||||
<maxFileSize>${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB}</maxFileSize>
|
||||
<!-- 日志文件的总大小,0 表示不限制 -->
|
||||
<totalSizeCap>${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0}</totalSizeCap>
|
||||
<!-- 日志文件的保留天数 -->
|
||||
<maxHistory>${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<!-- 异步写入日志,提升性能 -->
|
||||
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<!-- 不丢失日志。默认的,如果队列的 80% 已满,则会丢弃 TRACT、DEBUG、INFO 级别的日志 -->
|
||||
<discardingThreshold>0</discardingThreshold>
|
||||
<!-- 更改默认的队列的深度,该值会影响性能。默认值为 256 -->
|
||||
<queueSize>256</queueSize>
|
||||
<appender-ref ref="FILE"/>
|
||||
</appender>
|
||||
|
||||
<!-- SkyWalking GRPC 日志收集,实现日志中心。注意:SkyWalking 8.4.0 版本开始支持 -->
|
||||
<appender name="GRPC" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<pattern>${PATTERN_DEFAULT}</pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 本地环境 -->
|
||||
<springProfile name="local">
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="GRPC"/> <!-- 本地环境下,如果不想接入 SkyWalking 日志服务,可以注释掉本行 -->
|
||||
<appender-ref ref="ASYNC"/> <!-- 本地环境下,如果不想打印日志,可以注释掉本行 -->
|
||||
</root>
|
||||
</springProfile>
|
||||
<!-- 其它环境 -->
|
||||
<springProfile name="dev,test,stage,prod,default">
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="ASYNC"/>
|
||||
<appender-ref ref="GRPC"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user