物资和设计

This commit is contained in:
zt
2025-08-15 03:04:19 +08:00
parent e706540fe3
commit 01678fda6a
31 changed files with 858 additions and 68 deletions

View File

@ -183,6 +183,4 @@ public class BusMaterialbatchdemandplanController extends BaseController {
// return toAjax(busMaterialbatchdemandplanService.deleteWithValidByIds(List.of(ids), true));
// }
}

View File

@ -7,6 +7,7 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.cailiaoshebei.domain.dto.BusMrpDto;
import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto;
import org.dromara.cailiaoshebei.domain.vo.BusMrpVo;
import org.dromara.design.domain.dto.desCollect.DesCollectBatchDto;
import org.dromara.design.domain.vo.DesCollectVo;
@ -117,4 +118,15 @@ public class BusMrpBaseController extends BaseController {
}
/**
* 导入物资需求批次计划
*/
@SaCheckPermission("cailiaoshebei:mrpBase:add")
@Log(title = "物资-批次需求计划基础信息", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/import")
public R<Void> importData(BusMrpExportDto dto) {
return toAjax(busMrpBaseService.importData(dto));
}
}

View File

@ -1,11 +1,18 @@
package org.dromara.cailiaoshebei.controller;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation;
import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo;
import org.dromara.cailiaoshebei.domain.vo.BusMaterialbatchdemandplanVo;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
import org.dromara.cailiaoshebei.service.IBusPlanDocAssociationService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
@ -36,6 +43,10 @@ public class BusPurchaseDocController extends BaseController {
private final IBusPurchaseDocService busPurchaseDocService;
private final IBusMaterialbatchdemandplanService materialbatchdemandplanService;
private final IBusPlanDocAssociationService planDocAssociationService;
/**
* 查询物资-采购联系单列表
*/
@ -102,4 +113,22 @@ public class BusPurchaseDocController extends BaseController {
@PathVariable Long[] ids) {
return toAjax(busPurchaseDocService.deleteWithValidByIds(List.of(ids), true));
}
/**
* 查询采购单关联的计划
*/
@GetMapping("/planList/{id}")
public R<List<BusMaterialbatchdemandplanVo>> list(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
List<BusPlanDocAssociation> list = planDocAssociationService.list(Wrappers.lambdaQuery(BusPlanDocAssociation.class)
.eq(BusPlanDocAssociation::getDocId, id));
List<Long> list1 = list.stream().map(BusPlanDocAssociation::getPlanId).toList();
if (list1.isEmpty()) {
return R.ok(new ArrayList<>());
}
BusMaterialbatchdemandplanBo bo = new BusMaterialbatchdemandplanBo();
bo.setIds(list1);
return R.ok(materialbatchdemandplanService.queryList(bo));
}
}

View File

@ -6,6 +6,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.math.BigDecimal;
/**
* 物资-物流单号对象 bus_ltn
@ -45,7 +46,7 @@ public class BusLtn extends BaseEntity {
/**
* 数量
*/
private Long num;
private BigDecimal num;
/**
* 物流单号

View File

@ -33,6 +33,11 @@ public class BusPurchaseDoc extends BaseEntity {
*/
private Long projectId;
/**
* 1-采购单2-补货单
*/
private String docType;
/**
* 采购单编号
*/

View File

@ -9,6 +9,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
/**
* 物资-物流单号业务对象 bus_ltn
*
@ -46,7 +48,7 @@ public class BusLtnBo extends BaseEntity {
/**
* 数量
*/
private Long num;
private BigDecimal num;
/**
* 物流单号

View File

@ -11,6 +11,8 @@ import jakarta.validation.constraints.*;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
@ -105,4 +107,10 @@ public class BusMaterialbatchdemandplanBo extends BaseEntity {
* 质量标准
*/
private String qs;
/**
* 主键集合
*/
private List<Long> ids;
}

View File

@ -10,6 +10,8 @@ import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.math.BigDecimal;
/**
* 物资-物流单号业务对象 bus_ltn
*
@ -28,7 +30,7 @@ public class BusLtnListDto{
/**
* 数量
*/
private Long num;
private BigDecimal num;
/**
* 物流单号

View File

@ -0,0 +1,60 @@
package org.dromara.cailiaoshebei.domain.dto;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import java.time.LocalDate;
import java.util.List;
/**
* 物资-批次需求计划业务对象 bus_materialbatchdemandplan
*
* @author Lion Li
* @date 2025-08-02
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = BusMaterialbatchdemandplan.class, reverseConvertGenerate = false)
public class BusMaterialbatchdemandplanExportDto extends BaseEntity {
/**
* 设备材料名称
*/
private String name;
/**
* 规格型号
*/
private String specification;
/**
* 计量单位
*/
private String unit;
/**
* 需求数量
*/
private Long demandQuantity;
/**
* 质量标准
*/
private String qs;
/**
* 计划到场时间
*/
private LocalDate arrivalTime;
/**
* 备注
*/
private String remark;
}

View File

@ -0,0 +1,43 @@
package org.dromara.cailiaoshebei.domain.dto;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo;
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDate;
import java.util.List;
@Data
public class BusMrpExportDto {
/**
* 项目ID
*/
@NotNull(message = "项目ID不能为空", groups = { AddGroup.class, EditGroup.class })
private Long projectId;
/**
* 计划编号
*/
@NotBlank(message = "计划编号不能为空", groups = { AddGroup.class, EditGroup.class })
private String planCode;
/**
* 物资类别
*/
private String matCat;
/**
* 编制日期
*/
private LocalDate preparedDate;
private MultipartFile file;
}

View File

@ -10,6 +10,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@ -52,11 +53,16 @@ public class BusLtnVo implements Serializable {
@ExcelProperty(value = "计划id")
private Long planId;
/**
* 物资名称
*/
private String name;
/**
* 数量
*/
@ExcelProperty(value = "数量")
private Long num;
private BigDecimal num;
/**
* 物流单号

View File

@ -154,6 +154,16 @@ public class BusPurchaseDocVo implements Serializable {
*/
private Long mrpBaseId;
/**
* 计划编号
*/
private String planCode;
/**
* 1-采购单2-补货单
*/
private String docType;
/**
* 关联计划
*/

View File

@ -1,6 +1,7 @@
package org.dromara.cailiaoshebei.service;
import org.dromara.cailiaoshebei.domain.dto.BusMrpDto;
import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto;
import org.dromara.cailiaoshebei.domain.vo.BusMrpBaseVo;
import org.dromara.cailiaoshebei.domain.bo.BusMrpBaseBo;
import org.dromara.cailiaoshebei.domain.BusMrpBase;
@ -76,4 +77,9 @@ public interface IBusMrpBaseService extends IService<BusMrpBase>{
* 批量新增或修改物资-批次需求计划
*/
Boolean batchAddOrUpdate(BusMrpDto dto);
/**
* 导入物资需求批次计划
*/
Boolean importData(BusMrpExportDto dto);
}

View File

@ -7,7 +7,10 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
/**
@ -67,4 +70,9 @@ public interface IBusPurchaseDocService extends IService<BusPurchaseDoc>{
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 创建补货采购单
*/
void create(Long id, HashMap<Long, BigDecimal> map);
}

View File

@ -1,8 +1,13 @@
package org.dromara.cailiaoshebei.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.dromara.cailiaoshebei.domain.dto.BusLtnDto;
import org.dromara.cailiaoshebei.domain.dto.BusLtnListDto;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
@ -13,6 +18,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.dromara.cailiaoshebei.domain.bo.BusLtnBo;
import org.dromara.cailiaoshebei.domain.vo.BusLtnVo;
@ -20,6 +26,7 @@ import org.dromara.cailiaoshebei.domain.BusLtn;
import org.dromara.cailiaoshebei.mapper.BusLtnMapper;
import org.dromara.cailiaoshebei.service.IBusLtnService;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@ -38,6 +45,12 @@ public class BusLtnServiceImpl extends ServiceImpl<BusLtnMapper, BusLtn> impleme
private final IBusPurchaseDocService purchaseDocService;
private final IBusMaterialbatchdemandplanService planService;
@Resource
@Lazy
private IBusLtnService busLtnService;
/**
* 查询物资-物流单号
*
@ -60,6 +73,9 @@ public class BusLtnServiceImpl extends ServiceImpl<BusLtnMapper, BusLtn> impleme
public TableDataInfo<BusLtnVo> queryPageList(BusLtnBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<BusLtn> lqw = buildQueryWrapper(bo);
Page<BusLtnVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
result.getRecords().forEach(e -> {
e.setName(planService.queryById(e.getPlanId()).getName());
});
return TableDataInfo.build(result);
}
@ -146,10 +162,19 @@ public class BusLtnServiceImpl extends ServiceImpl<BusLtnMapper, BusLtn> impleme
if (busPurchaseDocVo == null) {
throw new ServiceException("采购单不存在");
}
return null;
busLtnService.getBaseMapper().delete(Wrappers.lambdaQuery(BusLtn.class)
.eq(BusLtn::getDocId, dto.getDocId()));
ArrayList<BusLtn> busLtns = new ArrayList<>();
for (BusLtnListDto ltnListDto : dto.getList()) {
BusLtn busLtn = BeanUtil.copyProperties(ltnListDto, BusLtn.class);
busLtn.setProjectId(busPurchaseDocVo.getProjectId());
busLtn.setDocId(dto.getDocId());
busLtns.add(busLtn);
}
boolean save = true;
if(CollectionUtil.isNotEmpty(busLtns)){
save = busLtnService.saveBatch(busLtns);
}
return save;
}
}

View File

@ -1,6 +1,7 @@
package org.dromara.cailiaoshebei.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@ -113,6 +114,7 @@ public class BusMaterialbatchdemandplanServiceImpl extends ServiceImpl<BusMateri
lqw.eq(bo.getDemandQuantity() != null, BusMaterialbatchdemandplan::getDemandQuantity, bo.getDemandQuantity());
lqw.eq(bo.getArrivalTime() != null, BusMaterialbatchdemandplan::getArrivalTime, bo.getArrivalTime());
lqw.eq(bo.getMrpBaseId()!=null, BusMaterialbatchdemandplan::getMrpBaseId, bo.getMrpBaseId());
lqw.in(CollectionUtil.isNotEmpty(bo.getIds()), BusMaterialbatchdemandplan::getId, bo.getIds());
return lqw;
}

View File

@ -1,12 +1,15 @@
package org.dromara.cailiaoshebei.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan;
import org.dromara.cailiaoshebei.domain.bo.BusMaterialbatchdemandplanBo;
import org.dromara.cailiaoshebei.domain.dto.BusMaterialbatchdemandplanExportDto;
import org.dromara.cailiaoshebei.domain.dto.BusMrpDto;
import org.dromara.cailiaoshebei.domain.dto.BusMrpExportDto;
import org.dromara.cailiaoshebei.domain.vo.BusMaterialbatchdemandplanVo;
import org.dromara.cailiaoshebei.domain.vo.BusMrpVo;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
@ -22,6 +25,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.utils.excel.ExcelDynamicReader;
import org.dromara.design.domain.DesCollect;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
@ -32,6 +36,7 @@ import org.dromara.cailiaoshebei.mapper.BusMrpBaseMapper;
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Collection;
@ -58,13 +63,13 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
* @return 物资-批次需求计划基础信息
*/
@Override
public BusMrpVo queryById(Long id){
public BusMrpVo queryById(Long id) {
BusMrpVo busMrpVo = new BusMrpVo();
BusMrpBaseVo busMrpBaseVo = baseMapper.selectVoById(id);
BusMaterialbatchdemandplanBo planBo = new BusMaterialbatchdemandplanBo();
BusMaterialbatchdemandplanBo planBo = new BusMaterialbatchdemandplanBo();
planBo.setMrpBaseId(id);
List<BusMaterialbatchdemandplanVo> voList = planservice.queryList(planBo);
List<BusMaterialbatchdemandplanVo> voList = planservice.queryList(planBo);
busMrpVo.setMrpBaseBo(busMrpBaseVo);
busMrpVo.setPlanList(voList);
@ -142,7 +147,7 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(BusMrpBase entity){
private void validEntityBeforeSave(BusMrpBase entity) {
//TODO 做一些数据校验,如唯一约束
}
@ -156,11 +161,11 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
planservice.remove(Wrappers.<BusMaterialbatchdemandplan>lambdaQuery()
.in(BusMaterialbatchdemandplan::getMrpBaseId,ids));
.in(BusMaterialbatchdemandplan::getMrpBaseId, ids));
return baseMapper.deleteByIds(ids) > 0;
}
@ -173,10 +178,10 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
boolean b = saveOrUpdate(convert);
planservice.remove(Wrappers.<BusMaterialbatchdemandplan>lambdaQuery()
.eq(BusMaterialbatchdemandplan::getMrpBaseId,convert.getId()));
.eq(BusMaterialbatchdemandplan::getMrpBaseId, convert.getId()));
if(CollectionUtil.isNotEmpty(dto.getPlanList())){
List<BusMaterialbatchdemandplan> plans = MapstructUtils.convert(dto.getPlanList(), BusMaterialbatchdemandplan.class);
if (CollectionUtil.isNotEmpty(dto.getPlanList())) {
List<BusMaterialbatchdemandplan> plans = MapstructUtils.convert(dto.getPlanList(), BusMaterialbatchdemandplan.class);
plans.forEach(item -> {
item.setMrpBaseId(convert.getId());
item.setProjectId(convert.getProjectId());
@ -186,6 +191,31 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
return b;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean importData(BusMrpExportDto dto) {
try {
List<BusMaterialbatchdemandplanExportDto> dtoList = ExcelDynamicReader.readExcel(dto.getFile(), 1, 1, 7, BusMaterialbatchdemandplanExportDto.class);
BusMrpBase busMrpBase = BeanUtil.copyProperties(dto, BusMrpBase.class);
save(busMrpBase);
ArrayList<BusMaterialbatchdemandplan> busMaterialbatchdemandplans = new ArrayList<>();
for (BusMaterialbatchdemandplanExportDto plan : dtoList) {
BusMaterialbatchdemandplan plan1 = BeanUtil.copyProperties(plan, BusMaterialbatchdemandplan.class);
plan1.setMrpBaseId(busMrpBase.getId());
plan1.setProjectId(busMrpBase.getProjectId());
busMaterialbatchdemandplans.add(plan1);
}
planservice.saveBatch(busMaterialbatchdemandplans);
} catch (Exception e) {
throw new RuntimeException(e);
}
return true;
}
/**
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
* 正常使用只需#processEvent.flowCode=='leave1'
@ -232,24 +262,5 @@ public class BusMrpBaseServiceImpl extends ServiceImpl<BusMrpBaseMapper, BusMrpB
log.info("监听删除流程事件,收资清单审核任务执行了{}", processDeleteEvent.toString());
}
}

View File

@ -1,11 +1,22 @@
package org.dromara.cailiaoshebei.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan;
import org.dromara.cailiaoshebei.domain.BusMrpBase;
import org.dromara.cailiaoshebei.domain.BusPlanDocAssociation;
import org.dromara.cailiaoshebei.domain.bo.BusPlanDocAssociationBo;
import org.dromara.cailiaoshebei.domain.vo.BusPlanDocAssociationVo;
import org.dromara.cailiaoshebei.service.IBusMaterialbatchdemandplanService;
import org.dromara.cailiaoshebei.service.IBusMrpBaseService;
import org.dromara.cailiaoshebei.service.IBusPlanDocAssociationService;
import org.dromara.common.core.domain.event.ProcessDeleteEvent;
import org.dromara.common.core.domain.event.ProcessEvent;
import org.dromara.common.core.domain.event.ProcessTaskEvent;
import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -14,6 +25,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.dromara.cailiaoshebei.domain.bo.BusPurchaseDocBo;
import org.dromara.cailiaoshebei.domain.vo.BusPurchaseDocVo;
@ -22,9 +35,11 @@ import org.dromara.cailiaoshebei.mapper.BusPurchaseDocMapper;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
* 物资-采购联系单Service业务层处理
@ -34,12 +49,18 @@ import java.util.Collection;
*/
@RequiredArgsConstructor
@Service
@Slf4j
public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper, BusPurchaseDoc> implements IBusPurchaseDocService {
private final BusPurchaseDocMapper baseMapper;
private final IBusPlanDocAssociationService planDocAssociationService;
private final IBusMaterialbatchdemandplanService materialbatchdemandplanService;
private final IBusMrpBaseService mrpBaseService;
/**
* 查询物资-采购联系单
*
@ -47,7 +68,7 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
* @return 物资-采购联系单
*/
@Override
public BusPurchaseDocVo queryById(Long id){
public BusPurchaseDocVo queryById(Long id) {
BusPurchaseDocVo busPurchaseDocVo = baseMapper.selectVoById(id);
BusPlanDocAssociationBo busPlanDocAssociationBo = new BusPlanDocAssociationBo();
busPlanDocAssociationBo.setDocId(id);
@ -67,6 +88,9 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
public TableDataInfo<BusPurchaseDocVo> queryPageList(BusPurchaseDocBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<BusPurchaseDoc> lqw = buildQueryWrapper(bo);
Page<BusPurchaseDocVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
result.getRecords().forEach(v -> {
v.setPlanCode(mrpBaseService.getById(v.getMrpBaseId()).getPlanCode());
});
return TableDataInfo.build(result);
}
@ -116,6 +140,11 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean insertByBo(BusPurchaseDocBo bo) {
if (CollectionUtil.isEmpty(bo.getAssociationList())) {
throw new ServiceException("请与计划关联");
}
BusPurchaseDoc add = MapstructUtils.convert(bo, BusPurchaseDoc.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
@ -123,14 +152,13 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
bo.setId(add.getId());
}
//存入联系表
if(CollectionUtil.isNotEmpty(bo.getAssociationList())){
List<BusPlanDocAssociation> convert = MapstructUtils.convert(bo.getAssociationList(), BusPlanDocAssociation.class);
convert.forEach(item -> {
item.setProjectId(add.getProjectId());
item.setDocId(add.getId());
});
planDocAssociationService.saveBatch(convert);
}
List<BusPlanDocAssociation> convert = MapstructUtils.convert(bo.getAssociationList(), BusPlanDocAssociation.class);
convert.forEach(item -> {
item.setProjectId(add.getProjectId());
item.setDocId(add.getId());
});
planDocAssociationService.saveBatch(convert);
return flag;
}
@ -149,7 +177,7 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
.eq(BusPlanDocAssociation::getProjectId, update.getProjectId())
.eq(BusPlanDocAssociation::getDocId, update.getId()));
if(CollectionUtil.isNotEmpty(bo.getAssociationList())){
if (CollectionUtil.isNotEmpty(bo.getAssociationList())) {
List<BusPlanDocAssociation> convert = MapstructUtils.convert(bo.getAssociationList(), BusPlanDocAssociation.class);
convert.forEach(item -> {
item.setProjectId(update.getProjectId());
@ -163,7 +191,7 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(BusPurchaseDoc entity){
private void validEntityBeforeSave(BusPurchaseDoc entity) {
//TODO 做一些数据校验,如唯一约束
}
@ -176,9 +204,92 @@ public class BusPurchaseDocServiceImpl extends ServiceImpl<BusPurchaseDocMapper,
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
@Override
@Async
@Transactional(rollbackFor = Exception.class)
public void create(Long id, HashMap<Long, BigDecimal> map) {
BusPurchaseDoc busPurchaseDoc = baseMapper.selectById(id);
if (busPurchaseDoc == null) {
return;
}
if (CollectionUtil.isEmpty(map.keySet())) {
return;
}
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); // 年月日时分秒格式
String dateTimeStr = now.format(formatter);
busPurchaseDoc.setId(null);
busPurchaseDoc.setDocCode("BH-" + busPurchaseDoc.getDocCode() + "-" + dateTimeStr);
busPurchaseDoc.setFeedbackUrl(null);
busPurchaseDoc.setStatus(BusinessStatusEnum.DRAFT.getStatus());
busPurchaseDoc.setDocType("2");
save(busPurchaseDoc);
//创建计划
ArrayList<BusPlanDocAssociation> busPlanDocAssociations = new ArrayList<>();
for (Long planId : map.keySet()) {
BusPlanDocAssociation busPlanDocAssociation = new BusPlanDocAssociation();
busPlanDocAssociation.setProjectId(busPurchaseDoc.getProjectId());
busPlanDocAssociation.setPlanId(planId);
busPlanDocAssociation.setDocId(busPurchaseDoc.getId());
busPlanDocAssociations.add(busPlanDocAssociation);
}
planDocAssociationService.saveBatch(busPlanDocAssociations);
}
/**
* 总体流程监听(例如: 草稿,撤销,退回,作废,终止,已完成,单任务完成等)
* 正常使用只需#processEvent.flowCode=='leave1'
* 示例为了方便则使用startsWith匹配了全部示例key
*
* @param processEvent 参数
*/
@EventListener(condition = "#processEvent.flowCode.endsWith('purchaseDoc')")
public void processHandler(ProcessEvent processEvent) {
log.info("收资清单审核任务执行了{}", processEvent.toString());
BusPurchaseDoc purchaseDoc = this.getById(Convert.toLong(processEvent.getBusinessId()));
purchaseDoc.setStatus(processEvent.getStatus());
if (processEvent.getSubmit()) {
purchaseDoc.setStatus(BusinessStatusEnum.WAITING.getStatus());
purchaseDoc.setPreparedDate(LocalDate.now());
}
this.updateById(purchaseDoc);
}
/**
* 执行任务创建监听
* 示例:也可通过 @EventListener(condition = "#processTaskEvent.flowCode=='leave1'")进行判断
* 在方法中判断流程节点key
* if ("xxx".equals(processTaskEvent.getNodeCode())) {
* //执行业务逻辑
* }
*
* @param processTaskEvent 参数
*/
@EventListener(condition = "#processTaskEvent.flowCode.endsWith('purchaseDoc')")
public void processTaskHandler(ProcessTaskEvent processTaskEvent) {
log.info("收资清单审核任务创建了{}", processTaskEvent.toString());
}
/**
* 监听删除流程事件
* 正常使用只需#processDeleteEvent.flowCode=='leave1'
* 示例为了方便则使用startsWith匹配了全部示例key
*
* @param processDeleteEvent 参数
*/
@EventListener(condition = "#processDeleteEvent.flowCode.endsWith('purchaseDoc')")
public void processDeleteHandler(ProcessDeleteEvent processDeleteEvent) {
log.info("监听删除流程事件,收资清单审核任务执行了{}", processDeleteEvent.toString());
}
}

View File

@ -66,4 +66,5 @@ public class DesVolumeFileController extends BaseController {
@PathVariable Long[] ids) {
return toAjax(desVolumeFileService.deleteByIds(List.of(ids)));
}
}

View File

@ -0,0 +1,106 @@
package org.dromara.design.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.design.domain.vo.volumefileviewer.DesVolumeFileViewerVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.design.domain.bo.DesVolumeFileViewerBo;
import org.dromara.design.service.IDesVolumeFileViewerService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
/**
* 卷册文件查阅人
*
* @author lilemy
* @date 2025-08-14
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/design/volumeFileViewer")
public class DesVolumeFileViewerController extends BaseController {
private final IDesVolumeFileViewerService desVolumeFileViewerService;
/**
* 查询卷册文件查阅人列表
*/
@SaCheckPermission("design:volumeFileViewer:list")
@GetMapping("/list")
public TableDataInfo<DesVolumeFileViewerVo> list(DesVolumeFileViewerBo bo, PageQuery pageQuery) {
return desVolumeFileViewerService.queryPageList(bo, pageQuery);
}
/**
* 导出卷册文件查阅人列表
*/
@SaCheckPermission("design:volumeFileViewer:export")
@Log(title = "卷册文件查阅人", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(DesVolumeFileViewerBo bo, HttpServletResponse response) {
List<DesVolumeFileViewerVo> list = desVolumeFileViewerService.queryList(bo);
ExcelUtil.exportExcel(list, "卷册文件查阅人", DesVolumeFileViewerVo.class, response);
}
/**
* 获取卷册文件查阅人详细信息
*
* @param id 主键
*/
@SaCheckPermission("design:volumeFileViewer:query")
@GetMapping("/{id}")
public R<DesVolumeFileViewerVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(desVolumeFileViewerService.queryById(id));
}
/**
* 新增卷册文件查阅人
*/
@SaCheckPermission("design:volumeFileViewer:add")
@Log(title = "卷册文件查阅人", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody DesVolumeFileViewerBo bo) {
return toAjax(desVolumeFileViewerService.insertByBo(bo));
}
/**
* 修改卷册文件查阅人
*/
@SaCheckPermission("design:volumeFileViewer:edit")
@Log(title = "卷册文件查阅人", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody DesVolumeFileViewerBo bo) {
return toAjax(desVolumeFileViewerService.updateByBo(bo));
}
/**
* 删除卷册文件查阅人
*
* @param ids 主键串
*/
@SaCheckPermission("design:volumeFileViewer:remove")
@Log(title = "卷册文件查阅人", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(desVolumeFileViewerService.deleteWithValidByIds(List.of(ids), true));
}
}

View File

@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 卷册文件查阅人对象 des_volume_file_viewer
@ -31,6 +32,11 @@ public class DesVolumeFileViewer implements Serializable {
*/
private Long volumeCatalogId;
/**
* 卷册文件ID
*/
private Long volumeFileId;
/**
* 用户ID
*/
@ -41,4 +47,10 @@ public class DesVolumeFileViewer implements Serializable {
*/
private String status;
/**
* 创建时间
*/
private LocalDateTime createTime;
}

View File

@ -0,0 +1,43 @@
package org.dromara.design.domain.bo;
import org.dromara.design.domain.DesVolumeFileViewer;
import org.dromara.common.mybatis.core.domain.BaseEntity;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;
import jakarta.validation.constraints.*;
/**
* 卷册文件查阅人业务对象 des_volume_file_viewer
*
* @author lilemy
* @date 2025-08-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = DesVolumeFileViewer.class, reverseConvertGenerate = false)
public class DesVolumeFileViewerBo extends BaseEntity {
/**
* 主键ID
*/
@NotNull(message = "主键ID不能为空", groups = { EditGroup.class })
private Long id;
/**
* 卷册文件ID
*/
@NotNull(message = "卷册文件ID不能为空", groups = { AddGroup.class, EditGroup.class })
private Long volumeFileId;
private Long userId;
private String status;
}

View File

@ -1,15 +1,22 @@
package org.dromara.design.domain.vo.volumefileviewer;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.common.translation.annotation.Translation;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.design.domain.DesPrelimScheme;
import org.dromara.design.domain.DesVolumeFileViewer;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author lilemy
* @date 2025-07-30 19:52
*/
@Data
@AutoMapper(target = DesVolumeFileViewer.class)
public class DesVolumeFileViewerVo implements Serializable {
@Serial
@ -30,8 +37,20 @@ public class DesVolumeFileViewerVo implements Serializable {
*/
private Long userId;
/**
* 用户ID
*/
@Translation(type = TransConstant.USER_ID_TO_NAME, mapper = "userId")
private String userName;
/**
* 状态1未查阅 2已查阅
*/
private String status;
/**
* 创建时间
*/
private LocalDateTime createTime;
}

View File

@ -1,14 +1,73 @@
package org.dromara.design.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.design.domain.DesVolumeFileViewer;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.design.domain.bo.DesVolumeFileViewerBo;
import org.dromara.design.domain.vo.volumefileviewer.DesVolumeFileViewerVo;
import java.util.Collection;
import java.util.List;
/**
* 卷册文件查阅人Service接口
*
* @author lilemy
* @date 2025-07-30
* @date 2025-08-14
*/
public interface IDesVolumeFileViewerService extends IService<DesVolumeFileViewer> {
public interface IDesVolumeFileViewerService extends IService<DesVolumeFileViewer>{
/**
* 查询卷册文件查阅人
*
* @param id 主键
* @return 卷册文件查阅人
*/
DesVolumeFileViewerVo queryById(Long id);
/**
* 分页查询卷册文件查阅人列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 卷册文件查阅人分页列表
*/
TableDataInfo<DesVolumeFileViewerVo> queryPageList(DesVolumeFileViewerBo bo, PageQuery pageQuery);
/**
* 查询符合条件的卷册文件查阅人列表
*
* @param bo 查询条件
* @return 卷册文件查阅人列表
*/
List<DesVolumeFileViewerVo> queryList(DesVolumeFileViewerBo bo);
/**
* 新增卷册文件查阅人
*
* @param bo 卷册文件查阅人
* @return 是否新增成功
*/
Boolean insertByBo(DesVolumeFileViewerBo bo);
/**
* 修改卷册文件查阅人
*
* @param bo 卷册文件查阅人
* @return 是否修改成功
*/
Boolean updateByBo(DesVolumeFileViewerBo bo);
/**
* 校验并批量删除卷册文件查阅人信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -217,6 +218,9 @@ public class DesDesignChangeServiceImpl extends ServiceImpl<DesDesignChangeMappe
@Override
public DesDesignChangeVo insertByBo(DesDesignChangeCreateReq req) {
DesDesignChange entity = new DesDesignChange();
if (StrUtil.isBlank(req.getVolumeNo())) {
throw new ServiceException("请选择卷号");
}
BeanUtils.copyProperties(req, entity);
validEntityBeforeSave(entity, true);
entity.setDetail(JSONUtil.toJsonStr(req.getExtendDetail()));

View File

@ -1,19 +1,140 @@
package org.dromara.design.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.design.domain.vo.volumefileviewer.DesVolumeFileViewerVo;
import org.springframework.stereotype.Service;
import org.dromara.design.domain.bo.DesVolumeFileViewerBo;
import org.dromara.design.domain.DesVolumeFileViewer;
import org.dromara.design.mapper.DesVolumeFileViewerMapper;
import org.dromara.design.service.IDesVolumeFileViewerService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 卷册文件查阅人Service业务层处理
*
* @author lilemy
* @date 2025-07-30
* @date 2025-08-14
*/
@RequiredArgsConstructor
@Service
public class DesVolumeFileViewerServiceImpl extends ServiceImpl<DesVolumeFileViewerMapper, DesVolumeFileViewer>
implements IDesVolumeFileViewerService {
public class DesVolumeFileViewerServiceImpl extends ServiceImpl<DesVolumeFileViewerMapper, DesVolumeFileViewer> implements IDesVolumeFileViewerService {
private final DesVolumeFileViewerMapper baseMapper;
/**
* 查询卷册文件查阅人
*
* @param id 主键
* @return 卷册文件查阅人
*/
@Override
public DesVolumeFileViewerVo queryById(Long id){
return baseMapper.selectVoById(id);
}
/**
* 分页查询卷册文件查阅人列表
*
* @param bo 查询条件
* @param pageQuery 分页参数
* @return 卷册文件查阅人分页列表
*/
@Override
public TableDataInfo<DesVolumeFileViewerVo> queryPageList(DesVolumeFileViewerBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<DesVolumeFileViewer> lqw = buildQueryWrapper(bo);
Page<DesVolumeFileViewerVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询符合条件的卷册文件查阅人列表
*
* @param bo 查询条件
* @return 卷册文件查阅人列表
*/
@Override
public List<DesVolumeFileViewerVo> queryList(DesVolumeFileViewerBo bo) {
LambdaQueryWrapper<DesVolumeFileViewer> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<DesVolumeFileViewer> buildQueryWrapper(DesVolumeFileViewerBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<DesVolumeFileViewer> lqw = Wrappers.lambdaQuery();
lqw.orderByDesc(DesVolumeFileViewer::getId);
lqw.eq(bo.getVolumeFileId() != null, DesVolumeFileViewer::getVolumeFileId, bo.getVolumeFileId());
lqw.eq(bo.getUserId() != null, DesVolumeFileViewer::getUserId, bo.getUserId());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), DesVolumeFileViewer::getStatus, bo.getStatus());
return lqw;
}
/**
* 新增卷册文件查阅人
*
* @param bo 卷册文件查阅人
* @return 是否新增成功
*/
@Override
public Boolean insertByBo(DesVolumeFileViewerBo bo) {
DesVolumeFileViewer add = MapstructUtils.convert(bo, DesVolumeFileViewer.class);
validEntityBeforeSave(add);
add.setUserId(LoginHelper.getUserId());
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改卷册文件查阅人
*
* @param bo 卷册文件查阅人
* @return 是否修改成功
*/
@Override
public Boolean updateByBo(DesVolumeFileViewerBo bo) {
DesVolumeFileViewer update = MapstructUtils.convert(bo, DesVolumeFileViewer.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(DesVolumeFileViewer entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 校验并批量删除卷册文件查阅人信息
*
* @param ids 待删除的主键集合
* @param isValid 是否进行有效性校验
* @return 是否删除成功
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -74,4 +74,9 @@ public class MatMaterialReceiveItem extends BaseEntity {
*/
private String remark;
/**
* 需求计划Id
*/
private Long planId;
}

View File

@ -55,4 +55,10 @@ public class MatMaterialReceiveItemDto {
*/
private String remark;
/**
* 需求计划Id
*/
private Long planId;
}

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.materials.domain.MatMaterials;
import org.dromara.materials.domain.dto.materialreceiveitem.MatMaterialReceiveItemDto;
import org.dromara.materials.domain.dto.materials.MatMaterialsCreateReq;
import org.dromara.materials.domain.dto.materials.MatMaterialsGisReq;
import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
@ -105,4 +106,11 @@ public interface IMatMaterialsService extends IService<MatMaterials> {
* @return 材料分页对象视图
*/
Page<MatMaterialsVo> getMaterialsVoPage(Page<MatMaterials> materialsPage);
/**
* 生成材料并入库
*/
void create(Long projectId, List<MatMaterialReceiveItemDto> itemList);
}

View File

@ -10,6 +10,8 @@ import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.dromara.cailiaoshebei.domain.BusMaterialbatchdemandplan;
import org.dromara.cailiaoshebei.service.IBusPurchaseDocService;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.ObjectUtils;
@ -34,6 +36,7 @@ import org.dromara.materials.domain.vo.materialreceive.MatMaterialReceiveVo;
import org.dromara.materials.mapper.MatMaterialReceiveMapper;
import org.dromara.materials.service.IMatMaterialReceiveItemService;
import org.dromara.materials.service.IMatMaterialReceiveService;
import org.dromara.materials.service.IMatMaterialsService;
import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.service.ISysOssService;
@ -72,6 +75,12 @@ public class MatMaterialReceiveServiceImpl extends ServiceImpl<MatMaterialReceiv
@Resource
private IMatMaterialReceiveItemService materialReceiveItemService;
@Resource
private IBusPurchaseDocService purchaseDocService;
@Resource
private IMatMaterialsService materialsService;
/**
* 查询物料接收单
*
@ -237,22 +246,37 @@ public class MatMaterialReceiveServiceImpl extends ServiceImpl<MatMaterialReceiv
throw new ServiceException("物料接收单新增失败", HttpStatus.ERROR);
}
List<MatMaterialReceiveItemDto> itemList = req.getItemList();
HashMap<Long, BigDecimal> map = new HashMap<>();
if (CollUtil.isNotEmpty(itemList)) {
List<MatMaterialReceiveItem> materialReceiveItemList = itemList.stream().map(item -> {
List<MatMaterialReceiveItem> materialReceiveItemList = new ArrayList<>();
for (MatMaterialReceiveItemDto item : itemList) {
MatMaterialReceiveItem materialReceiveItem = new MatMaterialReceiveItem();
BeanUtils.copyProperties(item, materialReceiveItem);
materialReceiveItem.setReceiveId(materialReceive.getId());
materialReceiveItem.setProjectId(materialReceive.getProjectId());
return materialReceiveItem;
}).toList();
//生成缺货采购单
if(item.getShortageQuantity().compareTo(BigDecimal.ZERO) > 0){
map.put(item.getPlanId(),item.getShortageQuantity());
}
materialReceiveItemList.add(materialReceiveItem);
}
boolean result = materialReceiveItemService.saveBatch(materialReceiveItemList);
if (!result) {
throw new RuntimeException("物料接收单明细项新增失败");
}
//生成缺货采购单
purchaseDocService.create(materialReceive.getDocId(), map);
//生成库存
materialsService.create(materialReceive.getProjectId(), itemList);
}
return true;
}
/**
* 修改物料接收单
*

View File

@ -5,6 +5,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
@ -18,6 +19,9 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.materials.domain.MatMaterials;
import org.dromara.materials.domain.MatMaterialsInventory;
import org.dromara.materials.domain.dto.materialreceiveitem.MatMaterialReceiveItemDto;
import org.dromara.materials.domain.dto.materialsinventory.MatMaterialsInventoryCreateReq;
import org.dromara.materials.domain.dto.materialsinventory.MatMaterialsInventoryUpdateReq;
import org.dromara.materials.domain.enums.MatMaterialsInventoryOutPutEnum;
import org.dromara.materials.domain.dto.materials.MatMaterialsCreateReq;
import org.dromara.materials.domain.dto.materials.MatMaterialsGisReq;
@ -33,12 +37,11 @@ import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusProjectService;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -61,6 +64,7 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
@Resource
private IMatMaterialsInventoryService materialsInventoryService;
/**
* 查询材料名称
*
@ -345,4 +349,43 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
materialsVoPage.setRecords(materialsVoList);
return materialsVoPage;
}
@Override
@Async
public void create(Long projectId,List<MatMaterialReceiveItemDto> itemList) {
for (MatMaterialReceiveItemDto item : itemList) {
Long materialsId ;
MatMaterials one = this.getOne(Wrappers.<MatMaterials>lambdaQuery()
.eq(MatMaterials::getMaterialsName, item.getName())
.eq(MatMaterials::getTypeSpecificationName, item.getSpecification()));
if (one != null) {
materialsId = one.getId();
BigDecimal bigDecimal = new BigDecimal(one.getQuantityCount());
BigDecimal add = item.getQuantity().add(bigDecimal);
one.setQuantityCount(add.toString());
}else {
MatMaterials matMaterials = new MatMaterials();
matMaterials.setMaterialsName(item.getName());
matMaterials.setProjectId(projectId);
matMaterials.setTypeSpecificationName(item.getSpecification());
matMaterials.setWeightId(item.getUnit());
matMaterials.setQuantityCount(item.getQuantity().toString());
save(matMaterials);
materialsId = matMaterials.getId();
}
MatMaterialsInventoryCreateReq req = new MatMaterialsInventoryCreateReq();
req.setMaterialsId(materialsId);
req.setProjectId(projectId);
req.setOutPut("0");
req.setNumber(item.getAcceptedQuantity().longValue());
req.setOutPutTime(new Date());
req.setOperator(LoginHelper.getUsername());
materialsInventoryService.insertByBo(req);
}
}
}