Bladeren bron

Merge remote-tracking branch 'origin/master'

tags/24080901
CMM 1 jaar geleden
bovenliggende
commit
f8f66eb6b3
9 gewijzigde bestanden met toevoegingen van 189 en 20 verwijderingen
  1. +17
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/util/CryptUtils.java
  2. +30
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java
  3. +9
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java
  4. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java
  5. +60
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java
  6. +62
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java
  7. +3
    -10
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  8. +5
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java
  9. +1
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java

+ 17
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/util/CryptUtils.java Bestand weergeven

@@ -7,6 +7,7 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -61,6 +62,22 @@ public class CryptUtils {
mac.init(secretKey);
return mac.doFinal(data);
}

/**
* 生成HMAC-MD5值
* @param data 消息数据
* @param key 密钥
* @return HMAC-MD5值
* @throws NoSuchAlgorithmException
* @throws InvalidKeyException
*/
public static byte[] hmacMd5(byte[] data, byte[] key)
throws NoSuchAlgorithmException, InvalidKeyException {
SecretKeySpec signingKey = new SecretKeySpec(key, "HmacMD5");
Mac mac = Mac.getInstance("HmacMD5");
mac.init(signingKey);
return mac.doFinal(data);
}
public static void main(String[] args) throws Exception{
System.out.println("HMACStr:\n" + encryptHMAC("a", "hank"));


+ 30
- 4
pmapi/src/main/java/com/ningdatech/pmapi/ding/controller/DingInfoPullController.java Bestand weergeven

@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.ding.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.HMac;
import cn.hutool.crypto.digest.MD5;
import com.google.common.collect.Maps;
import com.ningdatech.irs.service.IRefreshTokenService;
@@ -11,6 +12,8 @@ import com.ningdatech.pmapi.ding.task.EmployeeBatchGetTask;
import com.ningdatech.pmapi.ding.task.GovBusinessStripsTask;
import com.ningdatech.pmapi.ding.task.OrganizationBatchGetTask;
import com.ningdatech.pmapi.organization.manage.ProcDefManage;
import com.sun.crypto.provider.HmacMD5;
import com.sun.crypto.provider.HmacMD5KeyGenerator;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -20,6 +23,9 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Objects;

@@ -110,7 +116,7 @@ public class DingInfoPullController {

@ApiOperation(value = "测试项目归并", notes = "测试项目归并")
@GetMapping("/test-guibing")
public String testGuibing() {
public String testGuibing() throws Exception {
long timestamp = System.currentTimeMillis();
String appSecret = "496f0f2a19994f76b4fd9dae087366c7";
String appKey = "A331101453557202109017383";
@@ -127,7 +133,7 @@ public class DingInfoPullController {
restTemplate = new RestTemplate();
}
String appId = "A330000100000202105005790";
String capCode = MD5.create().digestHex(timestamp + appId);
String capCode = CryptUtils.encryptHMAC(timestamp + appId, "bcb4fc0f517fc168ee543fcf4d231f3b");
String url = "https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/" +
"dataSharing/5crv7i4727abLCv0.htm?requestTime=" + timestamp +
"&sign=" + sign + "&appKey=" + appKey +
@@ -141,7 +147,7 @@ public class DingInfoPullController {

@ApiOperation(value = "测试项目详情推送", notes = "测试项目详情推送")
@GetMapping("/test-push-project")
public String testPushProject() {
public String testPushProject() throws Exception {
long timestamp = System.currentTimeMillis();
String appSecret = "496f0f2a19994f76b4fd9dae087366c7";
String appKey = "A331101453557202109017383";
@@ -179,7 +185,7 @@ public class DingInfoPullController {
String baseManDeprtDing = "GO_9a7dce7fbaf54787998fa004f1b7c0e1";
String baseProvManDeprtDing = "GO_6c383c049d95461f9a0df780140ceb32";
String baseBasisEstablish = "中共遂昌县委办公室关于研究开发“天工”智能化管理平台(三期)的函";
String capCode = MD5.create().digestHex(timestamp + areaCode);
String capCode = CryptUtils.encryptHMAC(timestamp + areaCode, "bcb4fc0f517fc168ee543fcf4d231f3b");
String url = "https://interface.zjzwfw.gov.cn/gateway/api/proxy/001003001029/dataSharing/3XN9R93Pva6db7sf.htm?" +
"requestTime=" + timestamp + "&sign=" + sign +
"&appKey=" + appKey + "&baseProjPrincipal=" + baseProjPrincipal + "" +
@@ -198,4 +204,24 @@ public class DingInfoPullController {
log.info(forEntity.getBody());
return forEntity.getBody();
}

public static void main(String[] args) throws Exception {
long timestamp = System.currentTimeMillis();
String areaCode = "331123000";
String res = CryptUtils.encryptHMAC(timestamp + areaCode, "bcb4fc0f517fc168ee543fcf4d231f3b");
System.out.println(res);
}

/**
* 将byte数组转为十六进制字符串
* @param bytes byte数组
* @return 十六进制字符串
*/
private static String bytesToHex(byte[] bytes) {
StringBuilder hex = new StringBuilder();
for (byte b : bytes) {
hex.append(String.format("%02x", b));
}
return hex.toString();
}
}

+ 9
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/controller/PurchaseController.java Bestand weergeven

@@ -6,6 +6,7 @@ import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.projectdeclared.manage.ProjectAdjustmentManage;
import com.ningdatech.pmapi.projectdeclared.manage.PurchaseManage;
import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTO;
import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTOV1;
import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
@@ -55,11 +56,18 @@ public class PurchaseController {
ExcelDownUtil.downXls(response, req, purchaseManage::exportList);
}

@ApiOperation(value = "填写采购结果", notes = "填写采购结果")
/*@ApiOperation(value = "填写采购结果", notes = "填写采购结果")
@WebLog("填写采购结果")
@PostMapping("/submit-result")
public String submitResult(@Validated @RequestBody PurchaseSaveDTO dto) {
return purchaseManage.submitResult(dto);
}*/

@ApiOperation(value = "填写采购结果", notes = "填写采购结果")
@WebLog("填写采购结果")
@PostMapping("/submit-result")
public String submitResult(@Validated @RequestBody PurchaseSaveDTOV1 dto) {
return purchaseManage.submitResultV1(dto);
}




+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/ProjectAdjustmentManage.java Bestand weergeven

@@ -128,6 +128,8 @@ public class ProjectAdjustmentManage {
ProjectApplication projectApplication = new ProjectApplication();
BeanUtils.copyProperties(application, projectApplication);
projectApplication.setProjectId(project.getId());
projectApplication.setProjectCode(project.getProjectCode());
projectApplication.setProjectVersion(project.getVersion());
return projectApplication;
}).collect(Collectors.toList());
projectApplicationService.saveBatch(applications);


+ 60
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/manage/PurchaseManage.java Bestand weergeven

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.ningdatech.basic.exception.BizException;
@@ -11,12 +12,14 @@ import com.ningdatech.basic.function.VUtils;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.basic.util.CollUtils;
import com.ningdatech.basic.util.NdDateUtils;
import com.ningdatech.pmapi.common.constant.BizConst;
import com.ningdatech.pmapi.common.helper.UserInfoHelper;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.common.util.ExcelExportStyle;
import com.ningdatech.pmapi.projectdeclared.model.dto.DeclaredProjectExportDTO;
import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTO;
import com.ningdatech.pmapi.projectdeclared.model.dto.PurchaseSaveDTOV1;
import com.ningdatech.pmapi.projectdeclared.model.entity.Purchase;
import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO;
import com.ningdatech.pmapi.projectdeclared.service.IPurchaseService;
@@ -226,4 +229,61 @@ public class PurchaseManage {

return "保存失败";
}

/**
* 填写采购结果
*
* @param dto
* @return
*/
public String submitResultV1(PurchaseSaveDTOV1 dto) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
String employeeCode = user.getEmployeeCode();
VUtils.isTrue(StringUtils.isBlank(employeeCode)).throwMessage("获取登录用户 员工号 失败!");

Long projectId = dto.getProjectId();
VUtils.isTrue(Objects.isNull(projectId)).throwMessage("提交失败 缺少项目ID!");
Project project = projectService.getNewProject(dto.getProjectId());
VUtils.isTrue(Objects.isNull(project)).throwMessage("提交失败 此项目不存在!");

//首先要判断 项目当前状态 是不是 采购结果备案
VUtils.isTrue(!ProjectStatusEnum.TO_BE_PURCHASED.eq(project.getStatus())
|| !ProjectStatusEnum.PROJECT_APPROVED.eq(project.getStage()))
.throwMessage("提交失败 该项目不是 待采购备案状态或者已立项阶段");

Purchase purchase1 = purchaseService.getOne(Wrappers.lambdaQuery(Purchase.class)
.eq(Purchase::getProjectId, projectId)
.last(BizConst.LIMIT_1));
Purchase purchase = BeanUtil.copyProperties(dto, Purchase.class);
if (purchase1 == null) {
purchase.setCreateBy(employeeCode);
purchase.setCreateOn(LocalDateTime.now());
}
purchase.setProjectId(projectId);

if (purchaseService.saveOrUpdate(purchase)) {
// 如果 需要推送项目和应用管理的话 只有遂昌县才有
// String areaCode = project.getAreaCode();
// String appCode = dto.getAppCode();
// if(RegionConst.RC_SC.equals(areaCode) && StringUtils.isNotBlank(appCode)){
// try{
//
// }catch (Exception e){
// log.info("绑定以及推送项目和应用关系 失败! {}" + e.getMessage());
// }
// }
//进入到下一状态
stateMachineUtils.pass(project);
project.setUpdateOn(LocalDateTime.now());

// 获取总的成交时间及金额
project.setTransactionAmount(purchase.getTransactionAmount());
project.setTransactionTime(purchase.getTransactionTime());
projectService.updateById(project);

return "填写成功";
}

return "保存失败";
}
}

+ 62
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/model/dto/PurchaseSaveDTOV1.java Bestand weergeven

@@ -0,0 +1,62 @@
package com.ningdatech.pmapi.projectdeclared.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
* @Classname Purchase
* @Description
* @Date 2023/5/29 10:00
* @Author PoffyZhang
*/
@Data
@ApiModel(value = "采购对象", description = "采购对象")
@AllArgsConstructor
public class PurchaseSaveDTOV1 {

@ApiModelProperty("项目ID")
@NotNull(message = "请传项目ID")
private Long projectId;

@ApiModelProperty("供应商")
private String supplier;

@ApiModelProperty("供应商联系人")
private String supplierContact;

@ApiModelProperty("供应商联系方式")
private String supplierContactInfo;

@ApiModelProperty("采购方式 1公开招标 2自行采购")
private Integer purchaseMethod;

@ApiModelProperty("成交金额")
private BigDecimal transactionAmount;

@ApiModelProperty("成交时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDateTime transactionTime;

@ApiModelProperty("代理机构")
private String agency;

@ApiModelProperty("投标文件")
private String biddingDoc;

@ApiModelProperty("招标文件")
private String bidDoc;

@ApiModelProperty("中标通知书")
private String acceptanceLetter;

@ApiModelProperty("应用编码")
private String appCode;

}

+ 3
- 10
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java Bestand weergeven

@@ -499,17 +499,10 @@ public class ProjectLibManage {
.ne(Project::getId, project.getId())
.eq(Project::getProjectCode, project.getProjectCode()));

//采取批量删除 批量添加的方式 批量删除建设方案申报后的应用信息及关联的核心业务
List<String> projectCodeList = projectService.list(Wrappers.lambdaQuery(Project.class)
.eq(Project::getProjectCode, project.getProjectCode())
.eq(Project::getIsConstruct, isConstruct)).stream()
.map(Project::getProjectCode).collect(Collectors.toList());

//删除当前版本的app 一般情况是没有 保险起见
List<ProjectApplication> applications = projectApplicationService.list(Wrappers.lambdaQuery(ProjectApplication.class)
.eq(ProjectApplication::getProjectCode, project.getProjectCode())
.in(CollUtil.isNotEmpty(projectCodeList), ProjectApplication::getProjectCode, projectCodeList)
.eq(ProjectApplication::getProjectVersion, project.getVersion())
.eq(ProjectApplication::getIsConstruct, Boolean.TRUE));
.eq(ProjectApplication::getProjectVersion, project.getVersion()));
if (CollUtil.isNotEmpty(applications)) {
projectApplicationService.removeBatchByIds(applications);
List<Long> applicationIds = applications.stream().map(ProjectApplication::getId).collect(Collectors.toList());
@@ -517,7 +510,6 @@ public class ProjectLibManage {
.in(ProjectCoreBusinessIndicators::getApplicationId, applicationIds));
}


//app
List<ProjectApplicationDTO> applicationList = projecDto.getApplicationList();
if (CollUtil.isNotEmpty(applicationList)) {
@@ -526,6 +518,7 @@ public class ProjectLibManage {
ProjectApplication app = BeanUtil.copyProperties(a, ProjectApplication.class);
app.setId(null);
app.setProjectId(project.getId());
app.setProjectCode(project.getProjectCode());
app.setBuildOrgName(project.getBuildOrgName());
app.setBuildOrgCode(project.getBuildOrgCode());
app.setIsConstruct(isConstruct);


+ 5
- 5
pmapi/src/main/java/com/ningdatech/pmapi/provincial/service/impl/JoinReviewProvincialBureauServiceImpl.java Bestand weergeven

@@ -151,12 +151,12 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc

@Override
public List<ProvincialGovBusinessStripVO> searchGovUnits() {
Long timeStamp = System.currentTimeMillis()/1000;
Long timeStamp = System.currentTimeMillis();
String appSecret = govAppSecret;
String appKey = govAppKey;
String method = HttpMethod.POST.name();
String secret = refreshTokenService.refreshToken(appKey,appSecret,govRequestTokenUrl,govRefreshTokenUrl,interfaceName,method);
String sign = MD5.create().digestHex(appKey + secret + timeStamp * 1000);
String sign = MD5.create().digestHex(appKey + secret + timeStamp);
HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory();
RestTemplate restTemplate;
if(Objects.nonNull(factory)){
@@ -165,12 +165,12 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc
restTemplate = new RestTemplate();
}

String authSignature = getSha256(timeStamp,provincialProperties.getDomainUrl(), HttpMethod.POST.name(),
String authSignature = getSha256(timeStamp/1000,provincialProperties.getDomainUrl(), HttpMethod.POST.name(),
provincialProperties.getKey(),provincialProperties.getSecret());
String url = govUrl + "?appKey=" + appKey +
"&timestamp=" + timeStamp + "&sign=" + sign +
"&timestamp=" + timeStamp/1000 + "&sign=" + sign +
"&authKey=" + provincialProperties.getKey() + "&authSignature=" + authSignature +
"&requestTime=" + timeStamp*1000;
"&requestTime=" + timeStamp;
log.info("gov search url :{}",url);
ResponseEntity<JSONObject> forEntity = restTemplate.postForEntity(url,null, JSONObject.class, Maps.newHashMap());
JSONObject body = forEntity.getBody();


+ 1
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java Bestand weergeven

@@ -1146,6 +1146,7 @@ public class TodoCenterManage {
projectApplication.setId(null);
projectApplication.setProjectId(project.getId());
projectApplication.setProjectCode(project.getProjectCode());
projectApplication.setProjectVersion(project.getVersion());
if (!InstTypeEnum.UNIT_INNER_AUDIT.getCode().equals(instType) &&
!InstTypeEnum.PRELIMINARY_PREVIEW.getCode().equals(instType) &&
!InstTypeEnum.DEPT_UNITED_REVIEW.getCode().equals(instType)) {


Laden…
Annuleren
Opslaan