|
|
|
|
@@ -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.MaterialInventoryCheckRespVO;
|
|
|
|
|
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 jakarta.annotation.Resource;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
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.framework.common.pojo.PageResult;
|
|
|
|
|
@@ -32,6 +41,16 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
|
|
|
|
@Resource
|
|
|
|
|
private MaterialInventoryCheckMapper materialInventoryCheckMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MaterialInventoryCheckBatchMapper materialInventoryCheckBatchMapper;//盘点项目
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MaterialInventoryCheckDetailMapper materialInventoryCheckDetailMapper;//盘点明细
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MaterialInfomationMapper materialInfomationMapper;//物料实例
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MaterialInventoryCheckRespVO createMaterialInventoryCheck(MaterialInventoryCheckSaveReqVO createReqVO) {
|
|
|
|
|
// 插入
|
|
|
|
|
@@ -59,12 +78,12 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deleteMaterialInventoryCheckListByIds(List<Long> ids) {
|
|
|
|
|
public void deleteMaterialInventoryCheckListByIds(List<Long> ids) {
|
|
|
|
|
// 校验存在
|
|
|
|
|
validateMaterialInventoryCheckExists(ids);
|
|
|
|
|
// 删除
|
|
|
|
|
materialInventoryCheckMapper.deleteByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void validateMaterialInventoryCheckExists(List<Long> ids) {
|
|
|
|
|
List<MaterialInventoryCheckDO> list = materialInventoryCheckMapper.selectByIds(ids);
|
|
|
|
|
@@ -89,4 +108,60 @@ public class MaterialInventoryCheckServiceImpl implements MaterialInventoryCheck
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|