Explorar o código

成本模型新增

LLL hai 1 ano
pai
achega
365114af1f
Modificáronse 17 ficheiros con 624 adicións e 99 borrados
  1. 161 31
      module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/entity/CostModelClPrice.java
  2. 5 4
      module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/mapper/CostModelClPriceMapper.java
  3. 28 1
      module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/mapper/xml/CostModelClPriceMapper.xml
  4. 5 1
      module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/service/ICostModelClPriceService.java
  5. 15 2
      module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/service/impl/CostModelClPriceServiceImpl.java
  6. 79 44
      module_kzks/src/main/java/org/jeecg/modules/costModelList/controller/CostModelListController.java
  7. 22 0
      module_kzks/src/main/java/org/jeecg/modules/costModelList/convert/CostModelListConvert.java
  8. 56 0
      module_kzks/src/main/java/org/jeecg/modules/costModelList/dto/CostModelListAddDTO.java
  9. 14 0
      module_kzks/src/main/java/org/jeecg/modules/costModelList/dto/FileDTO.java
  10. 8 3
      module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/mapper/CostModelWxPriceMapper.java
  11. 28 1
      module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/mapper/xml/CostModelWxPriceMapper.xml
  12. 5 1
      module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/service/ICostModelWxPriceService.java
  13. 7 7
      module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/service/impl/CostModelWxPriceServiceImpl.java
  14. 8 1
      module_kzks/src/main/java/org/jeecg/modules/costModelXmxqCl/service/ICostModelXmxqClService.java
  15. 89 1
      module_kzks/src/main/java/org/jeecg/modules/costModelXmxqCl/service/impl/CostModelXmxqClServiceImpl.java
  16. 8 1
      module_kzks/src/main/java/org/jeecg/modules/costModelXmxqWx/service/ICostModelXmxqWxService.java
  17. 86 1
      module_kzks/src/main/java/org/jeecg/modules/costModelXmxqWx/service/impl/CostModelXmxqWxServiceImpl.java

+ 161 - 31
module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/entity/CostModelClPrice.java

