This commit is contained in:
lym
2025-01-15 10:45:27 +08:00
18 changed files with 230 additions and 225 deletions
@@ -1,6 +1,7 @@
package com.cf.imes.framework.es.core.service; package com.cf.imes.framework.es.core.service;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
import co.elastic.clients.elasticsearch._types.Result; import co.elastic.clients.elasticsearch._types.Result;
import co.elastic.clients.elasticsearch.core.BulkResponse; import co.elastic.clients.elasticsearch.core.BulkResponse;
import co.elastic.clients.elasticsearch.core.IndexResponse; import co.elastic.clients.elasticsearch.core.IndexResponse;
@@ -56,7 +57,7 @@ public interface ESDocumentService {
* @param documents 要增加的对象集合 * @param documents 要增加的对象集合
* @return 批量操作的结果 * @return 批量操作的结果
*/ */
<T> BulkResponse bulkCreate(String idxName, List<?extends ESDocument> documents) throws Exception; <T> BulkResponse bulkCreate(String idxName, List<?extends ESDocument> documents) throws IOException, ElasticsearchException;
/** /**
@@ -6,6 +6,7 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import co.elastic.clients.elasticsearch.ElasticsearchAsyncClient; import co.elastic.clients.elasticsearch.ElasticsearchAsyncClient;
import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
import co.elastic.clients.elasticsearch._types.Result; import co.elastic.clients.elasticsearch._types.Result;
import co.elastic.clients.elasticsearch.core.*; import co.elastic.clients.elasticsearch.core.*;
import com.cf.imes.framework.es.core.dal.ESDocument; import com.cf.imes.framework.es.core.dal.ESDocument;
@@ -130,7 +131,7 @@ public class ESDocumentServiceImpl implements ESDocumentService {
*/ */
@Override @Override
public <T> BulkResponse bulkCreate(String idxName, List<? extends ESDocument> documents) throws Exception { public <T> BulkResponse bulkCreate(String idxName, List<? extends ESDocument> documents) throws IOException, ElasticsearchException {
BulkRequest.Builder br = new BulkRequest.Builder(); BulkRequest.Builder br = new BulkRequest.Builder();
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Date date = new Date(); Date date = new Date();
@@ -30,6 +30,11 @@ public interface OrderPlanApi {
@Parameter(name = "orderId", description = "生产单ID", required = true) @Parameter(name = "orderId", description = "生产单ID", required = true)
CommonResult<Boolean> getOrder(@RequestParam("orderId") Long orderId); CommonResult<Boolean> getOrder(@RequestParam("orderId") Long orderId);
@GetMapping(PREFIX +"/apiGetOrderProcessScheme")
@Operation(summary = "查询加工组方案是否在排单中使用")
@Parameter(name = "processId", description = "加工方案ID", required = true)
CommonResult<Boolean> getOrderProcessScheme(@RequestParam("processId") Long processId);
/* /*
* 机台数据源数据查询 * 机台数据源数据查询
@@ -153,6 +153,17 @@ public class OrderPlanApiImpl implements OrderPlanApi{
@Override
public CommonResult<Boolean> getOrderProcessScheme(Long processId) {
List<PlanDO> planDOS = planMapper.selectProcessScheme(processId, getUserOrganId());
return CommonResult.success(CollUtil.isNotEmpty(planDOS));
}
/* /*
* 机台数据源数据查询 * 机台数据源数据查询
* *
@@ -175,7 +175,7 @@ public class PlanController {
@Operation(summary = "获取未排单的生产单的柜体和房间名称") @Operation(summary = "获取未排单的生产单的柜体和房间名称")
@Parameter(name = "orderIds", description = "生产单ID", required = true) @Parameter(name = "orderIds", description = "生产单ID", required = true)
@PreAuthorize("@ss.hasPermission('placeorder:orderlist')") @PreAuthorize("@ss.hasPermission('placeorder:orderlist')")
public CommonResult<List<OrderRoomBodyList>> getOrderRoomBody(@Valid @RequestParam @Size(max = 20,message = "最多可同时查询20个生产单信息") List<Long> orderIds) { public CommonResult<List<OrderRoomBodyList>> getOrderRoomBody(@Valid @NotEmpty(message = "生产单ID不能为空") @RequestParam @Size(max = 20,message = "最多可同时查询20个生产单信息") List<Long> orderIds) {
return success(planService.getOrderRoomBody(orderIds)); return success(planService.getOrderRoomBody(orderIds));
} }
@@ -6,7 +6,6 @@ import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Objects;
@Data @Data
@@ -118,11 +117,11 @@ public class RemainBoardInfo {
private Boolean isScrap; private Boolean isScrap;
private List<Objects> points; private List<Object> points;
private List<Blocks> blocks; private List<Blocks> blocks;
private List<Objects> objects; private List<Object> objects;
private BigDecimal area; private BigDecimal area;
@@ -157,7 +156,75 @@ public class RemainBoardInfo {
} }
@Data
public static class PlaceObject {
private Long orderId;
private Long oldBlockId;
private Long blockNo;
private BigDecimal cuttingWidth;
private BigDecimal cuttingLength;
private BigDecimal cuttingArea;
private Integer texture;
private Boolean isTurnFaceToPlace;
private Boolean isDoubleFaceProcess;
private Boolean isPlaced;
private PlaceObjectDetail blockDetail;
}
@Data
public static class PlaceObjectDetail {
private Long orderId;
private Long blockId;
private Integer psFrontNormalTexture;
private Integer psFrontReverseTexture;
private Integer psBackNormalTexture;
private Integer psBackReverseTexture;
private Boolean hasBlockInnerSpace;
private List<PlaceSpace> spaces;
}
@Data
public static class PlaceSpace {
private Long boardId;
private Long spaceId;
private BigDecimal x;
private BigDecimal y;
private BigDecimal width;
private BigDecimal length;
private Boolean isBlockInnerSpace;
private Object spaces;
}
} }
@@ -8,7 +8,6 @@ import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
@@ -85,7 +84,7 @@ public class OrderPageReqVOCopy extends PageParam {
@Schema(description = "商品ID-板材库对应的大板ID-由板材查询生产单时传") @Schema(description = "商品ID-板材库对应的大板ID-由板材查询生产单时传")
@Size(max = 20,message = "最多可同时查询20个板材") // @Size(max = 20,message = "最多可同时查询20个板材")
private List<String> goodsId; private List<String> goodsId;
@Schema(description = "排单ID-修改排单时为必传条件") @Schema(description = "排单ID-修改排单时为必传条件")
@@ -98,7 +97,7 @@ public class OrderPageReqVOCopy extends PageParam {
private List<Long> bodyId; private List<Long> bodyId;
@Schema(description = "生产单ids") @Schema(description = "生产单ids")
@Size(max = 20,message = "最多可同时查询20个生产单") // @Size(max = 20,message = "最多可同时查询20个生产单")
private List<Long> orderIds; private List<Long> orderIds;
} }
@@ -88,7 +88,7 @@ public interface GoodsMapper extends BaseMapperX<GoodsDO> {
default List<GoodsDO> selectListByGoodsId(List<Long> orderIds,List<String> goodsIds, Long organId) { default List<GoodsDO> selectListByGoodsId(List<Long> orderIds,List<String> goodsIds, Long organId) {
return selectList(new LambdaQueryWrapperX<GoodsDO>() return selectList(new LambdaQueryWrapperX<GoodsDO>()
.eq(GoodsDO::getOrganId, organId) .eq(GoodsDO::getOrganId, organId)
.in(GoodsDO::getOrderId,orderIds) .inIfPresent(GoodsDO::getOrderId,orderIds)
.in(GoodsDO::getGoodsId, goodsIds) .in(GoodsDO::getGoodsId, goodsIds)
.eq(GoodsDO::getDeleted, false)); .eq(GoodsDO::getDeleted, false));
@@ -5,10 +5,13 @@ import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX; import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderStatisticsReqVO;
import com.cf.imes.module.executor.controller.admin.plan.vo.*; import com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanStatisticsAreaRespVO;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO; import com.cf.imes.module.executor.controller.admin.plan.vo.OrderPlanStatisticsCountRespVO;
import com.cf.imes.module.executor.controller.admin.plan.vo.PlanPageReqVO;
import com.cf.imes.module.executor.controller.admin.plan.vo.PlateOptimize;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO; import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
import com.cf.imes.module.executor.dal.dataobject.planitem.PlanItemDO;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -42,8 +45,8 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PlanDO::getOperator, reqVO.getOperator()) .eqIfPresent(PlanDO::getOperator, reqVO.getOperator())
.betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime()) .betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime())
.leftJoin(GoodsDO.class, GoodsDO::getPlanId, PlanDO::getId) .leftJoin(PlanItemDO.class, PlanItemDO::getPlanId, PlanDO::getId)
.leftJoin(OrderDO.class, OrderDO::getId, GoodsDO::getOrderId) .leftJoin(OrderDO.class, OrderDO::getId, PlanItemDO::getOrderId)
.like(OrderDO::getCustomer, reqVO.getCustomer()) .like(OrderDO::getCustomer, reqVO.getCustomer())
.orderByDesc(PlanDO::getCreateTime) .orderByDesc(PlanDO::getCreateTime)
.distinct() .distinct()
@@ -133,4 +136,15 @@ public interface PlanMapper extends BaseMapperX<PlanDO> {
.in(PlanDO::getStatus,status) .in(PlanDO::getStatus,status)
.orderByAsc(PlanDO::getSort)); .orderByAsc(PlanDO::getSort));
} }
default List<PlanDO> selectProcessScheme(Long processId,Long organId) {
return selectList( new LambdaQueryWrapperX<PlanDO>()
.eq(PlanDO::getOrganId,organId)
.eq(PlanDO::getDeleted,false)
.in(PlanDO::getProcessId,processId)
.select(PlanDO::getId));
}
} }
@@ -31,7 +31,7 @@ public interface PlanItemMapper extends BaseMapperX<PlanItemDO> {
default List<PlanItemDO> selectPlanPlateList(List<Long> planIds, List<Long> orderIds, Long organId) { default List<PlanItemDO> selectPlanPlateList(List<Long> planIds, List<Long> orderIds, Long organId) {
return selectList( new LambdaQueryWrapperX<PlanItemDO>() return selectList( new LambdaQueryWrapperX<PlanItemDO>()
.eq(PlanItemDO::getOrganId, organId) .eq(PlanItemDO::getOrganId, organId)
.in(PlanItemDO::getOrderId,orderIds) .inIfPresent(PlanItemDO::getOrderId,orderIds)
.in(PlanItemDO::getPlanId,planIds)); .in(PlanItemDO::getPlanId,planIds));
} }
@@ -410,21 +410,37 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
PlanDO planDO = validatePlanExists(planId); PlanDO planDO = validatePlanExists(planId);
List<Long> orderIds = new ArrayList<>(JSON.parseArray(planDO.getOrderNos()).toJavaList(Long.class).stream().distinct().toList()); // 校验生产单信息和获取 orderId
String orderNos = Optional.ofNullable(planDO.getOrderNos()).orElseThrow(() -> new ServiceException(ORDER_PLAN_ERROR));
List<Long> orderIds = new ArrayList<>(JSON.parseArray(orderNos).toJavaList(Long.class).stream().distinct().toList());
// 查询优化信息
List<OptimizeBoardModelDO> optimizeBoardModelDOS = esUtils.getEsDocument(FIELD_PLAN_CONFIG_ID,FIELD_PLAN_ID,respVO.getPlanConfigId(), planId, ORDER_OPTIMIZE_PLATE_MODEL, OptimizeBoardModelDO.class); List<OptimizeBoardModelDO> optimizeBoardModelDOS = esUtils.getEsDocument(FIELD_PLAN_CONFIG_ID,FIELD_PLAN_ID,respVO.getPlanConfigId(), planId, ORDER_OPTIMIZE_PLATE_MODEL, OptimizeBoardModelDO.class);
AssertUtils.notEmpty(optimizeBoardModelDOS,ORDER_PLAN_OPTIMIZE_ERROR);
OptimizeBoardModelDO optimizeBoardModelDO = optimizeBoardModelDOS.get(0); OptimizeBoardModelDO optimizeBoardModelDO = optimizeBoardModelDOS.get(0);
// 校验信息
String remainBoardInfo = optimizeBoardModelDO.getRemainBoardInfo(); String remainBoardInfo = optimizeBoardModelDO.getRemainBoardInfo();
AssertUtils.notEmpty(remainBoardInfo,ORDER_PLAN_OPTIMIZE_ERROR);
Integer boardCount = optimizeBoardModelDO.getBoardCount(); Integer boardCount = optimizeBoardModelDO.getBoardCount();
AssertUtils.notEmpty(boardCount,ORDER_PLAN_OPTIMIZE_ERROR);
List<RemainBoardInfo> remainBoardInfos = parseArray(remainBoardInfo, RemainBoardInfo.class); List<RemainBoardInfo> remainBoardInfos;
try {
remainBoardInfos = new ArrayList<>(parseArray(remainBoardInfo, RemainBoardInfo.class));
}catch (Exception e){
log.error(e.getMessage());
throw exception(PLAN_PLATE_OPTIMIZE_DATA_ERROR);
}
AssertUtils.notEmpty(remainBoardInfos,ORDER_PLAN_OPTIMIZE_ERROR);
Long goodsNum = updatePlanOptimizeData(remainBoardInfos, optimizeBoardModelDO, orderIds, goodsIds, goodsNo, cutedType); Long goodsNum = updatePlanOptimizeData(remainBoardInfos, optimizeBoardModelDO, orderIds, goodsIds, goodsNo, cutedType);
@@ -506,21 +522,6 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
// 计算工资金额
public List<ProcessStepSalaryIds> calculateSalary(List<Long> processStepId){
// 查询当前工序对应的板材的面积
List<ProcessStepAreaIds> processStepAreaIds = processStepItemMapper.selectAreaByProcessStepId(processStepId,getUserOrganId());
// 计算当前工序的工资金额
return processStepMapper.calculateSalary(processStepAreaIds,getUserOrganId());
}
@Override @Override
public Map<String, Object> getLabelDataSourceValue(GetSourceDataReq req) { public Map<String, Object> getLabelDataSourceValue(GetSourceDataReq req) {
String sqlStr = dataSourceApi.getSqlById(req.getDataSourceId()).getCheckedData(); String sqlStr = dataSourceApi.getSqlById(req.getDataSourceId()).getCheckedData();
@@ -2,6 +2,7 @@ package com.cf.imes.module.executor.service.order;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch.core.*; import co.elastic.clients.elasticsearch.core.*;
import co.elastic.clients.elasticsearch.core.search.Hit; import co.elastic.clients.elasticsearch.core.search.Hit;
@@ -195,7 +196,7 @@ public class OrderInputProcessor {
log.error(bulkResponse.items().toString()); log.error(bulkResponse.items().toString());
throw new ServiceException(500, "未知异常"); throw new ServiceException(500, "未知异常");
} }
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -217,7 +218,7 @@ public class OrderInputProcessor {
log.error(bulkResponse.items().toString()); log.error(bulkResponse.items().toString());
throw new ServiceException(500, "未知异常"); throw new ServiceException(500, "未知异常");
} }
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -242,7 +243,7 @@ public class OrderInputProcessor {
log.error(bulkResponse.items().toString()); log.error(bulkResponse.items().toString());
throw new ServiceException(500, "未知异常"); throw new ServiceException(500, "未知异常");
} }
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
throw new RuntimeException(e); throw new RuntimeException(e);
@@ -285,7 +286,7 @@ public class OrderInputProcessor {
try { try {
DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build()); DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build());
log.info("Deleted {} documents with planId {}", response.deleted(), orderId); log.info("Deleted {} documents with planId {}", response.deleted(), orderId);
} catch (IOException e) { } catch (IOException | ElasticsearchException e) {
log.error("Error deleting documents with planId {}: {}", orderId, e.getMessage()); log.error("Error deleting documents with planId {}: {}", orderId, e.getMessage());
throw new ServiceException(INTERNAL_SERVER_ERROR); throw new ServiceException(INTERNAL_SERVER_ERROR);
} }
@@ -305,7 +306,7 @@ public class OrderInputProcessor {
try { try {
DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build()); DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build());
log.info("Deleted {} documents with planId {}", response.deleted(), orderIds); log.info("Deleted {} documents with planId {}", response.deleted(), orderIds);
} catch (IOException e) { } catch (IOException | ElasticsearchException e) {
log.error("Error deleting documents with planId {}: {}", orderIds, e.getMessage()); log.error("Error deleting documents with planId {}: {}", orderIds, e.getMessage());
throw new ServiceException(INTERNAL_SERVER_ERROR); throw new ServiceException(INTERNAL_SERVER_ERROR);
} }
@@ -4,7 +4,6 @@ import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO; import com.cf.imes.module.executor.controller.admin.order.vo.order.OrderRespVO;
import com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomBodyList; import com.cf.imes.module.executor.controller.admin.plan.bo.OrderRoomBodyList;
import com.cf.imes.module.executor.controller.admin.plan.vo.*; import com.cf.imes.module.executor.controller.admin.plan.vo.*;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List; import java.util.List;
@@ -72,8 +71,4 @@ public interface PlanService {
List<OrderRoomBodyList> getOrderRoomBody(List<Long> orderIds); List<OrderRoomBodyList> getOrderRoomBody(List<Long> orderIds);
List<OrderModelDO> buildPlateByOrderIds(List<Long> orderIds, List<Long> ids, Integer size);
} }
@@ -3,10 +3,7 @@ package com.cf.imes.module.executor.service.plan;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch.core.SearchRequest;
import co.elastic.clients.elasticsearch.core.SearchResponse;
import co.elastic.clients.elasticsearch.core.UpdateByQueryRequest; import co.elastic.clients.elasticsearch.core.UpdateByQueryRequest;
import co.elastic.clients.elasticsearch.core.search.Hit;
import co.elastic.clients.json.JsonData; import co.elastic.clients.json.JsonData;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
@@ -32,7 +29,6 @@ import com.cf.imes.module.executor.dal.dataobject.goods.OptimizeBoardModelDO;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO; import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO; import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO; import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO; import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
import com.cf.imes.module.executor.dal.dataobject.planitem.PlanItemDO; import com.cf.imes.module.executor.dal.dataobject.planitem.PlanItemDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO; import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
@@ -60,7 +56,6 @@ import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -72,7 +67,6 @@ import static com.cf.imes.framework.common.util.json.JsonUtils.toJsonString;
import static com.cf.imes.framework.common.util.string.SearchUtil.insertSeparator; import static com.cf.imes.framework.common.util.string.SearchUtil.insertSeparator;
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId; import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*; import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.ORDER_PLAN_ERROR;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*; import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
/** /**
@@ -172,9 +166,9 @@ public class PlanServiceImpl implements PlanService {
if (Boolean.TRUE.equals(createReqVO.getIsMix())) { if (Boolean.TRUE.equals(createReqVO.getIsMix())) {
// 混单时走的逻辑 // 混单时走的逻辑
List<SavePlanPlateList.PlateItemList> plateItemList = savePlanPlateList.getPlateItemList(); List<SavePlanPlateList.PlateItemList> plateItemList = Optional.ofNullable(savePlanPlateList.getPlateItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
List<SavePlanPlateList.GoodsItemList> goodsItemList = savePlanPlateList.getGoodsItemList(); List<SavePlanPlateList.GoodsItemList> goodsItemList = Optional.ofNullable(savePlanPlateList.getGoodsItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
// 查找材质和厚度相同的大板 // 查找材质和厚度相同的大板
Map<String, List<Long>> grouped = groupByMaterialAndThickness(goodsItemList); Map<String, List<Long>> grouped = groupByMaterialAndThickness(goodsItemList);
@@ -218,18 +212,17 @@ public class PlanServiceImpl implements PlanService {
// 获取所有的大板ID // 获取所有的大板ID
ids.addAll(goodsItemList.stream().map(SavePlanPlateList.GoodsItemList::getId).distinct().toList()); ids.addAll(goodsItemList.stream().map(SavePlanPlateList.GoodsItemList::getId).distinct().toList());
// 获取所有的小板ID // 获取所有的小板ID
plateIds.addAll(plateItemList.stream().map(SavePlanPlateList.PlateItemList::getPlateId).map(Long::valueOf).toList()); plateIds.addAll(plateItemList.stream().map(SavePlanPlateList.PlateItemList::getPlateId).toList());
// 获取所有的生产单ID // 获取所有的生产单ID
orderIds.addAll(plateItemList.stream().map(SavePlanPlateList.PlateItemList::getOrderId).distinct().map(Long::valueOf).toList()); orderIds.addAll(plateItemList.stream().map(SavePlanPlateList.PlateItemList::getOrderId).distinct().toList());
} else { } else {
// 非混单 // 非混单
List<SavePlanPlateList.PlateItemList> plateItemList = savePlanPlateList.getPlateItemList(); List<SavePlanPlateList.PlateItemList> plateItemList = Optional.ofNullable(savePlanPlateList.getPlateItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
List<SavePlanPlateList.GoodsItemList> goodsItemList = savePlanPlateList.getGoodsItemList();
List<SavePlanPlateList.GoodsItemList> goodsItemList = Optional.ofNullable(savePlanPlateList.getGoodsItemList()).orElseThrow(()-> new ServiceException(PLAN_PLATE_DATA_ERROR));
// 查找材质和厚度和颜色相同的大板 // 查找材质和厚度和颜色相同的大板
Map<String, List<Long>> grouped = groupByMaterialAndThicknessAndColor(goodsItemList); Map<String, List<Long>> grouped = groupByMaterialAndThicknessAndColor(goodsItemList);
@@ -340,7 +333,7 @@ public class PlanServiceImpl implements PlanService {
// 删除小板 // 删除小板
List<OrderPlateIds> deleteOrderPlateIds = updateReqVO.getDeleteOrderPlateIds(); List<OrderPlateIds> deleteOrderPlateIds = Optional.ofNullable(updateReqVO.getDeleteOrderPlateIds()).orElse(new ArrayList<>());
if(CollUtil.isNotEmpty(deleteOrderPlateIds)){ if(CollUtil.isNotEmpty(deleteOrderPlateIds)){
@@ -351,7 +344,7 @@ public class PlanServiceImpl implements PlanService {
// 添加小板 // 添加小板
List<OrderPlateIds> insertOrderPlateIds = updateReqVO.getInsertOrderPlateIds(); List<OrderPlateIds> insertOrderPlateIds = Optional.ofNullable(updateReqVO.getInsertOrderPlateIds()).orElse(new ArrayList<>());
if(CollUtil.isNotEmpty(insertOrderPlateIds)){ if(CollUtil.isNotEmpty(insertOrderPlateIds)){
@@ -366,16 +359,23 @@ public class PlanServiceImpl implements PlanService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean deletePlan(List<Long> planIds) { public Boolean deletePlan(List<Long> planIds) {
// 校验存在 // 校验存在
validatePlan(planIds);
List<PlanDO> planDOS = planMapper.selectBatchIds(planIds); List<PlanDO> planDOS = planMapper.selectBatchIds(planIds);
AssertUtils.notEmpty(planDOS,PLAN_NOT_EXISTS);
List<Long> orderIds = new ArrayList<>(); List<Long> orderIds = new ArrayList<>();
for (PlanDO planDO : planDOS) {
orderIds.addAll(JSON.parseArray(planDO.getOrderNos()).toJavaList(Long.class).stream().distinct().toList()); planDOS.forEach(f->{
if ( f.getStatus().equals(PlanStatusEnum.OPENING.getStatus()) || f.getStatus().equals(PlanStatusEnum.OPENED.getStatus()) ) {
throw exception(PLAN_NOT_ALLOW_DELETE,f.getId());
}
String orderNos = Optional.ofNullable(f.getOrderNos()).orElse("[]");
orderIds.addAll(JSON.parseArray(orderNos).toJavaList(Long.class).stream().distinct().toList());
});
}
// 删除排单信息,更新排单对应的余料板的排单ID为0 // 删除排单信息,更新排单对应的余料板的排单ID为0
planMapper.deleteBatchIds(planIds); planMapper.deleteBatchIds(planIds);
@@ -395,8 +395,8 @@ public class PlanServiceImpl implements PlanService {
// 删除板材和排单明细表里对应的小板ID // 删除板材和排单明细表里对应的小板ID
planItemMapper.delete(new LambdaQueryWrapperX<PlanItemDO>() planItemMapper.delete(new LambdaQueryWrapperX<PlanItemDO>()
.eq(PlanItemDO::getOrganId, getUserOrganId()) .eq(PlanItemDO::getOrganId, getUserOrganId())
.in(PlanItemDO::getOrderId,orderIds) .inIfPresent(PlanItemDO::getOrderId,orderIds)
.in(PlanItemDO::getPlateId, plateIds) .inIfPresent(PlanItemDO::getPlateId, plateIds)
.in(PlanItemDO::getPlanId, planIds)); .in(PlanItemDO::getPlanId, planIds));
@@ -410,7 +410,7 @@ public class PlanServiceImpl implements PlanService {
orderItemMapper.delete(new LambdaQueryWrapperX<OrderItemDO>() orderItemMapper.delete(new LambdaQueryWrapperX<OrderItemDO>()
.eq(OrderItemDO::getOrganId, getUserOrganId()) .eq(OrderItemDO::getOrganId, getUserOrganId())
.in(OrderItemDO::getOrderId, orderIds) .inIfPresent(OrderItemDO::getOrderId, orderIds)
.in(OrderItemDO::getPlateId, plateIdList)); .in(OrderItemDO::getPlateId, plateIdList));
@@ -519,15 +519,16 @@ public class PlanServiceImpl implements PlanService {
// 查询排单对应的小板数量和小板面积 // 查询排单对应的小板数量和小板面积
plateInfoVOS.forEach(m -> { if(CollUtil.isNotEmpty(plateInfoVOS)) {
plateInfoVOS.forEach(m -> {
m.setCount((int) m.getPlatePages().stream().map(PlatePage::getPlateId).count()); m.setCount((int) m.getPlatePages().stream().map(PlatePage::getPlateId).count());
m.setArea(m.getPlatePages().stream().map(PlatePage::getArea).reduce(BigDecimal.ZERO, BigDecimal::add)); m.setArea(m.getPlatePages().stream().map(PlatePage::getArea).reduce(BigDecimal.ZERO, BigDecimal::add));
m.setPlatePages(null); m.setPlatePages(null);
});
});
}
// 根据排单ID查询ES中的优化数据 // 根据排单ID查询ES中的优化数据
@@ -590,16 +591,17 @@ public class PlanServiceImpl implements PlanService {
List<PlateInfoVO> plateInfoVOS = goodsMapper.selectOrderGoodsPlateList(planIds, getUserOrganId()); List<PlateInfoVO> plateInfoVOS = goodsMapper.selectOrderGoodsPlateList(planIds, getUserOrganId());
// 查询排单对应的小板数量和小板面积 if(CollUtil.isNotEmpty(plateInfoVOS)) {
plateInfoVOS.forEach(m -> { // 查询排单对应的小板数量和小板面积
plateInfoVOS.forEach(m -> {
m.setCount((int) m.getPlatePages().stream().map(PlatePage::getPlateId).count()); m.setCount((int) m.getPlatePages().stream().map(PlatePage::getPlateId).count());
m.setArea(m.getPlatePages().stream().map(PlatePage::getArea).reduce(BigDecimal.ZERO, BigDecimal::add)); m.setArea(m.getPlatePages().stream().map(PlatePage::getArea).reduce(BigDecimal.ZERO, BigDecimal::add));
m.setPlatePages(null); m.setPlatePages(null);
});
});
}
// 根据排单ID查询ES中的优化数据 // 根据排单ID查询ES中的优化数据
List<OptimizeBoardModelDO> optimizeBoardModelDOS = esUtils.getEsDocument(FIELD_PLANID, planIds, planIds.size(), ORDER_REMAIN_PLATE_MODEL, OptimizeBoardModelDO.class); List<OptimizeBoardModelDO> optimizeBoardModelDOS = esUtils.getEsDocument(FIELD_PLANID, planIds, planIds.size(), ORDER_REMAIN_PLATE_MODEL, OptimizeBoardModelDO.class);
@@ -648,7 +650,7 @@ public class PlanServiceImpl implements PlanService {
statusList.add(OrderStatusEnum.IN_PRODUCTION.getStatus()); statusList.add(OrderStatusEnum.IN_PRODUCTION.getStatus());
statusList.add(OrderStatusEnum.SORTED.getStatus()); statusList.add(OrderStatusEnum.SORTED.getStatus());
List<String> goodsId = pageReqVO.getGoodsId(); List<String> goodsId = Optional.ofNullable(pageReqVO.getGoodsId()).orElse(new ArrayList<>());
QueryWrapperX<OrderDO> queryWrapperX = new QueryWrapperX<>(); QueryWrapperX<OrderDO> queryWrapperX = new QueryWrapperX<>();
queryWrapperX queryWrapperX
@@ -692,7 +694,7 @@ public class PlanServiceImpl implements PlanService {
QueryWrapperX<PlateDO> queryWrapperX2 = new QueryWrapperX<>(); QueryWrapperX<PlateDO> queryWrapperX2 = new QueryWrapperX<>();
queryWrapperX2 queryWrapperX2
.eq("op.organ_id",getUserOrganId()) .eq("op.organ_id",getUserOrganId())
.in("op.order_id",orderIds) .inIfPresent("op.order_id",orderIds)
.eq(FIELD_OP_DELETED,false) .eq(FIELD_OP_DELETED,false)
.eq("op.is_optimized",false) .eq("op.is_optimized",false)
.inIfPresent("op.goods_id",ids) .inIfPresent("op.goods_id",ids)
@@ -731,7 +733,6 @@ public class PlanServiceImpl implements PlanService {
if(CollUtil.isNotEmpty(pageReqVO.getRoomId()) || CollUtil.isNotEmpty(pageReqVO.getBodyId() )){ if(CollUtil.isNotEmpty(pageReqVO.getRoomId()) || CollUtil.isNotEmpty(pageReqVO.getBodyId() )){
AssertUtils.notEmpty(pageReqVO.getOrderIds(),ORDER_PLAN_ERROR);
queryWrapperX queryWrapperX
.eq(FIELD_ORGAN_ID, getUserOrganId()) .eq(FIELD_ORGAN_ID, getUserOrganId())
@@ -741,7 +742,7 @@ public class PlanServiceImpl implements PlanService {
.isNull(FIELD_PLAN_ID) .isNull(FIELD_PLAN_ID)
.isNotNull(FIELD_OP_ID) .isNotNull(FIELD_OP_ID)
.in("o.id", pageReqVO.getOrderIds()) .inIfPresent("o.id", pageReqVO.getOrderIds())
.inIfPresent("oi.room_id",pageReqVO.getRoomId()) .inIfPresent("oi.room_id",pageReqVO.getRoomId())
.inIfPresent("oi.body_id",pageReqVO.getBodyId()) .inIfPresent("oi.body_id",pageReqVO.getBodyId())
.likeIfPresent("o.id", pageReqVO.getOrderId()) .likeIfPresent("o.id", pageReqVO.getOrderId())
@@ -923,23 +924,23 @@ public class PlanServiceImpl implements PlanService {
List<PlateResList> plateResLists = goodsMapper.selectPlateListByPlanId(planIds, getUserOrganId()); List<PlateResList> plateResLists = goodsMapper.selectPlateListByPlanId(planIds, getUserOrganId());
if(plateResLists.isEmpty()){ Set<Long> bodyIds = plateResLists.stream().map(PlateResList::getBodyId).collect(Collectors.toSet());
if(plateResLists.isEmpty() || bodyIds.isEmpty()){
return new ArrayList<>(); return new ArrayList<>();
} }
Set<Long> bodyIds = plateResLists.stream().map(PlateResList::getBodyId).collect(Collectors.toSet());
List<OrderBodyDO> orderBodyDOS = orderBodyMapper.selectBatchIds(bodyIds); List<OrderBodyDO> orderBodyDOS = orderBodyMapper.selectBatchIds(bodyIds);
if(orderBodyDOS.isEmpty()){ if(orderBodyDOS.isEmpty()){
return plateResLists; return plateResLists;
} }
for (PlateResList resList :plateResLists) { plateResLists.forEach(f->{
resList.setBodyName(orderBodyDOS.stream().filter(e -> Objects.equals(e.getId(), resList.getBodyId())).map(OrderBodyDO::getName).findAny().orElse(null)); f.setBodyName(orderBodyDOS.stream().filter(e -> Objects.equals(e.getId(), f.getBodyId())).map(OrderBodyDO::getName).findAny().orElse(null));
resList.setRoomName(orderBodyDOS.stream().filter(e -> Objects.equals(e.getRoomId(), resList.getRoomId())).map(OrderBodyDO::getRoomName).findAny().orElse(null)); f.setRoomName(orderBodyDOS.stream().filter(e -> Objects.equals(e.getRoomId(), f.getRoomId())).map(OrderBodyDO::getRoomName).findAny().orElse(null));
} });
return plateResLists; return plateResLists;
@@ -984,23 +985,6 @@ public class PlanServiceImpl implements PlanService {
} }
private void validatePlan(List<Long> ids) {
List<PlanDO> planDOS = planMapper.selectBatchIds(ids);
AssertUtils.notEmpty(planDOS,PLAN_NOT_EXISTS);
for (PlanDO planDO : planDOS) {
if ( planDO.getStatus().equals(PlanStatusEnum.OPENING.getStatus()) || planDO.getStatus().equals(PlanStatusEnum.OPENED.getStatus()) ) {
throw exception(PLAN_NOT_ALLOW_DELETE,planDO.getId());
}
}
}
// 方案信息 // 方案信息
@@ -1060,104 +1044,9 @@ public class PlanServiceImpl implements PlanService {
private void goodsFilter(List<String> filter, List<GoodsDO> goodsReqVOS) {
int goodsNum = goodsReqVOS.size();
Map<String, Function<GoodsDO, ?>> attributeMap = new HashMap<>();
attributeMap.put(GoodsFilterConditionsEnum.THICKNESS.getFilterField(), GoodsDO::getThickness);
attributeMap.put(GoodsFilterConditionsEnum.MATERIAL.getFilterField(), GoodsDO::getMaterial);
attributeMap.put(GoodsFilterConditionsEnum.COLOR.getFilterField(), GoodsDO::getColor);
attributeMap.put(GoodsFilterConditionsEnum.TEXTURE.getFilterField(), GoodsDO::getTexture);
attributeMap.put(GoodsFilterConditionsEnum.BRAND.getFilterField(), GoodsDO::getBrand);
attributeMap.put(GoodsFilterConditionsEnum.WIDTH.getFilterField(), GoodsDO::getWidth);
attributeMap.put(GoodsFilterConditionsEnum.HEIGHT.getFilterField(), GoodsDO::getHeight);
for (String s : filter) {
Function<GoodsDO, ?> attributeFunc = attributeMap.get(s);
if (attributeFunc == null) {
throw new ServiceException(PLAN_MIXED_DATA_ERROR);
}
// 获取当前属性的第一个值
Object attributeValue = goodsReqVOS.stream()
.map(attributeFunc)
.findFirst()
.orElse(null);
// 根据属性值过滤列表
long count = goodsReqVOS.stream()
.filter(f -> attributeValue.equals(attributeFunc.apply(f)))
.count();
if (goodsNum != count) {
throw exception(PLAN_MIXED_ORDER_ERROR,GoodsFilterConditionsEnum.getValueByKey(s));
}
}
}
private void deletePlanPlate(List<OrderPlateIds> deleteOrderPlateIds) {
private List<OrderModelDO> getOrderModelList(List<Long> orderIds,List<Long> ids,Boolean isOptimized) {
int plateSize = plateMapper.selectPlateIds(orderIds, ids, getUserOrganId()).size();
List<OrderModelDO> orderModelDOS = buildPlateByOrderIds(orderIds,ids,plateSize);
AssertUtils.notEmpty(orderModelDOS,ORDER_PLAN_PLATE_MODEL_DATE_ERROR);
orderModelDOS.forEach(f->{
f.setIsOptimized(isOptimized);
f.setUpdateTime(LocalDateTime.now().toString());
});
return orderModelDOS;
}
@Override
public List<OrderModelDO> buildPlateByOrderIds(List<Long> orderIds,List<Long> ids, Integer size) {
List<FieldValue> orderIdList = orderIds.stream().map(FieldValue::of).toList();
List<FieldValue> plateGoodsIds = ids.stream().map(FieldValue::of).toList();
SearchRequest.Builder builder = new SearchRequest.Builder();
builder.index(ORDER_PLATE_MODEL);
builder.size(size);
builder.query(q -> q.bool(b -> b
.filter(m->{
m.terms(t->t.field("orderId").terms(e -> e.value(orderIdList)));
m.terms(t->t.field("plateGoodsId").terms(e -> e.value(plateGoodsIds)));
return m;
})));
try {
SearchResponse<OrderModelDO> search = elasticsearchClient.search(builder.build(), OrderModelDO.class);
List<Hit<OrderModelDO>> hits = search.hits().hits();
if (CollUtil.isNotEmpty(hits)) {
return hits.stream().map(Hit::source).toList();
}
return new ArrayList<>();
} catch (Exception e) {
log.error("ES_SELECT_DATA_ERROR"+e.getMessage());
throw new ServiceException(DATA_DATA_ERROR);
}
}
private void deletePlanPlate( List<OrderPlateIds> deleteOrderPlateIds) {
List<Long> deletePlanIds = deleteOrderPlateIds.stream().map(OrderPlateIds::getPlanId).distinct().toList(); List<Long> deletePlanIds = deleteOrderPlateIds.stream().map(OrderPlateIds::getPlanId).distinct().toList();
@@ -1175,11 +1064,16 @@ public class PlanServiceImpl implements PlanService {
List<Long> deletePlateIds = deleteOrderPlateIds.stream().map(OrderPlateIds::getPlateId).toList(); List<Long> deletePlateIds = deleteOrderPlateIds.stream().map(OrderPlateIds::getPlateId).toList();
List<Long> deleteOrderIds = deleteOrderPlateIds.stream().map(OrderPlateIds::getOrderId).distinct().toList(); AssertUtils.notEmpty(deletePlateIds,DELETE_PLAN_PLATE_DATA_ERROR);
List<Long> deleteOrderIds = deleteOrderPlateIds.stream().map(OrderPlateIds::getOrderId).toList();
AssertUtils.notEmpty(deleteOrderIds,DELETE_PLAN_PLATE_DATA_ERROR);
// 查询需要删除的小板对应的信息 // 查询需要删除的小板对应的信息
List<PlateDO> plateDOS = plateMapper.selectBatchIds(deletePlateIds); List<PlateDO> plateDOS = plateMapper.selectBatchIds(deletePlateIds);
AssertUtils.notEmpty(plateDOS,DELETE_PLAN_PLATE_DATA_ERROR);
List<PlateDO> plateDOList = plateDOS.stream().filter(f -> plateStatus.contains(f.getIsCutted())).toList(); List<PlateDO> plateDOList = plateDOS.stream().filter(f -> plateStatus.contains(f.getIsCutted())).toList();
@@ -1255,7 +1149,6 @@ public class PlanServiceImpl implements PlanService {
planMapper.deleteBatchIds(noPlanIds); planMapper.deleteBatchIds(noPlanIds);
// 删除排单对应的优化生产数据 // 删除排单对应的优化生产数据
esUtils.deleteEsDocument(FIELD_PLANID,planIds,ORDER_REMAIN_PLATE_MODEL); esUtils.deleteEsDocument(FIELD_PLANID,planIds,ORDER_REMAIN_PLATE_MODEL);
@@ -1313,12 +1206,10 @@ public class PlanServiceImpl implements PlanService {
private void insertPlanPlate(List<OrderPlateIds> insertOrderPlateIds){ private void insertPlanPlate(List<OrderPlateIds> insertOrderPlateIds){
// 后面还需要看看是否需要进行混单的判断 // 后面还需要看看是否需要进行混单的判断
List<Long> insertPlanIds = insertOrderPlateIds.stream().map(OrderPlateIds::getPlanId).distinct().toList(); List<Long> insertPlanIds = insertOrderPlateIds.stream().map(OrderPlateIds::getPlanId).distinct().toList();
List<PlanDO> planDOS = validatePlanExists(insertPlanIds); List<PlanDO> planDOS = validatePlanExists(insertPlanIds);
List<PlanItemDO> planItemDOS = new ArrayList<>(); List<PlanItemDO> planItemDOS = new ArrayList<>();
insertOrderPlateIds.forEach(f->{ insertOrderPlateIds.forEach(f->{
@@ -1335,7 +1226,6 @@ public class PlanServiceImpl implements PlanService {
if(f.getType().equals(PlanStatusEnum.OPENED.getStatus())){ if(f.getType().equals(PlanStatusEnum.OPENED.getStatus())){
f.setStatus(PlanStatusEnum.OPENING.getStatus()); f.setStatus(PlanStatusEnum.OPENING.getStatus());
} }
List<Long> orderIds = new ArrayList<>(insertOrderPlateIds.stream().map(OrderPlateIds::getOrderId).distinct().toList()); List<Long> orderIds = new ArrayList<>(insertOrderPlateIds.stream().map(OrderPlateIds::getOrderId).distinct().toList());
@@ -1408,7 +1298,6 @@ public class PlanServiceImpl implements PlanService {
private void updateProcessSchemeStatus(List<Long> planIds) { private void updateProcessSchemeStatus(List<Long> planIds) {
try { try {
@@ -3,6 +3,7 @@ package com.cf.imes.module.executor.util.elasticsearch;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.ElasticsearchException;
import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest; import co.elastic.clients.elasticsearch.core.DeleteByQueryRequest;
import co.elastic.clients.elasticsearch.core.DeleteByQueryResponse; import co.elastic.clients.elasticsearch.core.DeleteByQueryResponse;
@@ -17,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -64,7 +66,7 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList(); return hits.stream().map(Hit::source).toList();
} }
return new ArrayList<>(); return new ArrayList<>();
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR); throw new ServiceException(DATA_DATA_ERROR);
} }
@@ -86,7 +88,7 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList(); return hits.stream().map(Hit::source).toList();
} }
return new ArrayList<>(); return new ArrayList<>();
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR); throw new ServiceException(DATA_DATA_ERROR);
} }
@@ -113,7 +115,7 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList(); return hits.stream().map(Hit::source).toList();
} }
return new ArrayList<>(); return new ArrayList<>();
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR); throw new ServiceException(DATA_DATA_ERROR);
} }
@@ -135,7 +137,7 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList(); return hits.stream().map(Hit::source).toList();
} }
return new ArrayList<>(); return new ArrayList<>();
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR); throw new ServiceException(DATA_DATA_ERROR);
} }
@@ -162,7 +164,7 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList(); return hits.stream().map(Hit::source).toList();
} }
return new ArrayList<>(); return new ArrayList<>();
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR); throw new ServiceException(DATA_DATA_ERROR);
} }
@@ -189,7 +191,7 @@ public class EsUtils {
return hits.stream().map(Hit::source).toList(); return hits.stream().map(Hit::source).toList();
} }
return new ArrayList<>(); return new ArrayList<>();
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR); throw new ServiceException(DATA_DATA_ERROR);
} }
@@ -208,7 +210,7 @@ public class EsUtils {
try { try {
DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build()); DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build());
log.info("Deleted {} documents with value {}", response.deleted(), value); log.info("Deleted {} documents with value {}", response.deleted(), value);
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error("Error deleting documents with value {}: {}", value, e.getMessage()); log.error("Error deleting documents with value {}: {}", value, e.getMessage());
throw new ServiceException(ES_DATA_ERROR); throw new ServiceException(ES_DATA_ERROR);
} }
@@ -227,7 +229,7 @@ public class EsUtils {
try { try {
elasticsearchClient.deleteByQuery(builder.build()); elasticsearchClient.deleteByQuery(builder.build());
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error("ES文档删除失败:", e.getMessage()); log.error("ES文档删除失败:", e.getMessage());
throw new ServiceException(ES_DATA_ERROR); throw new ServiceException(ES_DATA_ERROR);
} }
@@ -246,7 +248,7 @@ public class EsUtils {
try { try {
DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build()); DeleteByQueryResponse response = elasticsearchClient.deleteByQuery(builder.build());
log.info("Deleted {} documents with values {}", response.deleted(), values); log.info("Deleted {} documents with values {}", response.deleted(), values);
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error("Error deleting documents with values {}: {}", values, e.getMessage()); log.error("Error deleting documents with values {}: {}", values, e.getMessage());
throw new ServiceException(ES_DATA_ERROR); throw new ServiceException(ES_DATA_ERROR);
} }
@@ -264,7 +266,7 @@ public class EsUtils {
esDocumentService.bulkCreate(index, targetClass); esDocumentService.bulkCreate(index, targetClass);
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
throw new ServiceException(DATA_DATA_ERROR); throw new ServiceException(DATA_DATA_ERROR);
@@ -286,7 +288,7 @@ public class EsUtils {
elasticsearchClient.indices().refresh(refreshRequest); elasticsearchClient.indices().refresh(refreshRequest);
} catch (Exception e) { } catch (IOException | ElasticsearchException e) {
log.error("ES文档数据刷新失败:"+e.getMessage()); log.error("ES文档数据刷新失败:"+e.getMessage());
throw new ServiceException(ES_DATA_ERROR); throw new ServiceException(ES_DATA_ERROR);
} }
@@ -305,10 +305,10 @@ public class ErrorCodeConstants {
public static final ErrorCode ORDER_DATE_ERROR = new ErrorCode(1_002_041_001, "生产单信息不存在,请重新进入或切换生产单"); public static final ErrorCode ORDER_DATE_ERROR = new ErrorCode(1_002_041_001, "生产单信息不存在,请重新进入或切换生产单");
public static final ErrorCode ORDER_PLATE_ERROR = new ErrorCode(1_002_041_002, "生产单对应的板材数据为空,请检查是否为空单或重新导入生产单,或联系客服"); public static final ErrorCode ORDER_PLATE_ERROR = new ErrorCode(1_002_041_002, "生产单对应的板材数据为空,请检查是否为空单或重新导入生产单,或联系客服");
public static final ErrorCode ORDER_PLAN_DATE_ERROR = new ErrorCode(1_002_041_004, "排单信息不存在,请重新进入或切换排单"); public static final ErrorCode ORDER_PLAN_DATE_ERROR = new ErrorCode(1_002_041_004, "排单信息不存在,请重新进入或切换排单");
public static final ErrorCode ORDER_PLAN_OPTIMIZE_ERROR = new ErrorCode(1_002_041_005, "排单的优化数据异常,请将该排单重新优化"); public static final ErrorCode ORDER_PLAN_OPTIMIZE_ERROR = new ErrorCode(1_002_041_005, "当前排单对应的优化数据为空,请重新进行优化");
public static final ErrorCode ORDER_PLATE_MODEL_DATE_ERROR = new ErrorCode(1_002_041_006, "生产单对应的板材造型数据为空,请重新导入生产单"); public static final ErrorCode ORDER_PLATE_MODEL_DATE_ERROR = new ErrorCode(1_002_041_006, "生产单对应的板材造型数据为空,请重新导入生产单");
public static final ErrorCode ORDER_PLAN_PLATE_ERROR = new ErrorCode(1_002_041_007, "当前排单对应的板材数据有异常,请查看板材信息或联系客服"); public static final ErrorCode ORDER_PLAN_PLATE_ERROR = new ErrorCode(1_002_041_007, "当前排单对应的板材数据有异常,请查看板材信息或联系客服");
public static final ErrorCode ORDER_PLAN_ERROR = new ErrorCode(1_002_041_008, "当前排单对应的生产单数据有异常,请查看生产单信息或联系客服"); public static final ErrorCode ORDER_PLAN_ERROR = new ErrorCode(1_002_041_008, "当前排单对应的生产单数据为空,请重新创建排单");
public static final ErrorCode ORDER_PLAN_PLATE_MODEL_DATE_ERROR = new ErrorCode(1_002_041_009, "当前排单对应的板材造型数据为空,请检查板材信息或者联系客服"); public static final ErrorCode ORDER_PLAN_PLATE_MODEL_DATE_ERROR = new ErrorCode(1_002_041_009, "当前排单对应的板材造型数据为空,请检查板材信息或者联系客服");
public static final ErrorCode ORDER_GOODS_DATA_ERROR = new ErrorCode(1_002_041_010, "当前大板数据异常,请检查大板信息或者联系客服"); public static final ErrorCode ORDER_GOODS_DATA_ERROR = new ErrorCode(1_002_041_010, "当前大板数据异常,请检查大板信息或者联系客服");
public static final ErrorCode ORDER_PACK_DATA_NULL_ERROR = new ErrorCode(1_002_041_011, "当前包裹数据为空,请重新查看包裹数据或联系客服"); public static final ErrorCode ORDER_PACK_DATA_NULL_ERROR = new ErrorCode(1_002_041_011, "当前包裹数据为空,请重新查看包裹数据或联系客服");
@@ -340,6 +340,11 @@ public class ErrorCodeConstants {
public static final ErrorCode CREAT_PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_033, "当前板材已有小板创建板材,请重新查询生产单信息再创建"); public static final ErrorCode CREAT_PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_033, "当前板材已有小板创建板材,请重新查询生产单信息再创建");
public static final ErrorCode UPDATE_NO_PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_034, "当前排单无开料板,无法取消开料,请重新尝试"); public static final ErrorCode UPDATE_NO_PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_034, "当前排单无开料板,无法取消开料,请重新尝试");
public static final ErrorCode PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_035, "当前排单没有选择板材数据,请进行选择"); public static final ErrorCode PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_035, "当前排单没有选择板材数据,请进行选择");
public static final ErrorCode DELETE_PLAN_PLATE_DATA_ERROR = new ErrorCode(1_002_041_036, "当前删除的小板信息有误,请检查小板是否存在或重新创建排单");
public static final ErrorCode PLAN_PLATE_OPTIMIZE_DATA_ERROR = new ErrorCode(1_002_041_037, "当前排单对应的优化数据异常,请重新进行优化");
//=========== 应用信息 1-002-037-000 ============ //=========== 应用信息 1-002-037-000 ============
@@ -378,5 +383,5 @@ public class ErrorCodeConstants {
public static final ErrorCode SYSTEM_PROCESS_SCHEME_DATA_ERROR = new ErrorCode(1_002_040_015, "加工方案组的:{} 为空,无法保存,请进行配置"); public static final ErrorCode SYSTEM_PROCESS_SCHEME_DATA_ERROR = new ErrorCode(1_002_040_015, "加工方案组的:{} 为空,无法保存,请进行配置");
public static final ErrorCode SYSTEM_PROCESS_SCHEME_CONFIG_DATA_ERROR = new ErrorCode(1_002_040_016, "加工方案组的:{} 为空,请检查配置信息"); public static final ErrorCode SYSTEM_PROCESS_SCHEME_CONFIG_DATA_ERROR = new ErrorCode(1_002_040_016, "加工方案组的:{} 为空,请检查配置信息");
public static final ErrorCode SYSTEM_PROCESS_SCHEME_CONFIG_FIELD_ERROR = new ErrorCode(1_002_040_017, "当前方案组的配置异常,请重新配置"); public static final ErrorCode SYSTEM_PROCESS_SCHEME_CONFIG_FIELD_ERROR = new ErrorCode(1_002_040_017, "当前方案组的配置异常,请重新配置");
public static final ErrorCode SYSTEM_PROCESS_SCHEME_CONFIG_IS_PLAN = new ErrorCode(1_002_040_018, "当前方案组已在排单中使用,无法删除");
} }
@@ -1,5 +1,6 @@
package com.cf.imes.module.system.api.systemconfig; package com.cf.imes.module.system.api.systemconfig;
import cn.hutool.core.collection.CollUtil;
import com.cf.imes.framework.common.enums.CommonStatusEnum; import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.pojo.CommonResult; import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.Assert.AssertUtils; import com.cf.imes.framework.common.util.Assert.AssertUtils;
@@ -23,6 +24,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -73,7 +75,9 @@ public class SystemConfigApiImpl implements SystemConfigApi {
.in(SystemConfigDO::getId, processIds) .in(SystemConfigDO::getId, processIds)
.select(SystemConfigDO::getId,SystemConfigDO::getName)); .select(SystemConfigDO::getId,SystemConfigDO::getName));
// AssertUtils.notEmpty(systemConfigDOS,PROCESS_CONFIG_DATA_ERROR); if(CollUtil.isEmpty(systemConfigDOS)){
return success(new ArrayList<>());
}
return success(BeanUtils.toBean(systemConfigDOS,SystemConfigRespDTO.class)); return success(BeanUtils.toBean(systemConfigDOS,SystemConfigRespDTO.class));
} }
@@ -5,6 +5,7 @@ import cn.hutool.core.text.CharSequenceUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cf.imes.framework.common.enums.CommonStatusEnum; import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.organ.core.context.OrganContextHolder; import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.executor.api.plan.OrderPlanApi;
import com.cf.imes.module.system.controller.admin.systemconfig.vo.*; import com.cf.imes.module.system.controller.admin.systemconfig.vo.*;
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO; import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigMapper; import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigMapper;
@@ -20,6 +21,7 @@ import java.util.concurrent.atomic.AtomicLong;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.framework.common.util.json.JsonUtils.parseArray; import static com.cf.imes.framework.common.util.json.JsonUtils.parseArray;
import static com.cf.imes.framework.common.util.json.JsonUtils.toJsonString; import static com.cf.imes.framework.common.util.json.JsonUtils.toJsonString;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_PROCESS_SCHEME_CONFIG_IS_PLAN;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_PROCESS_SCHEME_DATA_ERROR; import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_PROCESS_SCHEME_DATA_ERROR;
/** /**
@@ -34,6 +36,8 @@ public class ProcessSchemeServiceHandler extends AbstractSystemConfigServiceHand
@Resource @Resource
private SystemConfigMapper systemConfigMapper; private SystemConfigMapper systemConfigMapper;
@Resource
private OrderPlanApi orderPlanApi;
@Override @Override
public List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO) { public List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO) {
@@ -125,6 +129,12 @@ public class ProcessSchemeServiceHandler extends AbstractSystemConfigServiceHand
@Override @Override
public void deleteConfig(ConfigDeleteReqVO reqVO) { public void deleteConfig(ConfigDeleteReqVO reqVO) {
Boolean data = orderPlanApi.getOrderProcessScheme(reqVO.getId()).getCheckedData();
if(Boolean.TRUE.equals(data)){
throw exception(SYSTEM_PROCESS_SCHEME_CONFIG_IS_PLAN);
}
systemConfigMapper.deleteById(reqVO.getId()); systemConfigMapper.deleteById(reqVO.getId());
} }