入库单自动把采购单的字段显示出来,并且可以修改,非必填,需要有搜索功能。显示时按分类进行分组展示,可以按分类进行展开收起
This commit is contained in:
parent
b41ec206ac
commit
1af4c1ab53
@ -120,15 +120,15 @@ public class DlRepairSoController {
|
||||
/**
|
||||
* 采购入库
|
||||
*
|
||||
* @param repairSoReqVO DlRepairSoReqVO实体
|
||||
* @param repairSoRespVO DlRepairSoReqVO实体
|
||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
|
||||
* @author PQZ
|
||||
* @date 10:43 2024/10/25
|
||||
**/
|
||||
@PostMapping("/inWare")
|
||||
@Operation(summary = "采购入库")
|
||||
public CommonResult<?> inWare(@RequestBody DlRepairSoReqVO repairSoReqVO) {
|
||||
dlRepairSoService.inWare(repairSoReqVO);
|
||||
public CommonResult<?> inWare(@RequestBody DlRepairSoRespVO repairSoRespVO) {
|
||||
dlRepairSoService.inWare(repairSoRespVO);
|
||||
return CommonResult.ok();
|
||||
}
|
||||
}
|
||||
|
@ -75,5 +75,18 @@ public class DlRepairSoiController{
|
||||
public CommonResult<?> getRepairSoiBySoId(@RequestParam(value = "soId") String soId){
|
||||
return success(dlRepairSoiService.getRepairSoiBySoId(soId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主表的ID得到子表的所有数据,按类型区分的map,支持条件查询
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:51 2024/11/19
|
||||
* @param id id
|
||||
**/
|
||||
@GetMapping("/getMapBySoIdAndQuery")
|
||||
@Operation(summary = "根据主表的ID得到子表的所有数据,按类型区分的map,支持条件查询")
|
||||
public CommonResult<?> getMapBySoIdAndQuery(@RequestParam("id") String id, @RequestParam("query") String query) {
|
||||
return success(dlRepairSoiService.getMapBySoIdAndQuery(id, query));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,6 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 采购单领料单子表
|
||||
* @TableName dl_repair_soi
|
||||
*/
|
||||
/**
|
||||
* 采购单/领料单子表
|
||||
* @author 小李
|
||||
|
@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 针对表【dl_repair_so(采购单领料单)】的数据库操作Mapper
|
||||
* @author 小李
|
||||
|
@ -2,12 +2,15 @@ package cn.iocoder.yudao.module.stockOperate.mapper;
|
||||
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiReqVO;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiRespVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 针对表【dl_repair_soi(采购单领料单子表)】的数据库操作Mapper
|
||||
* @author 小李
|
||||
@ -24,6 +27,15 @@ public interface DlRepairSoiMapper extends BaseMapper<DlRepairSoi> {
|
||||
* @param repairSoiReqVO 查询对象
|
||||
**/
|
||||
IPage<DlRepairSoi> getRepairSoiPage(@Param("map") DlRepairSoiReqVO repairSoiReqVO, Page<DlRepairSoi> page);
|
||||
|
||||
/**
|
||||
* 根据主表的ID得到子表的所有数据,按类型区分的map,支持条件查询
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:51 2024/11/19
|
||||
* @param id id
|
||||
**/
|
||||
List<DlRepairSoiRespVO> getMapBySoIdAndQuery(@Param("id") String id, @Param("query") String query);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,6 +7,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 针对表【dl_repair_so(采购单领料单)】的数据库操作Service
|
||||
*
|
||||
@ -72,9 +75,9 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
|
||||
/**
|
||||
* 采购入库
|
||||
*
|
||||
* @param reqVO (接参实体中需传入:采购单id,子表中商品id,子表中入库数量inCount)
|
||||
* @param repairSoRespVO (接参实体中需传入:采购单id,子表中商品id,子表中入库数量inCount)
|
||||
* @author PQZ
|
||||
* @date 14:32 2024/10/24
|
||||
**/
|
||||
void inWare(DlRepairSoReqVO reqVO);
|
||||
void inWare(DlRepairSoRespVO repairSoRespVO);
|
||||
}
|
||||
|
@ -3,11 +3,13 @@ package cn.iocoder.yudao.module.stockOperate.service;
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiQueryRespVO;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiReqVO;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiRespVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 针对表【dl_repair_soi(采购单领料单子表)】的数据库操作Service
|
||||
@ -53,4 +55,13 @@ public interface DlRepairSoiService extends IService<DlRepairSoi> {
|
||||
* @date 14:39 2024/10/24
|
||||
**/
|
||||
List<DlRepairSoi> listByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据主表的ID得到子表的所有数据,按类型区分的map,支持条件查询
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:51 2024/11/19
|
||||
* @param id id
|
||||
**/
|
||||
Map<String, List<DlRepairSoiRespVO>> getMapBySoIdAndQuery(String id, String query);
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
**/
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void inWare(DlRepairSoReqVO reqVO) {
|
||||
public void inWare(DlRepairSoRespVO reqVO) {
|
||||
/*1、基础数据准备*/
|
||||
//获取当前登录用户
|
||||
Long userId = SecurityFrameworkUtils.getLoginUserId();
|
||||
@ -480,7 +480,9 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
// 查该采购单的所有采购配件
|
||||
List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, reqVO.getId()));
|
||||
// 过滤出入库数量大于等于采购数量的数据 (入库数量可以大于采购的数量)
|
||||
List<DlRepairSoi> allInSois = sois.stream().filter(item -> item.getInCount() >= item.getGoodsCount()).collect(Collectors.toList());
|
||||
List<DlRepairSoi> allInSois = sois.stream()
|
||||
.filter(item -> (ObjectUtil.isNotEmpty(item.getInCount()) && item.getInCount() >= item.getGoodsCount()))
|
||||
.collect(Collectors.toList());
|
||||
// 如果allInSois的size就是sois的size,那就是全部都入库了
|
||||
if (CollectionUtil.isNotEmpty(allInSois) && allInSois.size() == sois.size()) {
|
||||
// 更新采购单的状态为已入库
|
||||
@ -489,6 +491,22 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
.eq(DlRepairSo::getId, reqVO.getId())
|
||||
);
|
||||
}
|
||||
|
||||
// 不敢动上面的代码,在新加一个逻辑,重复了也没事儿
|
||||
// 更新配件信息---因为入库的时候,配件的信息还能改
|
||||
List<RepairWares> reqVOWaresList = reqVO.getWaresList();
|
||||
List<String> ids = reqVOWaresList.stream().map(item -> item.getId()).collect(Collectors.toList());
|
||||
List<RepairWares> oldWares = waresService.listByIds(ids);
|
||||
// 这里是因为传过来的库存不是最新的,但其他字段可能变了,所以用最新的库存替换传回来的,在用传回来的+最新库存构成最新数据
|
||||
List<RepairWares> newWares = reqVOWaresList.stream().map(item -> {
|
||||
RepairWares wares = BeanUtil.toBean(item, RepairWares.class);
|
||||
RepairWares findWares = oldWares.stream().filter(i -> i.getId().equals(wares.getId())).findFirst().orElse(null);
|
||||
if (findWares != null) {
|
||||
wares.setStock(findWares.getStock());
|
||||
}
|
||||
return wares;
|
||||
}).collect(Collectors.toList());
|
||||
waresService.updateBatchById(newWares);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.stockOperate.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.iocoder.yudao.module.conf.entity.BaseType;
|
||||
import cn.iocoder.yudao.module.conf.service.BaseTypeService;
|
||||
import cn.iocoder.yudao.module.project.entity.RepairWares;
|
||||
import cn.iocoder.yudao.module.project.service.RepairWaresService;
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
|
||||
@ -11,6 +13,7 @@ import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService;
|
||||
import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoiService;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiQueryRespVO;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiReqVO;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiRespVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -19,7 +22,9 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -40,6 +45,9 @@ public class DlRepairSoiServiceImpl extends ServiceImpl<DlRepairSoiMapper, DlRep
|
||||
@Lazy
|
||||
private DlRepairSoService soService;
|
||||
|
||||
@Resource
|
||||
private BaseTypeService typeService;
|
||||
|
||||
/**
|
||||
* 采购单领料单子表 分页
|
||||
*
|
||||
@ -120,6 +128,44 @@ public class DlRepairSoiServiceImpl extends ServiceImpl<DlRepairSoiMapper, DlRep
|
||||
public List<DlRepairSoi> listByIds(List<String> ids) {
|
||||
return baseMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主表的ID得到子表的所有数据,按类型区分的map,支持条件查询
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:51 2024/11/19
|
||||
* @param id id
|
||||
**/
|
||||
@Override
|
||||
public Map<String, List<DlRepairSoiRespVO>> getMapBySoIdAndQuery(String id, String query){
|
||||
// 查出该单据的子项和其对应的配件信息
|
||||
List<DlRepairSoiRespVO> respVOList = baseMapper.getMapBySoIdAndQuery(id, query);
|
||||
if (CollectionUtil.isEmpty(respVOList)){
|
||||
return null;
|
||||
}
|
||||
// 按配件信息的type进行分组
|
||||
Map<String, List<DlRepairSoiRespVO>> map = respVOList.stream().collect(Collectors.groupingBy(item -> {
|
||||
String key = item.getWares().getType();
|
||||
if (key == null || key.isEmpty()) {
|
||||
key = "default";
|
||||
}
|
||||
return key;
|
||||
}));
|
||||
// 查分类的信息
|
||||
List<BaseType> baseTypes = typeService.listByIds(map.keySet());
|
||||
Map<String, String> typeMap = baseTypes.stream().collect(Collectors.toMap(BaseType::getId, BaseType::getName));
|
||||
// 映射
|
||||
Map<String, List<DlRepairSoiRespVO>> result = new HashMap<>();
|
||||
for (Map.Entry<String, List<DlRepairSoiRespVO>> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String newKey = typeMap.get(key);
|
||||
if (newKey == null || newKey.isEmpty()) {
|
||||
newKey = "未分类";
|
||||
}
|
||||
result.put(newKey, entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,4 +21,7 @@ public class DlRepairSoRespVO extends DlRepairSo {
|
||||
|
||||
// 配件List
|
||||
private List<RepairWares> waresList;
|
||||
|
||||
/**关联商品*/
|
||||
List<DlRepairSoi> soiList;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.stockOperate.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.project.entity.RepairWares;
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi;
|
||||
import lombok.Data;
|
||||
|
||||
@ -10,4 +11,7 @@ import lombok.Data;
|
||||
**/
|
||||
@Data
|
||||
public class DlRepairSoiRespVO extends DlRepairSoi {
|
||||
|
||||
/** 对应的配件信息 */
|
||||
private RepairWares wares;
|
||||
}
|
||||
|
@ -69,4 +69,83 @@
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<resultMap id="SoiAndWares" type="cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiRespVO">
|
||||
<id property="id" column="id" />
|
||||
<result property="soId" column="so_id" />
|
||||
<result property="soiType" column="soi_type" />
|
||||
<result property="goodsId" column="goods_id" />
|
||||
<result property="goodsType" column="goods_type" />
|
||||
<result property="wareId" column="ware_id" />
|
||||
<result property="goodsCount" column="goods_count" />
|
||||
<result property="goodsPrice" column="goods_price" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="inCount" column="in_count" />
|
||||
<result property="rawId" column="raw_id" />
|
||||
<result property="typeName" column="type_name" />
|
||||
|
||||
<!-- 嵌套的结果映射 -->
|
||||
<association property="wares" javaType="cn.iocoder.yudao.module.project.entity.RepairWares">
|
||||
<id property="id" column="wares_id" />
|
||||
<result property="barCode" column="bar_code" />
|
||||
<result property="code" column="code" />
|
||||
<result property="name" column="name" />
|
||||
<result property="model" column="model" />
|
||||
<result property="price" column="price" />
|
||||
<result property="purPrice" column="pur_price" />
|
||||
<result property="type" column="type" />
|
||||
<result property="unit" column="unit" />
|
||||
<result property="warehouse" column="warehouse" />
|
||||
<result property="miniStock" column="mini_stock" />
|
||||
<result property="maxStock" column="max_stock" />
|
||||
<result property="stock" column="stock" />
|
||||
<result property="img" column="img" />
|
||||
<result property="attribute" column="attribute" />
|
||||
<result property="corpId" column="corp_id" />
|
||||
<result property="coverImg" column="cover_img" />
|
||||
<result property="carModel" column="car_model" />
|
||||
<result property="remark" column="wares_remark" />
|
||||
<result property="status" column="status" />
|
||||
<result property="dataForm" column="data_form" />
|
||||
</association>
|
||||
</resultMap>
|
||||
<select id="getMapBySoIdAndQuery" resultMap="SoiAndWares">
|
||||
select
|
||||
drs.*,
|
||||
drw.id AS wares_id,
|
||||
drw.bar_code,
|
||||
drw.code,
|
||||
drw.name,
|
||||
drw.model,
|
||||
drw.price,
|
||||
drw.pur_price,
|
||||
drw.type,
|
||||
drw.unit,
|
||||
drw.warehouse,
|
||||
drw.mini_stock,
|
||||
drw.max_stock,
|
||||
drw.stock,
|
||||
drw.img,
|
||||
drw.attribute,
|
||||
drw.corp_id,
|
||||
drw.cover_img,
|
||||
drw.car_model,
|
||||
drw.remark AS wares_remark,
|
||||
drw.status,
|
||||
drw.data_form
|
||||
from dl_repair_soi drs
|
||||
left join dl_repair_wares drw
|
||||
on drs.goods_id = drw.id
|
||||
where drs.deleted = '0' and drw.deleted = '0'
|
||||
and drs.so_id = #{id}
|
||||
<if test="query != null and query != '' and query != 'null'">
|
||||
and (
|
||||
drw.name like concat('%', #{query}, '%')
|
||||
or
|
||||
drw.code like concat('%', #{query}, '%')
|
||||
or
|
||||
drw.model like concat('%', #{query}, '%')
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user