优化结构树查询和单行查询导出接口开发
This commit is contained in:
@@ -98,6 +98,11 @@
|
|||||||
<artifactId>qomo-kn-cost-manage</artifactId>
|
<artifactId>qomo-kn-cost-manage</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.11.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,26 @@
|
|||||||
<artifactId>mybatis-plus-generator</artifactId>
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>easyexcel</artifactId>
|
||||||
|
<version>4.0.1</version> <!-- 请检查并使用最新稳定版本 -->
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.11.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>5.2.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.2.3</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
+19
-6
@@ -1,23 +1,35 @@
|
|||||||
package com.zzsmart.qomo.kn.cost.manage.controller;
|
package com.zzsmart.qomo.kn.cost.manage.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardVersion;
|
|
||||||
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
|
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.service.ICostStandardVersionService;
|
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailSearch;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.zzsmart.qomo.kn.cost.manage.util.EasyExcelUtil.getExcelPropertyAnnotatedFields;
|
||||||
|
import static com.zzsmart.qomo.kn.cost.manage.util.EasyExcelUtil.getIncludeFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -58,11 +70,12 @@ public class CostStandardDetailController extends JeecgController<CostStandardDe
|
|||||||
* 导出excel
|
* 导出excel
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param costStandardDetail
|
* @param costStandardDetailSearch
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/exportXls", method = RequestMethod.GET)
|
@RequestMapping(value = "/exportXls", method = RequestMethod.GET)
|
||||||
@ApiOperation(value = "单行查询导出", notes = "单行查询导出")
|
@ApiOperation(value = "单行查询导出", notes = "单行查询导出")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, CostStandardDetail costStandardDetail) {
|
public Result exportXls(HttpServletRequest request, HttpServletResponse response, CostStandardDetailSearch costStandardDetailSearch) throws IOException {
|
||||||
return super.exportXls(request, costStandardDetail, CostStandardDetail.class, "单行查询");
|
JSONObject result = costStandardDetailService.exportExcel(request, response, costStandardDetailSearch);
|
||||||
|
return Result.OK(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-4
@@ -1,5 +1,6 @@
|
|||||||
package com.zzsmart.qomo.kn.cost.manage.entity;
|
package com.zzsmart.qomo.kn.cost.manage.entity;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
@@ -9,10 +10,7 @@ import java.math.BigDecimal;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Builder;
|
import lombok.*;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,6 +24,7 @@ import lombok.experimental.Accessors;
|
|||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@TableName("cost_standard_detail")
|
@TableName("cost_standard_detail")
|
||||||
|
@EqualsAndHashCode
|
||||||
public class CostStandardDetail implements Serializable {
|
public class CostStandardDetail implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -41,6 +40,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("material_number")
|
@TableField("material_number")
|
||||||
@ApiModelProperty(value = "物料号,关联kn_new_sap_mara表matnr字段")
|
@ApiModelProperty(value = "物料号,关联kn_new_sap_mara表matnr字段")
|
||||||
|
@ExcelProperty("物料号")
|
||||||
private String materialNumber;
|
private String materialNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,6 +48,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("material_name")
|
@TableField("material_name")
|
||||||
@ApiModelProperty(value = "物料名称")
|
@ApiModelProperty(value = "物料名称")
|
||||||
|
@ExcelProperty("物料名称")
|
||||||
private String materialName;
|
private String materialName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,6 +56,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("parent_material_number")
|
@TableField("parent_material_number")
|
||||||
@ApiModelProperty(value = "父类物料号")
|
@ApiModelProperty(value = "父类物料号")
|
||||||
|
@ExcelProperty("父类物料号")
|
||||||
private String parentMaterialNumber;
|
private String parentMaterialNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,6 +71,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("level")
|
@TableField("level")
|
||||||
@ApiModelProperty(value = "层级")
|
@ApiModelProperty(value = "层级")
|
||||||
|
@ExcelProperty("层级")
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,6 +79,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("figure_number")
|
@TableField("figure_number")
|
||||||
@ApiModelProperty(value = "图号")
|
@ApiModelProperty(value = "图号")
|
||||||
|
@ExcelProperty("图号")
|
||||||
private String figureNumber;
|
private String figureNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,6 +87,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("dosage")
|
@TableField("dosage")
|
||||||
@ApiModelProperty(value = "用量")
|
@ApiModelProperty(value = "用量")
|
||||||
|
@ExcelProperty("用量")
|
||||||
private Double dosage;
|
private Double dosage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,6 +95,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("unit")
|
@TableField("unit")
|
||||||
@ApiModelProperty(value = "单位")
|
@ApiModelProperty(value = "单位")
|
||||||
|
@ExcelProperty("单位")
|
||||||
private String unit;
|
private String unit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +103,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("specification")
|
@TableField("specification")
|
||||||
@ApiModelProperty(value = "规格")
|
@ApiModelProperty(value = "规格")
|
||||||
|
@ExcelProperty("规格")
|
||||||
private String specification;
|
private String specification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,6 +111,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("bom_cost")
|
@TableField("bom_cost")
|
||||||
@ApiModelProperty(value = "bom材料费")
|
@ApiModelProperty(value = "bom材料费")
|
||||||
|
@ExcelProperty("bom材料费")
|
||||||
private BigDecimal bomCost;
|
private BigDecimal bomCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,6 +119,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("packing_cost")
|
@TableField("packing_cost")
|
||||||
@ApiModelProperty(value = "包装费")
|
@ApiModelProperty(value = "包装费")
|
||||||
|
@ExcelProperty("包装费")
|
||||||
private BigDecimal packingCost;
|
private BigDecimal packingCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,6 +127,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("auxiliary_cost")
|
@TableField("auxiliary_cost")
|
||||||
@ApiModelProperty(value = "本阶辅料费")
|
@ApiModelProperty(value = "本阶辅料费")
|
||||||
|
@ExcelProperty("本阶辅料费")
|
||||||
private BigDecimal auxiliaryCost;
|
private BigDecimal auxiliaryCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,6 +135,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("labor_cost")
|
@TableField("labor_cost")
|
||||||
@ApiModelProperty(value = "本阶人工费")
|
@ApiModelProperty(value = "本阶人工费")
|
||||||
|
@ExcelProperty("本阶人工费")
|
||||||
private BigDecimal laborCost;
|
private BigDecimal laborCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,6 +143,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("euip_depreciation_cost")
|
@TableField("euip_depreciation_cost")
|
||||||
@ApiModelProperty(value = "机器折旧费")
|
@ApiModelProperty(value = "机器折旧费")
|
||||||
|
@ExcelProperty("机器折旧费")
|
||||||
private BigDecimal euipDepreciationCost;
|
private BigDecimal euipDepreciationCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -139,6 +151,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("equip_consume_cost")
|
@TableField("equip_consume_cost")
|
||||||
@ApiModelProperty(value = "机物料消耗费")
|
@ApiModelProperty(value = "机物料消耗费")
|
||||||
|
@ExcelProperty("机物料消耗费")
|
||||||
private BigDecimal equipConsumeCost;
|
private BigDecimal equipConsumeCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,6 +159,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("hydroelectricity_cost")
|
@TableField("hydroelectricity_cost")
|
||||||
@ApiModelProperty(value = "水电费")
|
@ApiModelProperty(value = "水电费")
|
||||||
|
@ExcelProperty("水电费")
|
||||||
private BigDecimal hydroelectricityCost;
|
private BigDecimal hydroelectricityCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,6 +167,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("other_cost")
|
@TableField("other_cost")
|
||||||
@ApiModelProperty(value = "其他制造费")
|
@ApiModelProperty(value = "其他制造费")
|
||||||
|
@ExcelProperty("其他制造费")
|
||||||
private BigDecimal otherCost;
|
private BigDecimal otherCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,6 +175,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("trail_cost")
|
@TableField("trail_cost")
|
||||||
@ApiModelProperty(value = "物流费")
|
@ApiModelProperty(value = "物流费")
|
||||||
|
@ExcelProperty("物流费")
|
||||||
private BigDecimal trailCost;
|
private BigDecimal trailCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,6 +183,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("manufacture_cost")
|
@TableField("manufacture_cost")
|
||||||
@ApiModelProperty(value = "制造成本")
|
@ApiModelProperty(value = "制造成本")
|
||||||
|
@ExcelProperty("制造成本")
|
||||||
private BigDecimal manufactureCost;
|
private BigDecimal manufactureCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,6 +191,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("total_labor_cost")
|
@TableField("total_labor_cost")
|
||||||
@ApiModelProperty(value = "累计人工费")
|
@ApiModelProperty(value = "累计人工费")
|
||||||
|
@ExcelProperty("累计人工费")
|
||||||
private BigDecimal totalLaborCost;
|
private BigDecimal totalLaborCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -181,6 +199,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("total_equip_consume_cost")
|
@TableField("total_equip_consume_cost")
|
||||||
@ApiModelProperty(value = "累计机器消耗费")
|
@ApiModelProperty(value = "累计机器消耗费")
|
||||||
|
@ExcelProperty("累计机器消耗费")
|
||||||
private BigDecimal totalEquipConsumeCost;
|
private BigDecimal totalEquipConsumeCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,6 +207,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("total_euip_depreciation_cost")
|
@TableField("total_euip_depreciation_cost")
|
||||||
@ApiModelProperty(value = "累计机器折旧费")
|
@ApiModelProperty(value = "累计机器折旧费")
|
||||||
|
@ExcelProperty("累计机器折旧费")
|
||||||
private BigDecimal totalEuipDepreciationCost;
|
private BigDecimal totalEuipDepreciationCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,6 +215,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("total_hydroelectricity_cost")
|
@TableField("total_hydroelectricity_cost")
|
||||||
@ApiModelProperty(value = "累计水电费")
|
@ApiModelProperty(value = "累计水电费")
|
||||||
|
@ExcelProperty("累计水电费")
|
||||||
private BigDecimal totalHydroelectricityCost;
|
private BigDecimal totalHydroelectricityCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -202,6 +223,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("total_other_cost")
|
@TableField("total_other_cost")
|
||||||
@ApiModelProperty(value = "累计其它费用")
|
@ApiModelProperty(value = "累计其它费用")
|
||||||
|
@ExcelProperty("累计其它费用")
|
||||||
private BigDecimal totalOtherCost;
|
private BigDecimal totalOtherCost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,6 +266,7 @@ public class CostStandardDetail implements Serializable {
|
|||||||
*/
|
*/
|
||||||
@TableField("sort")
|
@TableField("sort")
|
||||||
@ApiModelProperty(value = "序号")
|
@ApiModelProperty(value = "序号")
|
||||||
|
@ExcelProperty("序号")
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -1,11 +1,15 @@
|
|||||||
package com.zzsmart.qomo.kn.cost.manage.service;
|
package com.zzsmart.qomo.kn.cost.manage.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailSearch;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -18,10 +22,20 @@ import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
|
|||||||
public interface CostStandardDetailService extends IService<CostStandardDetail> {
|
public interface CostStandardDetailService extends IService<CostStandardDetail> {
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
|
*
|
||||||
* @param page
|
* @param page
|
||||||
* @param
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
IPage<CostStandardDetailVO> pageList(Page<CostStandardDetailVO> page, CostStandardDetailVO costStandard);
|
IPage<CostStandardDetailVO> pageList(Page<CostStandardDetailVO> page, CostStandardDetailVO costStandard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出列表信息为Excel文件
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @param costStandardDetailSearch
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JSONObject exportExcel(HttpServletRequest request, HttpServletResponse response, CostStandardDetailSearch costStandardDetailSearch);
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -49,6 +49,16 @@ public class BomTreeServiceImpl implements BomTreeService {
|
|||||||
wrapper1.like("parent_material_number", materialNumber1);
|
wrapper1.like("parent_material_number", materialNumber1);
|
||||||
}
|
}
|
||||||
List<CostStandardDetail> costStandardDetails = costStandardDetailMapper.selectList(wrapper1);
|
List<CostStandardDetail> costStandardDetails = costStandardDetailMapper.selectList(wrapper1);
|
||||||
|
//第三层叶子节点
|
||||||
|
List<CostStandardDetail> threeNodes=new ArrayList<>();
|
||||||
|
if(costStandardDetails!=null&&costStandardDetails.size()>0){
|
||||||
|
List<String> materialNoList = costStandardDetails.stream().map(CostStandardDetail::getMaterialNumber).collect(Collectors.toList());
|
||||||
|
QueryWrapper<CostStandardDetail> wrapper2 = new QueryWrapper<>();
|
||||||
|
wrapper2.in("parent_material_number", materialNoList);
|
||||||
|
|
||||||
|
threeNodes = costStandardDetailMapper.selectList(wrapper2);
|
||||||
|
}
|
||||||
|
//把第二层叶子节点转化为bomtreeinfoVO对象集合
|
||||||
costStandardDetailVOS=new ArrayList<>();
|
costStandardDetailVOS=new ArrayList<>();
|
||||||
for (int i=0;i<costStandardDetails.size();i++){
|
for (int i=0;i<costStandardDetails.size();i++){
|
||||||
CostStandardDetail costStandardDetail = costStandardDetails.get(i);
|
CostStandardDetail costStandardDetail = costStandardDetails.get(i);
|
||||||
@@ -56,6 +66,13 @@ public class BomTreeServiceImpl implements BomTreeService {
|
|||||||
BeanUtils.copyProperties(costStandardDetail,vo);
|
BeanUtils.copyProperties(costStandardDetail,vo);
|
||||||
costStandardDetailVOS.add(vo);
|
costStandardDetailVOS.add(vo);
|
||||||
}
|
}
|
||||||
|
//把第三层叶子节点转化为bomtreeinfoVO对象集合
|
||||||
|
for (int i=0;i<threeNodes.size();i++){
|
||||||
|
CostStandardDetail costStandardDetail = threeNodes.get(i);
|
||||||
|
CostStandardDetailVO vo=new CostStandardDetailVO();
|
||||||
|
BeanUtils.copyProperties(costStandardDetail,vo);
|
||||||
|
costStandardDetailVOS.add(vo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<BomTreeInfoVO> bomTreeInfoVOS = BomTreeBuilder.buildBomTree(costStandardDetailVOS, parentDataMap);
|
List<BomTreeInfoVO> bomTreeInfoVOS = BomTreeBuilder.buildBomTree(costStandardDetailVOS, parentDataMap);
|
||||||
return bomTreeInfoVOS;
|
return bomTreeInfoVOS;
|
||||||
|
|||||||
+37
-8
@@ -1,18 +1,28 @@
|
|||||||
package com.zzsmart.qomo.kn.cost.manage.service.impl;
|
package com.zzsmart.qomo.kn.cost.manage.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.mapper.CostStandardDetailMapper;
|
import com.zzsmart.qomo.kn.cost.manage.mapper.CostStandardDetailMapper;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
|
import com.zzsmart.qomo.kn.cost.manage.service.CostStandardDetailService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailSearch;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardDetailVO;
|
||||||
import com.zzsmart.qomo.kn.cost.manage.vo.CostStandardVO;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static com.zzsmart.qomo.kn.cost.manage.util.EasyExcelUtil.getIncludeFields;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 标准成本明细表 服务实现类
|
* 标准成本明细表 服务实现类
|
||||||
@@ -26,6 +36,7 @@ public class CostStandardDetailServiceImpl extends ServiceImpl<CostStandardDetai
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
CostStandardDetailMapper costStandardDetailMapper;
|
CostStandardDetailMapper costStandardDetailMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
*
|
*
|
||||||
@@ -38,18 +49,36 @@ public class CostStandardDetailServiceImpl extends ServiceImpl<CostStandardDetai
|
|||||||
// 查询条件组装
|
// 查询条件组装
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
|
|
||||||
if(costStandard != null){
|
if (costStandard != null) {
|
||||||
|
|
||||||
if(StrUtil.isNotEmpty(costStandard.getMaterialNumber()) ){
|
if (StrUtil.isNotEmpty(costStandard.getMaterialNumber())) {
|
||||||
// 物料号
|
// 物料号
|
||||||
queryWrapper.like("c1.material_number",costStandard.getMaterialNumber());
|
queryWrapper.like("c1.material_number", costStandard.getMaterialNumber());
|
||||||
}
|
}
|
||||||
if(StrUtil.isNotEmpty(costStandard.getVersionNumber()) ){
|
if (StrUtil.isNotEmpty(costStandard.getVersionNumber())) {
|
||||||
// 版本号
|
// 版本号
|
||||||
queryWrapper.like("c2.version_number",costStandard.getVersionNumber());
|
queryWrapper.like("c2.version_number", costStandard.getVersionNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return (IPage<CostStandardDetailVO>) costStandardDetailMapper.pageList(page,queryWrapper);
|
return (IPage<CostStandardDetailVO>) costStandardDetailMapper.pageList(page, queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject exportExcel(HttpServletRequest request, HttpServletResponse response, CostStandardDetailSearch costStandardDetailSearch) {
|
||||||
|
QueryWrapper<CostStandardDetail> queryWrapper = QueryGenerator.initQueryWrapper(costStandardDetailSearch, request.getParameterMap());
|
||||||
|
if (costStandardDetailSearch != null && costStandardDetailSearch.getSelections() != null && costStandardDetailSearch.getSelections().size() > 0) {
|
||||||
|
queryWrapper.in("id", costStandardDetailSearch.getSelections());
|
||||||
|
}
|
||||||
|
List exportList = list(queryWrapper);
|
||||||
|
// EasyExcelUtil.export(response, "D:/WorkDoc/PHM/单机部署/单行查询.xls", null, exportList,CostStandardDetail.class);
|
||||||
|
// 根据用户传入字段 假设我们要忽略 date
|
||||||
|
Set<String> includeFields = getIncludeFields(CostStandardDetail.class);
|
||||||
|
EasyExcel.write("D:/WorkDoc/PHM/单机部署/单行查询.xls", CostStandardDetail.class).includeColumnFieldNames(includeFields).sheet("模板").doWrite(exportList);
|
||||||
|
// return super.exportXls(request, costStandardDetail, CostStandardDetail.class, "单行查询");
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("filePath", "D:/WorkDoc/PHM/单机部署/单行查询.xls");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -13,7 +13,7 @@ import java.util.stream.Collectors;
|
|||||||
public class BomTreeBuilder {
|
public class BomTreeBuilder {
|
||||||
public static List<BomTreeInfoVO> buildBomTree(List<CostStandardDetailVO> sourceData, Map<String, CostStandardDetailVO> parentDataMap) {
|
public static List<BomTreeInfoVO> buildBomTree(List<CostStandardDetailVO> sourceData, Map<String, CostStandardDetailVO> parentDataMap) {
|
||||||
List<BomTreeInfoVO> result = new ArrayList<>();
|
List<BomTreeInfoVO> result = new ArrayList<>();
|
||||||
if ((sourceData == null || (sourceData != null && sourceData.size() < 1))&& (parentDataMap == null || (parentDataMap != null && parentDataMap.size() < 1))) {
|
if ((sourceData == null || (sourceData != null && sourceData.size() < 1)) && (parentDataMap == null || (parentDataMap != null && parentDataMap.size() < 1))) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//1.把BOM信息分成按照物料号分组
|
//1.把BOM信息分成按照物料号分组
|
||||||
@@ -54,6 +54,11 @@ public class BomTreeBuilder {
|
|||||||
if (parentBomTreeInfoVO != null) {
|
if (parentBomTreeInfoVO != null) {
|
||||||
//4.根据物料号查找子节点
|
//4.根据物料号查找子节点
|
||||||
List<CostStandardDetailVO> childs = childDataMap.get(parentBomTreeInfoVO.getMaterialNumber());
|
List<CostStandardDetailVO> childs = childDataMap.get(parentBomTreeInfoVO.getMaterialNumber());
|
||||||
|
if (childs != null && childs.size() > 0) {
|
||||||
|
parentBomTreeInfoVO.setHasChildren(true);
|
||||||
|
} else {
|
||||||
|
parentBomTreeInfoVO.setHasChildren(false);
|
||||||
|
}
|
||||||
//构造父节点下的bomtree结构数据
|
//构造父节点下的bomtree结构数据
|
||||||
List<BomTreeInfoVO> children = new ArrayList<>();
|
List<BomTreeInfoVO> children = new ArrayList<>();
|
||||||
for (int j = 0; childs != null && childs.size() > 0 && j < childs.size(); j++) {
|
for (int j = 0; childs != null && childs.size() > 0 && j < childs.size(); j++) {
|
||||||
|
|||||||
+135
@@ -0,0 +1,135 @@
|
|||||||
|
package com.zzsmart.qomo.kn.cost.manage.util;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||||
|
import com.alibaba.excel.write.metadata.style.WriteFont;
|
||||||
|
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||||
|
import com.zzsmart.qomo.kn.cost.manage.entity.CostStandardDetail;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class EasyExcelUtil {
|
||||||
|
/**
|
||||||
|
* 导出Excel文件到HTTP响应流,包含自定义表头。
|
||||||
|
*
|
||||||
|
* @param response HTTP响应对象
|
||||||
|
* @param fileName 导出的文件名
|
||||||
|
* @param head 表头信息列表
|
||||||
|
* @param data 需要导出的数据列表
|
||||||
|
* @param clazz 数据模型的Class类型
|
||||||
|
* @throws IOException IO异常
|
||||||
|
*/
|
||||||
|
public static <T> void export(HttpServletResponse response, String fileName, List<?> head, List<T> data, Class<T> clazz) throws IOException {
|
||||||
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||||
|
try {
|
||||||
|
fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()).replaceAll("\\+", "%20");
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义表头样式
|
||||||
|
HorizontalCellStyleStrategy horizontalCellStyleStrategy = getHorizontalCellStyleStrategy();
|
||||||
|
|
||||||
|
// 使用EasyExcel导出
|
||||||
|
try {
|
||||||
|
EasyExcel.write(response.getOutputStream(), clazz)
|
||||||
|
// 注册样式策略
|
||||||
|
.registerWriteHandler(horizontalCellStyleStrategy).sheet("1111").doWrite(data);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
// FileOutputStream outputStream= new FileOutputStream(fileName);
|
||||||
|
// try {
|
||||||
|
// EasyExcel.write(outputStream)
|
||||||
|
// // 设置自定义样式,可选
|
||||||
|
// .sheet("Sheet1") // 设置工作表名称
|
||||||
|
// .doWrite(data); // 将数据写入Excel
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// System.out.println("zheli==============");
|
||||||
|
// } finally {
|
||||||
|
//// if (excelWriter != null) {
|
||||||
|
//// excelWriter.finish();
|
||||||
|
//// }
|
||||||
|
// if (outputStream != null) {
|
||||||
|
// outputStream.close();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建自定义的水平单元格样式策略,用于表头样式。
|
||||||
|
*
|
||||||
|
* @return 水平单元格样式策略
|
||||||
|
*/
|
||||||
|
private static HorizontalCellStyleStrategy getHorizontalCellStyleStrategy() {
|
||||||
|
// 设置表头字体样式
|
||||||
|
WriteFont headFont = new WriteFont();
|
||||||
|
headFont.setFontHeightInPoints((short) 12);
|
||||||
|
headFont.setFontName("Arial");
|
||||||
|
headFont.setBold(true);
|
||||||
|
|
||||||
|
// 设置表头单元格样式
|
||||||
|
WriteCellStyle headCellStyle = new WriteCellStyle();
|
||||||
|
headCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
||||||
|
headCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||||
|
headCellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
|
||||||
|
headCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
|
||||||
|
headCellStyle.setBorderLeft(BorderStyle.THIN);
|
||||||
|
headCellStyle.setBorderRight(BorderStyle.THIN);
|
||||||
|
headCellStyle.setBorderTop(BorderStyle.THIN);
|
||||||
|
headCellStyle.setBorderBottom(BorderStyle.THIN);
|
||||||
|
headCellStyle.setWriteFont(headFont);
|
||||||
|
|
||||||
|
// 创建并返回水平单元格样式策略
|
||||||
|
return new HorizontalCellStyleStrategy(headCellStyle, (List<WriteCellStyle>) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取带有@Excel注解的属性集合
|
||||||
|
*
|
||||||
|
* @param clazz 实体类的Class对象
|
||||||
|
* @return 带有@Excel注解的Field集合
|
||||||
|
*/
|
||||||
|
public static Field[] getExcelPropertyAnnotatedFields(Class<?> clazz) {
|
||||||
|
Field[] fields = clazz.getDeclaredFields();
|
||||||
|
List<Field> annotatedFields = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Field field : fields) {
|
||||||
|
if (field.isAnnotationPresent(ExcelProperty.class)) {
|
||||||
|
annotatedFields.add(field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return annotatedFields.toArray(new Field[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询类需要导出的列名
|
||||||
|
*
|
||||||
|
* @param clazz
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Set<String> getIncludeFields(Class<?> clazz) {
|
||||||
|
Field[] excelPropertyAnnotatedFields = getExcelPropertyAnnotatedFields(CostStandardDetail.class);
|
||||||
|
Set<String> includeColumnFiledNames = new HashSet<String>();
|
||||||
|
for (int i = 0; i < excelPropertyAnnotatedFields.length; i++) {
|
||||||
|
includeColumnFiledNames.add(excelPropertyAnnotatedFields[i].getName());
|
||||||
|
}
|
||||||
|
return includeColumnFiledNames;
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -137,4 +137,9 @@ public class BomTreeInfoVO {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "子节点")
|
@ApiModelProperty(value = "子节点")
|
||||||
private List<BomTreeInfoVO> children;
|
private List<BomTreeInfoVO> children;
|
||||||
|
/**
|
||||||
|
* 是否有叶子节点
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "是否有叶子节点")
|
||||||
|
private boolean hasChildren;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
package com.zzsmart.qomo.kn.cost.manage.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value="bom结构树", description="bom结构树")
|
||||||
|
public class CostStandardDetailSearch extends CostStandardDetailVO {
|
||||||
|
/**
|
||||||
|
* 选择行的id
|
||||||
|
*/
|
||||||
|
private List<String> selections;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user