机台模板是否发布,是否可用字段更新

This commit is contained in:
liuzhaotian
2024-09-13 09:29:52 +08:00
parent 6e3231888d
commit e772e10d6c
20 changed files with 544 additions and 410 deletions
@@ -16,6 +16,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
@@ -195,4 +196,7 @@ public interface GoodsMapper extends BaseMapperX<GoodsDO> {
List<OrderRoomBodyList> selectNoPlanRoomBody(@Param("orderIds") List<Long> orderIds, @Param("organId") Long organId);
IPage<OrderRespVOCopy> selectOrderPlate(@Param("page") IPage page,@Param("organId") Long organId);
List<Long> selectPlanOrderList(@Param("orderId") Long orderId,@Param("roomIds") Set<Long> roomIds, @Param("bodyId") Long bodyId,@Param("organId") Long organId);
}
@@ -7,10 +7,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cf.imes.framework.common.enums.OrderPackageStatusEnum;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.Assert.AssertUtils;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderBodyRespVO;
import com.cf.imes.module.executor.controller.admin.order.vo.product.OrderRoomBodyRespVO;
@@ -19,6 +24,7 @@ import com.cf.imes.module.executor.controller.admin.orderParts.vo.OrderPartsResp
import com.cf.imes.module.executor.controller.admin.plan.vo.OrderRespVOCopy;
import com.cf.imes.module.executor.controller.admin.plate.vo.PlateRespVO;
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
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.orderGroup.OrderGroupDO;
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
@@ -29,6 +35,7 @@ import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO;
import com.cf.imes.module.executor.dal.dataobject.rawgoods.RawGoodsDO;
import com.cf.imes.module.executor.dal.mysql.goods.GoodsMapper;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
import com.cf.imes.module.executor.dal.mysql.orderBody.OrderBodyMapper;
import com.cf.imes.module.executor.dal.mysql.orderGroup.OrderGroupMapper;
import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
@@ -39,7 +46,7 @@ import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
import com.cf.imes.module.executor.enums.OrderDeletedEnum;
import com.cf.imes.module.executor.enums.OrderStatusEnum;
import com.cf.imes.framework.common.enums.OrderPackageStatusEnum;
import com.cf.imes.module.executor.service.plan.PlanService;
import com.cf.imes.module.executor.util.deviseData.structure.PlateDetail;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataAchieve;
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize;
@@ -47,22 +54,14 @@ import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelTy
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.VO.OrderXmlVO;
import com.cf.imes.module.executor.util.fileConversion.admin.files.xml.XmlTypeRealize;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.time.*;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
@@ -74,8 +73,6 @@ import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.e
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getUserOrganId;
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
/**
* 生产单表 order_{N} Service 实现类
*
@@ -139,9 +136,14 @@ public class OrderServiceImpl implements OrderService {
public static final String ORDER_PARTS_REMARK_MODEL = "imes_order_parts_remark_model";
String ORDER_REMAIN_PLATE_MODEL = "imes_order_optimize_plate_model";
@Resource
private XmlTypeRealize xmlTypeRealize;
@Resource
private PlanService planService;
@Override
public void updateOrder(OrderSaveReqVO updateReqVO) {
// 校验存在, 生产单未删除
@@ -240,7 +242,8 @@ public class OrderServiceImpl implements OrderService {
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBodyDeletedByOrderId(Long orderId, Set<Long> roomIds, Long bodyId, Integer status) { // 要删除传1,还原传0
validateOrderStatus(orderId, getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus());
// 判断生产单的状态和生产单柜体对应的板擦是否已开料
List<Long> planIds = validateOrderStatus(orderId, roomIds, bodyId, getUserOrganId(), OrderDeletedEnum.NOT_DELETED.getStatus());
List<Long> bodyIds = new ArrayList<>();
Integer index = status == 1 ? 0 : 1;
@@ -292,7 +295,23 @@ public class OrderServiceImpl implements OrderService {
});
if (goodsIdDeleted.size() > 0) {
goodsMapper.updateDeletedById(goodsIdDeleted, status, getUserOrganId());
}
if(planIds != null) {
// 判断删除的柜体对应的板材是否和排单板材一样
List<GoodsDO> goodsDOS = goodsMapper.selectPlanGoodsListByPlanIdList(planIds, getUserOrganId());
// 一样,同时删除排单的信息
if(goodsDOS.isEmpty()){
planService.deletePlan(planIds);
}else {
// 只要有排单,不管删除的柜体的板材数和排单数一样,都要删除排单对应的优化数据(不用这种写法进行删除时,有时会报错,原因目前还没找到)
planService.deleteByPlanId(planIds, ORDER_REMAIN_PLATE_MODEL);
}
}
List<Long> partsList = orderPartsMapper.selectPartsIdListByBodyId(bodyIds, getUserOrganId(), orderId); // 配件
@@ -804,17 +823,28 @@ public class OrderServiceImpl implements OrderService {
return true;
}
// 判断生产单状态是否符合(开料之前状态判断)
private void validateOrderStatus(Long orderId, Long organId, Integer status) {
// 判断生产单状态是否符合(如果已开料,不允许删除)
private List<Long> validateOrderStatus(Long orderId,Set<Long> roomIds, Long bodyId, Long organId, Integer status) {
// 校验存在
OrderDO orderDO = orderMapper.selectOrderOne(orderId, organId);
if (orderDO == null)
throw exception(ORDER_NOT_EXISTS);
// 状态排除
if (!Objects.equals(orderDO.getStatus(), OrderStatusEnum.NEW_ORDER.getStatus()) &&
!Objects.equals(orderDO.getStatus(), OrderStatusEnum.SORTED.getStatus()) &&
!Objects.equals(orderDO.getStatus(), OrderStatusEnum.EMPTY.getStatus()))
throw exception(ORDER_NOT_CANCEL);
// 判断小板是否已开料,已开料不允许删除
List<Long> planIds = goodsMapper.selectPlanOrderList(orderId, roomIds, bodyId, organId);
if(!planIds.isEmpty()) {
List<PlanDO> planDOS = planMapper.selectPlanStatus(planIds, organId);
AssertUtils.empty(planDOS, ORDER_PLAN_ERROR);
// planService.deleteByPlanId(planIds, ORDER_REMAIN_PLATE_MODEL);
return planIds;
}
return null;
}
}
@@ -82,4 +82,6 @@ public interface PlanService {
List<NotPlanOrderPlateRespVO> getOrderPlateList(OrderPageReqVOCopy pageReqVO);
List<NotPlanGoodsRespVO> getNotOptimizeGoodsList(NotPlanGoodsReqVO reqVO);
void deleteByPlanId(List<Long> planIds, String index);
}
@@ -1055,6 +1055,7 @@ public class PlanServiceImpl implements PlanService {
}
@Override
public void deleteByPlanId(List<Long> planIds, String index) {
List<FieldValue> fieldValues = planIds.stream().map(FieldValue::of).toList();
@@ -41,7 +41,7 @@
<update id="updateDeletedById">
UPDATE order_goods
SET deleted = #{deleted}
SET deleted = #{deleted},plan_id = 0
WHERE id IN
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
@@ -383,4 +383,33 @@
</select>
<select id="selectPlanOrderList" resultType="java.lang.Long">
select distinct og.plan_id
from order_goods og
left join order_plate op on og.organ_id = op.organ_id and og.order_id = op.order_id and og.id = op.goods_id and og.deleted = op.deleted
left join order_item oi on op.organ_id = oi.organ_id and op.order_id = oi.order_id and op.id = oi.plate_id
<where> og.organ_id = #{organId}
and og.deleted = false
and og.order_id = #{orderId}
<if test="bodyId !=null">
and oi.body_id = #{bodyId}
</if>
<if test="roomIds !=null">
and oi.room_id in
<foreach item="roomIds" collection="roomIds" open="(" separator="," close=")">
#{roomIds}
</foreach>
</if>
</where>
</select>
</mapper>