@@ -32,51 +32,181 @@ import lombok.experimental.Accessors;
 public class CostModelClPrice implements Serializable {
 public class CostModelClPrice implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
-	/**id*/
-	@TableId(type = IdType.ASSIGN_ID)
+    /**id*/
+    @TableId(type = IdType.ASSIGN_ID)
     @ApiModelProperty(value = "id")
     @ApiModelProperty(value = "id")
     private java.lang.String id;
     private java.lang.String id;
-	/**创建人*/
+    /**物料编码*/
+    @Excel(name = "物料编码", width = 15)
+    @ApiModelProperty(value = "物料编码")
+    private java.lang.String wlbm;
+    /**规格型号*/
+    @Excel(name = "规格型号", width = 15)
+    @ApiModelProperty(value = "规格型号")
+    private java.lang.String ggxh;
+    /**质量等级*/
+    @Excel(name = "质量等级", width = 15)
+    @ApiModelProperty(value = "质量等级")
+    private java.lang.String zlLevel;
+    /**单价*/
+    @Excel(name = "单价", width = 15)
+    @ApiModelProperty(value = "单价")
+    private java.lang.String danjia;
+    /**批次号*/
+    @Excel(name = "批次号", width = 15)
+    @ApiModelProperty(value = "批次号")
+    private java.lang.String pici;
+    /**创建人*/
     @ApiModelProperty(value = "创建人")
     @ApiModelProperty(value = "创建人")
     private java.lang.String createBy;
     private java.lang.String createBy;
-	/**创建日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    /**供应商批次号*/
+    @Excel(name = "供应商批次号", width = 15)
+    @ApiModelProperty(value = "供应商批次号")
+    private java.lang.String wzGysPch;
+    /**合同签署日期*/
+    @Excel(name = "合同签署日期", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "合同签署日期")
+    private java.util.Date htDate;
+    /**合同余额*/
+    @Excel(name = "合同余额", width = 15)
+    @ApiModelProperty(value = "合同余额")
+    private java.lang.String htye;
+    /**发票开票时间*/
+    @Excel(name = "发票开票时间", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "发票开票时间")
+    private java.util.Date fpDate;
+    /**计量单位*/
+    @Excel(name = "计量单位", width = 15)
+    @ApiModelProperty(value = "计量单位")
+    private java.lang.String jldw;
+    /**DFHTH*/
+    @Excel(name = "DFHTH", width = 15)
+    @ApiModelProperty(value = "DFHTH")
+    private java.lang.String dfhth;
+    /**数量*/
+    @Excel(name = "数量", width = 15)
+    @ApiModelProperty(value = "数量")
+    private java.lang.String sl;
+    /**发票金额*/
+    @Excel(name = "发票金额", width = 15)
+    @ApiModelProperty(value = "发票金额")
+    private java.lang.String fpje;
+    /**供应商*/
+    @Excel(name = "供应商", width = 15)
+    @ApiModelProperty(value = "供应商")
+    private java.lang.String gys;
+    /**凭证金额*/
+    @Excel(name = "凭证金额", width = 15)
+    @ApiModelProperty(value = "凭证金额")
+    private java.lang.String pzje;
+    /**报销单金额*/
+    @Excel(name = "报销单金额", width = 15)
+    @ApiModelProperty(value = "报销单金额")
+    private java.lang.String bxdJe;
+    /**合同金额*/
+    @Excel(name = "合同金额", width = 15)
+    @ApiModelProperty(value = "合同金额")
+    private java.lang.String htJe;
+    /**入库单金额*/
+    @Excel(name = "入库单金额", width = 15)
+    @ApiModelProperty(value = "入库单金额")
+    private java.lang.String totalJe;
+    /**入库单号*/
+    @Excel(name = "入库单号", width = 15)
+    @ApiModelProperty(value = "入库单号")
+    private java.lang.Integer billno;
+    /**合同号*/
+    @Excel(name = "合同号", width = 15)
+    @ApiModelProperty(value = "合同号")
+    private java.lang.String hth;
+    /**合同年份*/
+    @Excel(name = "合同年份", width = 15)
+    @ApiModelProperty(value = "合同年份")
+    private java.lang.String tYear;
+    /**发票号*/
+    @Excel(name = "发票号", width = 15)
+    @ApiModelProperty(value = "发票号")
+    private java.lang.String fph;
+    /**报销单号*/
+    @Excel(name = "报销单号", width = 15)
+    @ApiModelProperty(value = "报销单号")
+    private java.lang.String bxdBh;
+    /**凭证日期*/
+    @Excel(name = "凭证日期", width = 15)
+    @ApiModelProperty(value = "凭证日期")
+    private java.lang.String pzrq;
+    /**费用类别*/
+    @Excel(name = "费用类别", width = 15)
+    @ApiModelProperty(value = "费用类别")
+    private java.lang.String fylb;
+    /**凭证编号*/
+    @Excel(name = "凭证编号", width = 15)
+    @ApiModelProperty(value = "凭证编号")
+    private java.lang.String pzbh;
+    /**银行流水号*/
+    @Excel(name = "银行流水号", width = 15)
+    @ApiModelProperty(value = "银行流水号")
+    private java.lang.String yhhdBh;
+    /**合同附件*/
+    @Excel(name = "合同附件", width = 15)
+    @ApiModelProperty(value = "合同附件")
+    private java.lang.String fjHt;
+    /**凭证附件*/
+    @Excel(name = "凭证附件", width = 15)
+    @ApiModelProperty(value = "凭证附件")
+    private java.lang.String fjPz;
+    /**报销单附件*/
+    @Excel(name = "报销单附件", width = 15)
+    @ApiModelProperty(value = "报销单附件")
+    private java.lang.String fjBxd;
+    /**回单附件*/
+    @Excel(name = "回单附件", width = 15)
+    @ApiModelProperty(value = "回单附件")
+    private java.lang.String fjYhhd;
+    /**入库单附件*/
+    @Excel(name = "入库单附件", width = 15)
+    @ApiModelProperty(value = "入库单附件")
+    private java.lang.String fjRkd;
+    /**发票附件*/
+    @Excel(name = "发票附件", width = 15)
+    @ApiModelProperty(value = "发票附件")
+    private java.lang.String fjFp;
+    /**物料名称*/
+    @Excel(name = "物料名称", width = 15)
+    @ApiModelProperty(value = "物料名称")
+    private java.lang.String wlmc;
+    /**凭证唯一码*/
+    @Excel(name = "凭证唯一码", width = 15)
+    @ApiModelProperty(value = "凭证唯一码")
+    private java.lang.String pzCode;
+    /**Unique Id(物料唯一码)*/
+    @Excel(name = "Unique Id(物料唯一码)", width = 15)
+    @ApiModelProperty(value = "Unique Id(物料唯一码)")
+    private java.lang.String uniqueId;
+    /**创建日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern="yyyy-MM-dd")
     @DateTimeFormat(pattern="yyyy-MM-dd")
     @ApiModelProperty(value = "创建日期")
     @ApiModelProperty(value = "创建日期")
     private java.util.Date createTime;
     private java.util.Date createTime;
-	/**更新人*/
+    /**更新人*/
     @ApiModelProperty(value = "更新人")
     @ApiModelProperty(value = "更新人")
     private java.lang.String updateBy;
     private java.lang.String updateBy;
-	/**更新日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    /**更新日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern="yyyy-MM-dd")
     @DateTimeFormat(pattern="yyyy-MM-dd")
     @ApiModelProperty(value = "更新日期")
     @ApiModelProperty(value = "更新日期")
     private java.util.Date updateTime;
     private java.util.Date updateTime;
-	/**所属部门*/
+    /**所属部门*/
     @ApiModelProperty(value = "所属部门")
     @ApiModelProperty(value = "所属部门")
     private java.lang.String sysOrgCode;
     private java.lang.String sysOrgCode;
-	/**物料编码*/
-	@Excel(name = "物料编码", width = 15)
-    @ApiModelProperty(value = "物料编码")
-    private java.lang.String wlbm;
-	/**规格型号*/
-	@Excel(name = "规格型号", width = 15)
-    @ApiModelProperty(value = "规格型号")
-    private java.lang.String ggxh;
-	/**质量等级*/
-	@Excel(name = "质量等级", width = 15)
-    @ApiModelProperty(value = "质量等级")
-    private java.lang.String zlLevel;
-	/**批次*/
-	@Excel(name = "批次", width = 15)
-    @ApiModelProperty(value = "批次")
-    private java.lang.String pici;
-	/**单价*/
-	@Excel(name = "单价", width = 15)
-    @ApiModelProperty(value = "单价")
-    private java.lang.String danjia;
     /**采购日期*/
     /**采购日期*/
-    @Excel(name = "采购日期", width = 15)
+    @Excel(name = "采购日期", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
     @ApiModelProperty(value = "采购日期")
     @ApiModelProperty(value = "采购日期")
-    private java.lang.String caigou_time;
+    private java.util.Date caigouTime;
 }
 }

