add:子卷步骤导出

This commit is contained in:
zhangzq
2025-05-13 15:20:54 +08:00
parent e4ecd9dd34
commit 4d88480851
6 changed files with 64 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
package org.nl.b_lms.pdm.productSpec.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
@@ -19,8 +21,10 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.common.enums.PackageInfoIvtEnum;
import org.nl.common.enums.SpecEnum;
import org.nl.common.utils.CopyUtil;
import org.nl.common.utils.MapOf;
import org.nl.common.utils.RedissonUtils;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.FileUtil;
import org.nl.modules.logging.annotation.Log;
import org.nl.modules.wql.util.SpringContextHolder;
import org.redisson.api.RLock;
@@ -29,13 +33,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@@ -67,5 +71,32 @@ public class PdmProductSpecController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
@GetMapping("/querySpec/{code}")
@SaIgnore
public void querySpec(@PathVariable int code,HttpServletResponse response) {
DateTime dateTime = DateUtil.offsetDay(new Date(), -code);
List<PdmProductSpec> pdmProductSpecs = ipdmProductSpecService.querySubSepc(dateTime.toString());
String[] col = {"子卷","子卷下线","质检","包装","包装解除","装箱入库","验箱","入库"};
if (!CollectionUtils.isEmpty(pdmProductSpecs)){
Map<String, List<PdmProductSpec>> collect = pdmProductSpecs.stream().collect(Collectors.groupingBy(PdmProductSpec::getContainer_name));
List<Map<String,String>> data = new ArrayList<>();
PdmProductSpec pdmProductSpec = new PdmProductSpec();
for (String sub : collect.keySet()) {
List<PdmProductSpec> item = collect.get(sub);
//2,3,4,5,7,9,10
String 子卷下线 = DateUtil.format((item.stream().filter(a -> 2 == a.getSpec()).findFirst().orElse(pdmProductSpec).getCreate_time()),"yyyy-MM-dd HH:mm:ss.SSS");
String 质检 = DateUtil.format((item.stream().filter(a -> 3 == a.getSpec()).findFirst().orElse(pdmProductSpec).getCreate_time()),"yyyy-MM-dd HH:mm:ss.SSS");
String 包装 = DateUtil.format((item.stream().filter(a -> 4 == a.getSpec()).findFirst().orElse(pdmProductSpec).getCreate_time()),"yyyy-MM-dd HH:mm:ss.SSS");
String 包装解除 = DateUtil.format((item.stream().filter(a -> 5 == a.getSpec()).findFirst().orElse(pdmProductSpec).getCreate_time()),"yyyy-MM-dd HH:mm:ss.SSS");
String 装箱入库 = DateUtil.format((item.stream().filter(a -> 6 == a.getSpec()).findFirst().orElse(pdmProductSpec).getCreate_time()),"yyyy-MM-dd HH:mm:ss.SSS");
String 验箱 = DateUtil.format((item.stream().filter(a -> 9 == a.getSpec()).findFirst().orElse(pdmProductSpec).getCreate_time()),"yyyy-MM-dd HH:mm:ss.SSS");
String 入库 = DateUtil.format((item.stream().filter(a -> 10 == a.getSpec()).findFirst().orElse(pdmProductSpec).getCreate_time()),"yyyy-MM-dd HH:mm:ss.SSS");
data.add(MapOf.of("子卷",sub,"子卷下线",子卷下线,"质检",质检,"包装",包装,"包装解除",包装解除,"装箱入库",装箱入库,"验箱",验箱,"入库",入库));
}
new FileUtil().downloadExcelIO(data,col, response);
}
}
}

View File

@@ -1,8 +1,11 @@
package org.nl.b_lms.pdm.productSpec.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.nl.b_lms.pdm.productSpec.dao.PdmProductSpec;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -14,5 +17,6 @@ import java.util.Map;
*/
public interface PdmProductSpecMapper extends BaseMapper<PdmProductSpec> {
@Select("select * from pdm_product_spec where create_time > #{date} and spec in (2,3,4,5,7,9,10)")
List<PdmProductSpec> querySpec(String date);
}

View File

@@ -21,6 +21,8 @@ import java.util.Set;
*/
public interface IpdmProductSpecService extends IService<PdmProductSpec> {
public void record(SpecEnum spec, Map param, Boolean sucess,String msg, List<String> container_name);
public List<PdmProductSpec> querySubSepc(String date);
}

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.log4j.Log4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.b_lms.pdm.productSpec.dao.PdmProductSpec;
import org.nl.b_lms.pdm.productSpec.dao.mapper.PdmProductSpecMapper;
import org.nl.b_lms.pdm.productSpec.service.IpdmProductSpecService;
@@ -58,5 +59,14 @@ public class PdmProductSpecServiceImpl extends ServiceImpl<PdmProductSpecMapper,
}
}
}
@Override
public List<PdmProductSpec> querySubSepc(String date) {
if (StringUtils.isEmpty(date)){
return null;
}
List<PdmProductSpec> pdmProductSpecs = this.baseMapper.querySpec(date);
return pdmProductSpecs;
}
}

View File

@@ -40,4 +40,15 @@ public enum SpecEnum {
}
return "";
}
public static String converName(Integer value){
if (value != null){
for (SpecEnum specEnum : SpecEnum.values()) {
if (specEnum.getValue().equals(value)){
return specEnum.getDesc();
}
}
}
return "";
}
}

View File

@@ -6,7 +6,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: dev
active: prod
jackson:
time-zone: GMT+8
data: