diff --git a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWhiteOrderController.java b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWhiteOrderController.java index e3f78b58..4cad2a16 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWhiteOrderController.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWhiteOrderController.java @@ -105,6 +105,6 @@ public class ProWhiteOrderController { @Log(title = "白坯订单管理", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable String[] ids) { - return success(proWhiteOrderService.deleteProOrderByIds(ids)); + return proWhiteOrderService.deleteProOrderByIds(ids); } } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java index a3fc22fb..63f9ddd3 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java @@ -205,4 +205,11 @@ public interface ProOrderMapper { * @param proOrder */ void updateWhiteOrder(ProOrder proOrder); + + /** + * 母订单id查询子订单id列表 + * @param id + * @return + */ + String[] selectOrderIdByParentOrder(String id); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java index c05b709d..12e8f004 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java @@ -141,5 +141,12 @@ public interface ProOrderWorkorderMapper { * @return */ String selectRouteNameByRouteCode(String routeCode); + + /** + * 通过订单id查询工单信息list(仅包含status、workorderId) + * @param orderId + * @return + */ + List selectProOrderWorkorderByOrderId(String orderId); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/IProWhiteOrderService.java b/op-modules/op-plan/src/main/java/com/op/plan/service/IProWhiteOrderService.java index 147a19d5..5eee5c46 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/IProWhiteOrderService.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/IProWhiteOrderService.java @@ -50,7 +50,7 @@ public interface IProWhiteOrderService { * @param ids 需要删除的白坯订单管理主键集合 * @return 结果 */ - public int deleteProOrderByIds(String[] ids); + public AjaxResult deleteProOrderByIds(String[] ids); /** * 删除白坯订单管理信息 diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWhiteOrderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWhiteOrderServiceImpl.java index 6ede6e4e..ae6820ac 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWhiteOrderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWhiteOrderServiceImpl.java @@ -6,16 +6,10 @@ import com.op.common.core.context.SecurityContextHolder; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.domain.AjaxResult; -import com.op.plan.domain.ProOrder; -import com.op.plan.domain.ProOrderWorkorder; -import com.op.plan.domain.ProRoute; -import com.op.plan.domain.ProShift; +import com.op.plan.domain.*; import com.op.plan.domain.vo.CascaderDTO; import com.op.plan.domain.vo.SplitProWhiteOrderVo; -import com.op.plan.mapper.ProOrderMapper; -import com.op.plan.mapper.ProOrderWorkorderMapper; -import com.op.plan.mapper.ProRouteMapper; -import com.op.plan.mapper.ProWhiteOrderMapper; +import com.op.plan.mapper.*; import com.op.plan.service.IProWhiteOrderService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -27,6 +21,9 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import java.util.*; +import static com.op.common.core.web.domain.AjaxResult.error; +import static com.op.common.core.web.domain.AjaxResult.success; + /** * 白坯订单管理Service业务层处理 * @@ -44,6 +41,12 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService { private ProOrderWorkorderMapper proOrderWorkorderMapper; @Autowired private ProOrderMapper proOrderMapper; + @Autowired + private ProWetMaterialPlanMapper proWetMaterialPlanMapper; + @Autowired + private ProOrderWorkorderBatchMapper proOrderWorkorderBatchMapper; + @Autowired + private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper; /** * 查询白坯订单管理 @@ -184,8 +187,44 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService { */ @Override @DS("#header.poolName") - public int deleteProOrderByIds(String[] ids) { - return proWhiteOrderMapper.deleteProOrderByIds(ids); + public AjaxResult deleteProOrderByIds(String[] ids) { + for (String id : ids) { + // 通过母订单查询自定单list + String[] orderIds = proOrderMapper.selectOrderIdByParentOrder(id); + // 通过子订单id列表查询 + for (String orderId : orderIds) { + + List proOrderWorkorderList = proOrderWorkorderMapper.selectProOrderWorkorderByOrderId(orderId); + if (proOrderWorkorderList.size() > 0) { + for (ProOrderWorkorder workOrder : proOrderWorkorderList) { + // 订单下存在已下发工单 + if (!(workOrder.getStatus().equals("w0") || workOrder.getStatus().equals("w1"))) { + return error("订单下存在已生产工单,不可删除!"); + } + // 订单下存在下发湿料计划 + ProWetMaterialPlan plan = proWetMaterialPlanMapper.selectProWetMaterialPlanByWorkId(workOrder.getWorkorderId()); + if (plan != null) { + return error("订单下存在已下发湿料计划工单,不可删除!"); + } + } + + for (ProOrderWorkorder workorder : proOrderWorkorderList) { + // 删除批次信息 + proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderId(workorder.getWorkorderId()); + // 删除湿料详情 + proWetMaterialPlanDetailMapper.deleteProWetMaterialPlanDetailByWorkId(workorder.getWorkorderId()); + // 删除工单 + proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderId(workorder.getWorkorderId()); + } + + } + } + // 删除子订单 + proWhiteOrderMapper.deleteProOrderByIds(orderIds); + } + // 删除母订单 + proWhiteOrderMapper.deleteProOrderByIds(ids); + return success(); } /** @@ -246,7 +285,7 @@ public class ProWhiteOrderServiceImpl implements IProWhiteOrderService { // 将工艺信息list放入返回实体 splitProWhiteOrderVo.setRouteList(routeList); - return AjaxResult.success(splitProWhiteOrderVo); + return success(splitProWhiteOrderVo); } /** diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml index 12abbe90..0ffc94c9 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml @@ -176,6 +176,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from pro_order where prod_type != 'white' + + insert into pro_order diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml index 659d48f2..2aae714d 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml @@ -324,6 +324,10 @@ select route_name from pro_route where route_code = #{routeCode} + + insert into mes_prepare_detail (