no message
							parent
							
								
									4f820b52d5
								
							
						
					
					
						commit
						af7aa0a046
					
				| 
						 | 
				
			
			@ -60,7 +60,7 @@
 | 
			
		|||
        <jsoup.version>1.18.1</jsoup.version>
 | 
			
		||||
        <tika.version>3.1.0</tika.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>
 | 
			
		||||
 | 
			
		||||
    <dependencyManagement>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.service.AddressQueryService;
 | 
			
		||||
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.excel.ExportTaskService;
 | 
			
		||||
import net.lab1024.sa.base.common.domain.RequestUser;
 | 
			
		||||
| 
						 | 
				
			
			@ -112,33 +113,11 @@ public class AddressController {
 | 
			
		|||
        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 = "导出 霍锦")
 | 
			
		||||
    @GetMapping("/address/exportAddress/{taskId}")
 | 
			
		||||
    @PostMapping("/address/exportAddress/{taskId}")
 | 
			
		||||
    @SaCheckPermission("address:exportAddress")
 | 
			
		||||
    public void exportAddress(@PathVariable String taskId, HttpServletResponse response) {
 | 
			
		||||
        long startTime = System.currentTimeMillis();
 | 
			
		||||
        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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    public void exportAddress(@PathVariable String taskId, @RequestBody @Valid AddressQueryForm queryForm, HttpServletResponse response) {
 | 
			
		||||
        addressQueryService.exportAddress(taskId,queryForm, response);
 | 
			
		||||
        exportTaskService.cleanupTask(taskId);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
 | 
			
		||||
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.Options;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +55,7 @@ public interface AddressDao extends BaseMapper<AddressEntity> {
 | 
			
		|||
    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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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.vo.AddressExcelVO;
 | 
			
		||||
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 java.io.IOException;
 | 
			
		||||
| 
						 | 
				
			
			@ -60,6 +61,19 @@ public interface AddressQueryService {
 | 
			
		|||
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -156,7 +156,7 @@ public class AddressQueryServiceImpl implements AddressQueryService {
 | 
			
		|||
        //进度条
 | 
			
		||||
        long processed = 0;
 | 
			
		||||
        while (true) {
 | 
			
		||||
            List<AddressVO> batch = addressDao.listByCursor(lastId, pageSize);
 | 
			
		||||
            List<AddressVO> batch = addressDao.listByCursor(lastId, pageSize,null);
 | 
			
		||||
            if (batch.isEmpty()) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +207,16 @@ public class AddressQueryServiceImpl implements AddressQueryService {
 | 
			
		|||
        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 {
 | 
			
		||||
            SmartExcelUtil.batchExportExcel(
 | 
			
		||||
                    response,
 | 
			
		||||
| 
						 | 
				
			
			@ -215,8 +224,8 @@ public class AddressQueryServiceImpl implements AddressQueryService {
 | 
			
		|||
                    "收货地址信息",
 | 
			
		||||
                    AddressExcelVO.class,
 | 
			
		||||
                    taskId,
 | 
			
		||||
                    addressManager.count(),
 | 
			
		||||
                    (lastId, pageSize) -> addressDao.listByCursor(lastId, pageSize),
 | 
			
		||||
                    addressCount(queryForm),
 | 
			
		||||
                    (lastId, pageSize) -> addressDao.listByCursor(lastId, pageSize,queryForm),
 | 
			
		||||
                    address -> AddressExcelVO.builder()
 | 
			
		||||
                            .name(address.getName())
 | 
			
		||||
                            .person(address.getPerson())
 | 
			
		||||
| 
						 | 
				
			
			@ -231,7 +240,6 @@ public class AddressQueryServiceImpl implements AddressQueryService {
 | 
			
		|||
            exportTaskService.updateProgress(taskId, -1);
 | 
			
		||||
        } finally {
 | 
			
		||||
            exportTaskService.updateProgress(taskId, 100);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,11 +113,11 @@ public class ItemController {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    @Operation(summary = "导出 霍锦")
 | 
			
		||||
    @GetMapping("/item/exportItems/{taskId}")
 | 
			
		||||
    @PostMapping("/item/exportItems/{taskId}")
 | 
			
		||||
    @SaCheckPermission("item:exportItems")
 | 
			
		||||
    @OperateLog
 | 
			
		||||
    public void exportItems(@PathVariable String taskId, HttpServletResponse response){
 | 
			
		||||
        itemQueryService.exportItem(taskId, response);
 | 
			
		||||
    public void exportItems(@PathVariable String taskId,@RequestBody @Valid ItemQueryForm queryForm, HttpServletResponse response){
 | 
			
		||||
        itemQueryService.exportItem(taskId, queryForm,response);
 | 
			
		||||
        exportTaskService.cleanupTask(taskId);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,6 +34,6 @@ public interface ItemDao extends BaseMapper<ItemEntity> {
 | 
			
		|||
    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);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
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 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;
 | 
			
		||||
| 
						 | 
				
			
			@ -69,5 +70,11 @@ public interface ItemQueryService {
 | 
			
		|||
     */
 | 
			
		||||
    List<ItemsExcelVO> queryItemsExcelVO();
 | 
			
		||||
 | 
			
		||||
    void exportItem(String taskId, HttpServletResponse response);
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取物料总数
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    long itemCount(ItemQueryForm queryForm);
 | 
			
		||||
 | 
			
		||||
    void exportItem(String taskId, ItemQueryForm queryForm, HttpServletResponse response);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -167,7 +167,19 @@ public class ItemQueryServiceImpl implements ItemQueryService {
 | 
			
		|||
                .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 {
 | 
			
		||||
            SmartExcelUtil.batchExportExcel(
 | 
			
		||||
                    response,
 | 
			
		||||
| 
						 | 
				
			
			@ -175,8 +187,8 @@ public class ItemQueryServiceImpl implements ItemQueryService {
 | 
			
		|||
                    "物料信息",
 | 
			
		||||
                    ItemsExcelVO.class,
 | 
			
		||||
                    taskId,
 | 
			
		||||
                    itemManager.count(),
 | 
			
		||||
                    (lastId, pageSize) -> itemDao.listByCursor(lastId, pageSize),
 | 
			
		||||
                    itemCount(queryForm),
 | 
			
		||||
                    (lastId, pageSize) -> itemDao.listByCursor(lastId, pageSize, queryForm),
 | 
			
		||||
                    item -> ItemsExcelVO.builder()
 | 
			
		||||
                            .itemCode(item.getItemCode())
 | 
			
		||||
                            .itemName(item.getItemName())
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -48,9 +48,15 @@
 | 
			
		|||
               t_address.telephone,
 | 
			
		||||
               t_address.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 -- 必须升序
 | 
			
		||||
            LIMIT #{pageSize}
 | 
			
		||||
        LIMIT #{pageSize}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
</mapper>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,10 @@
 | 
			
		|||
 | 
			
		||||
    <!-- 查询结果列 -->
 | 
			
		||||
    <sql id="base_columns">
 | 
			
		||||
        t_item.item_id,
 | 
			
		||||
        t_item
 | 
			
		||||
        .
 | 
			
		||||
        item_id
 | 
			
		||||
        ,
 | 
			
		||||
        t_item.item_code,
 | 
			
		||||
        t_item.item_name,
 | 
			
		||||
        t_item.unit,
 | 
			
		||||
| 
						 | 
				
			
			@ -21,11 +24,11 @@
 | 
			
		|||
        <include refid="base_columns"/>
 | 
			
		||||
        FROM t_item
 | 
			
		||||
        <where>
 | 
			
		||||
            <!--物料编码-->
 | 
			
		||||
            <!--物料-->
 | 
			
		||||
            <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>
 | 
			
		||||
| 
						 | 
				
			
			@ -35,15 +38,25 @@
 | 
			
		|||
 | 
			
		||||
    <select id="listByCursor" resultType="net.lab1024.sa.admin.module.business.wms.base.item.domain.vo.ItemVO">
 | 
			
		||||
        SELECT t_item.item_id,
 | 
			
		||||
               t_item.item_code,
 | 
			
		||||
               t_item.item_name,
 | 
			
		||||
               t_item.item_type,
 | 
			
		||||
               t_item.unit,
 | 
			
		||||
               t_item.disabled_flag
 | 
			
		||||
        t_item.item_code,
 | 
			
		||||
        t_item.item_name,
 | 
			
		||||
        t_item.item_type,
 | 
			
		||||
        t_item.unit,
 | 
			
		||||
        t_item.disabled_flag
 | 
			
		||||
        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 -- 必须升序
 | 
			
		||||
            LIMIT #{pageSize}
 | 
			
		||||
        LIMIT #{pageSize}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ public final class SmartExcelUtil {
 | 
			
		|||
            }
 | 
			
		||||
            if (System.currentTimeMillis() - startTime <= 1000) {
 | 
			
		||||
                try {
 | 
			
		||||
                    Thread.sleep(2000);
 | 
			
		||||
                    Thread.sleep(1500);
 | 
			
		||||
                } catch (InterruptedException e) {
 | 
			
		||||
                    System.out.println("异常" + e.getMessage());
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue