mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
1、新增组织编辑修改首购价格能力;2、账单分页支持非管理端只允许查看本组织下;3、统计公共入参和方法抽象、过期组织接口分离移到system、新增销售额统计接口;
This commit is contained in:
-28
@@ -1,10 +1,7 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
|
||||
import com.cf.imes.module.executor.service.order.OrderSupStatisticsService;
|
||||
import com.cf.imes.module.system.api.organ.OrganApi;
|
||||
import com.cf.imes.module.system.api.organ.dto.OrgStatisticsReqDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -15,8 +12,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
@@ -31,9 +26,6 @@ public class OrderSupStatisticsController {
|
||||
@Resource
|
||||
private OrderSupStatisticsService orderSupStatisticsService;
|
||||
|
||||
@Resource
|
||||
private OrganApi organApi;
|
||||
|
||||
@GetMapping("/total/order")
|
||||
@Operation(summary = "生产单总数")
|
||||
@PreAuthorize("@ss.hasPermission('homePage:analysis:org-statistic')")
|
||||
@@ -46,24 +38,4 @@ public class OrderSupStatisticsController {
|
||||
public CommonResult<Map<String, Double>> getPlateAreaTotal() {
|
||||
return success(orderSupStatisticsService.plateAreaTotal());
|
||||
}
|
||||
|
||||
@GetMapping("/separate/order")
|
||||
@Operation(summary = "有效、无效生产单数量统计")
|
||||
@PreAuthorize("@ss.hasPermission('homePage:analysis:order-count')")
|
||||
public CommonResult<Map<String, Object>> getOrderSeparate(@Valid OrderStatisticsReqVO reqVO) {
|
||||
return success(orderSupStatisticsService.orderSeparate(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/separate/org")
|
||||
@Operation(summary = "新增、注销组织数量统计")
|
||||
@PreAuthorize("@ss.hasPermission('homePage:analysis:org-count')")
|
||||
public CommonResult<Map<String, Object>> getOrgSeparate(@Valid OrgStatisticsReqDTO reqVO) {
|
||||
return organApi.getOrgSeparate(reqVO);
|
||||
}
|
||||
|
||||
@GetMapping("/warn/org")
|
||||
@Operation(summary = "组织过期日期统计")
|
||||
public CommonResult<Map<String, List<Object>>> getWarnToOrg() {
|
||||
return organApi.getWarnToOrg();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-18
@@ -1,12 +1,8 @@
|
||||
package com.cf.imes.module.executor.controller.admin.order.vo.order;
|
||||
|
||||
import com.cf.imes.module.executor.validation.order.OrderStatisticsUnitInEnum;
|
||||
import com.cf.imes.framework.common.pojo.CommonStatisticsReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
@@ -14,19 +10,7 @@ import java.time.LocalDate;
|
||||
*/
|
||||
@Schema(description = "管理后台 - 生产单统计 Request VO")
|
||||
@Data
|
||||
public class OrderStatisticsReqVO {
|
||||
public class OrderStatisticsReqVO extends CommonStatisticsReqVO {
|
||||
@Schema(description = "组织id")
|
||||
private Long organId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate[] createTime;
|
||||
|
||||
/**
|
||||
* 统计维度单位
|
||||
*/
|
||||
@Schema(description = "统计维度单位", example = "0", allowableValues = {"0", "1", "2", "3"}, type = "integer")
|
||||
@NotNull(message = "统计维度单位不能为空")
|
||||
@OrderStatisticsUnitInEnum
|
||||
private Integer unit;
|
||||
}
|
||||
|
||||
+2
-189
@@ -1,7 +1,6 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||
import co.elastic.clients.elasticsearch._types.FieldValue;
|
||||
@@ -45,6 +44,8 @@ import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.getDateList;
|
||||
import static com.cf.imes.module.executor.enums.EsIndexEnum.ORDER_OPTIMIZE_PLATE_MODEL;
|
||||
|
||||
/**
|
||||
@@ -623,194 +624,6 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取日期区间格式下的所有日期字符串
|
||||
* 1、reqVO设置机构id
|
||||
* 2、计算时间跨度设置到reqVO
|
||||
* 3、返回所有日期的集合
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
private List<String> getDateList(OrderStatisticsReqVO reqVO) {
|
||||
// 计算时间跨度
|
||||
getTimeSpan(reqVO);
|
||||
|
||||
// 重新计算开始时间喝结束时间
|
||||
countTimeSpan(reqVO);
|
||||
|
||||
// 所有的日期集合
|
||||
return generateDateRange(reqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取统计的时间跨度
|
||||
* 计算起止时间:前端不传入时间就根据维度单位从当前日期计算
|
||||
*
|
||||
* @param reqVO
|
||||
*/
|
||||
private void getTimeSpan(OrderStatisticsReqVO reqVO) {
|
||||
LocalDate[] createTime = reqVO.getCreateTime();
|
||||
LocalDate startTime = null;
|
||||
LocalDate endTime;
|
||||
LocalDate now = LocalDate.now();
|
||||
if (ArrayUtil.isEmpty(createTime) || ObjectUtil.isNull(createTime[0]) || ObjectUtil.isNull(createTime[1])) {
|
||||
endTime = now;
|
||||
switch (OrderStatisticsUnit.fromValue(reqVO.getUnit())) {
|
||||
case QUARTER:
|
||||
// 从now往前的1年
|
||||
startTime = now.minusYears(1);
|
||||
break;
|
||||
case MONTH:
|
||||
// 包含now往前的12个月
|
||||
startTime = now.minusMonths(11);
|
||||
break;
|
||||
case WEEK:
|
||||
// 包含now往前的12周
|
||||
startTime = now.minusWeeks(11);
|
||||
break;
|
||||
case DAY:
|
||||
// 包含now往前的15天
|
||||
startTime = now.minusDays(14);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// 声明一个LocalDateTime的数组,把startTime和endTime放进去
|
||||
reqVO.setCreateTime(new LocalDate[]{startTime, endTime});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传入信息重新计算时间范围
|
||||
*
|
||||
* @param reqVO
|
||||
*/
|
||||
private void countTimeSpan(OrderStatisticsReqVO reqVO) {
|
||||
Integer unit = reqVO.getUnit();
|
||||
// 计算时间跨度
|
||||
getTimeSpan(reqVO);
|
||||
// 计算后的开始和结束时间
|
||||
LocalDate startDate = ObjectUtil.clone(reqVO.getCreateTime()[0]);
|
||||
LocalDate endDate = ObjectUtil.clone(reqVO.getCreateTime()[1]);
|
||||
|
||||
if (startDate.isAfter(endDate)) {
|
||||
startDate = ObjectUtil.clone(reqVO.getCreateTime()[1]);
|
||||
endDate = ObjectUtil.clone(reqVO.getCreateTime()[0]);
|
||||
}
|
||||
LocalDate first = startDate;
|
||||
LocalDate end = endDate;
|
||||
switch (OrderStatisticsUnit.fromValue(unit)) {
|
||||
case QUARTER -> {
|
||||
first = firstDayOfQuarter(startDate);
|
||||
end = lastDayOfQuarter(endDate);
|
||||
}
|
||||
case MONTH -> {
|
||||
first = startDate.with(TemporalAdjusters.firstDayOfMonth());
|
||||
end = endDate.with(TemporalAdjusters.lastDayOfMonth());
|
||||
}
|
||||
case WEEK -> {
|
||||
first = startDate.with(TemporalAdjusters.previousOrSame(java.time.DayOfWeek.MONDAY));
|
||||
end = endDate.with(TemporalAdjusters.nextOrSame(java.time.DayOfWeek.SUNDAY));
|
||||
}
|
||||
default -> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
reqVO.setCreateTime(new LocalDate[]{first, end});
|
||||
}
|
||||
|
||||
private LocalDate firstDayOfQuarter(LocalDate date) {
|
||||
int month = date.getMonthValue();
|
||||
int quarter = (month - 1) / 3 + 1;
|
||||
int startMonth = (quarter - 1) * 3 + 1;
|
||||
return LocalDate.of(date.getYear(), startMonth, 1);
|
||||
}
|
||||
|
||||
private LocalDate lastDayOfQuarter(LocalDate date) {
|
||||
int month = date.getMonthValue();
|
||||
int quarter = (month - 1) / 3 + 1;
|
||||
int endMonth = (quarter - 1) * 3 + 3;
|
||||
return LocalDate.of(date.getYear(), endMonth, 1).with(TemporalAdjusters.lastDayOfMonth());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日期范围内的所有格式字符串
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
private List<String> generateDateRange(OrderStatisticsReqVO reqVO) {
|
||||
Integer unit = reqVO.getUnit();
|
||||
// 计算时间跨度
|
||||
getTimeSpan(reqVO);
|
||||
// 计算后的开始和结束时间
|
||||
LocalDate startDate = ObjectUtil.clone(reqVO.getCreateTime()[0]);
|
||||
LocalDate endDate = ObjectUtil.clone(reqVO.getCreateTime()[1]);
|
||||
|
||||
List<String> dates = new ArrayList<>();
|
||||
while (!startDate.isAfter(endDate)) {
|
||||
String dateStr;
|
||||
switch (OrderStatisticsUnit.fromValue(unit)) {
|
||||
case QUARTER:
|
||||
dateStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-Q"));
|
||||
// 加一季度(3个月)
|
||||
startDate = startDate.plusMonths(3);
|
||||
break;
|
||||
case MONTH:
|
||||
dateStr = startDate.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMATTER_PATTERN_YEAR_MONTH));
|
||||
// 加一月
|
||||
startDate = startDate.plusMonths(1);
|
||||
break;
|
||||
case WEEK:
|
||||
dateStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-M-ww"));
|
||||
// 加一周
|
||||
startDate = startDate.plusWeeks(1);
|
||||
break;
|
||||
case DAY:
|
||||
dateStr = startDate.format(DateTimeFormatter.ofPattern(DATE_TIME_FORMATTER_PATTERN_YEAR_MONTH_DAY));
|
||||
// 加一天
|
||||
startDate = startDate.plusDays(1);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported unit: " + unit);
|
||||
}
|
||||
dates.add(dateStr);
|
||||
}
|
||||
return dates;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建日期格式到图标横轴可用格式
|
||||
* 2024-1 -> 2024年第1季度
|
||||
* 2024-1-1 -> 2024年1月
|
||||
* ...
|
||||
* @param unit
|
||||
* @return
|
||||
*/
|
||||
private String generateDateRangeAxis(String date, Integer unit) {
|
||||
OrderStatisticsUnit orderStatisticsUnit = OrderStatisticsUnit.fromValue(unit);
|
||||
StringBuilder newDateStrBuffer = new StringBuilder();
|
||||
String[] dateSplit = date.split("-");
|
||||
switch (orderStatisticsUnit) {
|
||||
case QUARTER:
|
||||
newDateStrBuffer.append("第").append(dateSplit[1]).append("季度");
|
||||
break;
|
||||
case MONTH:
|
||||
newDateStrBuffer.append(dateSplit[1]).append("月");
|
||||
break;
|
||||
case WEEK:
|
||||
newDateStrBuffer.append("第").append(dateSplit[2]).append("周");
|
||||
break;
|
||||
case DAY:
|
||||
newDateStrBuffer.append(dateSplit[2]).append("日");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return newDateStrBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除尾数的0,600.000 -> 600
|
||||
*
|
||||
|
||||
-7
@@ -1,7 +1,5 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -18,9 +16,4 @@ public interface OrderSupStatisticsService {
|
||||
* 拆单板件平方数统计
|
||||
*/
|
||||
Map<String, Double> plateAreaTotal();
|
||||
|
||||
/**
|
||||
* 有效、无效生产单数量统计
|
||||
*/
|
||||
Map<String, Object> orderSeparate(OrderStatisticsReqVO reqVO);
|
||||
}
|
||||
|
||||
-61
@@ -1,10 +1,6 @@
|
||||
package com.cf.imes.module.executor.service.order;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.enums.OrderStatisticsUnit;
|
||||
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsIsLapseRespVO;
|
||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderStatisticsMapper;
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderSupStatisticsMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -15,9 +11,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.*;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
@@ -59,59 +53,4 @@ public class OrderSupStatisticsServiceImpl implements OrderSupStatisticsService{
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OrganIgnore
|
||||
public Map<String, Object> orderSeparate(OrderStatisticsReqVO reqVO) {
|
||||
setOrderStatisticsReqVO(reqVO);
|
||||
|
||||
Map<String, Object> resultMap = new LinkedHashMap<>();
|
||||
|
||||
// 所有的日期集合
|
||||
List<String> dateList = getDateList(reqVO.getCreateTime(),reqVO.getUnit());
|
||||
|
||||
// 生产单有效数量
|
||||
Map<String, List<OrderStatisticsIsLapseRespVO>> orderLapseRespMap = orderSupStatisticsMapper.selectOrderCountLapseByOrderDate(reqVO).stream()
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
// 生产单无效数量
|
||||
Map<String, List<OrderStatisticsIsLapseRespVO>> orderNotLapseRespMap = orderSupStatisticsMapper.selectOrderCountNotLapseByOrderDate(reqVO).stream()
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(OrderStatisticsIsLapseRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
// 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组
|
||||
for (String dateStr : dateList) {
|
||||
int[] countArr = new int[2];
|
||||
// 生产单有效数量
|
||||
Integer orderNotLapseCount = Optional.ofNullable(orderNotLapseRespMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new OrderStatisticsIsLapseRespVO()))
|
||||
.map(OrderStatisticsIsLapseRespVO::getOrderCount)
|
||||
.orElse(0);
|
||||
countArr[0] = orderNotLapseCount;
|
||||
|
||||
|
||||
// 生产单无效数量
|
||||
Integer orderLapseCount = Optional.ofNullable(orderLapseRespMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new OrderStatisticsIsLapseRespVO()))
|
||||
.map(OrderStatisticsIsLapseRespVO::getOrderCount)
|
||||
.orElse(0);
|
||||
countArr[1] = orderLapseCount;
|
||||
|
||||
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private void setOrderStatisticsReqVO(OrderStatisticsReqVO reqVO){
|
||||
if (ObjectUtil.isNull(reqVO.getUnit())){
|
||||
reqVO.setUnit(OrderStatisticsUnit.DAY.getValue());
|
||||
}
|
||||
if (ObjectUtil.isNull(reqVO.getCreateTime())){
|
||||
reqVO.setCreateTime(new LocalDate[2]);
|
||||
}
|
||||
LocalDate[] time = reqVO.getCreateTime();
|
||||
reqVO.setCreateTime(new LocalDate[]{time[0], time[1]});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user