钱惠东 vor 6 Tagen
Ursprung
Commit
58088fee78

+ 4 - 5
RuoYi-Vue-fast-master/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -6,6 +6,7 @@ import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.format.FormatStyle;
+import java.time.temporal.WeekFields;
 import java.time.zone.ZoneRules;
 import java.util.Calendar;
 import java.util.Date;
@@ -335,11 +336,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     public static Integer getWeekNumber(String date){
         Date current = parseDate(date);
         if (current == null) return null;
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(current);
-        calendar.setMinimalDaysInFirstWeek(7);
-        calendar.setFirstDayOfWeek(Calendar.SATURDAY);
-        return calendar.get(Calendar.WEEK_OF_YEAR);
+        LocalDate currentDate = LocalDate.parse(date);
+        WeekFields weekFields = WeekFields.of(DayOfWeek.SATURDAY, 1);
+        return currentDate.get(weekFields.weekOfWeekBasedYear());
     }
 
     // 获取所属年

+ 1 - 1
RuoYi-Vue-fast-master/src/main/java/com/ruoyi/project/business/mapper/contract/TqContractLiftMapper.java

@@ -82,7 +82,7 @@ public interface TqContractLiftMapper
 
     List<TqContractLiftVo> listAllById(Long[] ids,@Param("language") String language);
 
-    List<LiftCount> countStatistic(@Param("begin") String begin, @Param("end") String end);
+    List<LiftCount> countStatistic(@Param("week") Integer week);
 
     List<LiftCount> countStatisticByMonthAll(@Param("year") Integer year);
 

+ 5 - 5
RuoYi-Vue-fast-master/src/main/java/com/ruoyi/project/business/service/impl/TqContractServiceImpl.java

@@ -495,14 +495,15 @@ public class TqContractServiceImpl implements ITqContractService
 
         ContractSigningStatistic result = new ContractSigningStatistic();
         int year = DateUtils.getYear(end);
+        int week = DateUtils.getWeekNumber(end);
         result.setYear(year);
-        result.setWeek(DateUtils.getWeekNumber(end));
+        result.setWeek(week);
         // 1. 各区域本周、月电梯(签单、排产、发货)数量统计
-        List<LiftCount> weekCountList = tqContractLiftMapper.countStatistic(begin, end);
+        List<LiftCount> weekCountList = tqContractLiftMapper.countStatistic(week);
         List<List<String>> weekCountStatistics = Lists.newArrayList();
         weekCountStatistics.add(Lists.newArrayList("区域", "签单", "排产", "发货"));
         weekCountStatistics.addAll(getTotalList(weekCountList, "周合计"));
-        result.setAreaCountStatisticsTitle(year + "周各区域数据");
+        result.setAreaCountStatisticsTitle(week + "周各区域数据");
         result.setAreaCountStatistics(weekCountStatistics);
 
         // 2. 全年月度(签单、排产、发货)数量统计
@@ -662,7 +663,7 @@ public class TqContractServiceImpl implements ITqContractService
         if (CollectionUtils.isEmpty(amountAll)){
             return result;
         }
