修改材料设备出入库逻辑
This commit is contained in:
@ -18,7 +18,6 @@ import org.dromara.materials.domain.dto.materialissue.MatMaterialIssueUpdateReq;
|
|||||||
import org.dromara.materials.domain.vo.materialissue.MatMaterialIssueVo;
|
import org.dromara.materials.domain.vo.materialissue.MatMaterialIssueVo;
|
||||||
import org.dromara.materials.domain.vo.materialsinventory.MatMaterialsInventoryListVo;
|
import org.dromara.materials.domain.vo.materialsinventory.MatMaterialsInventoryListVo;
|
||||||
import org.dromara.materials.service.IMatMaterialIssueService;
|
import org.dromara.materials.service.IMatMaterialIssueService;
|
||||||
import org.dromara.materials.service.IMatMaterialsInventoryService;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -37,8 +36,6 @@ public class MatMaterialIssueController extends BaseController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private IMatMaterialIssueService matMaterialIssueService;
|
private IMatMaterialIssueService matMaterialIssueService;
|
||||||
@Resource
|
|
||||||
private IMatMaterialsInventoryService materialsInventoryService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询物料领料单列表
|
* 查询物料领料单列表
|
||||||
|
@ -19,6 +19,7 @@ import org.dromara.materials.domain.dto.materials.MatMaterialsCreateReq;
|
|||||||
import org.dromara.materials.domain.dto.materials.MatMaterialsGisReq;
|
import org.dromara.materials.domain.dto.materials.MatMaterialsGisReq;
|
||||||
import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
|
import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
|
||||||
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
|
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
|
||||||
|
import org.dromara.materials.domain.vo.materials.MatMaterialsByFormCodeVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsGisVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsGisVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsNumberVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsNumberVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsVo;
|
||||||
@ -81,6 +82,18 @@ public class MatMaterialsController extends BaseController {
|
|||||||
return R.ok(materialsService.queryInventoryList(projectId));
|
return R.ok(materialsService.queryInventoryList(projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取材料列表
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("materials:materials:listByFormCode")
|
||||||
|
@GetMapping("/listByFormCode/{projectId}")
|
||||||
|
public R<List<MatMaterialsByFormCodeVo>> listMaterialsByFormCode(@NotNull(message = "项目id不能为空")
|
||||||
|
@PathVariable Long projectId) {
|
||||||
|
return R.ok(materialsService.queryMaterialsByFormCode(projectId));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取材料详细信息
|
* 获取材料详细信息
|
||||||
*
|
*
|
||||||
|
@ -43,6 +43,11 @@ public class MatMaterials extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单编号
|
||||||
|
*/
|
||||||
|
private String formCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格型号名称
|
* 规格型号名称
|
||||||
*/
|
*/
|
||||||
@ -53,11 +58,6 @@ public class MatMaterials extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String fileOssId;
|
private String fileOssId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用部位
|
|
||||||
*/
|
|
||||||
private String usePart;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量单位
|
* 计量单位
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.dromara.materials.domain.dto.materialreceive;
|
package org.dromara.materials.domain.dto.materialreceive;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.dromara.materials.domain.dto.materialreceiveitem.MatMaterialReceiveItemDto;
|
import org.dromara.materials.domain.dto.materialreceiveitem.MatMaterialReceiveItemDto;
|
||||||
|
|
||||||
@ -20,26 +22,31 @@ public class MatMaterialReceiveCreateReq implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 项目id
|
* 项目id
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "项目id不能为空")
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 材料来源(1甲供 2乙供)
|
* 材料来源(1甲供 2乙供)
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "材料来源不能为空")
|
||||||
private String materialSource;
|
private String materialSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表单编号
|
* 表单编号
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "表单编号不能为空")
|
||||||
private String formCode;
|
private String formCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工程名称
|
* 工程名称
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "工程名称不能为空")
|
||||||
private String projectName;
|
private String projectName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备材料名称
|
* 设备材料名称
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "设备材料名称不能为空")
|
||||||
private String materialName;
|
private String materialName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,11 @@ public class MatMaterialsCreateReq implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单编号
|
||||||
|
*/
|
||||||
|
private String formCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格型号名称
|
* 规格型号名称
|
||||||
*/
|
*/
|
||||||
|
@ -4,7 +4,6 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author lilemy
|
* @author lilemy
|
||||||
@ -36,31 +35,21 @@ public class MatMaterialsQueryReq implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单编号
|
||||||
|
*/
|
||||||
|
private String formCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格型号名称
|
* 规格型号名称
|
||||||
*/
|
*/
|
||||||
private String typeSpecificationName;
|
private String typeSpecificationName;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件对象存储id列表
|
|
||||||
*/
|
|
||||||
private Map<String, Long> fileOssIdMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用部位
|
|
||||||
*/
|
|
||||||
private String usePart;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量单位
|
* 计量单位
|
||||||
*/
|
*/
|
||||||
private String weightId;
|
private String weightId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预计材料数量
|
* 预计材料数量
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package org.dromara.materials.domain.vo.materials;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author lilemy
|
||||||
|
* @date 2025-09-01 16:24
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MatMaterialsByFormCodeVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = -2113420582630471078L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单编号
|
||||||
|
*/
|
||||||
|
private String formCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工程名称
|
||||||
|
*/
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备材料名称
|
||||||
|
*/
|
||||||
|
private String materialName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订货单位
|
||||||
|
*/
|
||||||
|
private String orderingUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 供货单位
|
||||||
|
*/
|
||||||
|
private String supplierUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备材料列表
|
||||||
|
*/
|
||||||
|
private List<MatMaterialsNumberVo> materials;
|
||||||
|
}
|
@ -59,6 +59,12 @@ public class MatMaterialsVo implements Serializable {
|
|||||||
@ExcelProperty(value = "项目id")
|
@ExcelProperty(value = "项目id")
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表单编号
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "表单编号")
|
||||||
|
private String formCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格型号名称
|
* 规格型号名称
|
||||||
*/
|
*/
|
||||||
@ -70,12 +76,6 @@ public class MatMaterialsVo implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Map<String, Long> fileOssMap;
|
private Map<String, Long> fileOssMap;
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用部位
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "使用部位")
|
|
||||||
private String usePart;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量单位
|
* 计量单位
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@ import org.dromara.materials.domain.dto.materials.MatMaterialsCreateReq;
|
|||||||
import org.dromara.materials.domain.dto.materials.MatMaterialsGisReq;
|
import org.dromara.materials.domain.dto.materials.MatMaterialsGisReq;
|
||||||
import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
|
import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
|
||||||
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
|
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
|
||||||
|
import org.dromara.materials.domain.vo.materials.MatMaterialsByFormCodeVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsGisVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsGisVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsNumberVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsNumberVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsVo;
|
||||||
@ -111,7 +112,7 @@ public interface IMatMaterialsService extends IService<MatMaterials> {
|
|||||||
/**
|
/**
|
||||||
* 生成材料并入库
|
* 生成材料并入库
|
||||||
*/
|
*/
|
||||||
void create(Long projectId, List<MatMaterialReceiveItemDto> itemList,String nickname);
|
void create(Long projectId, List<MatMaterialReceiveItemDto> itemList, String formCode, String nickname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取材料库存数据列表
|
* 获取材料库存数据列表
|
||||||
@ -121,4 +122,11 @@ public interface IMatMaterialsService extends IService<MatMaterials> {
|
|||||||
*/
|
*/
|
||||||
List<MatMaterialsNumberVo> queryInventoryList(Long projectId);
|
List<MatMaterialsNumberVo> queryInventoryList(Long projectId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取材料库存数据列表
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @return 材料库存数据列表
|
||||||
|
*/
|
||||||
|
List<MatMaterialsByFormCodeVo> queryMaterialsByFormCode(Long projectId);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|||||||
import org.dromara.common.oss.core.OssClient;
|
import org.dromara.common.oss.core.OssClient;
|
||||||
import org.dromara.common.oss.exception.OssException;
|
import org.dromara.common.oss.exception.OssException;
|
||||||
import org.dromara.common.oss.factory.OssFactory;
|
import org.dromara.common.oss.factory.OssFactory;
|
||||||
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.common.utils.DocumentUtil;
|
import org.dromara.common.utils.DocumentUtil;
|
||||||
import org.dromara.materials.constants.MatMaterialsConstant;
|
import org.dromara.materials.constants.MatMaterialsConstant;
|
||||||
import org.dromara.materials.domain.MatMaterialIssue;
|
import org.dromara.materials.domain.MatMaterialIssue;
|
||||||
@ -35,6 +36,7 @@ import org.dromara.materials.domain.dto.materialissue.MatMaterialIssueUpdateReq;
|
|||||||
import org.dromara.materials.domain.dto.materialissue.MatMaterialIssueWordDto;
|
import org.dromara.materials.domain.dto.materialissue.MatMaterialIssueWordDto;
|
||||||
import org.dromara.materials.domain.dto.materialissueitem.MatMaterialIssueItemDto;
|
import org.dromara.materials.domain.dto.materialissueitem.MatMaterialIssueItemDto;
|
||||||
import org.dromara.materials.domain.dto.materialissueitem.MatMaterialIssueItemWordDto;
|
import org.dromara.materials.domain.dto.materialissueitem.MatMaterialIssueItemWordDto;
|
||||||
|
import org.dromara.materials.domain.enums.MatMaterialsInventoryOutPutEnum;
|
||||||
import org.dromara.materials.domain.vo.materialissue.MatMaterialIssueVo;
|
import org.dromara.materials.domain.vo.materialissue.MatMaterialIssueVo;
|
||||||
import org.dromara.materials.domain.vo.materialsinventory.MatMaterialsInventoryListVo;
|
import org.dromara.materials.domain.vo.materialsinventory.MatMaterialsInventoryListVo;
|
||||||
import org.dromara.materials.mapper.MatMaterialIssueMapper;
|
import org.dromara.materials.mapper.MatMaterialIssueMapper;
|
||||||
@ -238,6 +240,7 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean insertByBo(MatMaterialIssueCreateReq req) {
|
public Boolean insertByBo(MatMaterialIssueCreateReq req) {
|
||||||
|
String nickname = LoginHelper.getLoginUser().getNickname();
|
||||||
MatMaterialIssue materialIssue = new MatMaterialIssue();
|
MatMaterialIssue materialIssue = new MatMaterialIssue();
|
||||||
BeanUtils.copyProperties(req, materialIssue);
|
BeanUtils.copyProperties(req, materialIssue);
|
||||||
validEntityBeforeSave(materialIssue, true);
|
validEntityBeforeSave(materialIssue, true);
|
||||||
@ -264,14 +267,14 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
|
|||||||
throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR);
|
throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR);
|
||||||
}
|
}
|
||||||
// 创建设备材料出库记录
|
// 创建设备材料出库记录
|
||||||
/*List<MatMaterialsInventory> inventoryList = itemList.stream().map(item -> {
|
List<MatMaterialsInventory> inventoryList = itemList.stream().map(item -> {
|
||||||
MatMaterialsInventory inventory = new MatMaterialsInventory();
|
MatMaterialsInventory inventory = new MatMaterialsInventory();
|
||||||
inventory.setNumber(item.getIssuedQuantity().longValue());
|
inventory.setNumber(item.getIssuedQuantity().longValue());
|
||||||
inventory.setOutPutTime(new Date());
|
inventory.setOutPutTime(new Date());
|
||||||
inventory.setResidue(item.getRemainingQuantity().longValue());
|
inventory.setResidue(item.getRemainingQuantity().longValue());
|
||||||
inventory.setOperator(LoginHelper.getLoginUser().getNickname());
|
inventory.setOperator(nickname);
|
||||||
inventory.setRecipient(materialIssue.getIssueUnit());
|
inventory.setRecipient(materialIssue.getIssueUnit());
|
||||||
inventory.setShipper(LoginHelper.getLoginUser().getNickname());
|
inventory.setShipper(nickname);
|
||||||
inventory.setMaterialsId(item.getMaterialsId());
|
inventory.setMaterialsId(item.getMaterialsId());
|
||||||
inventory.setProjectId(materialIssue.getProjectId());
|
inventory.setProjectId(materialIssue.getProjectId());
|
||||||
inventory.setOutPut(MatMaterialsInventoryOutPutEnum.OUT.getValue());
|
inventory.setOutPut(MatMaterialsInventoryOutPutEnum.OUT.getValue());
|
||||||
@ -281,7 +284,7 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
|
|||||||
boolean saved = materialsInventoryService.saveBatch(inventoryList);
|
boolean saved = materialsInventoryService.saveBatch(inventoryList);
|
||||||
if (!saved) {
|
if (!saved) {
|
||||||
throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
|
throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ public class MatMaterialReceiveServiceImpl extends ServiceImpl<MatMaterialReceiv
|
|||||||
purchaseDocService.create(materialReceive.getDocId(), map);
|
purchaseDocService.create(materialReceive.getDocId(), map);
|
||||||
}
|
}
|
||||||
//生成库存
|
//生成库存
|
||||||
materialsService.create(materialReceive.getProjectId(), itemList, nickname);
|
materialsService.create(materialReceive.getProjectId(), itemList, materialReceive.getFormCode(), nickname);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import cn.hutool.json.JSONObject;
|
|||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -17,6 +16,7 @@ import org.dromara.common.json.utils.JsonUtils;
|
|||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
|
import org.dromara.materials.domain.MatMaterialReceive;
|
||||||
import org.dromara.materials.domain.MatMaterials;
|
import org.dromara.materials.domain.MatMaterials;
|
||||||
import org.dromara.materials.domain.MatMaterialsInventory;
|
import org.dromara.materials.domain.MatMaterialsInventory;
|
||||||
import org.dromara.materials.domain.dto.materialreceiveitem.MatMaterialReceiveItemDto;
|
import org.dromara.materials.domain.dto.materialreceiveitem.MatMaterialReceiveItemDto;
|
||||||
@ -26,11 +26,13 @@ import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
|
|||||||
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
|
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
|
||||||
import org.dromara.materials.domain.dto.materialsinventory.MatMaterialsInventoryCreateReq;
|
import org.dromara.materials.domain.dto.materialsinventory.MatMaterialsInventoryCreateReq;
|
||||||
import org.dromara.materials.domain.enums.MatMaterialsInventoryOutPutEnum;
|
import org.dromara.materials.domain.enums.MatMaterialsInventoryOutPutEnum;
|
||||||
|
import org.dromara.materials.domain.vo.materials.MatMaterialsByFormCodeVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsGisVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsGisVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsNumberVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsNumberVo;
|
||||||
import org.dromara.materials.domain.vo.materials.MatMaterialsVo;
|
import org.dromara.materials.domain.vo.materials.MatMaterialsVo;
|
||||||
import org.dromara.materials.mapper.MatMaterialsMapper;
|
import org.dromara.materials.mapper.MatMaterialsMapper;
|
||||||
import org.dromara.materials.service.IMatCompanyService;
|
import org.dromara.materials.service.IMatCompanyService;
|
||||||
|
import org.dromara.materials.service.IMatMaterialReceiveService;
|
||||||
import org.dromara.materials.service.IMatMaterialsInventoryService;
|
import org.dromara.materials.service.IMatMaterialsInventoryService;
|
||||||
import org.dromara.materials.service.IMatMaterialsService;
|
import org.dromara.materials.service.IMatMaterialsService;
|
||||||
import org.dromara.project.domain.BusProject;
|
import org.dromara.project.domain.BusProject;
|
||||||
@ -65,6 +67,10 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
|
|||||||
@Resource
|
@Resource
|
||||||
private IMatMaterialsInventoryService materialsInventoryService;
|
private IMatMaterialsInventoryService materialsInventoryService;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Resource
|
||||||
|
private IMatMaterialReceiveService materialReceiveService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询材料名称
|
* 查询材料名称
|
||||||
@ -310,16 +316,12 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
|
|||||||
Long companyId = req.getCompanyId();
|
Long companyId = req.getCompanyId();
|
||||||
Long projectId = req.getProjectId();
|
Long projectId = req.getProjectId();
|
||||||
String typeSpecificationName = req.getTypeSpecificationName();
|
String typeSpecificationName = req.getTypeSpecificationName();
|
||||||
String usePart = req.getUsePart();
|
|
||||||
String weightId = req.getWeightId();
|
String weightId = req.getWeightId();
|
||||||
String remark = req.getRemark();
|
|
||||||
String quantityCount = req.getQuantityCount();
|
String quantityCount = req.getQuantityCount();
|
||||||
String status = req.getStatus();
|
String status = req.getStatus();
|
||||||
// 模糊查询
|
// 模糊查询
|
||||||
lqw.like(StringUtils.isNotBlank(materialsName), MatMaterials::getMaterialsName, materialsName);
|
lqw.like(StringUtils.isNotBlank(materialsName), MatMaterials::getMaterialsName, materialsName);
|
||||||
lqw.like(StringUtils.isNotBlank(typeSpecificationName), MatMaterials::getTypeSpecificationName, typeSpecificationName);
|
lqw.like(StringUtils.isNotBlank(typeSpecificationName), MatMaterials::getTypeSpecificationName, typeSpecificationName);
|
||||||
lqw.like(StringUtils.isNotBlank(usePart), MatMaterials::getUsePart, usePart);
|
|
||||||
lqw.like(StringUtils.isNotBlank(remark), MatMaterials::getRemark, remark);
|
|
||||||
lqw.like(StringUtils.isNotBlank(weightId), MatMaterials::getWeightId, weightId);
|
lqw.like(StringUtils.isNotBlank(weightId), MatMaterials::getWeightId, weightId);
|
||||||
lqw.like(StringUtils.isNotBlank(quantityCount), MatMaterials::getQuantityCount, quantityCount);
|
lqw.like(StringUtils.isNotBlank(quantityCount), MatMaterials::getQuantityCount, quantityCount);
|
||||||
// 精确查询
|
// 精确查询
|
||||||
@ -353,33 +355,18 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Async
|
@Async
|
||||||
public void create(Long projectId, List<MatMaterialReceiveItemDto> itemList, String nickname) {
|
public void create(Long projectId, List<MatMaterialReceiveItemDto> itemList, String formCode, String nickname) {
|
||||||
for (MatMaterialReceiveItemDto item : itemList) {
|
for (MatMaterialReceiveItemDto item : itemList) {
|
||||||
|
MatMaterials matMaterials = new MatMaterials();
|
||||||
Long materialsId;
|
matMaterials.setMaterialsName(item.getName());
|
||||||
|
matMaterials.setProjectId(projectId);
|
||||||
MatMaterials one = this.getOne(Wrappers.<MatMaterials>lambdaQuery()
|
matMaterials.setTypeSpecificationName(item.getSpecification());
|
||||||
.eq(MatMaterials::getMaterialsName, item.getName())
|
matMaterials.setWeightId(item.getUnit());
|
||||||
.eq(MatMaterials::getTypeSpecificationName, item.getSpecification()));
|
matMaterials.setQuantityCount(item.getQuantity().toString());
|
||||||
if (one != null) {
|
matMaterials.setFormCode(formCode);
|
||||||
materialsId = one.getId();
|
save(matMaterials);
|
||||||
BigDecimal bigDecimal = new BigDecimal(one.getQuantityCount());
|
Long materialsId = matMaterials.getId();
|
||||||
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();
|
MatMaterialsInventoryCreateReq req = new MatMaterialsInventoryCreateReq();
|
||||||
|
|
||||||
req.setMaterialsId(materialsId);
|
req.setMaterialsId(materialsId);
|
||||||
req.setProjectId(projectId);
|
req.setProjectId(projectId);
|
||||||
req.setOutPut(MatMaterialsInventoryOutPutEnum.PUT.getValue());
|
req.setOutPut(MatMaterialsInventoryOutPutEnum.PUT.getValue());
|
||||||
@ -418,4 +405,75 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
|
|||||||
return vo;
|
return vo;
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取材料库存数据列表
|
||||||
|
*
|
||||||
|
* @param projectId 项目id
|
||||||
|
* @return 材料库存数据列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<MatMaterialsByFormCodeVo> queryMaterialsByFormCode(Long projectId) {
|
||||||
|
List<MatMaterials> materials = this.lambdaQuery()
|
||||||
|
.eq(MatMaterials::getProjectId, projectId)
|
||||||
|
.eq(MatMaterials::getStatus, "0")
|
||||||
|
.list();
|
||||||
|
if (CollUtil.isEmpty(materials)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<Long> materialIds = materials.stream()
|
||||||
|
.filter(material -> StringUtils.isNotBlank(material.getFormCode()))
|
||||||
|
.map(MatMaterials::getId)
|
||||||
|
.toList();
|
||||||
|
List<MatMaterialsInventory> materialsInventories = materialsInventoryService.selectLatestByMaterialIds(materialIds);
|
||||||
|
Map<Long, MatMaterialsInventory> inventoryMap = materialsInventories.stream().collect(Collectors.toMap(
|
||||||
|
MatMaterialsInventory::getMaterialsId,
|
||||||
|
Function.identity(),
|
||||||
|
(a, b) -> a));
|
||||||
|
Map<String, List<MatMaterials>> formCodeMap = materials.stream()
|
||||||
|
.collect(Collectors.groupingBy(MatMaterials::getFormCode));
|
||||||
|
Set<String> formCodeList = materials.stream().map(MatMaterials::getFormCode).collect(Collectors.toSet());
|
||||||
|
List<MatMaterialReceive> receiveList = materialReceiveService.lambdaQuery()
|
||||||
|
.in(MatMaterialReceive::getFormCode, formCodeList)
|
||||||
|
.list();
|
||||||
|
Map<String, MatMaterialReceive> receiveMap = receiveList.stream().collect(Collectors.toMap(
|
||||||
|
MatMaterialReceive::getFormCode,
|
||||||
|
Function.identity(),
|
||||||
|
(a, b) -> a));
|
||||||
|
List<MatMaterialsByFormCodeVo> resultList = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, List<MatMaterials>> entry : formCodeMap.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
List<MatMaterials> value = entry.getValue();
|
||||||
|
List<MatMaterials> list = value.stream().filter(material -> {
|
||||||
|
Long materialId = material.getId();
|
||||||
|
if (inventoryMap.containsKey(materialId)) {
|
||||||
|
MatMaterialsInventory inventory = inventoryMap.get(materialId);
|
||||||
|
Long residue = inventory.getResidue();
|
||||||
|
return residue > 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}).toList();
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MatMaterialsByFormCodeVo vo = new MatMaterialsByFormCodeVo();
|
||||||
|
vo.setFormCode(key);
|
||||||
|
if (receiveMap.containsKey(key)) {
|
||||||
|
MatMaterialReceive receive = receiveMap.get(key);
|
||||||
|
BeanUtils.copyProperties(receive, vo);
|
||||||
|
}
|
||||||
|
List<MatMaterialsNumberVo> numberVos = value.stream().map(material -> {
|
||||||
|
MatMaterialsNumberVo numberVo = new MatMaterialsNumberVo();
|
||||||
|
BeanUtils.copyProperties(material, numberVo);
|
||||||
|
Long materialId = material.getId();
|
||||||
|
if (inventoryMap.containsKey(materialId)) {
|
||||||
|
numberVo.setInventoryNumber(BigDecimal.valueOf(inventoryMap.get(materialId).getNumber()));
|
||||||
|
}
|
||||||
|
return numberVo;
|
||||||
|
}).toList();
|
||||||
|
vo.setMaterials(numberVos);
|
||||||
|
resultList.add(vo);
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,4 +156,9 @@ public class BusProject extends BaseEntity {
|
|||||||
@TableLogic
|
@TableLogic
|
||||||
private Long isDelete;
|
private Long isDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* go项目id
|
||||||
|
*/
|
||||||
|
private Long goId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
Map<Long, List<BusProject>> projectMap = projectService.lambdaQuery()
|
Map<Long, List<BusProject>> projectMap = projectService.lambdaQuery()
|
||||||
.select(BusProject::getId, BusProject::getPId, BusProject::getProjectName, BusProject::getShortName)
|
.select(BusProject::getId, BusProject::getPId, BusProject::getProjectName, BusProject::getShortName, BusProject::getGoId)
|
||||||
.in(BusProject::getId, projectIdList)
|
.in(BusProject::getId, projectIdList)
|
||||||
.eq(BusProject::getPId, BusProjectConstant.PARENT_ID)
|
.eq(BusProject::getPId, BusProjectConstant.PARENT_ID)
|
||||||
.list()
|
.list()
|
||||||
@ -328,6 +328,7 @@ public class BusUserProjectRelevancyServiceImpl extends ServiceImpl<BusUserProje
|
|||||||
loginUserProjectRelevancy.setProjectId(projectId);
|
loginUserProjectRelevancy.setProjectId(projectId);
|
||||||
loginUserProjectRelevancy.setProjectName(project.getProjectName());
|
loginUserProjectRelevancy.setProjectName(project.getProjectName());
|
||||||
loginUserProjectRelevancy.setShortName(project.getShortName());
|
loginUserProjectRelevancy.setShortName(project.getShortName());
|
||||||
|
loginUserProjectRelevancy.setGoId(project.getGoId());
|
||||||
return loginUserProjectRelevancy;
|
return loginUserProjectRelevancy;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user