Commit 6242eafe by 谢海旭

v5.6.0版本 策略中心:策略中心PC端-历史人员记录

1 parent 805ccd64
...@@ -55,4 +55,9 @@ public interface StrategyInfoRemote { ...@@ -55,4 +55,9 @@ public interface StrategyInfoRemote {
@ApiParam(name = "pagination", notes = "分页查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "分页查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("策略分页列表") @ApiResponse("策略分页列表")
RpcResponse<RpcPagination<StrategyInfo>> selectStrategyInfoPage(RpcPagination<StrategyInfo> pagination); RpcResponse<RpcPagination<StrategyInfo>> selectStrategyInfoPage(RpcPagination<StrategyInfo> pagination);
@ApiMethod("策略中心-门店分析-历史人员记录")
@ApiParam(name = "merchantId", notes = "查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("策略中心-门店分析-历史人员记录")
RpcResponse<List<StaffHistoryRecordDTO>> listMerchantAnalysisEmployeeHistory(Integer merchantId, Integer bizs);
} }
package cn.com.glsx.dj.strategy.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Configuration
public class DataStatsConfig {
/** 无品牌时的默认传参 */
@Value("${default.brand.id:-1,-2,3454,-4}")
public String defaultBrandId;
}
...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.peanalysis.remote.BusinessSceneAnalysisRemote; ...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.peanalysis.remote.BusinessSceneAnalysisRemote;
import cn.com.glsx.dj.riskmanage.remote.LearningCenterCourseRemote; import cn.com.glsx.dj.riskmanage.remote.LearningCenterCourseRemote;
import cn.com.glsx.dj.smartcarlife.remote.MerchantGoodsInfoRemote; import cn.com.glsx.dj.smartcarlife.remote.MerchantGoodsInfoRemote;
import cn.com.glsx.dj.smartcarlife.remote.PayOrderRemote; import cn.com.glsx.dj.smartcarlife.remote.PayOrderRemote;
import cn.com.glsx.dj.smartcarlife.remote.StaffInfoRemote;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory; import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -73,5 +74,9 @@ public class DubboConfig { ...@@ -73,5 +74,9 @@ public class DubboConfig {
} }
@Bean
public StaffInfoRemote staffInfoRemote() {
return factory.builder(StaffInfoRemote.class).check(check).version("1.0.0").timeout(timeout).build();
}
} }
...@@ -85,4 +85,14 @@ public interface StrategyInfoMapper extends OreMapper<StrategyInfo> { ...@@ -85,4 +85,14 @@ public interface StrategyInfoMapper extends OreMapper<StrategyInfo> {
* @return 未完成策略任务的策略-人员信息列表 * @return 未完成策略任务的策略-人员信息列表
*/ */
List<Integer> selectUnfinishedStrategyStaffList(); List<Integer> selectUnfinishedStrategyStaffList();
/**
* 查询临时支援的员工UUID列表
*
* @param merchantId
* @param yearMonth
* @param userUuidList
* @return
*/
List<String> selectStaffTempSupport(@Param("merchantId") Integer merchantId, @Param("yearMonth") String yearMonth, @Param("userUuidList") List<String> userUuidList);
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,12 @@ package cn.com.glsx.dj.strategy.mapper; ...@@ -2,7 +2,12 @@ package cn.com.glsx.dj.strategy.mapper;
import cn.com.glsx.dj.strategy.model.StrategyMerchantTimeline; import cn.com.glsx.dj.strategy.model.StrategyMerchantTimeline;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper @Mapper
public interface StrategyMerchantTimelineMapper extends OreMapper<StrategyMerchantTimeline> { public interface StrategyMerchantTimelineMapper extends OreMapper<StrategyMerchantTimeline> {
List<StrategyMerchantTimeline> selectMerchantTimeline(@Param("merchantId") Integer merchantId, @Param("bizs") Integer bizs);
} }
\ No newline at end of file \ No newline at end of file
...@@ -149,4 +149,18 @@ public class StrategyInfoRemoteImpl implements StrategyInfoRemote { ...@@ -149,4 +149,18 @@ public class StrategyInfoRemoteImpl implements StrategyInfoRemote {
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
} }
} }
@Override
public RpcResponse<List<StaffHistoryRecordDTO>> listMerchantAnalysisEmployeeHistory(Integer merchantId, Integer bizs) {
try {
List<StaffHistoryRecordDTO> list = strategyInfoService.listMerchantAnalysisEmployeeHistory(merchantId, bizs);
return RpcResponse.success(list);
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error(e.getMessage(), e);
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
} }
package cn.com.glsx.dj.strategy.resp;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class DataResp<T> {
private Integer code;
private String msg;
private T content;
}
package cn.com.glsx.dj.strategy.util;
import cn.com.glsx.dj.peanalysis.dto.DataBusinessDTO;
import cn.com.glsx.dj.strategy.resp.DataResp;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSONUtil;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpRequestUtils {
private static final String DEFAULT_USER_AGENT = "Java-HttpRequestUtils/1.0";
private static final int DEFAULT_CONNECT_TIMEOUT = 30000; // 30秒
private static final int DEFAULT_READ_TIMEOUT = 60000; // 60秒
/**
* 发送 POST 请求(JSON 数据)
*
* @param urlStr 目标 URL
* @param jsonBody JSON 格式的请求体
* @return 响应内容字符串
* @throws IOException 网络异常
*/
public static String postJson(String urlStr, String jsonBody) throws IOException {
return post(urlStr, jsonBody, "application/json; charset=utf-8");
}
/**
* 发送 POST 请求(表单数据)
*
* @param urlStr 目标 URL
* @param formData 表单参数(如:key1=value1&key2=value2)
* @return 响应内容字符串
* @throws IOException 网络异常
*/
public static String postForm(String urlStr, String formData) throws IOException {
return post(urlStr, formData, "application/x-www-form-urlencoded; charset=utf-8");
}
/**
* 通用 POST 方法(支持自定义请求头和超时)
*
* @param urlStr 目标 URL
* @param body 请求体内容
* @param contentType 内容类型
* @param headers 自定义请求头(可选)
* @param connectTimeout 连接超时(毫秒)
* @param readTimeout 读取超时(毫秒)
* @return 响应内容字符串
* @throws IOException 网络异常
*/
public static String post(String urlStr, String body, String contentType,
Map<String, String> headers, int connectTimeout, int readTimeout) throws IOException {
URL url = new URL(urlStr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 配置请求
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", contentType);
connection.setRequestProperty("User-Agent", DEFAULT_USER_AGENT);
// 添加自定义请求头
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
}
// 设置超时
connection.setConnectTimeout(connectTimeout);
connection.setReadTimeout(readTimeout);
// 写入请求体
try (OutputStream os = connection.getOutputStream()) {
byte[] input = body.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
// 处理响应
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
try (BufferedReader br = new BufferedReader(
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
response.append(line);
}
return response.toString();
}
} else {
throw new IOException("HTTP error code: " + responseCode +
" - " + getErrorResponse(connection));
}
}
// 重载方法(默认值)
public static String post(String urlStr, String body, String contentType) throws IOException {
return post(urlStr, body, contentType, null, DEFAULT_CONNECT_TIMEOUT, DEFAULT_READ_TIMEOUT);
}
// 重载:JSON POST
public static String postJson(String urlStr, String jsonBody, Map<String, String> headers) throws IOException {
return post(urlStr, jsonBody, "application/json; charset=utf-8", headers,
DEFAULT_CONNECT_TIMEOUT, DEFAULT_READ_TIMEOUT);
}
// 重载:表单 POST
public static String postForm(String urlStr, String formData, Map<String, String> headers) throws IOException {
return post(urlStr, formData, "application/x-www-form-urlencoded; charset=utf-8", headers,
DEFAULT_CONNECT_TIMEOUT, DEFAULT_READ_TIMEOUT);
}
// 获取错误响应体
private static String getErrorResponse(HttpURLConnection connection) throws IOException {
try (BufferedReader br = new BufferedReader(
new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
StringBuilder errorResponse = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
errorResponse.append(line);
}
return errorResponse.toString();
} catch (IOException e) {
return "Error reading error stream";
}
}
// 示例:调用方式
public static void main(String[] args) {
try {
// 带自定义请求头的 JSON 请求
Map<String, String> headers = new HashMap<>();
String jsonResponse = postJson(
"http://192.168.3.211:8021/data",
"{\n" +
" \"bizs\": 1,\n" +
" \"brandIds\": \"-1,-3\",\n" +
" \"dateType\": 2,\n" +
" \"endDate\": \"2025-12-31\",\n" +
" \"exts\": \"merchantIds\",\n" +
" \"merchantIds\":\"44218026\",\n" +
" \"itemCodes\": \"A036\",\n" +
" \"startDate\": \"2025-01-01\"\n" +
"}",
headers
);
DataResp<List<DataBusinessDTO>> dataResp = JSONUtil.toBean(jsonResponse, new TypeReference<DataResp<List<DataBusinessDTO>>>() {
}, true);
// DataResp<List<DataBusinessDTO>> dataResp = JSON.parseObject(jsonResponse, new TypeReference<DataResp<List<DataBusinessDTO>>>() {});
// System.out.println("JSON Response: " + DateUtil.format(DateUtil.offsetMonth(DateUtil.parse(String.valueOf(2024), "yyyy"), -0), "yyyy-MM"));
// 获取指定年份的12个月
// for (int i = 0; i <= 11; i++) {
// String yyyyMM = DateUtil.format(DateUtil.offsetMonth(DateUtil.parse(String.valueOf(2024), "yyyy"), i), "yyyy-MM");
// System.out.println(yyyyMM);
// }
// for (int i = 10; i >= 1; i--) {
// String yyyyMM = DateUtil.format(DateUtil.offsetMonth(DateUtil.date(), -i + 1), "yyyy-MM");
// System.out.println(yyyyMM);
// }
// 示例数据:已完成量和总量
// BigDecimal completed = new BigDecimal("123.45789");
// BigDecimal total = new BigDecimal("1000");
// 计算完成率(百分比)并保留两位小数
// BigDecimal rate = NumberUtil.div(completed, total, 4, RoundingMode.HALF_UP)
// .multiply(new BigDecimal("100"))
// .setScale(2, RoundingMode.HALF_UP);
//
// System.out.println("完成率: " + rate + "%"); // 输出: 12.35%
int i = new BigDecimal("30000").compareTo(new BigDecimal("1000"));
System.out.println(i);
} catch (Exception e) {
System.err.println("Request failed: " + e.getMessage());
e.printStackTrace();
}
}
}
\ No newline at end of file \ No newline at end of file
...@@ -218,4 +218,22 @@ ...@@ -218,4 +218,22 @@
AND l.id IS NULL AND l.id IS NULL
group by ssr.id group by ssr.id
</select> </select>
<select id="selectStaffTempSupport" resultType="java.lang.String">
SELECT DISTINCT
ssr.user_uuid
FROM dj_car_life_strategy_info si
INNER JOIN dj_car_life_strategy_staff_rel ssr ON si.id = ssr.strategy_id
WHERE si.deleted_flag = 'N'
AND ssr.deleted_flag = 'N'
AND si.strategy_type IN (2, 4)
AND si.end_date IS NOT NULL
AND si.start_date IS NOT NULL
AND si.merchant_id = #{merchantId}
AND DATE_FORMAT(si.start_date, '%Y-%m') &lt;= #{yearMonth}
AND DATE_FORMAT(si.end_date, '%Y-%m') >= #{yearMonth}
AND user_uuid in
<foreach item="userUuidList" index="index" collection="uuids" open="(" separator="," close=")">
#{uuid}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -22,4 +22,14 @@ ...@@ -22,4 +22,14 @@
id, merchant_id, node_type, node_date, created_by, created_date, updated_by, updated_date, id, merchant_id, node_type, node_date, created_by, created_date, updated_by, updated_date,
deleted_flag deleted_flag
</sql> </sql>
<select id="selectMerchantTimeline" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM dj_car_life_strategy_merchant_timeline
WHERE deleted_flag = 'N'
AND merchant_id = #{merchantId}
AND biz = #{bizs}
ORDER BY node_date ASC
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!