|
|
@ -31,10 +31,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -149,7 +146,8 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
CustomerDTO customerDTO = new CustomerDTO(); |
|
|
|
customerDTO.setId(formDTO.getCustomerId()); |
|
|
|
PaCustomerDTO paCustomerDTO = paCustomerService.get(formDTO.getCustomerId()); |
|
|
|
|
|
|
|
//删除旧的开发版本
|
|
|
|
codeCustomerService.deleteCommitCode(formDTO.getCustomerId(),formDTO.getClientType()); |
|
|
|
//将上传信息存入表中
|
|
|
|
CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class); |
|
|
|
codeCustomerDTO.setCustomerName(paCustomerDTO.getCustomerName()); |
|
|
@ -157,6 +155,7 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
codeCustomerDTO.setExtJson(extJson); |
|
|
|
codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid()); |
|
|
|
codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); |
|
|
|
codeCustomerDTO.setCommitTime(new Date()); |
|
|
|
String codeId = codeCustomerService.save(codeCustomerDTO); |
|
|
|
|
|
|
|
saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), codeId, formDTO.getUserVersion(), CodeConstant.OPER_UPLOAD, "上传成功"); |
|
|
@ -172,63 +171,76 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
CodeVersionInfoResultDTO resultDTO = new CodeVersionInfoResultDTO(); |
|
|
|
//开发版本
|
|
|
|
CodeCustomerDTO commit = codeCustomerService.getCommitInfo(formDTO.getCustomerId(), formDTO.getClientType()); |
|
|
|
resultDTO.getCommit().setCodeId(commit.getId()); |
|
|
|
resultDTO.getCommit().setCodeInfo(commit.getUserDesc()); |
|
|
|
resultDTO.getCommit().setModelId(commit.getTemplateId()); |
|
|
|
resultDTO.getCommit().setVersion(commit.getUserVersion()); |
|
|
|
resultDTO.getCommit().setCommitTime(DateUtils.format(commit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
if (null != commit) { |
|
|
|
CodeVersionInfoResultDTO.CommitBean commitBean = new CodeVersionInfoResultDTO.CommitBean(); |
|
|
|
commitBean.setCodeId(commit.getId()); |
|
|
|
commitBean.setCodeInfo(commit.getUserDesc()); |
|
|
|
commitBean.setModelId(commit.getTemplateId()); |
|
|
|
commitBean.setVersion(commit.getUserVersion()); |
|
|
|
commitBean.setCommitTime(DateUtils.format(commit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
resultDTO.setCommit(commitBean); |
|
|
|
} |
|
|
|
//审核版本
|
|
|
|
CodeCustomerDTO audit = codeCustomerService.getAuditInfo(formDTO.getCustomerId(), formDTO.getClientType()); |
|
|
|
resultDTO.getAudit().setCodeId(audit.getId()); |
|
|
|
resultDTO.getAudit().setVersion(audit.getUserVersion()); |
|
|
|
resultDTO.getAudit().setCodeInfo(audit.getUserDesc()); |
|
|
|
if (CodeConstant.AUDITING.equals(audit.getStatus())) { |
|
|
|
//获取小程序调用令牌
|
|
|
|
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); |
|
|
|
//获取审核结果信息
|
|
|
|
CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(audit.getId()); |
|
|
|
//调用微信API获取最新审核状态
|
|
|
|
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); |
|
|
|
request.setAuditId(auditResult.getAuditId()); |
|
|
|
WxResult<WxMaAuditStatusResult> wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); |
|
|
|
if (wxAuditResult.success()) { |
|
|
|
WxMaAuditStatusResult result = wxAuditResult.getData(); |
|
|
|
if (result.getStatus() == NumConstant.ZERO) { |
|
|
|
audit.setStatus(CodeConstant.AUDIT_SUCCESS); |
|
|
|
auditResult.setResult(CodeConstant.AUDIT_SUCCESS); |
|
|
|
saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_SUCCESS |
|
|
|
, "审核成功"); |
|
|
|
} else if (result.getStatus() == NumConstant.ONE) { |
|
|
|
audit.setStatus(CodeConstant.AUDIT_FAILED); |
|
|
|
auditResult.setResult(CodeConstant.AUDIT_FAILED); |
|
|
|
auditResult.setReason(result.getReason()); |
|
|
|
auditResult.setScreenShot(result.getScreenshot()); |
|
|
|
saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_FAILED, |
|
|
|
result.getReason()); |
|
|
|
} else if (result.getStatus() == NumConstant.FOUR) { |
|
|
|
audit.setStatus(CodeConstant.DELAY); |
|
|
|
auditResult.setResult(CodeConstant.DELAY); |
|
|
|
auditResult.setReason(result.getReason()); |
|
|
|
saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_DELAY, |
|
|
|
result.getReason()); |
|
|
|
if(null != audit) { |
|
|
|
CodeVersionInfoResultDTO.AuditBean auditBean = new CodeVersionInfoResultDTO.AuditBean(); |
|
|
|
auditBean.setCodeId(audit.getId()); |
|
|
|
auditBean.setVersion(audit.getUserVersion()); |
|
|
|
auditBean.setCodeInfo(audit.getUserDesc()); |
|
|
|
if (CodeConstant.AUDITING.equals(audit.getStatus())) { |
|
|
|
//获取小程序调用令牌
|
|
|
|
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); |
|
|
|
//获取审核结果信息
|
|
|
|
CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(audit.getId()); |
|
|
|
//调用微信API获取最新审核状态
|
|
|
|
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq(); |
|
|
|
request.setAuditId(auditResult.getAuditId()); |
|
|
|
WxResult<WxMaAuditStatusResult> wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request); |
|
|
|
if (wxAuditResult.success()) { |
|
|
|
WxMaAuditStatusResult result = wxAuditResult.getData(); |
|
|
|
if (result.getStatus() == NumConstant.ZERO) { |
|
|
|
audit.setStatus(CodeConstant.AUDIT_SUCCESS); |
|
|
|
auditResult.setResult(CodeConstant.AUDIT_SUCCESS); |
|
|
|
saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_SUCCESS |
|
|
|
, "审核成功"); |
|
|
|
} else if (result.getStatus() == NumConstant.ONE) { |
|
|
|
audit.setStatus(CodeConstant.AUDIT_FAILED); |
|
|
|
auditResult.setResult(CodeConstant.AUDIT_FAILED); |
|
|
|
auditResult.setReason(result.getReason()); |
|
|
|
auditResult.setScreenShot(result.getScreenshot()); |
|
|
|
saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_FAILED, |
|
|
|
result.getReason()); |
|
|
|
} else if (result.getStatus() == NumConstant.FOUR) { |
|
|
|
audit.setStatus(CodeConstant.DELAY); |
|
|
|
auditResult.setResult(CodeConstant.DELAY); |
|
|
|
auditResult.setReason(result.getReason()); |
|
|
|
saveOperation(formDTO.getCustomerId(), formDTO.getClientType(), audit.getId(), audit.getUserVersion(), CodeConstant.OPER_DELAY, |
|
|
|
result.getReason()); |
|
|
|
} |
|
|
|
codeCustomerService.update(audit); |
|
|
|
codeAuditResultService.update(auditResult); |
|
|
|
} |
|
|
|
codeCustomerService.update(audit); |
|
|
|
codeAuditResultService.update(auditResult); |
|
|
|
} |
|
|
|
auditBean.setStatus(audit.getStatus()); |
|
|
|
auditBean.setCommitTime(DateUtils.format(audit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
auditBean.setAuditTime(DateUtils.format(audit.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
resultDTO.setAudit(auditBean); |
|
|
|
} |
|
|
|
resultDTO.getAudit().setStatus(audit.getStatus()); |
|
|
|
resultDTO.getAudit().setCommitTime(DateUtils.format(audit.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
resultDTO.getAudit().setAuditTime(DateUtils.format(audit.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
//线上版本
|
|
|
|
CodeCustomerDTO release = codeCustomerService.getReleaseInfo(formDTO.getCustomerId(), formDTO.getClientType()); |
|
|
|
resultDTO.getRelease().setCodeId(release.getId()); |
|
|
|
resultDTO.getRelease().setCodeInfo(release.getUserDesc()); |
|
|
|
resultDTO.getRelease().setCommitTime(DateUtils.format(release.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
resultDTO.getRelease().setAuditTime(DateUtils.format(release.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
resultDTO.getRelease().setReleaseTime(DateUtils.format(release.getReleaseTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
resultDTO.getRelease().setReleaseType(release.getReleaseType()); |
|
|
|
resultDTO.getRelease().setGrayPercentage(release.getGaryPercentage()); |
|
|
|
resultDTO.getRelease().setVersion(release.getUserVersion()); |
|
|
|
if(null != release) { |
|
|
|
CodeVersionInfoResultDTO.ReleaseBean releaseBean = new CodeVersionInfoResultDTO.ReleaseBean(); |
|
|
|
releaseBean.setCodeId(release.getId()); |
|
|
|
releaseBean.setCodeInfo(release.getUserDesc()); |
|
|
|
releaseBean.setCommitTime(DateUtils.format(release.getCommitTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
releaseBean.setAuditTime(DateUtils.format(release.getAuditTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
releaseBean.setReleaseTime(DateUtils.format(release.getReleaseTime(), DateUtils.DATE_TIME_PATTERN)); |
|
|
|
releaseBean.setReleaseType(release.getReleaseType()); |
|
|
|
releaseBean.setGrayPercentage(release.getGaryPercentage()); |
|
|
|
releaseBean.setVersion(release.getUserVersion()); |
|
|
|
resultDTO.setRelease(releaseBean); |
|
|
|
} |
|
|
|
|
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
@ -245,7 +257,16 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
if (null == authInfo) { |
|
|
|
throw new RenException("未授权"); |
|
|
|
} |
|
|
|
|
|
|
|
//获取上传代码信息
|
|
|
|
CodeCustomerDTO uploadCode = codeCustomerService.getUploadCodeByCustomer(formDTO.getCodeId(), codeCustomerDTO.getCustomerId(), |
|
|
|
codeCustomerDTO.getClientType()); |
|
|
|
if (null != uploadCode) { |
|
|
|
if (CodeConstant.AUDITING.equals(uploadCode.getStatus())) { |
|
|
|
throw new RenException("已经有正在审核的版本"); |
|
|
|
} else { |
|
|
|
codeCustomerService.deleteById(uploadCode.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
//调用微信API上提交审核
|
|
|
|
WxMaCodeSubmitAuditRequest request = new WxMaCodeSubmitAuditRequest(); |
|
|
|
request.setVersionDesc(formDTO.getVersionDesc()); |
|
|
@ -292,6 +313,7 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
} |
|
|
|
//更新代码表状态
|
|
|
|
codeCustomerDTO.setStatus(CodeConstant.AUDITING); |
|
|
|
codeCustomerDTO.setAuditTime(new Date()); |
|
|
|
codeCustomerService.update(codeCustomerDTO); |
|
|
|
saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), |
|
|
|
CodeConstant.OPER_SUBMIT, "审核中"); |
|
|
@ -370,6 +392,9 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
|
|
|
|
//更新代码表状态
|
|
|
|
codeCustomerDTO.setStatus(CodeConstant.RELEASE_SUCCESS); |
|
|
|
codeCustomerDTO.setReleaseTime(new Date()); |
|
|
|
codeCustomerDTO.setReleaseType("total"); |
|
|
|
codeCustomerDTO.setGaryPercentage(NumConstant.ZERO); |
|
|
|
codeCustomerService.update(codeCustomerDTO); |
|
|
|
saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), |
|
|
|
CodeConstant.OPER_RELEASE, "发布成功"); |
|
|
@ -467,7 +492,6 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
public PageData history(CodeCommonFormDTO formDTO) { |
|
|
|
PageHelper.startPage(formDTO.getPage(), formDTO.getLimit()); |
|
|
|
//获取上传代码信息
|
|
|
|
// CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
|
|
|
|
List<CodeHistoryResultDTO> list = codeOperationHistoryService.getHistoryList(formDTO.getCodeId()); |
|
|
|
PageInfo<CodeHistoryResultDTO> pageInfo = new PageInfo<>(list); |
|
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
@ -553,6 +577,57 @@ public class CodeServiceImpl implements CodeService { |
|
|
|
return paCustomerService.getCustomerList(formDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void speedUpAudit(CodeCommonFormDTO formDTO) { |
|
|
|
//获取上传代码信息
|
|
|
|
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); |
|
|
|
//获取小程序调用令牌
|
|
|
|
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); |
|
|
|
if (null == authInfo) { |
|
|
|
throw new RenException("未授权"); |
|
|
|
} |
|
|
|
//获取审核结果信息
|
|
|
|
CodeAuditResultDTO codeAuditResultDTO = codeAuditResultService.getAuditResultByCodeId(formDTO.getCodeId()); |
|
|
|
//调用微信API 加急审核
|
|
|
|
WxMaSpeedUpAuditReq speedRequest = new WxMaSpeedUpAuditReq(); |
|
|
|
speedRequest.setAuditId(codeAuditResultDTO.getAuditId()); |
|
|
|
WxResult wxSpeedResult = wxMaCodeService.speedUpAudit(authInfo.getAuthorizerAccessToken(), speedRequest); |
|
|
|
if (!wxSpeedResult.success()) { |
|
|
|
saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), |
|
|
|
codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, wxSpeedResult.getErrorMsg()); |
|
|
|
throw new RenException(wxSpeedResult.getErrorCode(), wxSpeedResult.getErrorMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void grayRelease(CodeCommonFormDTO formDTO) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void revertGrayRelease(CodeCommonFormDTO formDTO) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void revertCodeRelease(CodeCommonFormDTO formDTO) { |
|
|
|
//获取上传代码信息
|
|
|
|
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); |
|
|
|
//获取小程序调用令牌
|
|
|
|
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); |
|
|
|
if (null == authInfo) { |
|
|
|
throw new RenException("未授权"); |
|
|
|
} |
|
|
|
WxResult wxSpeedResult = wxMaCodeService.revertCodeRelease(authInfo.getAuthorizerAccessToken()); |
|
|
|
if (!wxSpeedResult.success()) { |
|
|
|
saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType(), codeCustomerDTO.getId(), |
|
|
|
codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT, wxSpeedResult.getErrorMsg()); |
|
|
|
throw new RenException(wxSpeedResult.getErrorCode(), wxSpeedResult.getErrorMsg()); |
|
|
|
} |
|
|
|
codeCustomerService.revertCodeRelease(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); |
|
|
|
codeCustomerService.deleteById(codeCustomerDTO.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
private void saveOperation(String customerId, String clientType, String codeId, String version, String operation, String describe) { |
|
|
|
CodeOperationHistoryDTO operationDTO = new CodeOperationHistoryDTO(); |
|
|
|
operationDTO.setCustomerId(customerId); |
|
|
|