-        List<String> header = Lists.newArrayList("月份", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月", "合计", "占比");
+        List<String> header = Lists.newArrayList("区域", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月", "合计", "占比");
         result.add(header);
 
         List<BigDecimal> sum = Lists.newArrayList();
@@ -705,7 +706,6 @@ public class TqContractServiceImpl implements ITqContractService
     @Override
     public boolean contractSigningStatisticExport(TqContractDto params) {
         ContractSigningStatistic contractSigningStatistic = contractSigningStatistic(params);
-        Integer year = contractSigningStatistic.getYear();
 
         // 返回生成的excel文件
         HttpServletResponse response =ServletUtils.getResponse();

+ 9 - 9
RuoYi-Vue-fast-master/src/main/resources/mybatis/business/contract/TqContractLiftMapper.xml

@@ -707,15 +707,15 @@
             cl.signing_date,
             YEAR(cl.signing_date) as `signing_year`,
             MONTH(cl.signing_date) as `signing_month`,
-            WEEK(cl.signing_date + INTERVAL -6 DAY, 6) as `signing_week`,
+           CEIL((dayofyear(cl.signing_date) + dayofweek(DATE_FORMAT(cl.signing_date, '%Y-01-01'))) / 7) as `signing_week`,
             cl.actual_production_schedule_date,
            YEAR(cl.actual_production_schedule_date) as `production_year`,
            MONTH(cl.actual_production_schedule_date) as `production_month`,
-           WEEK(cl.actual_production_schedule_date + INTERVAL -6 DAY, 6) as `production_week`,
+           CEIL((dayofyear(cl.actual_production_schedule_date) + dayofweek(DATE_FORMAT(cl.actual_production_schedule_date, '%Y-01-01'))) / 7) as `production_week`,
             cl.actual_delivery_date,
            YEAR(cl.actual_delivery_date) as `delivery_year`,
            MONTH(cl.actual_delivery_date) as `delivery_month`,
-           WEEK(cl.actual_delivery_date + INTERVAL -6 DAY, 6) as `delivery_week`,
+           CEIL((dayofyear(cl.actual_delivery_date) + dayofweek(DATE_FORMAT(cl.actual_delivery_date, '%Y-01-01'))) / 7) as `delivery_week`,
             FLOOR(cl.unit_price / cl.rate_4_signing_contracts) as `amount`
         from tq_contract_lift cl
             left join (select a.*, SUBSTRING_INDEX(SUBSTRING_INDEX(a.permission_char, ',', -3), ',', 1) as top_id
@@ -727,9 +727,9 @@
     </sql>
     <select id="countStatistic"  resultType="com.ruoyi.project.business.dto.LiftCount">
         select area_name as `key`,
-                SUM(IF(signing_date between #{begin} and #{end}, amount, 0)) as `signCount`,
-                SUM(IF(actual_production_schedule_date between #{begin} and #{end}, amount, 0)) as `productionCount`,
-                SUM(IF(actual_delivery_date between #{begin} and #{end}, amount, 0)) as `deliveryCount`
+                SUM(IF(signing_week = #{week}, amount, 0)) as `signCount`,
+                SUM(IF(production_week = #{week}, amount, 0)) as `productionCount`,
+                SUM(IF(delivery_week = #{week}, amount, 0)) as `deliveryCount`
         from (<include refid="statisticAmount"/>) T
         group by area_id
         order by area_id
@@ -757,11 +757,11 @@
                SUM(IF(type = 3, amount, 0)) as `deliveryCount`
         from
             (
-                select WEEK(signing_date + INTERVAL -6 DAY, 6) as `key`, 1 as `type`, FLOOR(unit_price / rate_4_signing_contracts) as `amount` from tq_contract_lift where del_flag = 0 and YEAR(signing_date) = #{year}
+                select CEIL((dayofyear(signing_date) + dayofweek(DATE_FORMAT(signing_date, '%Y-01-01'))) / 7) as `key`, 1 as `type`, FLOOR(unit_price / rate_4_signing_contracts) as `amount` from tq_contract_lift where del_flag = 0 and YEAR(signing_date) = #{year}
                 union all
-                select WEEK(actual_production_schedule_date + INTERVAL -6 DAY, 6) as `key`, 2 as `type`, FLOOR(unit_price / rate_4_signing_contracts) as `amount` from tq_contract_lift where del_flag = 0 and YEAR(actual_production_schedule_date) = #{year}
+                select CEIL((dayofyear(actual_production_schedule_date) + dayofweek(DATE_FORMAT(actual_production_schedule_date, '%Y-01-01'))) / 7) as `key`, 2 as `type`, FLOOR(unit_price / rate_4_signing_contracts) as `amount` from tq_contract_lift where del_flag = 0 and YEAR(actual_production_schedule_date) = #{year}
                 union all
-                select WEEK(actual_delivery_date + INTERVAL -6 DAY, 6) as `key`, 3 as `type`, FLOOR(unit_price / rate_4_signing_contracts) as `amount` from tq_contract_lift where del_flag = 0 and YEAR(actual_delivery_date) = #{year}
+                select CEIL((dayofyear(actual_delivery_date) + dayofweek(DATE_FORMAT(actual_delivery_date, '%Y-01-01'))) / 7) as `key`, 3 as `type`, FLOOR(unit_price / rate_4_signing_contracts) as `amount` from tq_contract_lift where del_flag = 0 and YEAR(actual_delivery_date) = #{year}
             ) T
         group by `key`
         order by `key`

+ 0 - 1
ruoyi-ui-vue2/src/components/element/table/Column.vue

@@ -113,7 +113,6 @@ export default {
       default: 150,
     },
     fixed: {
-      type: String,
     },
     align: {
       type : String,

+ 17 - 3
ruoyi-ui-vue2/src/views/board/agentTargetProgress/index.vue

@@ -11,12 +11,16 @@
         :editable="false"
       >
       </el-date-picker>
+      <span style="margin-left:10px;padding-right: 20px;font-size: 16px;font-weight: bold;">{{ weekList }}{{ $t('周') }}</span>
+      <el-select   v-model="queryParams.weeks" multiple filterable >
+        <el-option v-for="item in weekList" :key="item" :label="item" :value="item"></el-option>
+      </el-select>
       <el-button style="margin-left: 10px;" type="primary" icon="el-icon-search" size="mini" @click="getList">{{ $t('common.search') }}
       </el-button>
     </div>
     <card-table :delProp="[]" :loading="loading" :modalData="list" :searchParams="queryParams"
                 :tableSearch="true" labelWidth="120px" @columnSearch="handleQuery" @pagination="getList" :max-height="$store.getters.tableMaxHeight"
-                @resetList="resetQuery" @sortChange="sortChange" show-no
+                @resetList="resetQuery" show-no
     >
       <template #operations="{ selections }">
         <el-button v-hasPermi="['bt:business:quotation:export']" icon="el-icon-download" plain size="mini"
@@ -69,6 +73,12 @@ import {getAreaList, getCountryList} from "@/api/business/crm/project";
 import {selectForYear} from "@/api/user/agent";
 import Column from "@/components/element/table/Column";
 import Elevator from "@/views/civil/engineering/elevator";
+import moment from "moment";
+
+moment.updateLocale('en', { week: {
+  dow: 6, // First day of week is Saturday
+  doy: 12 // First week of year must contain 1 January (7 + 6 - 1)
+}})
 
 export default {
   name: "AgentTargetProgress",
@@ -83,8 +93,8 @@ export default {
         pageSize: 10,
         total: 0,
         language: this.$i18n.locale,
-        yearParam:'2024',
-
+        yearParam: moment().format('YYYY'),
+        weeks: []
       },
       list:[],
       areaList: [],
@@ -103,6 +113,10 @@ export default {
       const invisibleRoles = ['area_sales_director', 'sales_manager', 'agent_manager', 'agent_sales', 'sales_support'];
       return !this.$store.getters.roles.some(role => invisibleRoles.includes(role));
     },
+    weekList(){
+      console.log(this.queryParams.yearParam, moment(this.queryParams.yearParam, 'YYYY').locale('en').isoWeeksInYear())
+      return moment(this.queryParams.yearParam, 'YYYY').locale('en').isoWeeksInYear();
+    }
   },
   created() {
     this.handleQuery()

+ 28 - 11
ruoyi-ui-vue2/src/views/board/contractSigningStatistic/index.vue

@@ -6,9 +6,10 @@
         v-model="queryParams.weekData"
         type="week"
         value-format="yyyy-MM-dd"
-        format="yyyy 第 WW 周"
+        :format="weekValue"
         :picker-options="{'firstDayOfWeek': 6}"
         placeholder="选择周"
+        @change="handleWeekChange"
         :clearable="false"/>
       <el-button style="margin-left: 10px;" type="primary" icon="el-icon-search" size="mini" @click="getList">{{ $t('common.search') }}
       </el-button>
@@ -24,14 +25,14 @@
           <h2>{{ data.areaCountStatisticsTitle }}</h2>
           <el-table :data="getBody(data.areaCountStatistics, 2)" :summary-method="() => getWeekCountSummaries()" :show-summary="true" v-loading="loading"
           :height="300" class="page-table" element-loading-text="loading..." :header-cell-style="{'background-color':'#F4F6F8','border-right':'1px solid #dfdcdc','color':'#92A2B5'}" border>
-            <Column v-for="(label, index) in getHeader(data.areaCountStatistics)" :label="label" :prop="index" :fixed="index === 0? 'left' : false"/>
+            <Column v-for="(label, index) in getHeader(data.areaCountStatistics)" :label="label" :prop="String(index)" :fixed="index === 0? 'left' : false"/>
           </el-table>
         </el-col>
         <el-col :span="12">
           <h2>{{ data.monthCountStatisticsTitle }}</h2>
           <el-table :data="getBody(data.monthCountStatistics)" :summary-method="() => getFooter(data.monthCountStatistics)" :show-summary="true" v-loading="loading"
           :height="300" class="page-table" element-loading-text="loading..." :header-cell-style="{'background-color':'#F4F6F8','border-right':'1px solid #dfdcdc','color':'#92A2B5'}" border>
-            <Column v-for="(label, index) in getHeader(data.monthCountStatistics)" :label="label" :prop="index" :fixed="index === 0? 'left' : false"/>
+            <Column v-for="(label, index) in getHeader(data.monthCountStatistics)" :label="label" :prop="String(index)" :fixed="index === 0? 'left' : false"/>
           </el-table>
         </el-col>
       </el-row>
@@ -41,14 +42,14 @@
           <h2>{{ data.weekCountStatisticsTitle }}</h2>
           <el-table :data="getBody(data.weekCountStatistics)" :summary-method="() => getFooter(data.weekCountStatistics)" :show-summary="true" v-loading="loading"
           :height="300" class="page-table" element-loading-text="loading..." :header-cell-style="{'background-color':'#F4F6F8','border-right':'1px solid #dfdcdc','color':'#92A2B5'}" border>
-            <Column v-for="(label, index) in getHeader(data.weekCountStatistics)" :label="label" :prop="index" :fixed="index === 0? 'left' : false"/>
+            <Column v-for="(label, index) in getHeader(data.weekCountStatistics)" :label="label" :prop="String(index)" :fixed="index === 0? 'left' : false"/>
           </el-table>
         </el-col>
         <el-col :span="12">
           <h2>{{ data.signingAreaColStatisticsTitle }}</h2>
           <el-table :data="getBody(data.signingAreaColStatistics)" :summary-method="() => getFooter(data.signingAreaColStatistics)" :show-summary="true" v-loading="loading"
           :height="300" class="page-table" element-loading-text="loading..." :header-cell-style="{'background-color':'#F4F6F8','border-right':'1px solid #dfdcdc','color':'#92A2B5'}" border>
-            <Column v-for="(label, index) in getHeader(data.signingAreaColStatistics)" :label="label" :prop="index" :fixed="index === 0? 'left' : false"/>
+            <Column v-for="(label, index) in getHeader(data.signingAreaColStatistics)" :label="label" :prop="String(index)" :fixed="index === 0? 'left' : false"/>
           </el-table>
         </el-col>
       </el-row>
@@ -58,14 +59,14 @@
           <h2>{{ data.productionAreaColStatisticsTitle }}</h2>
           <el-table :data="getBody(data.productionAreaColStatistics)" :summary-method="() => getFooter(data.productionAreaColStatistics)" :show-summary="true" v-loading="loading"
            :height="300" class="page-table" element-loading-text="loading..." :header-cell-style="{'background-color':'#F4F6F8','border-right':'1px solid #dfdcdc','color':'#92A2B5'}" border>
-            <Column v-for="(label, index) in getHeader(data.productionAreaColStatistics)" :label="label" :prop="index" :fixed="index === 0? 'left' : false"/>
+            <Column v-for="(label, index) in getHeader(data.productionAreaColStatistics)" :label="label" :prop="String(index)" :fixed="index === 0? 'left' : false"/>
           </el-table>
         </el-col>
         <el-col :span="12">
           <h2>{{ data.deliveryMonthColStatisticsTitle }}</h2>
           <el-table :data="getBody(data.deliveryMonthColStatistics)" :summary-method="() => getFooter(data.deliveryMonthColStatistics)" :show-summary="true" v-loading="loading"
           :height="300" class="page-table" element-loading-text="loading..." :header-cell-style="{'background-color':'#F4F6F8','border-right':'1px solid #dfdcdc','color':'#92A2B5'}" border>
-            <Column v-for="(label, index) in getHeader(data.deliveryMonthColStatistics)" :label="label" :prop="index" :fixed="index === 0? 'left' : false"/>
+            <Column v-for="(label, index) in getHeader(data.deliveryMonthColStatistics)" :label="label" :prop="String(index)" :fixed="index === 0? 'left' : false"/>
           </el-table>
         </el-col>
       </el-row>
@@ -75,7 +76,7 @@
           <h2>{{ data.productionMonthColStatisticsTitle }}</h2>
           <el-table :data="getBody(data.productionMonthColStatistics)" :summary-method="() => getFooter(data.productionMonthColStatistics)" :show-summary="true" v-loading="loading"
           :height="300" class="page-table" element-loading-text="loading..." :header-cell-style="{'background-color':'#F4F6F8','border-right':'1px solid #dfdcdc','color':'#92A2B5'}" border>
-            <Column v-for="(label, index) in getHeader(data.productionMonthColStatistics)" :label="label" :prop="index" :fixed="index === 0? 'left' : false"/>
+            <Column v-for="(label, index) in getHeader(data.productionMonthColStatistics)" :label="label" :prop="String(index)" :fixed="index === 0? 'left' : false"/>
           </el-table>
         </el-col>
       </el-row>
@@ -88,6 +89,11 @@
 import {contractSigningStatistic} from "@/api/contract/contract.js";
 import moment from "moment";
 
+moment.updateLocale('en', { week: {
+  dow: 6, // First day of week is Saturday
+  doy: 12 // First week of year must contain 1 January (7 + 6 - 1)
+}})
+
 export default {
   name: "ContractSigningStatistic",
   data() {
@@ -109,6 +115,15 @@ export default {
   },
   created() {
     this.handleWeekChange(moment().startOf('week').format('YYYY-MM-DD'))
+    this.getList()
+  },
+  computed: {
+    weekValue(){
+      const currentDate = moment(this.queryParams.weekData).locale('en')
+      const weekYear = currentDate.weekYear();
+      const weekNumber = currentDate.week();
+      return `${weekYear} 第 ${weekNumber} 周`
+    }
   },
   methods:{
     handleWeekChange(val){
@@ -116,7 +131,6 @@ export default {
       this.queryParams.weekData = date.format('YYYY-MM-DD')
       this.queryParams.beginTime = date.add(-1, 'days').format('YYYY-MM-DD')
       this.queryParams.endTime = date.add(6, 'days').format('YYYY-MM-DD')
-      this.getList()
     },
     getList() {
       this.loading = true;
@@ -145,7 +159,10 @@ export default {
       ]
     },
     getHeader(list){
-      return list[0] || []
+      if (!list || list.length < 3) {
+        return []
+      }
+      return list[0]
     },
     getBody(list, footerOffset = 1){
       if (!list || list.length < 3) {
@@ -154,7 +171,7 @@ export default {
       return list.slice(1, list.length - footerOffset)
     },
     getFooter(list, footerOffset = 1){
-      if (!list || list.length === 0) {
+      if (!list || list.length < 3) {
         return []
       }
       return list[list.length - 1] || []