添加删除排单、作废排单接口

This commit is contained in:
yangshb
2024-03-07 13:55:18 +08:00
parent c86578c099
commit b59b795b58
15 changed files with 208 additions and 57 deletions
@@ -11,6 +11,10 @@ public interface ErrorCodeConstants {
// ========== 生产单开料排单
ErrorCode PLAN_NOT_EXISTS = new ErrorCode(1_001_107_000, "生产单开料排单不存在");
ErrorCode PLAN_NOT_ALLOW_DELETE = new ErrorCode(1_001_107_001, "排单 开料中 已开料 不予许删除");
ErrorCode PLAN_NOT_ALLOW_CANCEL = new ErrorCode(1_001_107_002, "排单 新单 不予许作废");
// ========== 生产单商品 TODO 补充编号 ==========
ErrorCode GOODS_NOT_EXISTS = new ErrorCode(1_001_108_000, "生产单商品不存在");
@@ -55,16 +55,23 @@ public class PlanController {
@DeleteMapping("/delete")
@Operation(summary = "删除排单")
@Parameter(name = "id", description = "编号", required = true)
@Parameter(name = "id", description = "排单id", required = true)
@PreAuthorize("@ss.hasPermission('executor:plan:delete')")
public CommonResult<Boolean> deletePlan(@RequestParam("id") Long id) {
planService.deletePlan(id);
return success(true);
return success(planService.deletePlan(id));
}
@DeleteMapping("cancellation")
@Operation(summary = "作废")
@Parameter(name = "id", description = "排单id", required = true)
@PreAuthorize("@ss.hasPermission('executor:plan:delete')")
public CommonResult<Boolean> cancellation(@RequestParam("id") Long id) {
return success(planService.cancellation(id));
}
@GetMapping("/get")
@Operation(summary = "获得排单")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@Parameter(name = "id", description = "排单id", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('executor:plan:query')")
public CommonResult<PlanRespVO> getPlan(@RequestParam("id") Long id) {
PlanRespVO plan = planService.getPlan(id);
@@ -79,7 +86,7 @@ public class PlanController {
return success(BeanUtils.toBean(pageResult, PlanRespVO.class));
}
@GetMapping("getOrderPageByPlanId")
@GetMapping("getNotPlanOrderListPage")
@Operation(summary = "获取未排单的板材生产单板材分页列表")
@PreAuthorize("@ss.hasPermission('executor:plan:query')")
public CommonResult<PageResult<OrderRespVO>> getOrderPage(@Valid OrderPageReqVO pageReqVO) {
@@ -31,51 +31,30 @@ public class OrderPageReqVO extends PageParam {
private String consigneeAddress;
@Schema(description = "状态列表")
private List<Integer> stateList;
@Schema(description = "状搜索条件")
private CheckDicBean checkDic;
@Schema(description = "")
private boolean rectangle;
@Schema(description = "异形")
private boolean specialShaped;
@Schema(description = "造型")
private boolean sculpt;
@Schema(description = "有挖穿造型")
private boolean holeThrough;
@Schema(description = "有挖穿孔")
private boolean burrow;
@Schema(description = "有二维纹路")
private boolean twoDimensionalToolPath;
@Schema(description = "开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date beginDate;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endDate;
@Schema(description = "长范围")
private LongRangBean longRang;
@Schema(description = "范围")
private WidthRangBean widthRang;
@Schema(description = "范围")
private BigDecimal longMinRang;
@Schema(description = "长 大范围")
private BigDecimal longMaxRang;
@Schema(description = "宽 小范围")
private BigDecimal widthMinRang;
@Schema(description = "宽 大范围")
private BigDecimal widthMaxRang;
@NoArgsConstructor
@Data
public static class CheckDicBean {
@Schema(description = "矩形")
private boolean rectangle;
@Schema(description = "异形")
private boolean specialShaped;
@Schema(description = "造型")
private boolean sculpt;
@Schema(description = "有挖穿造型")
private boolean holeThrough;
@Schema(description = "有挖穿孔")
private boolean burrow;
@Schema(description = "有二维纹路")
private boolean twoDimensionalToolPath;
}
@NoArgsConstructor
@Data
public static class LongRangBean {
@Schema(description = "生产单id")
private BigDecimal min;
@Schema(description = "生产单id")
private BigDecimal max;
}
@NoArgsConstructor
@Data
public static class WidthRangBean {
@Schema(description = "生产单id")
private BigDecimal min;
@Schema(description = "生产单id")
private BigDecimal max;
}
}
@@ -41,6 +41,10 @@ public class PlanRespVO {
@ExcelProperty("机台 ID")
private Long machineId;
@Schema(description = "机台 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "16707")
@ExcelProperty("机台 名称")
private String machineName;
@Schema(description = "计划时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("计划时间")
private LocalDateTime planTime;
@@ -166,5 +166,9 @@ public class PlateDO extends BaseDO {
* 备注
*/
private String remark;
/**
* 是否作废
*/
private Boolean isCancel;
}
@@ -1,5 +1,6 @@
package com.cf.imes.module.executor.framework.rpc.config;
import com.cf.imes.module.system.api.machine.MachineApi;
import com.cf.imes.module.system.api.user.AdminUserApi;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Configuration;
@@ -8,6 +9,6 @@ import org.springframework.context.annotation.Configuration;
* @author there
*/
@Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = AdminUserApi.class)
@EnableFeignClients(clients = {AdminUserApi.class, MachineApi.class})
public class RpcConfiguration {
}
@@ -34,7 +34,7 @@ public interface PlanService {
*
* @param id 编号
*/
void deletePlan(Long id);
Boolean deletePlan(Long id);
/**
* 获得生产单开料排单
@@ -57,4 +57,6 @@ public interface PlanService {
PageResult<PlatePage> getNotPlanPlateListPage(PlateReqPageVO pageVO);
Boolean addPlate(AddPlateReq req);
Boolean cancellation(Long id);
}
@@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.util.date.LocalDateTimeUtils;
@@ -21,6 +23,8 @@ import com.cf.imes.module.executor.dal.mysql.orderItem.OrderItemMapper;
import com.cf.imes.module.executor.dal.mysql.planitem.PlanItemMapper;
import com.cf.imes.module.executor.dal.mysql.planorder.PlanOrderMapper;
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
import com.cf.imes.module.system.api.machine.MachineApi;
import com.cf.imes.module.system.api.machine.dto.CuttingRespDTO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -74,6 +78,9 @@ public class PlanServiceImpl implements PlanService {
@Resource
private PlateMapper plateMapper;
@Resource
private MachineApi machineApi;
@Override
@Transactional(rollbackFor = Exception.class)
@@ -148,13 +155,20 @@ public class PlanServiceImpl implements PlanService {
@Override
@Transactional(rollbackFor = Exception.class)
public void deletePlan(Long id) {
public Boolean deletePlan(Long id) {
// 校验存在
validatePlanExists(id);
PlanDO planDO = planMapper.selectById(id);
if (planDO == null) {
throw exception(PLAN_NOT_EXISTS);
}
if (planDO.getStatus().equals(2) || planDO.getStatus().equals(3)) {
throw exception(PLAN_NOT_ALLOW_DELETE);
}
// 删除
planMapper.deleteById(id);
planOrderMapper.delete(new LambdaQueryWrapperX<PlanOrderDO>().eq(PlanOrderDO::getPlanId, id));
planItemMapper.delete(new LambdaQueryWrapperX<PlanItemDO>().eq(PlanItemDO::getPlanId, id));
return Boolean.TRUE;
}
private void validatePlanExists(Long id) {
@@ -192,11 +206,14 @@ public class PlanServiceImpl implements PlanService {
if (CollectionUtil.isEmpty(planDOPageResult.getList())) {
return new PageResult<>();
}
Set<Long> macheineIds = planDOPageResult.getList().stream().map(e -> e.getMachineId()).collect(Collectors.toSet());
List<CuttingRespDTO> machines = machineApi.list(macheineIds).getCheckedData();
Set<Long> ids = planDOPageResult.getList().stream().map(e -> e.getId()).collect(Collectors.toSet());
List<GoodsDO> goodsDOS = goodsMapper.selectList(new LambdaQueryWrapperX<GoodsDO>().in(GoodsDO::getOrderId, ids));
List<PlateDO> plateDOS = plateMapper.selectList(new LambdaQueryWrapperX<PlateDO>().in(PlateDO::getGoodsId, goodsDOS.stream().map(e -> e.getGoodsId()).collect(Collectors.toSet())));
PageResult<PlanRespVO> planRespVOPageResult = BeanUtils.toBean(planDOPageResult, PlanRespVO.class);
planRespVOPageResult.getList().stream().forEach(e -> {
e.setMachineName(machines.stream().filter(f -> Objects.equals(f.getId(), e.getMachineId())).map(m -> m.getName()).findAny().orElse(null));
e.setPlateInfoList(goodsDOS.stream()
.filter(f -> Objects.equals(f.getOrderId(), e.getId()))
.map(p -> PlateInfoVO.builder()
@@ -223,13 +240,18 @@ public class PlanServiceImpl implements PlanService {
.betweenIfPresent("delivery_date", new Date[]{pageReqVO.getBeginDate(), pageReqVO.getEndDate()})
.isNull("d.order_id")
;
List<Integer> filterTypes = new ArrayList<>();
if (pageReqVO.isHoleThrough()) {
filterTypes.add(1);
}
if (pageReqVO.isBurrow()) {
filterTypes.add(2);
}
if (pageReqVO.isTwoDimensionalToolPath()) {
filterTypes.add(4);
}
LambdaQueryWrapperX<OrderDO> wrapper = new LambdaQueryWrapperX<OrderDO>()
.eqIfPresent(OrderDO::getId, pageReqVO.getOrderId())
.eqIfPresent(OrderDO::getCustomer, pageReqVO.getConsignee())
.eqIfPresent(OrderDO::getAddress, pageReqVO.getConsigneeAddress())
.eqIfPresent(OrderDO::getCustomOrderNo, pageReqVO.getDefaultId())
.betweenIfPresent(OrderDO::getDeliveryDate, new Date[]{pageReqVO.getBeginDate(), pageReqVO.getEndDate()});
queryWrapperX.inIfPresent("c.filter_type", filterTypes);
IPage<OrderRespVO> orderDOPageResult = orderMapper.selectOrderPage(page, queryWrapperX);
if (CollectionUtil.isEmpty(orderDOPageResult.getRecords())) {
@@ -268,4 +290,21 @@ public class PlanServiceImpl implements PlanService {
return Boolean.TRUE;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean cancellation(Long id) {
PlanDO planDO = planMapper.selectById(id);
if (planDO == null) {
throw exception(PLAN_NOT_EXISTS);
}
if (planDO.getStatus().equals(0) || planDO.getStatus().equals(1)) {
throw exception(PLAN_NOT_ALLOW_CANCEL);
}
Set<Long> itemIds = planItemMapper.selectList(new LambdaQueryWrapperX<PlanItemDO>().eq(PlanItemDO::getPlanId, id))
.stream().map(e -> e.getItemId())
.collect(Collectors.toSet());
plateMapper.update(new LambdaUpdateWrapper<PlateDO>().in(PlateDO::getId, itemIds).set(PlateDO::getIsCancel, Boolean.TRUE));
return Boolean.TRUE;
}
}
@@ -6,7 +6,7 @@
select a.id as orderId, a.delivery_date, a.customer, a.address, a.custom_order_no as defineId,
count(c.id) as num, sum(c.area) as area, p.goods_name, p.color, p.material, p.goods_id
from `order` a
left join order_plate c ON a.id = c.order_id
left join order_plate c ON a.id = c.order_id and c.is_cancel = 0
left join plate p on c.goods_id = p.goods_id
left join order_item d ON c.order_id = d.order_id
${ew.customSqlSegment}
@@ -11,6 +11,7 @@
LEFT JOIN order_goods c on a.order_id = c.order_id
<where>
p.id is null
and a.is_cancel = 0
<if test="orderId !=null">
and a.order_id = #{orderId}
</if>
@@ -0,0 +1,39 @@
package com.cf.imes.module.system.api.machine;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.system.api.machine.dto.CuttingRespDTO;
import com.cf.imes.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
@Tag(name = "RPC 服务 - 机台")
public interface MachineApi {
String PREFIX = ApiConstants.PREFIX + "/machine";
@GetMapping(PREFIX + "/get-cutting")
@Operation(summary = "获得开料机台信息")
@Parameter(name = "id", description = "机台id", example = "1024", required = true)
CommonResult<CuttingRespDTO> getCutting(@RequestParam("id") Long id);
@GetMapping(PREFIX + "/get-drill")
@Operation(summary = "获得钻孔机台信息")
@Parameter(name = "id", description = "机台id", example = "1024", required = true)
CommonResult<CuttingRespDTO> getDrill(@RequestParam("id") Long id);
@GetMapping(PREFIX + "/list")
@Operation(summary = "获得机台基本信息列表")
@Parameter(name = "ids", description = "机台id", example = "1024", required = true)
CommonResult<List<CuttingRespDTO>> list(@RequestParam("ids") Collection<Long> ids);
}
@@ -0,0 +1,25 @@
package com.cf.imes.module.system.api.machine.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 机台 Response VO")
@Data
public class CuttingRespDTO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "14092")
private Long id;
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
private String name;
@Schema(description = "1机台设备 2CNC设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Integer machineType;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}
@@ -0,0 +1,39 @@
package com.cf.imes.module.system.api.machine;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.module.system.api.machine.dto.CuttingRespDTO;
import com.cf.imes.module.system.controller.admin.machine.vo.CuttingRespVO;
import com.cf.imes.module.system.service.machine.MachineService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import static com.cf.imes.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口,给 Feign 调用
@Validated
public class MachineApiImpl implements MachineApi {
@Resource
private MachineService machineService;
@Override
public CommonResult<CuttingRespDTO> getCutting(Long id) {
return success(BeanUtils.toBean(machineService.getCutting(id), CuttingRespDTO.class));
}
@Override
public CommonResult<CuttingRespDTO> getDrill(Long id) {
return success(BeanUtils.toBean(machineService.getDrill(id), CuttingRespDTO.class));
}
@Override
public CommonResult<List<CuttingRespDTO>> list(Collection<Long> ids) {
return success(BeanUtils.toBean(machineService.list(ids), CuttingRespDTO.class));
}
}
@@ -68,4 +68,6 @@ public interface MachineService {
void batchDeleteDrill(List<Long> ids);
DrillRespVO getDrill(Long id);
List<MachineDO> list(Collection<Long> ids);
}
@@ -222,6 +222,11 @@ public class MachineServiceImpl implements MachineService {
return respVO;
}
@Override
public List<MachineDO> list(Collection<Long> ids) {
return machineMapper.selectBatchIds(ids);
}
private void validateExists(Long id) {
if (machineMapper.selectById(id) == null) {
throw exception(MACHINE_NOT_EXISTS);