refactor(mat): 优化物料出入库服务事务管理和代码规范
- 在 MatMaterialOutServiceImpl 中添加 @Transactional 注解确保数据一致性 - 修复 MatPriceHistoryController 中的服务注入变量名错误 - 统一控制器中的服务调用方法,提升代码可读性 - 优化 MatPurchaseInDetailServiceImpl 的事务配置和方法实现 - 规范化代码格式和命名约定,提高代码质量
This commit is contained in:
@@ -35,14 +35,14 @@ import com.gear.common.core.page.TableDataInfo;
|
||||
@RequestMapping("/mat/matPriceHistory")
|
||||
public class MatPriceHistoryController extends BaseController {
|
||||
|
||||
private final IMatPriceHistoryService iMatMatPriceHistoryService;
|
||||
private final IMatPriceHistoryService iMatPriceHistoryService;
|
||||
|
||||
/**
|
||||
* 查询配料价格/均价变动历史列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<MatPriceHistoryVo> list(MatPriceHistoryBo bo, PageQuery pageQuery) {
|
||||
return iMatMatPriceHistoryService.queryPageList(bo, pageQuery);
|
||||
return iMatPriceHistoryService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ public class MatPriceHistoryController extends BaseController {
|
||||
@Log(title = "配料价格/均价变动历史", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(MatPriceHistoryBo bo, HttpServletResponse response) {
|
||||
List<MatPriceHistoryVo> list = iMatMatPriceHistoryService.queryList(bo);
|
||||
List<MatPriceHistoryVo> list = iMatPriceHistoryService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "配料价格/均价变动历史", MatPriceHistoryVo.class, response);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MatPriceHistoryController extends BaseController {
|
||||
@GetMapping("/{historyId}")
|
||||
public R<MatPriceHistoryVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long historyId) {
|
||||
return R.ok(iMatMatPriceHistoryService.queryById(historyId));
|
||||
return R.ok(iMatPriceHistoryService.queryById(historyId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ public class MatPriceHistoryController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody MatPriceHistoryBo bo) {
|
||||
return toAjax(iMatMatPriceHistoryService.insertByBo(bo));
|
||||
return toAjax(iMatPriceHistoryService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ public class MatPriceHistoryController extends BaseController {
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody MatPriceHistoryBo bo) {
|
||||
return toAjax(iMatMatPriceHistoryService.updateByBo(bo));
|
||||
return toAjax(iMatPriceHistoryService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,6 +95,6 @@ public class MatPriceHistoryController extends BaseController {
|
||||
@DeleteMapping("/{historyIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] historyIds) {
|
||||
return toAjax(iMatMatPriceHistoryService.deleteWithValidByIds(Arrays.asList(historyIds), true));
|
||||
return toAjax(iMatPriceHistoryService.deleteWithValidByIds(Arrays.asList(historyIds), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.gear.mat.service.IMatMaterialOutService;
|
||||
import com.gear.mat.service.IMatMaterialService;
|
||||
import com.gear.mat.domain.vo.MatMaterialVo;
|
||||
import com.gear.mat.domain.bo.MatMaterialBo;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -110,6 +111,7 @@ public class MatMaterialOutServiceImpl implements IMatMaterialOutService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean insertByBoWithInventoryAdjustment(MatMaterialOutBo bo) {
|
||||
boolean success = insertByBo(bo);
|
||||
|
||||
@@ -122,6 +124,7 @@ public class MatMaterialOutServiceImpl implements IMatMaterialOutService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean deleteWithValidByIdsWithInventoryAdjustment(Collection<Long> ids, Boolean isValid) {
|
||||
// 获取待删除的出库记录信息,以便后续恢复库存
|
||||
List<MatMaterialOutVo> recordsToDelete = new ArrayList<>();
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.gear.mat.domain.vo.MatMaterialVo;
|
||||
import com.gear.mat.domain.vo.MatPriceHistoryVo;
|
||||
import com.gear.mat.domain.bo.MatMaterialBo;
|
||||
import com.gear.mat.domain.bo.MatPriceHistoryBo;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -142,6 +143,7 @@ public class MatPurchaseInDetailServiceImpl implements IMatPurchaseInDetailServi
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean insertByBoWithInventoryAndPriceHistory(MatPurchaseInDetailBo bo) {
|
||||
boolean success = insertByBo(bo);
|
||||
|
||||
@@ -157,6 +159,7 @@ public class MatPurchaseInDetailServiceImpl implements IMatPurchaseInDetailServi
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean deleteWithValidByIdsWithInventoryAndPriceHistory(Collection<Long> ids, Boolean isValid) {
|
||||
// 获取待删除的入库记录信息,以便后续还原库存和价格历史
|
||||
List<MatPurchaseInDetailVo> recordsToDelete = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user