填报经营指标
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
package com.lideeyunji.core.framework.enhance.example.report.record;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.lideeyunji.core.framework.config.aspect.enhance.model.EnhanceContext;
|
||||||
|
import com.lideeyunji.core.framework.config.aspect.enhance.plugin.AroundAdvicePlugin;
|
||||||
|
import com.lideeyunji.core.framework.mapper.BusinessRealRecordMapper;
|
||||||
|
import com.lideeyunji.tool.framework.common.constant.ByglConstant;
|
||||||
|
import com.lideeyunji.tool.framework.common.constant.lideeYunJiBaseConstant;
|
||||||
|
import com.lideeyunji.tool.framework.yunji.utils.lideeYunJiUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保养管理-保养工单
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component("businessRealRecordPlugin")
|
||||||
|
public class BusinessRealRecordPlugin implements AroundAdvicePlugin {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
||||||
|
|
||||||
|
private static final String ORDER_ID_PREFIX = "GD";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BusinessRealRecordMapper businessRealRecordMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeExecute(EnhanceContext enhanceContext) {
|
||||||
|
Map<String, Object> params = enhanceContext.getParam().getParams();
|
||||||
|
//新增方法默认状态字段
|
||||||
|
params.put("order_state",ByglConstant.GD_STATE_DKS);
|
||||||
|
String useyear = lideeYunJiUtils.getMap2Str(params, "useyear");
|
||||||
|
String revenueYearplan = lideeYunJiUtils.getMap2Str(params, "revenue_yearplan");
|
||||||
|
String revenueYearrate = lideeYunJiUtils.getMap2Str(params, "revenue_yearrate");
|
||||||
|
String profitYearplan = lideeYunJiUtils.getMap2Str(params, "profit_yearplan");
|
||||||
|
String profitYearrate = lideeYunJiUtils.getMap2Str(params, "profit_yearrate");
|
||||||
|
List<Map<String, Object>> record = businessRealRecordMapper.getLastMonth(lideeYunJiBaseConstant.DS_ERP_BI_DATA,useyear);
|
||||||
|
if (CollUtil.isEmpty(record)) {
|
||||||
|
throw new RuntimeException("请选择正确的年,当前年月没有指标");
|
||||||
|
}
|
||||||
|
String last_month = (String) record.get(0).get("last_month");
|
||||||
|
businessRealRecordMapper.updateByRecord(lideeYunJiBaseConstant.DS_ERP_BI_DATA, useyear, last_month, "1", revenueYearplan, revenueYearrate);
|
||||||
|
businessRealRecordMapper.updateByRecord(lideeYunJiBaseConstant.DS_ERP_BI_DATA, useyear, last_month, "4", profitYearplan, profitYearrate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterExecute(EnhanceContext enhanceContext) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
package com.lideeyunji.core.framework.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.Master;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Master
|
||||||
|
public interface BusinessRealRecordMapper {
|
||||||
|
|
||||||
|
@DS(value = "#dataSourceType")
|
||||||
|
List<Map<String,Object>> getRecord(@Param("dataSourceType") String dataSourceType, String year);
|
||||||
|
@DS(value = "#dataSourceType")
|
||||||
|
List<Map<String,Object>> getLastMonth(@Param("dataSourceType") String dataSourceType, String year);
|
||||||
|
@DS(value = "#dataSourceType")
|
||||||
|
int updateByRecord(@Param("dataSourceType") String dataSourceType, String year, String month, String itemid, String yearplan, String yearrate);
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.lideeyunji.core.framework.mapper.BusinessRealRecordMapper">
|
||||||
|
|
||||||
|
<select id="getRecord" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
USEYEAR,
|
||||||
|
USEMONTH AS last_month,
|
||||||
|
ITEMID,
|
||||||
|
YEAR_PLAN,
|
||||||
|
YEAR_RATE,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY USEYEAR, ITEMID ORDER BY USEYEAR DESC, CAST(USEMONTH AS UNSIGNED) DESC) AS rn
|
||||||
|
FROM
|
||||||
|
GR_BI_FS_BUSINESS_REAL_RATE
|
||||||
|
where
|
||||||
|
USEYEAR = #{year}
|
||||||
|
) tn
|
||||||
|
WHERE
|
||||||
|
tn.rn = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getLastMonth" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
USEMONTH AS last_month
|
||||||
|
FROM
|
||||||
|
GR_BI_FS_BUSINESS_REAL
|
||||||
|
where
|
||||||
|
USEYEAR = #{year}
|
||||||
|
ORDER BY
|
||||||
|
CAST(USEMONTH AS UNSIGNED) DESC
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="updateByRecord">
|
||||||
|
INSERT INTO gr_bi_fs_business_real_rate (YEAR_PLAN, YEAR_RATE, USEYEAR,USEMONTH,ITEMID)
|
||||||
|
VALUES (#{yearplan}, #{yearrate}, #{year}, #{month}, #{itemid})
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
YEAR_PLAN = #{yearplan},
|
||||||
|
YEAR_RATE = #{yearrate}
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user