Merge remote-tracking branch 'origin/main'

This commit is contained in:
liuzhaotian
2024-05-07 11:04:48 +08:00
16 changed files with 233 additions and 2 deletions
@@ -108,6 +108,14 @@ public class PlanController {
return success(planService.getNotPlanPlateListPage(pageVO));
}
@GetMapping("getNotPlanGoodsListPageByOrderId")
@Operation(summary = "根据生产单id获取未排单的商品分页列表")
@PreAuthorize("@ss.hasPermission('executor:plan:query')")
public CommonResult<PageResult<PlanGoodsVO>> getNotPlanGoodsListPageByOrderId(@Valid NotPlanGoodsListPageVO pageVO) {
return success(planService.getNotPlanGoodsListPageByOrderId(pageVO));
}
@PostMapping("addPlate")
@Operation(summary = "添加板材")
@PreAuthorize("@ss.hasPermission('executor:plan:update')")
@@ -0,0 +1,17 @@
package com.cf.imes.module.executor.controller.admin.plan.vo;
import com.cf.imes.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author Beal
*/
@Data
public class NotPlanGoodsListPageVO extends PageParam {
@Schema(description = "生产单id")
@NotNull(message = "生产单id不能空")
private Long orderId;
}
@@ -0,0 +1,32 @@
package com.cf.imes.module.executor.controller.admin.plan.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author Beal
*/
@Data
public class PlanGoodsVO {
@Schema(description = "商品id")
private Long goodsId;
@Schema(description = "商品名称")
private String goodsName;
@Schema(description = "材质")
private String material;
@Schema(description = "颜色")
private String color;
@Schema(description = "厚度")
private BigDecimal thickness;
@Schema(description = "")
private BigDecimal width;
@Schema(description = "")
private BigDecimal height;
@Schema(description = "片数")
private int num;
@Schema(description = "平方")
private BigDecimal area = new BigDecimal("0");
}
@@ -1,5 +1,7 @@
package com.cf.imes.module.executor.controller.admin.plate;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@@ -10,6 +12,7 @@ import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import javax.servlet.http.*;
import javax.validation.constraints.NotEmpty;
import java.util.*;
import java.io.IOException;
@@ -108,4 +111,12 @@ public class PlateController {
public CommonResult<PageResult<PlateRespVO>> getPlatesByOrderId(@Valid PlateTermsPageReqVO pageVO) {
return success(plateService.getPlatePageByTerms(pageVO));
}
@GetMapping("/getPlateModelByBodyId")
@Operation(summary = "根据柜体id列表查询小板的造型")
@Parameter(name = "bodyIds", description = "柜体id列表", required = true)
public CommonResult<List<BodyPlateDetailVO>> getPlateModelByPlateId(@Valid @RequestParam @NotEmpty List<Long> bodyIds) {
return success(plateService.getPlateModelByPlateId(bodyIds));
}
}
@@ -0,0 +1,27 @@
package com.cf.imes.module.executor.controller.admin.plate.vo;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author Beal
* 模块中小板详情包含造型信息
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class BodyPlateDetailVO {
@Schema(description = "模块id")
private Long bodyId;
@Schema(description = "造型列表")
private List<OrderModelDO> orderModelList;
}
@@ -0,0 +1,12 @@
package com.cf.imes.module.executor.controller.admin.plate.vo;
import lombok.Data;
/**
* @author Beal
*/
@Data
public class BodyPlateIdDTO {
private Long bodyId;
private Long plateId;
}
@@ -7,6 +7,9 @@ import java.util.List;
import java.util.Map;
public interface OptimizePlanService {
String ORDER_PLATE_MODEL = "imes_order_plate_model";
List<PlateOptimize> getPlateListByPlanId(Long planId);
Boolean addRemain(AddRemainReqVO vo);
@@ -90,7 +90,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
@Resource
private ElasticsearchClient elasticsearchClient;
public static final String ORDER_PLATE_MODEL = "imes_order_plate_model";
//public static final String ORDER_PLATE_MODEL = "imes_order_plate_model";
@Resource
private MachineApi machineApi;
@@ -64,4 +64,6 @@ public interface PlanService {
PageResult<PlateResList> getPlateByPlanId(GetPlateByPlanIdVO vo);
PageResult<OrderRespVO> getOrderByPlanId(PlanOrderPageReqVO pageReqVO);
PageResult<PlanGoodsVO> getNotPlanGoodsListPageByOrderId( NotPlanGoodsListPageVO pageVO);
}
@@ -382,4 +382,19 @@ public class PlanServiceImpl implements PlanService {
return BeanUtils.toBean(pageResult, OrderRespVO.class);
}
@Override
public PageResult<PlanGoodsVO> getNotPlanGoodsListPageByOrderId(NotPlanGoodsListPageVO pageVO) {
return goodsMapper.selectJoinPage(pageVO, PlanGoodsVO.class, new MPJLambdaWrapperX<GoodsDO>()
.leftJoin(PlateDO.class, PlateDO::getGoodsId, GoodsDO::getId)
.leftJoin(OrderItemDO.class, OrderItemDO::getPlateId, PlateDO::getId)
.leftJoin(PlanItemDO.class, PlanItemDO::getItemId, OrderItemDO::getId)
.select(GoodsDO::getGoodsId, GoodsDO::getHeight, GoodsDO::getWidth, GoodsDO::getColor, GoodsDO::getGoodsName, GoodsDO::getThickness)
.selectSum(PlateDO::getArea, "area")
.selectCount(PlateDO::getId, "num")
.isNotNull(PlanItemDO::getId)
.eq(GoodsDO::getOrderId, pageVO.getOrderId())
.groupBy(GoodsDO::getId)
);
}
}
@@ -5,6 +5,7 @@ import javax.validation.*;
import com.cf.imes.module.executor.controller.admin.goods.vo.GoodsSaveReqVO;
import com.cf.imes.module.executor.controller.admin.plate.vo.*;
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -87,4 +88,6 @@ public interface PlateService {
* @return void
*/
void updatePlateByRawGoodsId(List<GoodsSaveReqVO> createReqVOS);
List<BodyPlateDetailVO> getPlateModelByPlateId(List<Long> bodyIds);
}
@@ -1,20 +1,39 @@
package com.cf.imes.module.executor.service.plate;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
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.search.Hit;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.es.core.service.ESDocumentService;
import com.cf.imes.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.cf.imes.module.executor.controller.admin.goods.vo.GoodsSaveReqVO;
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.mysql.orderItem.OrderItemMapper;
import com.cf.imes.module.executor.util.RandomUtils;
import com.cf.imes.module.system.enums.ErrorCodeConstants;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import com.cf.imes.module.executor.controller.admin.plate.vo.*;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -22,7 +41,9 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
import static com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.cf.imes.module.executor.service.optimizeplan.OptimizePlanService.ORDER_PLATE_MODEL;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.PLATE_NOT_EXISTS;
/**
@@ -32,11 +53,18 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.PLATE_NOT_EXIST
*/
@Service
@Validated
@Slf4j
public class PlateServiceImpl implements PlateService {
@Resource
private PlateMapper plateMapper;
@Resource
private OrderItemMapper orderItemMapper;
@Resource
private ElasticsearchClient elasticsearchClient;
@Override
public Long createPlate(PlateSaveReqVO createReqVO) {
// 插入
@@ -134,4 +162,50 @@ public class PlateServiceImpl implements PlateService {
}
@SneakyThrows
@Override
public List<BodyPlateDetailVO> getPlateModelByPlateId(List<Long> bodyIds) {
List<BodyPlateIdDTO> list = plateMapper.selectJoinList(BodyPlateIdDTO.class, new MPJLambdaWrapperX<PlateDO>()
.selectAs(PlateDO::getId, "plateId")
.leftJoin(OrderItemDO.class, OrderItemDO::getPlateId, PlateDO::getId)
.in(OrderItemDO::getBodyId, bodyIds)
.select(OrderItemDO::getBodyId)
);
Set<Long> plateIds = list.stream().map(BodyPlateIdDTO::getPlateId).collect(Collectors.toSet());
List<OrderModelDO> orderModelDOS = buildRespByPlateIds(plateIds, ORDER_PLATE_MODEL);
Map<Long, List<OrderModelDO>> map = orderModelDOS.stream().collect(Collectors.groupingBy(e -> {
return list.stream().filter(f -> Objects.equals(f.getPlateId(), e.getPlateId())).map(BodyPlateIdDTO::getBodyId).findAny().orElse(null);
}));
List<BodyPlateDetailVO> bodyPlateDetailVOS = new ArrayList<>();
map.entrySet().forEach(e->{
bodyPlateDetailVOS.add(BodyPlateDetailVO.builder()
.orderModelList(e.getValue())
.bodyId(e.getKey())
.build()
);
});
return bodyPlateDetailVOS;
}
private List<OrderModelDO> buildRespByPlateIds(Collection<Long> plateIds, String index) {
List<FieldValue> fieldValues = plateIds.stream().map(FieldValue::of).toList();
SearchRequest.Builder builder = new SearchRequest.Builder();
builder.index(index);
builder.query(q -> q.terms(b -> b.field("plateId").terms(e->e.value(fieldValues))));
try {
SearchResponse<OrderModelDO> search = elasticsearchClient.search(builder.build(), OrderModelDO.class);
List<Hit<OrderModelDO>> hits = search.hits().hits();
if (CollectionUtil.isNotEmpty(hits)) {
return hits.stream().map(Hit::source).collect(Collectors.toList());
}
return new ArrayList<>();
} catch (IOException e) {
log.error(e.getMessage());
throw new ServiceException(INTERNAL_SERVER_ERROR);
}
}
}
@@ -1,5 +1,6 @@
package com.cf.imes.module.executor.util.deviseData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -15,17 +16,24 @@ import lombok.experimental.Accessors;
@NoArgsConstructor
public class HoleDetail {
@Schema(description = "孔ID")
private Integer holeId; //孔ID
@Schema(description = "孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)")
private Integer holeType;// 孔类型(0大孔, 10小孔, 20木削, 21木削大孔, 30层板钉, 40通孔, 50连接杆, -10造型孔)
@Schema(description = "孔面类型(0正面, 1反面, 2侧面)")
private Integer faceType; // 孔面类型(0正面, 1反面, 2侧面)
private float pointX;
private float pointY;
private float pointZ;
@Schema(description = "孔半径")
private float radius; //孔半径
@Schema(description = "孔深度")
private float depth; //孔深度
@Schema(description = "孔末端点")
private float endPoint; //孔末端点
private float pointX2;
private float pointY2;
@Schema(description = "角度")
private float angle; //角度
}
@@ -1,5 +1,6 @@
package com.cf.imes.module.executor.util.deviseData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -17,14 +18,22 @@ import java.util.List;
@NoArgsConstructor
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
public class ModelDetail {//去除order_module_extra
@Schema(description = "造型ID")
private Integer modelId; //造型ID
@Schema(description = "纹路ID")
private Integer lineID; //纹路ID
@Schema(description = "排版面 0正面, 1反面, 2侧面")
private Integer typographicFace; //排版面 0正面, 1反面, 2侧面
@Schema(description = "刀具名称")
private String knifeName; //刀具名称
@Schema(description = "刀半径")
private float knifeRadius; //刀半径
@Schema(description = "深度")
private float depth; //深度
@Schema(description = "造型数据")
private IOriginModelingData originModeling; //造型数据
@Schema(description = "点列表")
private List<PointList> pointList; //点列表
@Schema(description = "偏移量列表 //模块偏移数据")
private List<OffSetList> offSetList; //偏移量列表 //模块偏移数据
}
@@ -1,5 +1,6 @@
package com.cf.imes.module.executor.util.deviseData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -16,10 +17,16 @@ import lombok.experimental.Accessors;
@Accessors(chain = false) // 设置 chain = false,避免生产单导入有问
public class OffSetList {
@Schema(description = "名称")
private String name; //名称
@Schema(description = "面向类型(0正面, 1反面, 2侧面)")
private Integer faceType;// 面向类型(0正面, 1反面, 2侧面)
@Schema(description = "")
private float value; //值
@Schema(description = "半径")
private float radius;//半径
@Schema(description = "深度")
private float deep;//深度
@Schema(description = "角度")
private float angle;//角度
}
@@ -1,5 +1,6 @@
package com.cf.imes.module.executor.util.deviseData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -18,6 +19,8 @@ public class PointDetail {
private Integer pointId;
private float pointX;
private float pointY;
@Schema(description = "曲线")
private float curve;//曲线
@Schema(description = "封边尺寸")
private float SealSize;//封边尺寸
}