+ 5 - 4
module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/mapper/CostModelClPriceMapper.java

@@ -1,10 +1,8 @@
 package org.jeecg.modules.costModelClPrice.mapper;
 package org.jeecg.modules.costModelClPrice.mapper;
 
 
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-import org.jeecg.modules.costModelClPrice.entity.CostModelClPrice;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.costModelClPrice.entity.CostModelClPrice;
+import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
 
 
 /**
 /**
  * @Description: 材料价格库
  * @Description: 材料价格库
@@ -14,4 +12,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
  */
 public interface CostModelClPriceMapper extends BaseMapper<CostModelClPrice> {
 public interface CostModelClPriceMapper extends BaseMapper<CostModelClPrice> {
 
 
+    /**查询*/
+    public CostModelXmxqCl selectClPriceValue(CostModelXmxqCl cl);
+
 }
 }

+ 28 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/mapper/xml/CostModelClPriceMapper.xml

@@ -2,4 +2,31 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.costModelClPrice.mapper.CostModelClPriceMapper">
 <mapper namespace="org.jeecg.modules.costModelClPrice.mapper.CostModelClPriceMapper">
 
 
-</mapper>
+    <select id="selectClPriceValue" parameterType="org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl" resultType="org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl">
+        select max(CONVERT(danjia, DECIMAL)) as maxDanjia,
+               min(CONVERT(danjia, DECIMAL)) as minDanjia,
+               avg(CONVERT(danjia, DECIMAL)) as aveDanjia,
+               ifnull((select danjia from kzks_cost_model_cl_price
+               ORDER BY ABS(NOW() - ifnull(caigou_time,now())) ASC limit 1),0) as recentDanjia,
+               max(CONVERT(danjia, DECIMAL)) * #{number} as maxPrice,
+               min(CONVERT(danjia, DECIMAL)) * #{number} as minPrice,
+               avg(CONVERT(danjia, DECIMAL)) * #{number} as avePrice,
+               ifnull((select danjia from kzks_cost_model_cl_price
+               ORDER BY ABS(NOW() - ifnull(caigou_time,now())) ASC limit 1),0) * #{number} as recentPrice,
+               #{xiangmuId} as xiangmuId,
+               #{xiangmuName} as xiangmuName,
+               #{caigouTime} as caigouTime,
+               #{number} as number,
+               #{wlbm} as wlbm,
+               #{ggxh} as ggxh,
+               #{zlLevel} as zlLevel,
+               #{pici} as pici
+        from kzks_cost_model_cl_price
+        <where>
+            <if test="wlbm != null  and wlbm != ''">and wlbm = #{wlbm}</if>
+            <if test="ggxh != null  and ggxh != ''">and ggxh = #{ggxh}</if>
+            <if test="zlLevel != null  and zlLevel != ''">and zl_level = #{zlLevel}</if>
+            <if test="pici != null  and pici != ''">and pici = #{pici}</if>
+        </where>
+    </select>
+</mapper>

+ 5 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/service/ICostModelClPriceService.java

@@ -1,7 +1,8 @@
 package org.jeecg.modules.costModelClPrice.service;
 package org.jeecg.modules.costModelClPrice.service;
 
 
-import org.jeecg.modules.costModelClPrice.entity.CostModelClPrice;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.costModelClPrice.entity.CostModelClPrice;
+import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
 
 
 /**
 /**
  * @Description: 材料价格库
  * @Description: 材料价格库
@@ -11,4 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
  */
 public interface ICostModelClPriceService extends IService<CostModelClPrice> {
 public interface ICostModelClPriceService extends IService<CostModelClPrice> {
 
 
+    /**查询*/
+    public CostModelXmxqCl selectClPriceValue(CostModelXmxqCl cl);
+
 }
 }

+ 15 - 2
module_kzks/src/main/java/org/jeecg/modules/costModelClPrice/service/impl/CostModelClPriceServiceImpl.java

