PBOM-导出
This commit is contained in:
parent
7f8f9dcd27
commit
46a870b3a1
|
|
@ -72,9 +72,15 @@ public class PBomApi extends BaseApi {
|
|||
}
|
||||
|
||||
@PostMapping("exportWorkDetailsListByPage")
|
||||
@ApiOperation("导出工作列表")
|
||||
public void exportWorkDetailsListByPage(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException {
|
||||
bomNewPbomParentService.exportWorkDetailsListByPage(query,response);
|
||||
@ApiOperation("导出工作列表--导出")
|
||||
public void exportWorkDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException {
|
||||
bomNewPbomParentService.workDetailsExcel(query,response);
|
||||
}
|
||||
|
||||
@PostMapping("releaseListDownLoad")
|
||||
@ApiOperation("PBom已发布工作列表--导出")
|
||||
public void releaseListDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException {
|
||||
bomNewPbomParentService.releaseListExcel(query,response);
|
||||
}
|
||||
|
||||
@GetMapping("getChild")
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewPbomWorkExcelVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -21,6 +22,11 @@ public interface BomNewPbomParentMapper extends BaseMapper<BomNewPbomParentEntit
|
|||
|
||||
Page<BomNewPbomParentVO> workDetailsListByPage(Page<BomNewPbomParentQuery> page, @Param("query") BomNewPbomParentQuery query , @Param("userFac") String userFac);
|
||||
|
||||
|
||||
List<BomNewPbomWorkExcelVO> workDetailsExcel(@Param("userFac") String userFac);
|
||||
|
||||
|
||||
List<BomNewPbomWorkExcelVO> releaseListExcel(@Param("query") BomNewPbomParentQuery query);
|
||||
/**
|
||||
* 已发布列表
|
||||
* @author 大米
|
||||
|
|
|
|||
|
|
@ -0,0 +1,146 @@
|
|||
package com.nflg.product.bomnew.pojo.vo;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* pom编辑导出Excel模版
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BomNewPbomWorkExcelVO implements Serializable {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ExcelColumn("工厂编码")
|
||||
private String facCode;
|
||||
|
||||
@ExcelColumn(value = "项目类别")
|
||||
private String projectType;
|
||||
|
||||
@ExcelColumn(value = "物料编码")
|
||||
private String materialNo;
|
||||
|
||||
@ExcelColumn("物料名称")
|
||||
private String materialName;
|
||||
|
||||
@ExcelColumn(value = "图号")
|
||||
private String drawingNo;
|
||||
|
||||
@ExcelColumn(value = "版本号")
|
||||
private String currentVersion;
|
||||
|
||||
|
||||
@ExcelColumn(value = "物料描述")
|
||||
private String materialDesc;
|
||||
|
||||
@ExcelColumn("材质")
|
||||
private String materialTexture;
|
||||
|
||||
@ExcelColumn(value = "单位")
|
||||
private String materialUnit;
|
||||
|
||||
@ExcelColumn(value = "数量")
|
||||
private BigDecimal num;
|
||||
|
||||
@ExcelColumn("单重")
|
||||
private BigDecimal unitWeight;
|
||||
|
||||
@ExcelColumn(value = "总重")
|
||||
private BigDecimal totalWeight;
|
||||
|
||||
|
||||
|
||||
private Integer bomExist;
|
||||
|
||||
@ExcelColumn(value = "有无下级")
|
||||
private String bomExistName;
|
||||
|
||||
public String getBomExistName() {
|
||||
return bomExist.equals(1)? "有" : "无";
|
||||
}
|
||||
|
||||
private Integer superMaterialStatus;
|
||||
|
||||
@ExcelColumn(value = "是否超级物料")
|
||||
private Integer superMaterialStatusName;
|
||||
|
||||
public String getSuperMaterialStatusName() {
|
||||
return superMaterialStatus.equals(1)? "是" : "否";
|
||||
}
|
||||
|
||||
@ExcelColumn(value = "物料分类")
|
||||
private String categoryName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ExcelColumn(value = "创建时间")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
|
||||
@ExcelColumn(value = "更新时间")
|
||||
private LocalDateTime modifyTime;
|
||||
|
||||
|
||||
@ExcelColumn(value = "生效日期")
|
||||
private LocalDateTime effectStartTime;
|
||||
|
||||
public LocalDateTime getEffectStartTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
@ExcelColumn(value = "有效至")
|
||||
private String expireEndTimeStr="99-12-31 23:59:59";
|
||||
|
||||
@ApiModelProperty("物料状态 1:激活 2:禁止采购 3:售后专用 4:冻结 5:完全弃用")
|
||||
private Integer materialState;
|
||||
|
||||
@ExcelColumn(value = "物料状态")
|
||||
private String materialStateName;
|
||||
|
||||
private String[] materialStateNameArr= {"","激活","禁止采购","售后专用","冻结","完全弃用"};
|
||||
|
||||
@ExcelColumn(value = "物料状态")
|
||||
public String getMaterialStateName() {
|
||||
return materialState==null?"": materialStateNameArr[materialState];
|
||||
}
|
||||
|
||||
@ApiModelProperty("BOM状态:1=待发布 2-借用件 4=已发布 8=待分配工厂 16=已分配工厂")
|
||||
public Integer status;
|
||||
|
||||
private Map<Integer,String> statusNameArr= ImmutableMap.of(1,"待发布",2,"借用件",4,"已发布",8,"待分配工厂",16,"已分配工厂");
|
||||
|
||||
@ExcelColumn(value = "BOM状态")
|
||||
public String statusName() {
|
||||
return status==null?"": statusNameArr.get(status);
|
||||
}
|
||||
|
||||
@ExcelColumn(value = "设计人员")
|
||||
private String deviseName;
|
||||
|
||||
@ExcelColumn(value = "设计部门")
|
||||
private String deptName;
|
||||
|
||||
@ExcelColumn(value = "升版说明")
|
||||
private String changeDesc;
|
||||
|
||||
@ExcelColumn(value = "备注")
|
||||
private String remark;
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
|
@ -193,19 +193,31 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
|||
return result;
|
||||
}
|
||||
|
||||
public void exportWorkDetailsListByPage(BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
|
||||
/**
|
||||
* 导出工作列表
|
||||
* @param query
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
public void workDetailsExcel(BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
|
||||
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
|
||||
new Workbook().addSheet(new ListSheet<BomNewPbomParentVO>() {
|
||||
Long n = 1L;
|
||||
List<BomNewPbomWorkExcelVO> result = this.getBaseMapper().workDetailsExcel(userRoleService.getUserFactory());
|
||||
materialMainService.intiMaterialInfo(result,BomNewPbomWorkExcelVO::getMaterialNo,EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
||||
new Workbook().addSheet(result).writeTo(response.getOutputStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<BomNewPbomParentVO> more() {
|
||||
query.setPage(n);
|
||||
n++;
|
||||
List<BomNewPbomParentVO> result = workDetailsListByPage(query).getRecords();
|
||||
return CollUtil.isNotEmpty(result) ? result : null;
|
||||
}
|
||||
}).writeTo(response.getOutputStream());
|
||||
/**
|
||||
* 导出正式工作表
|
||||
* @param query
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
public void releaseListExcel(BomNewPbomParentQuery query, HttpServletResponse response) throws IOException {
|
||||
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
|
||||
List<BomNewPbomWorkExcelVO> result = this.getBaseMapper().releaseListExcel(query);
|
||||
materialMainService.intiMaterialInfo(result,BomNewPbomWorkExcelVO::getMaterialNo,EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
|
||||
|
||||
new Workbook().addSheet(result).writeTo(response.getOutputStream());
|
||||
}
|
||||
|
||||
public List<BomNewPbomParentVO> getChild(Long rowId) {
|
||||
|
|
|
|||
|
|
@ -141,6 +141,19 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
|||
}
|
||||
}
|
||||
|
||||
public <T> void intiMaterialInfo(List<T> data, Function<T, String> getMaterialFun,String ... ignorePropertyList) {
|
||||
List<String> materialNos = data.stream().filter(u -> StrUtil.isNotBlank(getMaterialFun.apply(u))).map(u -> getMaterialFun.apply(u)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(materialNos)) {
|
||||
List<BaseMaterialVO> materialBaseInfos = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
|
||||
Map<String, BaseMaterialVO> materialMp = ListCommonUtil.listToMap(materialBaseInfos, BaseMaterialVO::getMaterialNo);
|
||||
for (T t : data) {
|
||||
if (StrUtil.isNotBlank(getMaterialFun.apply(t)) && materialMp.containsKey(getMaterialFun.apply(t))) {
|
||||
BeanUtil.copyProperties(materialMp.get(getMaterialFun.apply(t)), t,ignorePropertyList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过图号初始化BOM信息
|
||||
|
|
|
|||
|
|
@ -60,12 +60,12 @@ public class UserRoleService {
|
|||
*/
|
||||
public String getUserFactory(){
|
||||
Integer userMultiplantFacRoleCount = materialMainService.getBaseMapper().getUserMultiplantFacRoleCount(SessionUtil.getRowId());
|
||||
// return "";
|
||||
if(userMultiplantFacRoleCount>0){
|
||||
return "";
|
||||
}else {
|
||||
return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010;
|
||||
}
|
||||
return "";
|
||||
// if(userMultiplantFacRoleCount>0){
|
||||
// return "";
|
||||
// }else {
|
||||
// return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,16 @@
|
|||
order by created_time desc
|
||||
</select>
|
||||
|
||||
<!--获取工作列表-EXCEL-->
|
||||
<select id="workDetailsExcel" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomWorkExcelVO">
|
||||
select * , row_id as bomRowId
|
||||
from t_bom_new_pbom_parent where root_is=1 and status < 4
|
||||
<if test="userFac!=null and userFac!=''">
|
||||
and fac_code=#{userFac}
|
||||
</if>
|
||||
order by created_time desc
|
||||
</select>
|
||||
|
||||
<!--获取已发布列表-->
|
||||
<select id="releaseListByPage" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
|
||||
select * , row_id as bomRowId
|
||||
|
|
@ -103,6 +113,25 @@
|
|||
order by release_time desc
|
||||
</select>
|
||||
|
||||
<!--获取已发布列表-->
|
||||
<select id="releaseListExcel" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomWorkExcelVO">
|
||||
select * , row_id as bomRowId
|
||||
from t_bom_new_pbom_parent where status >= 4
|
||||
<if test="query.startDate== null">
|
||||
and release_time > DATE_SUB(release_time, INTERVAL 3 DAY)
|
||||
</if>
|
||||
<if test="query.facCode!= null and query.facCode!=''">
|
||||
and fac_code = #{query.facCode}
|
||||
</if>
|
||||
<if test="query.materialNo!= null and query.materialNo!=''">
|
||||
and material_no = #{query.materialNo}
|
||||
</if>
|
||||
<if test="query.drawingNo!= null and query.drawingNo!=''">
|
||||
and drawing_no = #{query.drawingNo}
|
||||
</if>
|
||||
order by release_time desc
|
||||
</select>
|
||||
|
||||
<select id="getParentChild" resultType="com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO">
|
||||
select * from t_bom_new_pbom_child where parent_row_id=#{parentRowId}
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue