余料库接口完善修改

This commit is contained in:
lym
2024-06-11 10:04:09 +08:00
parent 1d5c0dd0de
commit 2e1c673be2
20 changed files with 254 additions and 54 deletions
@@ -0,0 +1,24 @@
package com.cf.imes.module.manage.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum RemainPlateUseTypeEnum {
TYPE_ONE(0, "核销"),
TYPE_TWO(1, "排单"),
TYPE_THREE(2, "补板");
private final Integer status;
private String description;
public boolean equals(Integer status) {
return this.status .equals(status) ;
}
public boolean equals(RemainPlateUseTypeEnum enableStatusEnum) {
return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ;
}
}
@@ -3,6 +3,7 @@ package com.cf.imes.module.manage.controller.admin.plate;
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlatePageReqVO;
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateRespVO;
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateSaveReqVO;
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateUptReqVO;
import com.cf.imes.module.manage.dal.dataobject.remainplaten.RemainPlateDO;
import com.cf.imes.module.manage.service.remainplaten.RemainPlateService;
import io.swagger.v3.oas.annotations.Parameters;
@@ -41,12 +42,19 @@ public class RemainPlateController {
private RemainPlateService remainPlateService;
@PostMapping("/create")
@Operation(summary = "创建生产单余料板表")
@Operation(summary = "创建生产单余料板表(单个)")
@PreAuthorize("@ss.hasPermission('manage:remain-plate:create')")
public CommonResult<Long> createRemainPlate(@Valid @RequestBody RemainPlateSaveReqVO createReqVO) {
return success(remainPlateService.createRemainPlate(createReqVO));
}
@PostMapping("/createMultiple")
@Operation(summary = "创建生产单余料板表(多个)")
@PreAuthorize("@ss.hasPermission('manage:remain-plate:create')")
public CommonResult<Boolean> createRemainPlateMultiple(@Valid @RequestBody Set<RemainPlateSaveReqVO> createReqVOS) {
return success(remainPlateService.createRemainPlateMultiple(createReqVOS));
}
@PutMapping("/update")
@Operation(summary = "更新生产单余料板表")
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
@@ -57,31 +65,20 @@ public class RemainPlateController {
@PutMapping("/updateStatus")
@Operation(summary = "余料板批量核销")
@Parameters({
@Parameter(name = "id", description = "余料板id集", required = true),
@Parameter(name = "status", description = "修改的状态", required = true , example = "1"),
@Parameter(name = "useType", description = "使用类型,0核销,1排单,2补板", required = true , example = "1"),
@Parameter(name = "planId", description = "排单 ID", example = "1")
})
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
public CommonResult<Boolean> updateRemainPlate(@RequestParam("id") Set<Long> ids,
@RequestParam("status") Integer status,
@RequestParam("useType") Integer useType,
@RequestParam("planId") Long planId) {
remainPlateService.updateRemainPlateStatus(ids,status,useType,planId);
public CommonResult<Boolean> updateRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
remainPlateService.updateRemainPlateStatus(updateReqVO.getIds(),
updateReqVO.getStatus(),
updateReqVO.getUseType(),
updateReqVO.getPlanId());
return success(true);
}
@PutMapping("/revertUpdate")
@Operation(summary = "余料板批量释放")
@Parameters({
@Parameter(name = "id", description = "余料板id集", required = true),
@Parameter(name = "status", description = "修改的状态", required = true , example = "1")
})
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
public CommonResult<Boolean> updateRemainPlate(@RequestParam("id") Set<Long> ids,
@RequestParam("status") Integer status) {
remainPlateService.revertRemainPlateStatus(ids,status);
public CommonResult<Boolean> revertRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
remainPlateService.revertRemainPlateStatus(updateReqVO.getIds(),updateReqVO.getStatus());
return success(true);
}
@@ -16,6 +16,9 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
@ToString(callSuper = true)
public class RemainPlatePageReqVO extends PageParam {
@Schema(description = "ID", example = "16628")
private Long id;
@Schema(description = "排单 ID", example = "16628")
private Long planId;
@@ -23,8 +23,7 @@ public class RemainPlateSaveReqVO {
@Schema(description = "初始排单 ID")
private Long initPlanId;
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "余料板状态,0未使用,1使用中,2已使用不能为空")
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", example = "1")
private Integer status;
@Schema(description = "是否为开料添加,0否,1是", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@@ -34,12 +33,10 @@ public class RemainPlateSaveReqVO {
@Schema(description = "使用类型,0核销,1排单,2补板", example = "0")
private Integer useType;
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7425")
@NotEmpty(message = "商品 ID不能为空")
@Schema(description = "商品 ID", example = "7425")
private String goodsId;
@Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
@NotEmpty(message = "商品名不能为空")
@Schema(description = "商品名", example = "晨丰")
private String name;
@Schema(description = "材料", requiredMode = Schema.RequiredMode.REQUIRED)
@@ -78,8 +75,7 @@ public class RemainPlateSaveReqVO {
@Schema(description = "备注", example = "随便")
private String remark;
@Schema(description = "轮廊数据,Json 串", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "轮廊数据,Json 串不能为空")
@Schema(description = "轮廊数据,Json 串")
private String outLineJson;
}
@@ -0,0 +1,23 @@
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.Set;
@Schema(description = "管理后台 - 生产单余料板表 order_remain_plate_{N} Response VO")
@Data
public class RemainPlateUptReqVO {
@Schema(description = "余料板集", requiredMode = Schema.RequiredMode.REQUIRED, example = "16470")
private Set<Long> ids;
@Schema(description = "余料板状态,0未使用,1使用中", example = "1")
private Integer status;
@Schema(description = "使用类型,0核销,1排单,2补板", example = "0")
private Integer useType;
@Schema(description = "排单 ID", example = "6628")
private Long planId;
}
@@ -23,6 +23,14 @@ public interface RemainPlateService {
*/
Long createRemainPlate(@Valid RemainPlateSaveReqVO createReqVO);
/**
* 创建生产单余料板表
*
* @param createReqVOS 创建信息
* @return 编号
*/
Boolean createRemainPlateMultiple(@Valid Set<RemainPlateSaveReqVO> createReqVOS);
/**
* 批量核销
*
@@ -6,6 +6,7 @@ import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateSav
import com.cf.imes.module.manage.dal.dataobject.remainplaten.RemainPlateDO;
import com.cf.imes.module.manage.dal.mysql.remainplaten.RemainPlateMapper;
import com.cf.imes.module.manage.enums.RemainPlateStatusEnum;
import com.cf.imes.module.manage.enums.RemainPlateUseTypeEnum;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -15,6 +16,7 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Set;
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
@@ -41,19 +43,31 @@ public class RemainPlateServiceImpl implements RemainPlateService {
return remainPlate.getId();
}
@Override
public Boolean createRemainPlateMultiple(Set<RemainPlateSaveReqVO> createReqVOS) {
// 批量插入
return remainPlateMapper.insertBatch(Collections.singleton(BeanUtils.toBean(createReqVOS, RemainPlateDO.class)));
}
@Override
public void updateRemainPlateStatus(Set<Long> ids, Integer status, Integer useType,Long planId) {
//判断是否符合核销标准
validateRemainPlateStatus(ids,RemainPlateStatusEnum.UNUSED.getStatus());
validateRemainPlateStatus(ids,RemainPlateStatusEnum.IN_USE.getStatus());
//以id为条件批量修改余料库中的状态
remainPlateMapper.updateRemainPlateStatus(ids, status, useType, OrganContextHolder.getOrganId(),planId);
}
@Override
public void revertRemainPlateStatus(Set<Long> ids, Integer status) {
// 判断余料的状态使用中
validateRemainPlateStatus(ids,RemainPlateStatusEnum.IN_USE.getStatus());
remainPlateMapper.updateRemainPlateStatus(ids, status, null, OrganContextHolder.getOrganId(),null);
// 判断余料的状态是否存在使用中
validateRemainPlateStatus(ids,RemainPlateStatusEnum.UNUSED.getStatus());
// 判断使用类型是否为核销
for (Long id : ids) {
if (validateRemainPlateUseType(id) != RemainPlateUseTypeEnum.TYPE_ONE.getStatus()) {
throw exception(REMAIN_PLATE_USR_TYPE);
}
}
remainPlateMapper.updateRemainPlateStatus(ids, status, null, OrganContextHolder.getOrganId(),0L);
}
@Override
@@ -77,7 +91,7 @@ public class RemainPlateServiceImpl implements RemainPlateService {
@Override
public void deleteRemainPlate(Set<Long> ids) {
// 判断余料的状态使用中
// 判断余料的状态是否存在使用中
validateRemainPlateStatus(ids,RemainPlateStatusEnum.IN_USE.getStatus());
// 删除
remainPlateMapper.deleteBatchIds(ids);