@@ -1,12 +1,15 @@
 package org.jeecg.modules.costModelClPrice.service.impl;
 package org.jeecg.modules.costModelClPrice.service.impl;
 
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.jeecg.modules.costModelClPrice.entity.CostModelClPrice;
 import org.jeecg.modules.costModelClPrice.entity.CostModelClPrice;
 import org.jeecg.modules.costModelClPrice.mapper.CostModelClPriceMapper;
 import org.jeecg.modules.costModelClPrice.mapper.CostModelClPriceMapper;
 import org.jeecg.modules.costModelClPrice.service.ICostModelClPriceService;
 import org.jeecg.modules.costModelClPrice.service.ICostModelClPriceService;
+import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
+import org.jeecg.modules.dataSourceSwitch.annotation.TargetDataSource;
+import org.jeecg.modules.dataSourceSwitch.enums.DataSourceType;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-
 /**
 /**
  * @Description: 材料价格库
  * @Description: 材料价格库
  * @Author: jeecg-boot
  * @Author: jeecg-boot
@@ -14,6 +17,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  * @Version: V1.0
  * @Version: V1.0
  */
  */
 @Service
 @Service
+@TargetDataSource(value = DataSourceType.SLAVE)
 public class CostModelClPriceServiceImpl extends ServiceImpl<CostModelClPriceMapper, CostModelClPrice> implements ICostModelClPriceService {
 public class CostModelClPriceServiceImpl extends ServiceImpl<CostModelClPriceMapper, CostModelClPrice> implements ICostModelClPriceService {
 
 
+    @Autowired
+    @SuppressWarnings("all")
+    private CostModelClPriceMapper clPriceMapper;
+
+    /**查询*/
+    public CostModelXmxqCl selectClPriceValue(CostModelXmxqCl cl){
+        return clPriceMapper.selectClPriceValue(cl);
+    }
+
 }
 }

+ 79 - 44
module_kzks/src/main/java/org/jeecg/modules/costModelList/controller/CostModelListController.java

@@ -1,45 +1,34 @@
 package org.jeecg.modules.costModelList.controller;
 package org.jeecg.modules.costModelList.controller;
 
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.aspect.annotation.PermissionData;
 import org.jeecg.common.aspect.annotation.PermissionData;
+import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.config.JeecgBaseConfig;
+import org.jeecg.modules.costModelList.convert.CostModelListConvert;
+import org.jeecg.modules.costModelList.dto.CostModelListAddDTO;
 import org.jeecg.modules.costModelList.entity.CostModelList;
 import org.jeecg.modules.costModelList.entity.CostModelList;
 import org.jeecg.modules.costModelList.service.ICostModelListService;
 import org.jeecg.modules.costModelList.service.ICostModelListService;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.extern.slf4j.Slf4j;
-
-import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
+import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
+import org.jeecg.modules.costModelXmxqCl.service.ICostModelXmxqClService;
 import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
-import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
-import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.costModelXmxqWx.service.ICostModelXmxqWxService;
 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.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.ModelAndView;
-import com.alibaba.fastjson.JSON;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.jeecg.common.aspect.annotation.AutoLog;
 
 
- /**
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+
+/**
  * @Description: 成本模型
  * @Description: 成本模型
  * @Author: jeecg-boot
  * @Author: jeecg-boot
  * @Date:   2023-09-11
  * @Date:   2023-09-11
@@ -52,6 +41,52 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 public class CostModelListController extends JeecgController<CostModelList, ICostModelListService> {
 public class CostModelListController extends JeecgController<CostModelList, ICostModelListService> {
 	@Autowired
 	@Autowired
 	private ICostModelListService costModelListService;
 	private ICostModelListService costModelListService;
+	@Autowired
+	private ICostModelXmxqClService clService;
+	@Autowired
+	private ICostModelXmxqWxService wxService;
+	@Autowired
+	@SuppressWarnings("all")
+	private JeecgBaseConfig jeecgBaseConfig;
+
+	 /**
+	  *   成本模型新增
+	  */
+	 @AutoLog(value = "成本模型-添加")
+	 @ApiOperation(value="成本模型-添加", notes="成本模型-添加")
+	 //@RequiresPermissions("org.jeecg.modules:kzks_cost_model:add")
+	 @PostMapping(value = "/add")
+	 public Result<String> add(@RequestBody CostModelListAddDTO dto) {
+		 CostModelList costModelList = CostModelListConvert.INSTANCE.toCostModelList(dto);
+		 costModelListService.save(costModelList);
+
+		 String xmId = costModelList.getId();
+	 	 String xmName = dto.getXmName();
+		 String clfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  dto.getClfurl().get(0).getFilePath();
+		 String wxfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  dto.getClfurl().get(0).getFilePath();
+		 log.info("导入的材料费详情地址为:",wxfUrl);
+		 log.info("导入的外协费详情地址为:",wxfUrl);
+	 	 //计算并导入数据
+		 Result<CostModelList> result1 = clService.importExcel1(xmId, xmName, clfUrl, CostModelXmxqCl.class);
+		 CostModelList costModel1 = result1.getResult();
+		 if(costModel1!=null){
+			 costModelList.setMaxClf(costModel1.getMaxClf());
+			 costModelList.setMinClf(costModel1.getMinClf());
+			 costModelList.setAveClf(costModel1.getAveClf());
+			 costModelList.setRecentClf(costModel1.getRecentClf());
+		 }
+		 Result<CostModelList> result2 = wxService.importExcel1(xmId, xmName, clfUrl, CostModelXmxqWx.class);
+		 CostModelList costModel2 = result2.getResult();
+		 if(costModel2!=null){
+			 costModelList.setMaxWxf(costModel2.getMaxWxf());
+			 costModelList.setMinWxf(costModel2.getMinWxf());
+			 costModelList.setAveWxf(costModel2.getAveWxf());
+		 }
+
+		 costModelListService.updateById(costModelList);
+
+		 return Result.OK("添加成功!");
+	 }
 
 
 	/**
 	/**
 	 * 分页列表查询
 	 * 分页列表查询
@@ -76,20 +111,20 @@ public class CostModelListController extends JeecgController<CostModelList, ICos
 		return Result.OK(pageList);
 		return Result.OK(pageList);
 	}
 	}
 
 
-	/**
-	 *   添加
-	 *
-	 * @param costModelList
-	 * @return
-	 */
-	@AutoLog(value = "成本模型-添加")
-	@ApiOperation(value="成本模型-添加", notes="成本模型-添加")
-	//@RequiresPermissions("org.jeecg.modules:kzks_cost_model:add")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody CostModelList costModelList) {
-		costModelListService.save(costModelList);
-		return Result.OK("添加成功!");
-	}
+//	/**
+//	 *   添加
+//	 *
+//	 * @param costModelList
+//	 * @return
+//	 */
+//	@AutoLog(value = "成本模型-添加")
+//	@ApiOperation(value="成本模型-添加", notes="成本模型-添加")
+//	//@RequiresPermissions("org.jeecg.modules:kzks_cost_model:add")
+//	@PostMapping(value = "/add")
+//	public Result<String> add(@RequestBody CostModelList costModelList) {
+//		costModelListService.save(costModelList);
+//		return Result.OK("添加成功!");
+//	}
 
 
 	/**
 	/**
 	 *  编辑
 	 *  编辑

+ 22 - 0
module_kzks/src/main/java/org/jeecg/modules/costModelList/convert/CostModelListConvert.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.costModelList.convert;
+
+import org.jeecg.modules.costModelList.dto.CostModelListAddDTO;
+import org.jeecg.modules.costModelList.entity.CostModelList;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+import org.mapstruct.factory.Mappers;
+import org.springframework.util.CollectionUtils;
+
+import java.util.stream.Collectors;
+
+
+@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE,imports ={ CollectionUtils.class, Collectors.class})
+public interface CostModelListConvert {
+
+    CostModelListConvert INSTANCE = Mappers.getMapper(CostModelListConvert.class);
+
+//    @Mapping(target = "clf",source = "clf")
+//    @Mapping(target = "wxf",source = "wxf")
+    CostModelList toCostModelList(CostModelListAddDTO dto);
+
+}

+ 56 - 0
module_kzks/src/main/java/org/jeecg/modules/costModelList/dto/CostModelListAddDTO.java

@@ -0,0 +1,56 @@
+package org.jeecg.modules.costModelList.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class CostModelListAddDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**主键*/
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private java.lang.String id;
+    /**项目名称*/
+    @Excel(name = "项目名称", width = 15)
+    @ApiModelProperty(value = "项目名称")
+    private java.lang.String xmName;
+    /**外协费*/
+    @Excel(name = "外协费", width = 15)
+    @ApiModelProperty(value = "外协费文件地址")
+    private List<FileDTO> wxfurl;
+    /**材料费*/
+    @Excel(name = "材料费", width = 15)
+    @ApiModelProperty(value = "材料费文件地址")
+    private List<FileDTO> clfurl;
+    /**知会给*/
+    @ApiModelProperty(value = "知会给")
+    private java.lang.String informTo;
+    /**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private java.lang.String createBy;
+    /**创建日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private java.util.Date createTime;
+    /**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private java.lang.String updateBy;
+    /**更新日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private java.util.Date updateTime;
+    /**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private java.lang.String sysOrgCode;
+}

+ 14 - 0
module_kzks/src/main/java/org/jeecg/modules/costModelList/dto/FileDTO.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.costModelList.dto;
+
+import lombok.Data;
+
+@Data
+public class FileDTO {
+
+    private java.lang.String fileName;
+
+    private java.lang.String filePath;
+
+    private java.lang.String filesize;
+
+}

+ 8 - 3
module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/mapper/CostModelWxPriceMapper.java

@@ -1,11 +1,12 @@
 package org.jeecg.modules.costModelWxPrice.mapper;
 package org.jeecg.modules.costModelWxPrice.mapper;
 
 
-import java.util.List;
-
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Select;
 import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
 import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
+
+import java.util.List;
 
 
 /**
 /**
  * @Description: 外协价格库
  * @Description: 外协价格库
@@ -14,6 +15,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @Version: V1.0
  * @Version: V1.0
  */
  */
 public interface CostModelWxPriceMapper extends BaseMapper<CostModelWxPrice> {
 public interface CostModelWxPriceMapper extends BaseMapper<CostModelWxPrice> {
+
+    /**查询*/
+    public CostModelXmxqWx selectWxPriceValue(CostModelXmxqWx wx);
+
     /**外协价格库-查看表中所有数据-用来判断导入的数据是否有重复数据*/
     /**外协价格库-查看表中所有数据-用来判断导入的数据是否有重复数据*/
     @Select("select * from kzks_cost_model_wx_price")
     @Select("select * from kzks_cost_model_wx_price")
     public List<CostModelWxPrice> getWXPAllDetailList();
     public List<CostModelWxPrice> getWXPAllDetailList();

+ 28 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/mapper/xml/CostModelWxPriceMapper.xml

@@ -2,4 +2,31 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.modules.costModelWxPrice.mapper.CostModelWxPriceMapper">
 <mapper namespace="org.jeecg.modules.costModelWxPrice.mapper.CostModelWxPriceMapper">
 
 
-</mapper>
+    <select id="selectWxPriceValue" parameterType="org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx" resultType="org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx">
+        select
+        CONVERT(max_price, DECIMAL) as maxDanjia,
+        CONVERT(min_price, DECIMAL) as minDanjia,
+        CONVERT(ave_price, DECIMAL) as aveDanjia,
+        CONVERT(ave_price, DECIMAL) as recentDanjia,
+        CONVERT(max_price, DECIMAL) * #{number} as maxPrice,
+        CONVERT(min_price, DECIMAL) * #{number} as minPrice,
+        CONVERT(ave_price, DECIMAL) * #{number} as avePrice,
+        CONVERT(ave_price, DECIMAL) * #{number} as recentPrice,
+        #{xiangmuId} as xiangmuId,
+        #{xiangmuName} as xiangmuName,
+        #{wxProject} as wxProject,
+        #{wxCompany} as wxCompany,
+        #{unit} as unit,
+        #{number} as number,
+        #{remark} as remark
+        from kzks_cost_model_wx_price
+        <where>
+            <if test="wxProject != null  and wxProject != ''">and wx_project = #{wxProject}</if>
+            <if test="wxCompany != null  and wxCompany != ''">and wx_company = #{wxCompany}</if>
+            <if test="unit != null  and unit != ''">and unit = #{unit}</if>
+        </where>
+        limit 1
+    </select>
+
+
+</mapper>

+ 5 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/service/ICostModelWxPriceService.java

@@ -1,8 +1,9 @@
 package org.jeecg.modules.costModelWxPrice.service;
 package org.jeecg.modules.costModelWxPrice.service;
 
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
 import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
-import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
@@ -16,6 +17,9 @@ import java.util.List;
  */
  */
 public interface ICostModelWxPriceService extends IService<CostModelWxPrice> {
 public interface ICostModelWxPriceService extends IService<CostModelWxPrice> {
 
 
+    /**查询*/
+    public CostModelXmxqWx selectWxPriceValue(CostModelXmxqWx wx);
+
     /**查看表中所有数据-用来判断导入的数据是否有重复数据*/
     /**查看表中所有数据-用来判断导入的数据是否有重复数据*/
     public List<CostModelWxPrice> getWXPAllDetailList();
     public List<CostModelWxPrice> getWXPAllDetailList();
 
 

+ 7 - 7
module_kzks/src/main/java/org/jeecg/modules/costModelWxPrice/service/impl/CostModelWxPriceServiceImpl.java

@@ -1,27 +1,22 @@
 package org.jeecg.modules.costModelWxPrice.service.impl;
 package org.jeecg.modules.costModelWxPrice.service.impl;
 
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
-import org.hibernate.query.criteria.internal.expression.function.AggregationFunction;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
 import org.jeecg.modules.costModelWxPrice.entity.CostModelWxPrice;
 import org.jeecg.modules.costModelWxPrice.mapper.CostModelWxPriceMapper;
 import org.jeecg.modules.costModelWxPrice.mapper.CostModelWxPriceMapper;
 import org.jeecg.modules.costModelWxPrice.service.ICostModelWxPriceService;
 import org.jeecg.modules.costModelWxPrice.service.ICostModelWxPriceService;
+import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jetbrains.annotations.NotNull;
 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.*;
 import java.util.*;
 
 
 /**
 /**
@@ -38,6 +33,11 @@ public class CostModelWxPriceServiceImpl extends ServiceImpl<CostModelWxPriceMap
     @SuppressWarnings("all")
     @SuppressWarnings("all")
     public CostModelWxPriceMapper wxpMapper;
     public CostModelWxPriceMapper wxpMapper;
 
 
+    /**查询*/
+    public CostModelXmxqWx selectWxPriceValue(CostModelXmxqWx wx){
+        return wxpMapper.selectWxPriceValue(wx);
+    }
+
     /**查看表中所有数据-用来判断导入的数据是否有重复数据*/
     /**查看表中所有数据-用来判断导入的数据是否有重复数据*/
     public List<CostModelWxPrice> getWXPAllDetailList(){
     public List<CostModelWxPrice> getWXPAllDetailList(){
         return wxpMapper.getWXPAllDetailList();
         return wxpMapper.getWXPAllDetailList();

+ 8 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelXmxqCl/service/ICostModelXmxqClService.java

@@ -1,7 +1,9 @@
 package org.jeecg.modules.costModelXmxqCl.service;
 package org.jeecg.modules.costModelXmxqCl.service;
 
 
-import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.costModelList.entity.CostModelList;
+import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
 
 
 /**
 /**
  * @Description: 项目材料导入详情
  * @Description: 项目材料导入详情
@@ -11,4 +13,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
  */
 public interface ICostModelXmxqClService extends IService<CostModelXmxqCl> {
 public interface ICostModelXmxqClService extends IService<CostModelXmxqCl> {
 
 
+    /**
+     * 通过excel导入材料费
+     */
+    public Result<CostModelList> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqCl> clazz);
+
 }
 }

+ 89 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelXmxqCl/service/impl/CostModelXmxqClServiceImpl.java

@@ -1,11 +1,25 @@
 package org.jeecg.modules.costModelXmxqCl.service.impl;
 package org.jeecg.modules.costModelXmxqCl.service.impl;
 
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.costModelClPrice.service.ICostModelClPriceService;
+import org.jeecg.modules.costModelList.entity.CostModelList;
 import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
 import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
 import org.jeecg.modules.costModelXmxqCl.mapper.CostModelXmxqClMapper;
 import org.jeecg.modules.costModelXmxqCl.mapper.CostModelXmxqClMapper;
 import org.jeecg.modules.costModelXmxqCl.service.ICostModelXmxqClService;
 import org.jeecg.modules.costModelXmxqCl.service.ICostModelXmxqClService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
 /**
  * @Description: 项目材料导入详情
  * @Description: 项目材料导入详情
@@ -14,6 +28,80 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  * @Version: V1.0
  * @Version: V1.0
  */
  */
 @Service
 @Service
+@Slf4j
 public class CostModelXmxqClServiceImpl extends ServiceImpl<CostModelXmxqClMapper, CostModelXmxqCl> implements ICostModelXmxqClService {
 public class CostModelXmxqClServiceImpl extends ServiceImpl<CostModelXmxqClMapper, CostModelXmxqCl> implements ICostModelXmxqClService {
+    @Autowired
+    @SuppressWarnings("all")
+    private ICostModelClPriceService costModelClPriceService;
+
+    /**
+     * 通过excel导入材料费
+     */
+    public Result<CostModelList> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqCl> clazz) {
+        CostModelList costModelList = new CostModelList();
+        costModelList.setId(xmId);
+
+        InputStream inputStream = null;
+        try {
+            inputStream = new FileInputStream(strUrl);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        // 获取上传文件对象
+        ImportParams params = new ImportParams();
+        params.setTitleRows(0);/*表格标题所占行数(默认是0)*/
+        params.setHeadRows(1);/*表头所占据的行数行数,默认1,代表标题占据一行*/
+        params.setNeedSave(true);
+        try {
+            List<CostModelXmxqCl> list = ExcelImportUtil.importExcel(inputStream, clazz, params);
+
+            List<CostModelXmxqCl> list1 = new ArrayList<>();
+            BigDecimal clfMax = new BigDecimal(0);
+            BigDecimal clfMin = new BigDecimal(0);
+            BigDecimal clfAve = new BigDecimal(0);
+            BigDecimal clfRecent = new BigDecimal(0);
+            for(CostModelXmxqCl cl:list){
+                cl.setXiangmuName(xmName);
+                cl.setXiangmuId(xmId);
+                CostModelXmxqCl clxq = costModelClPriceService.selectClPriceValue(cl);
+                if(clxq != null){
+                    list1.add(clxq);
+                    clfMax = clfMax.add(new BigDecimal(clxq.getMaxPrice()));
+                    clfMin = clfMin.add(new BigDecimal(clxq.getMinPrice()));
+                    clfAve = clfAve.add(new BigDecimal(clxq.getAvePrice()));
+                    clfRecent = clfRecent.add(new BigDecimal(clxq.getRecentPrice()));
+                }
+            }
+            costModelList.setMaxClf(clfMax.toString());
+            costModelList.setMinClf(clfMin.toString());
+            costModelList.setAveClf(clfAve.toString());
+            costModelList.setRecentClf(clfRecent.toString());
+            //update-begin-author:taoyan date:20190528 for:批量插入数据
+            long start = System.currentTimeMillis();
+            this.saveBatch(list1);
+            //400条 saveBatch消耗时间1592毫秒  循环插入消耗时间1947毫秒
+            //1200条  saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
+            log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
+            //update-end-author:taoyan date:20190528 for:批量插入数据
+            return Result.OK("文件导入成功!数据行数:" + list.size(),costModelList);
+        } catch (Exception e) {
+            //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
+            String msg = e.getMessage();
+            log.error(msg, e);
+            if(msg!=null && msg.indexOf("Duplicate entry")>=0){
+                return Result.error("文件导入失败:有重复数据!");
+            }else{
+                return Result.error("文件导入失败:" + e.getMessage());
+            }
+            //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
+        } finally {
+            try {
+                inputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
 
 
 }
 }

+ 8 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelXmxqWx/service/ICostModelXmxqWxService.java

@@ -1,7 +1,9 @@
 package org.jeecg.modules.costModelXmxqWx.service;
 package org.jeecg.modules.costModelXmxqWx.service;
 
 
-import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.costModelList.entity.CostModelList;
+import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 
 
 /**
 /**
  * @Description: 项目外协导入详情
  * @Description: 项目外协导入详情
@@ -11,4 +13,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
  */
 public interface ICostModelXmxqWxService extends IService<CostModelXmxqWx> {
 public interface ICostModelXmxqWxService extends IService<CostModelXmxqWx> {
 
 
+    /**
+     * 通过excel导入材料费
+     */
+    public Result<CostModelList> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqWx> clazz);
+
 }
 }

+ 86 - 1
module_kzks/src/main/java/org/jeecg/modules/costModelXmxqWx/service/impl/CostModelXmxqWxServiceImpl.java

@@ -1,11 +1,25 @@
 package org.jeecg.modules.costModelXmxqWx.service.impl;
 package org.jeecg.modules.costModelXmxqWx.service.impl;
 
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.costModelList.entity.CostModelList;
+import org.jeecg.modules.costModelWxPrice.service.ICostModelWxPriceService;
 import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 import org.jeecg.modules.costModelXmxqWx.mapper.CostModelXmxqWxMapper;
 import org.jeecg.modules.costModelXmxqWx.mapper.CostModelXmxqWxMapper;
 import org.jeecg.modules.costModelXmxqWx.service.ICostModelXmxqWxService;
 import org.jeecg.modules.costModelXmxqWx.service.ICostModelXmxqWxService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
 /**
  * @Description: 项目外协导入详情
  * @Description: 项目外协导入详情
@@ -14,6 +28,77 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  * @Version: V1.0
  * @Version: V1.0
  */
  */
 @Service
 @Service
+@Slf4j
 public class CostModelXmxqWxServiceImpl extends ServiceImpl<CostModelXmxqWxMapper, CostModelXmxqWx> implements ICostModelXmxqWxService {
 public class CostModelXmxqWxServiceImpl extends ServiceImpl<CostModelXmxqWxMapper, CostModelXmxqWx> implements ICostModelXmxqWxService {
 
 
+    @Autowired
+    @SuppressWarnings("all")
+    private ICostModelWxPriceService costModelwXPriceService;
+
+    /**
+     * 通过excel导入材料费
+     */
+    public Result<CostModelList> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqWx> clazz){
+        CostModelList costModel = new CostModelList();
+
+        InputStream inputStream = null;
+        try {
+            inputStream = new FileInputStream(strUrl);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        // 获取上传文件对象
+        ImportParams params = new ImportParams();
+        params.setTitleRows(0);/*表格标题所占行数(默认是0)*/
+        params.setHeadRows(1);/*表头所占据的行数行数,默认1,代表标题占据一行*/
+        params.setNeedSave(true);
+        try {
+            List<CostModelXmxqWx> list = ExcelImportUtil.importExcel(inputStream, clazz, params);
+
+            List<CostModelXmxqWx> list1 = new ArrayList<>();
+            BigDecimal wxfMax = new BigDecimal(0);
+            BigDecimal wxfMin = new BigDecimal(0);
+            BigDecimal wxfAve = new BigDecimal(0);
+            for(CostModelXmxqWx wx:list){
+                wx.setXiangmuId(xmId);
+                wx.setXiangmuName(xmName);
+                CostModelXmxqWx wxxq = costModelwXPriceService.selectWxPriceValue(wx);
+                if(wxxq!=null){
+                    list1.add(wxxq);
+                    wxfMax = wxfMax.add(new BigDecimal(wxxq.getMaxPrice()));
+                    wxfMin = wxfMin.add(new BigDecimal(wxxq.getMinPrice()));
+                    wxfAve = wxfAve.add(new BigDecimal(wxxq.getAvePrice()));
+                }
+            }
+            costModel.setMaxWxf(wxfMax.toString());
+            costModel.setMinWxf(wxfMin.toString());
+            costModel.setAveWxf(wxfAve.toString());
+            //update-begin-author:taoyan date:20190528 for:批量插入数据
+            long start = System.currentTimeMillis();
+            this.saveBatch(list1);
+            //400条 saveBatch消耗时间1592毫秒  循环插入消耗时间1947毫秒
+            //1200条  saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
+            log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
+            //update-end-author:taoyan date:20190528 for:批量插入数据
+            return Result.OK("文件导入成功!数据行数:" + list.size(),costModel);
+        } catch (Exception e) {
+            //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
+            String msg = e.getMessage();
+            log.error(msg, e);
+            if(msg!=null && msg.indexOf("Duplicate entry")>=0){
+                return Result.error("文件导入失败:有重复数据!");
+            }else{
+                return Result.error("文件导入失败:" + e.getMessage());
+            }
+            //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示
+        } finally {
+            try {
+                inputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
 }
 }