更新
This commit is contained in:
parent
f8c7e851de
commit
80aa8fd246
@ -6,10 +6,12 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo;
|
||||
import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi;
|
||||
import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO;
|
||||
import cn.iocoder.yudao.module.stockOperate.vo.RepairSoExportVO;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -72,7 +74,25 @@ public class DlRepairSoController {
|
||||
Page<DlRepairSo> page = new Page<>(pageNo, pageSize);
|
||||
return success(dlRepairSoService.getRepairSoPage(repairSoReqVO, page));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 采购单/领料单新增分页(包含子表数据)
|
||||
*
|
||||
* @param repairSoReqVO 查询对象
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 条数
|
||||
* @author 小李
|
||||
* @date 18:14 2024/9/14
|
||||
**/
|
||||
@GetMapping("/page-with-items")
|
||||
@Operation(summary = "采购单/领料单 分页(包含子表数据)")
|
||||
public CommonResult<?> getRepairSoPageWithItems(DlRepairSoReqVO repairSoReqVO,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
Page<DlRepairSo> page = new Page<>(pageNo, pageSize);
|
||||
return success(dlRepairSoService.getRepairSoPageWithItems(repairSoReqVO, page));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计采购金额
|
||||
*
|
||||
@ -115,8 +135,8 @@ public class DlRepairSoController {
|
||||
|
||||
/**
|
||||
* 领料单、退料单APP查看
|
||||
* @author vinjor-M
|
||||
* @date 11:10 2024/11/21
|
||||
* @author vinjor-M
|
||||
* @date 11:10 2024/11/21
|
||||
* @param id 单据id
|
||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
|
||||
**/
|
||||
@ -192,5 +212,92 @@ public class DlRepairSoController {
|
||||
}
|
||||
ExcelUtils.write(response, "单据数据.xls", "数据", RepairSoExportVO.class, list);
|
||||
}
|
||||
|
||||
@GetMapping("/export-with-items")
|
||||
@Operation(summary = "导出数据(包含子表)")
|
||||
public void exportWithItems(DlRepairSoReqVO repairSoReqVO, HttpServletResponse response) throws IOException {
|
||||
int pageNo = 1, pageSize = 1000;
|
||||
Page<DlRepairSo> page = new Page<>(pageNo, pageSize);
|
||||
|
||||
List<DlRepairSo> list = new ArrayList<>();
|
||||
do {
|
||||
IPage<DlRepairSo> repairSoPage = dlRepairSoService.getRepairSoPageWithItems(repairSoReqVO, page);
|
||||
List<DlRepairSo> records = repairSoPage.getRecords();
|
||||
if (CollUtil.isEmpty(records)){
|
||||
break;
|
||||
}
|
||||
list.addAll(records);
|
||||
pageNo++;
|
||||
page.setCurrent(pageNo);
|
||||
} while (true);
|
||||
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw exception0(500, "没有数据可以导出");
|
||||
}
|
||||
|
||||
// 构建导出数据
|
||||
List<List<String>> rows = new ArrayList<>();
|
||||
|
||||
// 表头
|
||||
rows.add(CollUtil.newArrayList(
|
||||
"序号", "单号", "数量", "金额", "供应商", "时间", "操作人",
|
||||
"商品", "商品数量", "商品价格", "仓库"
|
||||
));
|
||||
|
||||
int index = 1;
|
||||
for (DlRepairSo so : list) {
|
||||
// 获取子表项目列表
|
||||
List<DlRepairSoi> items = so.getItems();
|
||||
|
||||
// 如果没有子项,则至少添加一行显示主表信息
|
||||
if (CollUtil.isEmpty(items)) {
|
||||
rows.add(CollUtil.newArrayList(
|
||||
String.valueOf(index++),
|
||||
so.getSoNo() != null ? so.getSoNo() : "",
|
||||
so.getItemCount() != null ? so.getItemCount().toString() : "0",
|
||||
so.getTotalPrice() != null ? so.getTotalPrice().toString() : "0",
|
||||
so.getSupplierName() != null ? so.getSupplierName() : "",
|
||||
so.getSoTime() != null ? so.getSoTime().toString() : "",
|
||||
so.getUserName() != null ? so.getUserName() : "",
|
||||
"", "", "", ""
|
||||
));
|
||||
} else {
|
||||
// 有子项时,第一行显示主表信息和第一个子项信息
|
||||
DlRepairSoi firstItem = items.get(0);
|
||||
rows.add(CollUtil.newArrayList(
|
||||
String.valueOf(index++),
|
||||
so.getSoNo() != null ? so.getSoNo() : "",
|
||||
so.getItemCount() != null ? so.getItemCount().toString() : "0",
|
||||
so.getTotalPrice() != null ? so.getTotalPrice().toString() : "0",
|
||||
so.getSupplierName() != null ? so.getSupplierName() : "",
|
||||
so.getSoTime() != null ? DateUtils.format(so.getSoTime(), "yyyy-MM-dd HH:mm:ss") : "",
|
||||
so.getUserName() != null ? so.getUserName() : "",
|
||||
firstItem.getWares() != null && firstItem.getWares().getName() != null ? firstItem.getWares().getName() : "",
|
||||
firstItem.getGoodsCount() != null ? firstItem.getGoodsCount().toString() : "0",
|
||||
firstItem.getGoodsPrice() != null ? firstItem.getGoodsPrice().toString() : "0",
|
||||
firstItem.getHouseName() != null ? firstItem.getHouseName() : ""
|
||||
));
|
||||
|
||||
// 后续行只显示子项信息
|
||||
for (int i = 1; i < items.size(); i++) {
|
||||
DlRepairSoi item = items.get(i);
|
||||
rows.add(CollUtil.newArrayList(
|
||||
"", so.getSoNo() != null ? so.getSoNo() : "",
|
||||
so.getItemCount() != null ? so.getItemCount().toString() : "0",
|
||||
so.getTotalPrice() != null ? so.getTotalPrice().toString() : "0",
|
||||
so.getSupplierName() != null ? so.getSupplierName() : "",
|
||||
so.getSoTime() != null ? DateUtils.format(so.getSoTime(), "yyyy-MM-dd HH:mm:ss") : "",
|
||||
so.getUserName() != null ? so.getUserName() : "",
|
||||
item.getWares() != null && item.getWares().getName() != null ? item.getWares().getName() : "",
|
||||
item.getGoodsCount() != null ? item.getGoodsCount().toString() : "0",
|
||||
item.getGoodsPrice() != null ? item.getGoodsPrice().toString() : "0",
|
||||
firstItem.getHouseName() != null ? firstItem.getHouseName() : ""
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExcelUtils.exportExcel(("06").equals(repairSoReqVO.getSoType()) ?"采购退货单明细" : "采购单明细", rows, CollUtil.newArrayList(6), response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 采购单领料单
|
||||
@ -127,4 +128,10 @@ public class DlRepairSo extends TenantBaseDO {
|
||||
|
||||
/** 用户记录那些人可以看这条记录 */
|
||||
private String userIds;
|
||||
|
||||
/**
|
||||
* 子表数据
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<DlRepairSoi> items;
|
||||
}
|
||||
@ -84,4 +84,10 @@ public class DlRepairSoi extends TenantBaseDO {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String typeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String houseName;
|
||||
}
|
||||
|
||||
@ -50,8 +50,19 @@ public interface DlRepairSoMapper extends BaseMapper<DlRepairSo> {
|
||||
* @return java.util.List<cn.iocoder.yudao.module.tickets.vo.AppWaresGroupVO>
|
||||
**/
|
||||
List<DlRepairSoiRespVO> selectByIdGroup(@Param("id")String id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID查询主表及子表数据
|
||||
* @param id 主表ID
|
||||
* @return DlRepairSo 主表及子表数据
|
||||
*/
|
||||
DlRepairSo selectWithItemsById(@Param("id") String id);
|
||||
|
||||
/**
|
||||
* 分页查询主表及子表数据
|
||||
* @param repairSoReqVO 查询条件
|
||||
* @param page 分页参数
|
||||
* @return IPage<DlRepairSo> 分页结果
|
||||
*/
|
||||
IPage<DlRepairSo> getRepairSoPageWithItems(@Param("map") DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page);
|
||||
}
|
||||
@ -35,6 +35,17 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
|
||||
**/
|
||||
IPage<DlRepairSo> getRepairSoPage(DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page);
|
||||
|
||||
/**
|
||||
* 采购单/领料单新增分页(包含子表数据)
|
||||
*
|
||||
* @param repairSoReqVO 查询对象
|
||||
* @param page 分页参数
|
||||
* @return IPage<DlRepairSo> 分页结果
|
||||
* @author 小李
|
||||
* @date 18:14 2024/9/14
|
||||
**/
|
||||
IPage<DlRepairSo> getRepairSoPageWithItems(DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page);
|
||||
|
||||
/**
|
||||
* 统计采购金额
|
||||
*
|
||||
|
||||
@ -183,6 +183,19 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
public IPage<DlRepairSo> getRepairSoPage(DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page) {
|
||||
return baseMapper.getRepairSoPage(repairSoReqVO, page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采购单/领料单新增分页(包含子表数据)
|
||||
* @param repairSoReqVO 查询对象
|
||||
* @param page 分页参数
|
||||
* @return IPage<DlRepairSo> 分页结果
|
||||
* @author 小李
|
||||
* @date 18:14 2024/9/14
|
||||
**/
|
||||
@Override
|
||||
public IPage<DlRepairSo> getRepairSoPageWithItems(DlRepairSoReqVO repairSoReqVO, Page<DlRepairSo> page) {
|
||||
return baseMapper.getRepairSoPageWithItems(repairSoReqVO, page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getPurchaseAmount(DlRepairSoReqVO repairSoReqVO) {
|
||||
|
||||
@ -29,6 +29,74 @@
|
||||
<result property="userIds" column="user_ids" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 新增带子表数据的ResultMap -->
|
||||
<resultMap id="DetailResultMap" type="cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo">
|
||||
<!-- 主表字段 -->
|
||||
<id property="id" column="id" jdbcType="VARCHAR"/>
|
||||
<result property="soType" column="so_type" jdbcType="VARCHAR"/>
|
||||
<result property="purchaseType" column="purchase_type" jdbcType="VARCHAR"/>
|
||||
<result property="soNo" column="so_no" jdbcType="VARCHAR"/>
|
||||
<result property="supplierId" column="supplier_id" jdbcType="VARCHAR"/>
|
||||
<result property="supplierName" column="supplier_name" jdbcType="VARCHAR"/>
|
||||
<result property="userId" column="user_id" jdbcType="BIGINT"/>
|
||||
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
|
||||
<result property="soTime" column="so_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="itemCount" column="item_count" jdbcType="INTEGER"/>
|
||||
<result property="totalPrice" column="total_price" jdbcType="DECIMAL"/>
|
||||
<result property="soStatus" column="so_status" jdbcType="VARCHAR"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
<result property="corpId" column="corp_id" jdbcType="VARCHAR"/>
|
||||
<result property="corpName" column="corp_name" jdbcType="VARCHAR"/>
|
||||
<result property="deptId" column="dept_id" jdbcType="BIGINT"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updater" column="updater" jdbcType="VARCHAR"/>
|
||||
<result property="twId" column="tw_id" />
|
||||
<result property="licenseNumber" column="license_number" />
|
||||
<result property="userIds" column="user_ids" />
|
||||
|
||||
<!-- 子表集合 -->
|
||||
<collection property="items" ofType="cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi">
|
||||
<id property="id" column="soi_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="soi_remark"/>
|
||||
<result property="inCount" column="in_count"/>
|
||||
<result property="rawId" column="raw_id"/>
|
||||
<result property="houseName" column="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="wares_code"/>
|
||||
<result property="name" column="wares_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="wares_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>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_SQL">
|
||||
select so.id,
|
||||
so.so_type,
|
||||
@ -58,6 +126,109 @@
|
||||
where so.deleted = '0'
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询带子表数据 -->
|
||||
<select id="getRepairSoPageWithItems" resultMap="DetailResultMap">
|
||||
SELECT
|
||||
so.id,
|
||||
so.so_type,
|
||||
so.purchase_type,
|
||||
so.so_no,
|
||||
so.supplier_id,
|
||||
so.supplier_name,
|
||||
so.user_id,
|
||||
so.user_name,
|
||||
so.so_time,
|
||||
so.item_count,
|
||||
so.total_price,
|
||||
so.so_status,
|
||||
so.remark,
|
||||
so.corp_id,
|
||||
so.main_id,
|
||||
so.corp_name,
|
||||
so.dept_id,
|
||||
so.create_time,
|
||||
so.update_time,
|
||||
so.updater,
|
||||
so.tw_id,
|
||||
so.user_ids,
|
||||
dtw.license_number,
|
||||
soi.id AS soi_id,
|
||||
soi.so_id,
|
||||
soi.soi_type,
|
||||
soi.goods_id,
|
||||
soi.goods_type,
|
||||
soi.ware_id,
|
||||
soi.goods_count,
|
||||
soi.goods_price,
|
||||
soi.remark AS soi_remark,
|
||||
soi.in_count,
|
||||
soi.raw_id,
|
||||
wares.id AS wares_id,
|
||||
wares.bar_code,
|
||||
wares.code AS wares_code,
|
||||
wares.name AS wares_name,
|
||||
wares.model,
|
||||
wares.price,
|
||||
wares.pur_price,
|
||||
wares.type,
|
||||
wares.unit,
|
||||
wares.warehouse,
|
||||
wares.mini_stock,
|
||||
wares.max_stock,
|
||||
wares.stock,
|
||||
wares.img,
|
||||
wares.attribute,
|
||||
wares.corp_id AS wares_corp_id,
|
||||
wares.cover_img,
|
||||
wares.car_model,
|
||||
wares.remark AS wares_remark,
|
||||
wares.status,
|
||||
wares.data_form,
|
||||
bw.name
|
||||
FROM dl_repair_so so
|
||||
LEFT JOIN dl_ticket_wares dtw ON so.tw_id = dtw.id
|
||||
LEFT JOIN dl_repair_soi soi ON so.id = soi.so_id AND soi.deleted = '0'
|
||||
LEFT JOIN dl_repair_wares wares ON soi.goods_id = wares.id AND wares.deleted = '0'
|
||||
LEFT JOIN dl_base_warehouse bw ON soi.ware_id = bw.id AND bw.deleted = '0'
|
||||
WHERE so.deleted = '0'
|
||||
<if test="map.soType != null and map.soType">
|
||||
and so.so_type = #{map.soType}
|
||||
</if>
|
||||
<if test="map.purchaseType != null and map.purchaseType != ''">
|
||||
and so.purchase_type = #{map.purchaseType}
|
||||
</if>
|
||||
<if test="map.soStatus != null and map.soStatus != ''">
|
||||
and so.so_status = #{map.soStatus}
|
||||
</if>
|
||||
<if test="map.soStatus == null">
|
||||
and (so.so_status != '06' or so.so_status is null)
|
||||
</if>
|
||||
<if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
|
||||
and (so.create_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]})
|
||||
</if>
|
||||
<if test="map.query != null and map.query != ''">
|
||||
and (so.so_no like concat('%', #{map.query}, '%') or so.remark like concat('%', #{map.query}, '%') or dtw.license_number like concat('%', #{map.query}, '%'))
|
||||
</if>
|
||||
<if test="map.supplierId != null and map.supplierId != ''">
|
||||
and so.supplier_id = #{map.supplierId}
|
||||
</if>
|
||||
<if test="map.corpId != null and map.corpId != ''">
|
||||
and so.corp_id = #{map.corpId}
|
||||
</if>
|
||||
<if test="map.soNo != null and map.soNo != ''">
|
||||
and (so.so_no like concat('%', #{map.soNo}, '%') or so.remark like concat('%', #{map.soNo}, '%'))
|
||||
</if>
|
||||
<if test="map.userId != null and map.userId != ''">
|
||||
and (so.user_id = #{map.userId} or find_in_set(#{map.userId}, so.user_ids) > 0)
|
||||
</if>
|
||||
<if test="map.mainId != null and map.mainId != ''">
|
||||
and so.main_id = #{map.mainId}
|
||||
</if>
|
||||
<if test="map.twId != null and map.twId != ''">
|
||||
and so.tw_id = #{map.twId}
|
||||
</if>
|
||||
ORDER BY so.create_time DESC
|
||||
</select>
|
||||
<select id="getRepairSoPage" resultMap="BaseResultMap">
|
||||
<include refid="Base_SQL"/>
|
||||
<if test="map.soType != null and map.soType">
|
||||
@ -138,7 +309,71 @@
|
||||
drs.deleted = '0'
|
||||
AND drs.so_id=#{id}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 根据ID查询主表及子表数据 -->
|
||||
<select id="selectWithItemsById" resultMap="DetailResultMap">
|
||||
SELECT
|
||||
so.id,
|
||||
so.so_type,
|
||||
so.purchase_type,
|
||||
so.so_no,
|
||||
so.supplier_id,
|
||||
so.supplier_name,
|
||||
so.user_id,
|
||||
so.user_name,
|
||||
so.so_time,
|
||||
so.item_count,
|
||||
so.total_price,
|
||||
so.so_status,
|
||||
so.remark,
|
||||
so.corp_id,
|
||||
so.corp_name,
|
||||
so.dept_id,
|
||||
so.create_time,
|
||||
so.update_time,
|
||||
so.updater,
|
||||
so.tw_id,
|
||||
so.user_ids,
|
||||
dtw.license_number,
|
||||
soi.id AS soi_id,
|
||||
soi.so_id,
|
||||
soi.soi_type,
|
||||
soi.goods_id,
|
||||
soi.goods_type,
|
||||
soi.ware_id,
|
||||
soi.goods_count,
|
||||
soi.goods_price,
|
||||
soi.remark AS soi_remark,
|
||||
soi.in_count,
|
||||
soi.raw_id,
|
||||
wares.id AS wares_id,
|
||||
wares.bar_code,
|
||||
wares.code AS wares_code,
|
||||
wares.name AS wares_name,
|
||||
wares.model,
|
||||
wares.price,
|
||||
wares.pur_price,
|
||||
wares.type,
|
||||
wares.unit,
|
||||
wares.warehouse,
|
||||
wares.mini_stock,
|
||||
wares.max_stock,
|
||||
wares.stock,
|
||||
wares.img,
|
||||
wares.attribute,
|
||||
wares.corp_id AS wares_corp_id,
|
||||
wares.cover_img,
|
||||
wares.car_model,
|
||||
wares.remark AS wares_remark,
|
||||
wares.status,
|
||||
wares.data_form
|
||||
FROM dl_repair_so so
|
||||
LEFT JOIN dl_ticket_wares dtw ON so.tw_id = dtw.id
|
||||
LEFT JOIN dl_repair_soi soi ON so.id = soi.so_id AND soi.deleted = '0'
|
||||
LEFT JOIN dl_repair_wares wares ON soi.goods_id = wares.id AND wares.deleted = '0'
|
||||
WHERE so.deleted = '0' AND so.id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 统计采购金额 -->
|
||||
<select id="getPurchaseAmount" resultType="java.math.BigDecimal">
|
||||
SELECT
|
||||
|
||||
Loading…
Reference in New Issue
Block a user