单价优化

This commit is contained in:
磷叶 2024-10-18 15:53:45 +08:00
parent 143198c9b5
commit 7d833113b0
6 changed files with 50 additions and 1 deletions
ruoyi-web/src/main/java/com/ruoyi/web/yh/price

View File

@ -115,4 +115,11 @@ public class PriceController extends BaseController
return toAjax(priceService.disable(priceId));
}
@PreAuthorize("@ss.hasPermi('yh:price:enable')")
@Log(title = "单价启用", businessType = BusinessType.OTHER)
@PutMapping("/{priceId}/enable")
public AjaxResult enable(@PathVariable Long priceId) {
return toAjax(priceService.enable(priceId));
}
}

View File

@ -50,6 +50,7 @@ public class Price extends BaseEntity
@Excel(name = "工序名称")
@ApiModelProperty("工序名称")
@NotNull(message = "工序名称不允许为空", groups = ValidGroup.Create.class)
@Size(max = 200, message = "工序名称不允许超过200个字符")
private String name;

View File

@ -32,7 +32,7 @@ public enum PriceStatus {
* 允许修改的状态
*/
public static List<String> canEdit() {
return asList(WAIT_SUBMIT);
return asList(WAIT_SUBMIT, REJECT);
}
/**
@ -62,4 +62,11 @@ public enum PriceStatus {
public static List<String> canDisable() {
return asList(PASS);
}
/**
* 允许启用的状态
*/
public static List<String> canEnable() {
return asList(PASS);
}
}

View File

@ -92,4 +92,10 @@ public interface PriceService
* @param priceId 单价ID
*/
int disable(Long priceId);
/**
* 启用操作
* @param priceId 单价ID
*/
int enable(Long priceId);
}

View File

@ -53,6 +53,7 @@ public class PriceConverterImpl implements PriceConverter {
LoginUser loginUser = SecurityUtils.getLoginUser();
Price po = new Price();
po.setStatus(PriceStatus.WAIT_SUBMIT.getStatus());
po.setPriceId(data.getPriceId());
po.setDeptId(data.getDeptId());
po.setCategory(data.getCategory());

View File

@ -227,4 +227,31 @@ public class PriceServiceImpl implements PriceService
return result == null ? 0 : result;
}
@Override
public int enable(Long priceId) {
if (priceId == null) {
return 0;
}
PriceVO old = selectPriceByPriceId(priceId);
ServiceUtil.assertion(old == null, "待启用的单价不存在,请刷新后重试");
ServiceUtil.assertion(!PriceStatus.canEnable().contains(old.getStatus()), "待启用的单价当前状态不允许禁用");
ServiceUtil.assertion(old.getDisabled() != null && !old.getDisabled(), "待启用的单价已启用,请勿重复操作");
Integer result = transactionTemplate.execute(status -> {
Price data = new Price();
data.setDisabled(false);
PriceQuery query = new PriceQuery();
query.setStatusList(PriceStatus.canEnable());
query.setPriceId(priceId);
query.setDisabled(true);
int update = this.updateByQuery(data, query);
ServiceUtil.assertion(update != 1, "启用单价失败,当前状态已发生变化,请刷新后重试");
return update;
});
return result == null ? 0 : result;
}
}