feat:新增盘点表数据
This commit is contained in:
@@ -37,7 +37,7 @@ import com.zt.plat.module.qms.resource.material.service.MaterialInventoryCheckSe
|
|||||||
|
|
||||||
@Tag(name = "管理后台 - 库存盘点")
|
@Tag(name = "管理后台 - 库存盘点")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/qms/material-inventory-check")
|
@RequestMapping("/qms/resource/material-inventory-check")
|
||||||
@Validated
|
@Validated
|
||||||
@FileUploadController(source = "qms.materialinventorycheck")
|
@FileUploadController(source = "qms.materialinventorycheck")
|
||||||
public class MaterialInventoryCheckController extends AbstractFileUploadController implements BusinessControllerMarker{
|
public class MaterialInventoryCheckController extends AbstractFileUploadController implements BusinessControllerMarker{
|
||||||
@@ -115,4 +115,12 @@ public class MaterialInventoryCheckController extends AbstractFileUploadControll
|
|||||||
BeanUtils.toBean(list, MaterialInventoryCheckRespVO.class));
|
BeanUtils.toBean(list, MaterialInventoryCheckRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/create-form")
|
||||||
|
@Operation(summary = "创建库存盘点")
|
||||||
|
public CommonResult<MaterialInventoryCheckRespVO> createMaterialInventoryCheckForm(@Valid @RequestBody MaterialInventoryCheckSaveReqVO createReqVO) {
|
||||||
|
|
||||||
|
|
||||||
|
return success(materialInventoryCheckService.createMaterialInventoryCheckForm(createReqVO));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -36,4 +36,7 @@ public class MaterialInventoryCheckBatchSaveReqVO {
|
|||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "盘点明细")
|
||||||
|
private List<MaterialInventoryCheckDetailSaveReqVO> detailList;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -68,4 +68,7 @@ public class MaterialInventoryCheckRespVO {
|
|||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "盘点项")
|
||||||
|
@ExcelProperty("盘点项")
|
||||||
|
private List<MaterialInventoryCheckBatchRespVO> batchList;
|
||||||
}
|
}
|
||||||
@@ -50,4 +50,7 @@ public class MaterialInventoryCheckSaveReqVO {
|
|||||||
@Schema(description = "备注")
|
@Schema(description = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "盘点项")
|
||||||
|
private List<MaterialInventoryCheckBatchSaveReqVO> batchList;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -61,4 +61,12 @@ public interface MaterialInventoryCheckService {
|
|||||||
*/
|
*/
|
||||||
PageResult<MaterialInventoryCheckDO> getMaterialInventoryCheckPage(MaterialInventoryCheckPageReqVO pageReqVO);
|
PageResult<MaterialInventoryCheckDO> getMaterialInventoryCheckPage(MaterialInventoryCheckPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建库存盘点表单
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
MaterialInventoryCheckRespVO createMaterialInventoryCheckForm(@Valid MaterialInventoryCheckSaveReqVO createReqVO);
|
||||||
}
|
}
|
||||||
@@ -4,11 +4,20 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckPageReqVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckPageReqVO;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckRespVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckRespVO;
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckSaveReqVO;
|
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInventoryCheckSaveReqVO;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryCheckBatchDO;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryCheckDetailDO;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInfomationMapper;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryCheckBatchMapper;
|
||||||
|
import com.zt.plat.module.qms.resource.material.dal.mapper.MaterialInventoryCheckDetailMapper;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
import com.zt.plat.module.qms.resource.material.controller.vo.*;
|
||||||
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryCheckDO;
|
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInventoryCheckDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
@@ -32,6 +41,16 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
|||||||
@Resource
|
@Resource
|
||||||
private MaterialInventoryCheckMapper materialInventoryCheckMapper;
|
private MaterialInventoryCheckMapper materialInventoryCheckMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialInventoryCheckBatchMapper materialInventoryCheckBatchMapper;//盘点项目
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialInventoryCheckDetailMapper materialInventoryCheckDetailMapper;//盘点明细
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialInfomationMapper materialInfomationMapper;//物料实例
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialInventoryCheckRespVO createMaterialInventoryCheck(MaterialInventoryCheckSaveReqVO createReqVO) {
|
public MaterialInventoryCheckRespVO createMaterialInventoryCheck(MaterialInventoryCheckSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@@ -59,12 +78,12 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialInventoryCheckListByIds(List<Long> ids) {
|
public void deleteMaterialInventoryCheckListByIds(List<Long> ids) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateMaterialInventoryCheckExists(ids);
|
validateMaterialInventoryCheckExists(ids);
|
||||||
// 删除
|
// 删除
|
||||||
materialInventoryCheckMapper.deleteByIds(ids);
|
materialInventoryCheckMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMaterialInventoryCheckExists(List<Long> ids) {
|
private void validateMaterialInventoryCheckExists(List<Long> ids) {
|
||||||
List<MaterialInventoryCheckDO> list = materialInventoryCheckMapper.selectByIds(ids);
|
List<MaterialInventoryCheckDO> list = materialInventoryCheckMapper.selectByIds(ids);
|
||||||
@@ -89,4 +108,60 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
|||||||
return materialInventoryCheckMapper.selectPage(pageReqVO);
|
return materialInventoryCheckMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public MaterialInventoryCheckRespVO createMaterialInventoryCheckForm(@Valid MaterialInventoryCheckSaveReqVO createReqVO) {
|
||||||
|
// 校验 batchList 不为空
|
||||||
|
if (CollUtil.isEmpty(createReqVO.getBatchList())) {
|
||||||
|
throw exception(MATERIAL_INVENTORY_CHECK_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 插入库存盘点数据 */
|
||||||
|
MaterialInventoryCheckDO materialInventoryCheck = BeanUtils.toBean(createReqVO, MaterialInventoryCheckDO.class);
|
||||||
|
materialInventoryCheckMapper.insert(materialInventoryCheck);
|
||||||
|
|
||||||
|
MaterialInventoryCheckRespVO resultVo = BeanUtils.toBean(materialInventoryCheck, MaterialInventoryCheckRespVO.class);
|
||||||
|
|
||||||
|
// 获取生成的ID作为父ID
|
||||||
|
Long parentId = materialInventoryCheck.getId();
|
||||||
|
|
||||||
|
|
||||||
|
/** 插入库存盘点项目数据 */
|
||||||
|
List<MaterialInventoryCheckBatchSaveReqVO> batchList = createReqVO.getBatchList();
|
||||||
|
List<MaterialInventoryCheckBatchRespVO> BatchRespVOList = new ArrayList<>();
|
||||||
|
for (MaterialInventoryCheckBatchSaveReqVO batchItem : batchList) {
|
||||||
|
batchItem.setCheckId(parentId);
|
||||||
|
// 插入
|
||||||
|
MaterialInventoryCheckBatchDO materialInventoryCheckBatch = BeanUtils.toBean(batchItem, MaterialInventoryCheckBatchDO.class);
|
||||||
|
materialInventoryCheckBatchMapper.insert(materialInventoryCheckBatch);
|
||||||
|
BatchRespVOList.add(BeanUtils.toBean(materialInventoryCheckBatch, MaterialInventoryCheckBatchRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据盘点数据自动填入盘点明细 */
|
||||||
|
for (MaterialInventoryCheckBatchRespVO materialInventoryCheckBatchRespVO : BatchRespVOList) {
|
||||||
|
MaterialInfomationPageReqVO reqVO = new MaterialInfomationPageReqVO();
|
||||||
|
reqVO.setProductId(materialInventoryCheckBatchRespVO.getCheckProductId());
|
||||||
|
|
||||||
|
PageResult<MaterialInfomationDO> materialInfomationDOPageResult = materialInfomationMapper.selectAll(reqVO);
|
||||||
|
|
||||||
|
materialInventoryCheckBatchRespVO.setExpected(String.valueOf(materialInfomationDOPageResult.getList().size()));//以实例数量为应盘数量
|
||||||
|
|
||||||
|
materialInfomationDOPageResult.getList().forEach(materialInfomationDO -> {
|
||||||
|
// 插入
|
||||||
|
MaterialInventoryCheckDetailDO materialInventoryCheckDetail = new MaterialInventoryCheckDetailDO();
|
||||||
|
materialInventoryCheckDetail.setCheckBatchId(materialInventoryCheckBatchRespVO.getId());//盘点项目ID
|
||||||
|
materialInventoryCheckDetail.setInfomationId(materialInfomationDO.getId());//物料实例ID
|
||||||
|
materialInventoryCheckDetail.setStatus("0");//待盘点状态
|
||||||
|
materialInventoryCheckDetailMapper.insert(materialInventoryCheckDetail);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resultVo.setBatchList(BatchRespVOList);
|
||||||
|
// 返回结果
|
||||||
|
return resultVo;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user