no message

main
HUOJIN\92525 2025-05-12 11:41:08 +08:00
parent 4f820b52d5
commit af7aa0a046
13 changed files with 125 additions and 54 deletions

View File

@ -60,7 +60,7 @@
<jsoup.version>1.18.1</jsoup.version> <jsoup.version>1.18.1</jsoup.version>
<tika.version>3.1.0</tika.version> <tika.version>3.1.0</tika.version>
<jimureport-spring.version>1.9.4</jimureport-spring.version> <jimureport-spring.version>1.9.4</jimureport-spring.version>
<jimubi-spring.version>1.9.4</jimubi-spring.version> <jimubi-spring.version>1.9.5</jimubi-spring.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>

View File

@ -12,6 +12,7 @@ import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressEx
import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO; import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO;
import net.lab1024.sa.admin.module.business.wms.base.address.service.AddressQueryService; import net.lab1024.sa.admin.module.business.wms.base.address.service.AddressQueryService;
import net.lab1024.sa.admin.module.business.wms.base.address.service.AddressService; import net.lab1024.sa.admin.module.business.wms.base.address.service.AddressService;
import net.lab1024.sa.admin.module.business.wms.base.item.domain.form.ItemQueryForm;
import net.lab1024.sa.admin.module.business.wms.base.item.domain.vo.ItemsExcelVO; import net.lab1024.sa.admin.module.business.wms.base.item.domain.vo.ItemsExcelVO;
import net.lab1024.sa.admin.module.business.wms.excel.ExportTaskService; import net.lab1024.sa.admin.module.business.wms.excel.ExportTaskService;
import net.lab1024.sa.base.common.domain.RequestUser; import net.lab1024.sa.base.common.domain.RequestUser;
@ -112,33 +113,11 @@ public class AddressController {
return addressService.importAddress(file); return addressService.importAddress(file);
} }
@PostMapping("/address/createExportTask")
public ResponseDTO<String> createExportTask() {
String taskId = exportTaskService.createTask();
return ResponseDTO.ok(taskId);
}
@GetMapping("/address/progress/{taskId}")
public ResponseDTO<Long> getExportProgress(@PathVariable String taskId) {
Long progress = exportTaskService.getProgress(taskId);
return ResponseDTO.ok(progress);
}
@Operation(summary = "导出 霍锦") @Operation(summary = "导出 霍锦")
@GetMapping("/address/exportAddress/{taskId}") @PostMapping("/address/exportAddress/{taskId}")
@SaCheckPermission("address:exportAddress") @SaCheckPermission("address:exportAddress")
public void exportAddress(@PathVariable String taskId, HttpServletResponse response) { public void exportAddress(@PathVariable String taskId, @RequestBody @Valid AddressQueryForm queryForm, HttpServletResponse response) {
long startTime = System.currentTimeMillis(); addressQueryService.exportAddress(taskId,queryForm, response);
addressQueryService.exportAddress(taskId, response);
long endTime = System.currentTimeMillis();
log.info("导出地址数据完成,耗时:{}ms", endTime - startTime);
if (endTime - startTime <= 1000) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
log.error("异常", e);
}
}
exportTaskService.cleanupTask(taskId); exportTaskService.cleanupTask(taskId);
} }
} }

View File

@ -8,6 +8,7 @@ import net.lab1024.sa.admin.module.business.wms.base.address.domain.form.Address
import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO; import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.lab1024.sa.admin.module.business.wms.base.item.domain.form.ItemQueryForm;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -54,7 +55,7 @@ public interface AddressDao extends BaseMapper<AddressEntity> {
Cursor<AddressVO> selectAllByCursor(); Cursor<AddressVO> selectAllByCursor();
//游标分页 //游标分页
List<AddressVO> listByCursor(@Param("lastId") Long lastId, @Param("pageSize") int pageSize); List<AddressVO> listByCursor(@Param("lastId") Long lastId, @Param("pageSize") int pageSize,@Param("queryForm") AddressQueryForm queryForm);
} }

View File

@ -6,6 +6,7 @@ import net.lab1024.sa.admin.module.business.wms.base.address.domain.form.Address
import net.lab1024.sa.admin.module.business.wms.base.address.domain.form.AddressSelect; import net.lab1024.sa.admin.module.business.wms.base.address.domain.form.AddressSelect;
import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressExcelVO; import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressExcelVO;
import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO; import net.lab1024.sa.admin.module.business.wms.base.address.domain.vo.AddressVO;
import net.lab1024.sa.admin.module.business.wms.base.item.domain.form.ItemQueryForm;
import net.lab1024.sa.base.common.domain.PageResult; import net.lab1024.sa.base.common.domain.PageResult;
import java.io.IOException; import java.io.IOException;
@ -60,6 +61,19 @@ public interface AddressQueryService {
List<AddressExcelVO> queryAddressExcel3(); List<AddressExcelVO> queryAddressExcel3();
void exportAddress(String taskId,HttpServletResponse response); /**
*
* @param queryForm
* @return long
*/
long addressCount(AddressQueryForm queryForm);
/**
*
* @param taskId ID
* @param queryForm
* @param response
*/
void exportAddress(String taskId,AddressQueryForm queryForm,HttpServletResponse response);
} }

