Merge remote-tracking branch 'origin/main'

This commit is contained in:
liuzhaotian
2024-09-11 16:13:47 +08:00
11 changed files with 187 additions and 105 deletions
@@ -311,6 +311,7 @@ public class OrderController {
} else {
list = (List<?>) map.get("plate");
mapOrder = (Map<String, Object>) map.get("order");
orderDO = (OrderDO) mapOrder.get("order");
if (list.size() == 0) {
orderDO.setStatus(OrderStatusEnum.EMPTY.getStatus());
} else {
@@ -327,6 +328,7 @@ public class OrderController {
// }
assert orderXmlVO != null;
mapOrder = xmlTypeRealize.changeOrder(orderXmlVO, getUserOrganId());
orderDO = (OrderDO) mapOrder.get("order");
if (orderXmlVO.getMaterialXmlVO().getPlateXmlVOS().getPlateXmlVOList().size() == 0) {
orderDO.setStatus(OrderStatusEnum.EMPTY.getStatus());
} else {
@@ -335,8 +337,6 @@ public class OrderController {
}
if (index == null || index == 0) { // 整单导入
assert mapOrder != null;
orderDO = (OrderDO) mapOrder.get("order");
err = ((String) mapOrder.get("error"));
orderDO.setOrderType(OrderTypeEnum.MAIN_ORDER.getStatus());
if (!orderService.customOrderNoIsExists(orderDO.getCustomOrderNo())) {
@@ -15,7 +15,7 @@ import java.math.BigDecimal;
public class OrderGoodsPlateRespVO implements Comparable<OrderGoodsPlateRespVO> {
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "243")
private Long goodsId;
private String goodsId;
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
private String goodsName;
@@ -32,7 +32,7 @@ public interface OrderPlateStatisticsMapper extends BaseMapperX<PlateDO> {
* @param reqVO
* @return
*/
List<OrderGoodsPlateRespVO> selectTopTenPlateCountListGroupByOrderDate(@Param("goodsIds") List<Long> goodsIdList, @Param("req") OrderStatisticsReqVO reqVO);
List<OrderGoodsPlateRespVO> selectTopTenPlateCountListGroupByOrderDate(@Param("goodsIds") List<String> goodsIdList, @Param("req") OrderStatisticsReqVO reqVO);
/**
@@ -49,6 +49,6 @@ public interface OrderPlateStatisticsMapper extends BaseMapperX<PlateDO> {
* @param reqVO
* @return
*/
List<OrderGoodsPlateRespVO> selectTopTenPlateAreaListGroupByOrderDate(@Param("goodsIds") List<Long> goodsIdList, @Param("req") OrderStatisticsReqVO reqVO);
List<OrderGoodsPlateRespVO> selectTopTenPlateAreaListGroupByOrderDate(@Param("goodsIds") List<String> goodsIdList, @Param("req") OrderStatisticsReqVO reqVO);
}
@@ -240,7 +240,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
List<String> dateList = getDateList(reqVO);
// 查询时间段内数量最多的小板,列出数量前10的goods_id
List<Long> topTenCountGoodsId = orderPlateStatisticsMapper.selectPlateCountList(reqVO).stream()
List<String> topTenCountGoodsId = orderPlateStatisticsMapper.selectPlateCountList(reqVO).stream()
.map(OrderGoodsPlateRespVO::getGoodsId)
.toList();
@@ -254,8 +254,8 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
// 获取所有商品{goodsId:respvo},根据top10排序
Map<Long, OrderGoodsPlateRespVO> goodsMap = new LinkedHashMap<>();
for (Long id : topTenCountGoodsId) {
Map<String, OrderGoodsPlateRespVO> goodsMap = new LinkedHashMap<>();
for (String id : topTenCountGoodsId) {
List<OrderGoodsPlateRespVO> list = orderGoodsPlateRespMap.values().stream()
.flatMap(List::stream)
.filter(vo -> vo.getGoodsId().equals(id))
@@ -268,7 +268,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
// 遍历所有goods_id
List<Map<String, Object>> series = new ArrayList<>();
for (Map.Entry<Long, OrderGoodsPlateRespVO> entry : goodsMap.entrySet()) {
for (Map.Entry<String, OrderGoodsPlateRespVO> entry : goodsMap.entrySet()) {
Map<String, Object> seriesItem = new HashMap<>();
int[] sumArr = new int[dateList.size()];
@@ -310,7 +310,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
List<String> dateList = getDateList(reqVO);
// 查询时间段内面积最多的小板,列出前10面积的goods_id
List<Long> topTenCountGoodsId = orderPlateStatisticsMapper.selectPlateAreaList(reqVO).stream()
List<String> topTenCountGoodsId = orderPlateStatisticsMapper.selectPlateAreaList(reqVO).stream()
.map(OrderGoodsPlateRespVO::getGoodsId)
.toList();
@@ -324,8 +324,8 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
// 获取所有商品{goodsId:respvo},根据top10排序
Map<Long, OrderGoodsPlateRespVO> goodsMap = new LinkedHashMap<>();
for (Long id : topTenCountGoodsId) {
Map<String, OrderGoodsPlateRespVO> goodsMap = new LinkedHashMap<>();
for (String id : topTenCountGoodsId) {
List<OrderGoodsPlateRespVO> list = orderGoodsPlateRespMap.values().stream()
.flatMap(List::stream)
.filter(vo -> vo.getGoodsId().equals(id))
@@ -338,7 +338,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
// 遍历所有goods_id
List<Map<String, Object>> series = new ArrayList<>();
for (Map.Entry<Long, OrderGoodsPlateRespVO> entry : goodsMap.entrySet()) {
for (Map.Entry<String, OrderGoodsPlateRespVO> entry : goodsMap.entrySet()) {
Map<String, Object> seriesItem = new HashMap<>();
BigDecimal[] areaArr = new BigDecimal[dateList.size()];
@@ -402,13 +402,13 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
Map<String, Aggregate> goodsCountAggMap = response.aggregations();
Aggregate goodsCountAgg = goodsCountAggMap.get(ORDER_REMAIN_PLATE_MODEL_GOODS_GROUP_NAME);
List<Long> goodsIds = new ArrayList<>();
List<String> goodsIds = new ArrayList<>();
// 构建map{日期:{goodsId、count}}
Map<String, List<OrderGoodsPlateRespVO>> goodsDateGroupMap = new HashMap<>();
/**
* 获取数量最大前十的goodsId列表
*/
goodsCountAgg.lterms().buckets().array().forEach(e -> goodsIds.add(e.key()));
goodsCountAgg.sterms().buckets().array().forEach(e -> goodsIds.add(e.key().stringValue()));
if (CollUtil.isNotEmpty(goodsIds)) {
List<FieldValue> goodsIdFieldValueList = goodsIds.stream().map(FieldValue::of).toList();
@@ -433,12 +433,11 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
Aggregate goodsDateAgg = goodsDateCountAggMap.get(ORDER_REMAIN_PLATE_MODEL_GOODS_GROUP_NAME);
goodsDateAgg.lterms().buckets().array().forEach(goodsDateAggBucket -> {
Long goodsId = goodsDateAggBucket.key();
goodsDateAgg.sterms().buckets().array().forEach(goodsDateAggBucket -> {
// todo 目前没有发现好的es统计月周的方式,先把年月日查出来转周,后续优化
String dateStr = dateToWeekMonth(goodsDateAggBucket.aggregations().get("date_group").dateHistogram().buckets().array().get(0).keyAsString(), unit);
double goodsCount = goodsDateAggBucket.aggregations().get(ORDER_REMAIN_PLATE_MODEL_GOODS_COUNT_NAME).sum().value();
OrderGoodsPlateRespVO vo = OrderGoodsPlateRespVO.builder().goodsId(goodsId).orderDate(dateStr).orderCount((int) goodsCount).build();
OrderGoodsPlateRespVO vo = OrderGoodsPlateRespVO.builder().goodsId(goodsDateAggBucket.key().stringValue()).orderDate(dateStr).orderCount((int) goodsCount).build();
List<OrderGoodsPlateRespVO> orderGoodsPlateRespVOS = goodsDateGroupMap.get(dateStr);
if (ObjectUtil.isNotNull(orderGoodsPlateRespVOS)) {
orderGoodsPlateRespVOS.add(vo);
@@ -452,7 +451,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
// 遍历所有goods_id
List<Map<String, Object>> series = new ArrayList<>();
for (Long goodsId : goodsIds) {
for (String goodsId : goodsIds) {
Map<String, Object> seriesItem = new HashMap<>();
int[] countArr = new int[dateList.size()];
@@ -8,9 +8,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
/**
* @projectName: cf_imes_server
* @author: 晨丰科技
* @date: 2024/8/21 17:58
* xml 转换工具
*/
public class XmlBuilder {
@@ -582,9 +582,9 @@ public class XmlTypeRealize {
long plateNo = idWorker.nextId();
long obtainingTime = idWorker.obtainingTime();
Long plateId = (Long) identifierGenerator.nextId(null);
BigDecimal area = BigDecimal.valueOf((Double.parseDouble(blockXmlVO.getWidth()) / 1000) * (Double.parseDouble(blockXmlVO.getLength())) );
BigDecimal area = BigDecimal.valueOf((Double.parseDouble(blockXmlVO.getWidth()) / 1000) * (Double.parseDouble(blockXmlVO.getLength()) / 1000) );
// 开料面积
BigDecimal sealAcreage = BigDecimal.valueOf( (Double.parseDouble(blockXmlVO.getCuttingWidth()) / 1000) * ( Double.parseDouble(blockXmlVO.getCuttingLength()) / 1000));
BigDecimal sealAcreage = BigDecimal.valueOf( (Double.parseDouble(blockXmlVO.getCuttingWidth()) / 1000) * ( Double.parseDouble(blockXmlVO.getCuttingLength()) / 1000));
// 开门类型获取
Integer doorType = Integer.valueOf(dictDataApi.parseDictData(DictTypeConstants.DOOR_OPENING_DIRECTIONS, blockXmlVO.getOpenDirection()).getData().getValue());