@@ -143,7 +143,8 @@ public class UserInfoHelperImpl implements UserInfoHelper { | |||
@Override | |||
public UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode) { | |||
return getUserFullInfoByEmployeeCode(employeeCode); | |||
UserInfo userInfo = userInfoService.getUserInfoByEmployeeCode(employeeCode); | |||
return getUserFullInfo(userInfo); | |||
} | |||
@Override | |||
@@ -1,15 +1,12 @@ | |||
package com.ningdatech.pmapi.provincial.controller; | |||
import cn.hutool.core.io.resource.ResourceUtil; | |||
import com.ningdatech.basic.model.ApiResponse; | |||
import com.ningdatech.pmapi.projectdeclared.manage.ReviewByProvincialDeptManage; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | |||
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; | |||
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.validation.Valid; | |||
@@ -43,7 +40,7 @@ public class TestController { | |||
@GetMapping("/detail") | |||
@ApiOperation("测试获取详情") | |||
private ApiResponse detail(@RequestParam String projectId){ | |||
private SjApiResponse detail(@RequestParam String projectId){ | |||
return joinReviewProvincialBureauService.processInfo(projectId); | |||
} | |||
@@ -0,0 +1,120 @@ | |||
package com.ningdatech.pmapi.provincial.model.res; | |||
import com.ningdatech.basic.enumeration.Status; | |||
import com.ningdatech.basic.model.ApiStatus; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* ApiResponse - 省局统一的接口返回值封装 | |||
* </p> | |||
* | |||
* @author ZPF | |||
* @since 14:29 2022/9/29 | |||
*/ | |||
@Data | |||
@NoArgsConstructor | |||
public class SjApiResponse<T> implements Serializable { | |||
private static final long serialVersionUID = 532384723325394156L; | |||
public static final int SUCCESS_CODE = 200; | |||
public static final String SUCCESS_MSG = "success"; | |||
public static final int ERROR_CODE = 500; | |||
public static final String ERROR_MSG = "Internal server error"; | |||
/** | |||
* 状态码 | |||
*/ | |||
private Integer code; | |||
/** | |||
* 返回内容 | |||
*/ | |||
private String msg; | |||
/** | |||
* 返回数据 | |||
*/ | |||
private T data; | |||
/** | |||
* 全参构造函数 | |||
* | |||
* @param code 状态码 | |||
* @param msg 返回内容 | |||
* @param data 返回数据 | |||
*/ | |||
private SjApiResponse(Integer code, String msg, T data) { | |||
this.code = code; | |||
this.msg = msg; | |||
this.data = data; | |||
} | |||
/** | |||
* 构造一个自定义的API返回 | |||
* | |||
* @param code 状态码 | |||
* @param msg 返回内容 | |||
* @param data 返回数据 | |||
* @return ApiResponse | |||
*/ | |||
public static <T> SjApiResponse<T> of(Integer code, String msg, T data) { | |||
return new SjApiResponse<T>(code, msg, data); | |||
} | |||
/** | |||
* 构造一个成功且不带数据的API返回 | |||
* | |||
* @return ApiResponse | |||
*/ | |||
public static <T> SjApiResponse<T> ofSuccess() { | |||
return ofSuccess(null); | |||
} | |||
/** | |||
* 构造一个成功且带数据的API返回 | |||
* | |||
* @param data 返回数据 | |||
* @return ApiResponse | |||
*/ | |||
public static <T> SjApiResponse<T> ofSuccess(T data) { | |||
return ofStatus(Status.OK, data); | |||
} | |||
/** | |||
* 构造一个成功且自定义消息的API返回 | |||
* | |||
* @param msg 返回内容 | |||
* @return ApiResponse | |||
*/ | |||
public static <T> SjApiResponse<T> ofMessage(String msg) { | |||
return of(Status.OK.getCode(), msg, null); | |||
} | |||
/** | |||
* 构造一个有状态的API返回 | |||
* | |||
* @param status 状态 {@link Status} | |||
* @return ApiResponse | |||
*/ | |||
public static <T> SjApiResponse<T> ofStatus(ApiStatus status) { | |||
return ofStatus(status, null); | |||
} | |||
/** | |||
* 构造一个有状态且带数据的API返回 | |||
* | |||
* @param status 状态 {@link Status} | |||
* @param data 返回数据 | |||
* @return ApiResponse | |||
*/ | |||
public static <T> SjApiResponse<T> ofStatus(ApiStatus status, T data) { | |||
return of(status.getCode(), status.getReasonPhrase(), data); | |||
} | |||
} |
@@ -1,7 +1,7 @@ | |||
package com.ningdatech.pmapi.provincial.service; | |||
import com.ningdatech.basic.model.ApiResponse; | |||
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | |||
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; | |||
/** | |||
* @Classname JointReviewProvincialBureauService | |||
@@ -22,5 +22,5 @@ public interface IJoinReviewProvincialBureauService { | |||
* 查看 本区域 省局联审 的项目审核详情 | |||
* @return | |||
*/ | |||
ApiResponse processInfo(String projectId); | |||
SjApiResponse processInfo(String projectId); | |||
} |
@@ -8,6 +8,7 @@ import com.ningdatech.basic.model.ApiResponse; | |||
import com.ningdatech.pmapi.common.config.ProvincialProperties; | |||
import com.ningdatech.pmapi.provincial.model.dto.ProvincialProjectDTO; | |||
import com.ningdatech.pmapi.provincial.model.res.ProvincialProjectRes; | |||
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; | |||
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -80,13 +81,13 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc | |||
* @return | |||
*/ | |||
@Override | |||
public ApiResponse processInfo(String projectId) { | |||
public SjApiResponse processInfo(String projectId) { | |||
Long timeStamp = System.currentTimeMillis()/1000; | |||
String url = provincialProperties.getHost() + provincialProperties.getDetailUrl() | |||
+ "?timestamp=" + timeStamp; | |||
log.info("省局获取审核详情 url {}",url); | |||
ResponseEntity<ApiResponse> responseEntity = null; | |||
ResponseEntity<SjApiResponse> responseEntity = null; | |||
String signature = getSha256(timeStamp,provincialProperties.getDetailUrl(), | |||
HttpMethod.POST.name()); | |||
@@ -104,7 +105,7 @@ public class JoinReviewProvincialBureauServiceImpl implements IJoinReviewProvinc | |||
.body(jsonBaby); //也可以是DTO | |||
try { | |||
responseEntity = restTemplate.exchange(requestEntity,ApiResponse.class); | |||
responseEntity = restTemplate.exchange(requestEntity,SjApiResponse.class); | |||
log.info("获取审批详情 响应 :{}",responseEntity); | |||
} catch (Exception e) { | |||
log.error("[省局获取审核详情] http request error", e); | |||
@@ -4,14 +4,13 @@ import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.http.HttpStatus; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.ningdatech.basic.model.ApiResponse; | |||
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; | |||
import com.ningdatech.pmapi.projectdeclared.manage.PrequalificationDeclaredProjectManage; | |||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | |||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||
import com.ningdatech.pmapi.provincial.enumeration.ProjectProvincialAuditStatusEnum; | |||
import com.ningdatech.pmapi.provincial.model.res.ProvincialProjectRes; | |||
import com.ningdatech.pmapi.provincial.model.res.SjApiResponse; | |||
import com.ningdatech.pmapi.provincial.service.IJoinReviewProvincialBureauService; | |||
import com.ningdatech.pmapi.scheduler.contants.TaskContant; | |||
import lombok.RequiredArgsConstructor; | |||
@@ -41,8 +40,6 @@ public class CheckProvincialReviewResultTask { | |||
private final IProjectService projectService; | |||
private final StateMachineUtils stateMachineUtils; | |||
private final PrequalificationDeclaredProjectManage prequalificationDeclaredProjectManage; | |||
@Scheduled(cron = "0 */2 * * * ?") | |||
public void statusFlow() throws UnknownHostException { | |||
//测试暂时用自己电脑HOST | |||
@@ -62,7 +59,7 @@ public class CheckProvincialReviewResultTask { | |||
//遍历 | |||
for(Project project: projectList){ | |||
try{ | |||
ApiResponse apiResponse = reviewProvincialBureauService.processInfo(project.getProjectCode()); | |||
SjApiResponse apiResponse = reviewProvincialBureauService.processInfo(project.getProjectCode()); | |||
log.info("项目 【{}】 去获取省局联审结果 :{}",project.getId(),apiResponse); | |||
if(Objects.isNull(apiResponse) || !Integer.valueOf(HttpStatus.HTTP_OK).equals(apiResponse.getCode())){ | |||
log.info("项目 【{}】 去获取省局联审结果失败",project.getId()); | |||
@@ -15,4 +15,6 @@ public interface IUserInfoService extends IService<UserInfo> { | |||
UserInfo getUserInfoByPhoneNo(String phoneNo); | |||
UserInfo getUserInfoByEmployeeCode(String employeeCode); | |||
} |
@@ -1,5 +1,6 @@ | |||
package com.ningdatech.pmapi.user.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||
@@ -20,16 +21,22 @@ import org.springframework.stereotype.Service; | |||
@Service | |||
@RequiredArgsConstructor | |||
public class UserInfoServiceImpl extends ServiceImpl<NdUserInfoMapper, UserInfo> implements IUserInfoService { | |||
private final NdUserInfoMapper userInfoMapper; | |||
@Override | |||
public UserInfo getUserInfoByPhoneNo(String phoneNo) { | |||
if (StringUtils.isEmpty(phoneNo)) { | |||
return null; | |||
} | |||
UserInfo userInfo = userInfoMapper | |||
.selectOne(Wrappers.lambdaQuery(UserInfo.class) | |||
.eq(UserInfo::getMobile, phoneNo)); | |||
return userInfo; | |||
LambdaQueryWrapper<UserInfo> query = Wrappers.lambdaQuery(UserInfo.class) | |||
.eq(UserInfo::getMobile, phoneNo); | |||
return getOne(query); | |||
} | |||
@Override | |||
public UserInfo getUserInfoByEmployeeCode(String employeeCode) { | |||
LambdaQueryWrapper<UserInfo> query = Wrappers.lambdaQuery(UserInfo.class) | |||
.eq(UserInfo::getEmployeeCode, employeeCode); | |||
return getOne(query); | |||
} | |||
} |