View File

@ -156,7 +156,7 @@ public class AddressQueryServiceImpl implements AddressQueryService {
//进度条 //进度条
long processed = 0; long processed = 0;
while (true) { while (true) {
List<AddressVO> batch = addressDao.listByCursor(lastId, pageSize); List<AddressVO> batch = addressDao.listByCursor(lastId, pageSize,null);
if (batch.isEmpty()) { if (batch.isEmpty()) {
break; break;
} }
@ -207,7 +207,16 @@ public class AddressQueryServiceImpl implements AddressQueryService {
return list; return list;
} }
public void exportAddress(String taskId, HttpServletResponse response){ @Override
public long addressCount(AddressQueryForm queryForm) {
LambdaQueryWrapper<AddressEntity> queryWrapper = new LambdaQueryWrapper<>();
if (queryForm.getAddressId() != null) {
queryWrapper.eq(AddressEntity::getAddressId, queryForm.getAddressId());
}
return addressManager.count(queryWrapper);
}
public void exportAddress(String taskId,AddressQueryForm queryForm, HttpServletResponse response){
try { try {
SmartExcelUtil.batchExportExcel( SmartExcelUtil.batchExportExcel(
response, response,
@ -215,8 +224,8 @@ public class AddressQueryServiceImpl implements AddressQueryService {
"收货地址信息", "收货地址信息",
AddressExcelVO.class, AddressExcelVO.class,
taskId, taskId,
addressManager.count(), addressCount(queryForm),
(lastId, pageSize) -> addressDao.listByCursor(lastId, pageSize), (lastId, pageSize) -> addressDao.listByCursor(lastId, pageSize,queryForm),
address -> AddressExcelVO.builder() address -> AddressExcelVO.builder()
.name(address.getName()) .name(address.getName())
.person(address.getPerson()) .person(address.getPerson())
@ -231,7 +240,6 @@ public class AddressQueryServiceImpl implements AddressQueryService {
exportTaskService.updateProgress(taskId, -1); exportTaskService.updateProgress(taskId, -1);
} finally { } finally {
exportTaskService.updateProgress(taskId, 100); exportTaskService.updateProgress(taskId, 100);
} }
} }
} }

View File

@ -113,11 +113,11 @@ public class ItemController {
} }
@Operation(summary = "导出 霍锦") @Operation(summary = "导出 霍锦")
@GetMapping("/item/exportItems/{taskId}") @PostMapping("/item/exportItems/{taskId}")
@SaCheckPermission("item:exportItems") @SaCheckPermission("item:exportItems")
@OperateLog @OperateLog
public void exportItems(@PathVariable String taskId, HttpServletResponse response){ public void exportItems(@PathVariable String taskId,@RequestBody @Valid ItemQueryForm queryForm, HttpServletResponse response){
itemQueryService.exportItem(taskId, response); itemQueryService.exportItem(taskId, queryForm,response);
exportTaskService.cleanupTask(taskId); exportTaskService.cleanupTask(taskId);
} }
} }

View File

@ -34,6 +34,6 @@ public interface ItemDao extends BaseMapper<ItemEntity> {
List<ItemVO> queryPage(Page page, @Param("queryForm") ItemQueryForm queryForm); List<ItemVO> queryPage(Page page, @Param("queryForm") ItemQueryForm queryForm);
//游标分页 //游标分页
List<ItemVO> listByCursor(@Param("lastId") Long lastId, @Param("pageSize") int pageSize); List<ItemVO> listByCursor(@Param("lastId") Long lastId, @Param("pageSize") int pageSize,@Param("queryForm") ItemQueryForm queryForm);
} }

View File

@ -1,5 +1,6 @@
package net.lab1024.sa.admin.module.business.wms.base.item.service; package net.lab1024.sa.admin.module.business.wms.base.item.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import net.lab1024.sa.admin.module.business.wms.base.item.domain.entity.ItemEntity; import net.lab1024.sa.admin.module.business.wms.base.item.domain.entity.ItemEntity;
import net.lab1024.sa.admin.module.business.wms.base.item.domain.form.ItemQueryForm; import net.lab1024.sa.admin.module.business.wms.base.item.domain.form.ItemQueryForm;
@ -69,5 +70,11 @@ public interface ItemQueryService {
*/ */
List<ItemsExcelVO> queryItemsExcelVO(); List<ItemsExcelVO> queryItemsExcelVO();
void exportItem(String taskId, HttpServletResponse response); /**
*
* @return
*/
long itemCount(ItemQueryForm queryForm);
void exportItem(String taskId, ItemQueryForm queryForm, HttpServletResponse response);
} }

View File

@ -167,7 +167,19 @@ public class ItemQueryServiceImpl implements ItemQueryService {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public void exportItem(String taskId, HttpServletResponse response){ @Override
public long itemCount(ItemQueryForm queryForm) {
LambdaQueryWrapper<ItemEntity> queryWrapper = new LambdaQueryWrapper<>();
if (queryForm.getDisabledFlag() != null) {
queryWrapper.eq(ItemEntity::getDisabledFlag, queryForm.getDisabledFlag());
}
if (queryForm.getItemId() != null) {
queryWrapper.eq(ItemEntity::getItemId, queryForm.getItemId());
}
return itemManager.count(queryWrapper);
}
public void exportItem(String taskId, ItemQueryForm queryForm, HttpServletResponse response) {
try { try {
SmartExcelUtil.batchExportExcel( SmartExcelUtil.batchExportExcel(
response, response,
@ -175,8 +187,8 @@ public class ItemQueryServiceImpl implements ItemQueryService {
"物料信息", "物料信息",
ItemsExcelVO.class, ItemsExcelVO.class,
taskId, taskId,
itemManager.count(), itemCount(queryForm),
(lastId, pageSize) -> itemDao.listByCursor(lastId, pageSize), (lastId, pageSize) -> itemDao.listByCursor(lastId, pageSize, queryForm),
item -> ItemsExcelVO.builder() item -> ItemsExcelVO.builder()
.itemCode(item.getItemCode()) .itemCode(item.getItemCode())
.itemName(item.getItemName()) .itemName(item.getItemName())

View File

@ -0,0 +1,31 @@
package net.lab1024.sa.admin.module.business.wms.excel;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Tag(name = "导出")
@Slf4j
public class ExportTaskController {
@Resource
private ExportTaskService exportTaskService;
@PostMapping("/export/createExportTask")
public ResponseDTO<String> createExportTask() {
String taskId = exportTaskService.createTask();
return ResponseDTO.ok(taskId);
}
@GetMapping("/export/progress/{taskId}")
public ResponseDTO<Long> getExportProgress(@PathVariable String taskId) {
Long progress = exportTaskService.getProgress(taskId);
return ResponseDTO.ok(progress);
}
}

View File

@ -48,9 +48,15 @@
t_address.telephone, t_address.telephone,
t_address.address t_address.address
FROM t_address FROM t_address
WHERE t_address.address_id > #{lastId} <where>
t_address.address_id > #{lastId}
<!--收货单位-->
<if test="queryForm.addressId != null ">
AND t_address.address_id= #{queryForm.addressId}
</if>
</where>
ORDER BY t_address.address_id ASC -- 必须升序 ORDER BY t_address.address_id ASC -- 必须升序
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>
</mapper> </mapper>

View File

@ -4,7 +4,10 @@
<!-- 查询结果列 --> <!-- 查询结果列 -->
<sql id="base_columns"> <sql id="base_columns">
t_item.item_id, t_item
.
item_id
,
t_item.item_code, t_item.item_code,
t_item.item_name, t_item.item_name,
t_item.unit, t_item.unit,
@ -21,11 +24,11 @@
<include refid="base_columns"/> <include refid="base_columns"/>
FROM t_item FROM t_item
<where> <where>
<!--物料编码--> <!--物料-->
<if test="queryForm.itemId != null"> <if test="queryForm.itemId != null">
AND t_item.item_id=#{queryForm.itemId} AND t_item.item_id=#{queryForm.itemId}
</if> </if>
<!--物料名称--> <!--是否启用-->
<if test="queryForm.disabledFlag != null"> <if test="queryForm.disabledFlag != null">
AND t_item.disabled_flag=#{queryForm.disabledFlag} AND t_item.disabled_flag=#{queryForm.disabledFlag}
</if> </if>
@ -35,15 +38,25 @@
<select id="listByCursor" resultType="net.lab1024.sa.admin.module.business.wms.base.item.domain.vo.ItemVO"> <select id="listByCursor" resultType="net.lab1024.sa.admin.module.business.wms.base.item.domain.vo.ItemVO">
SELECT t_item.item_id, SELECT t_item.item_id,
t_item.item_code, t_item.item_code,
t_item.item_name, t_item.item_name,
t_item.item_type, t_item.item_type,
t_item.unit, t_item.unit,
t_item.disabled_flag t_item.disabled_flag
FROM t_item FROM t_item
WHERE t_item.item_id > #{lastId} <where>
t_item.item_id > #{lastId}
<!--物料-->
<if test="queryForm.itemId != null">
AND t_item.item_id=#{queryForm.itemId}
</if>
<!--是否启用-->
<if test="queryForm.disabledFlag != null">
AND t_item.disabled_flag=#{queryForm.disabledFlag}
</if>
</where>
ORDER BY t_item.item_id ASC -- 必须升序 ORDER BY t_item.item_id ASC -- 必须升序
LIMIT #{pageSize} LIMIT #{pageSize}
</select> </select>

View File

@ -111,7 +111,7 @@ public final class SmartExcelUtil {
} }
if (System.currentTimeMillis() - startTime <= 1000) { if (System.currentTimeMillis() - startTime <= 1000) {
try { try {
Thread.sleep(2000); Thread.sleep(1500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
System.out.println("异常" + e.getMessage()); System.out.println("异常" + e.getMessage());
} }