Przeglądaj źródła

成本模型导入可以先不导入文件;返回信息加上提示信息

LLL 1 rok temu
rodzic
commit
20fd217e59

+ 90 - 53
module_kzks/src/main/java/org/jeecg/modules/costModelList/controller/CostModelListController.java

@@ -18,7 +18,9 @@ import org.jeecg.modules.costModelList.dto.CostModelListUpdateDTO;
 import org.jeecg.modules.costModelList.dto.FileDTO;
 import org.jeecg.modules.costModelList.entity.CostModelList;
 import org.jeecg.modules.costModelList.service.ICostModelListService;
+import org.jeecg.modules.costModelList.vo.CostModelImportVO;
 import org.jeecg.modules.costModelList.vo.CostModelListQueryVO;
+import org.jeecg.modules.costModelMsg.service.ICostModelMsgService;
 import org.jeecg.modules.costModelXmxqCl.entity.CostModelXmxqCl;
 import org.jeecg.modules.costModelXmxqCl.service.ICostModelXmxqClService;
 import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
@@ -51,6 +53,8 @@ public class CostModelListController extends JeecgController<CostModelList, ICos
 	@Autowired
 	@SuppressWarnings("all")
 	private JeecgBaseConfig jeecgBaseConfig;
+	@Autowired
+	private ICostModelMsgService modelMsgService;
 
 	 /**
 	  *   成本模型新增
@@ -65,43 +69,52 @@ public class CostModelListController extends JeecgController<CostModelList, ICos
 		 	return Result.error("项目名称不可重复!");
 		 }
 
+		 String msg ="添加成功!";
+
 		 CostModelList costModelList = CostModelListConvert.INSTANCE.toCostModelList(dto);
 		 costModelListService.save(costModelList);
-
 		 String xmId = costModelList.getId();
 	 	 String xmName = dto.getXmName();
-		 String clfUrl1 = dto.getClfurl().get(0).getFilePath();
-		 String wxfUrl1 = dto.getWxfurl().get(0).getFilePath();
-		 costModelList.setClfUrl(clfUrl1);
-		 costModelList.setClfFilename(dto.getClfurl().get(0).getFileName());
-		 costModelList.setClfFilesize(dto.getClfurl().get(0).getFileSize());
-		 costModelList.setWxfUrl(wxfUrl1);
-		 costModelList.setWxfFilename(dto.getWxfurl().get(0).getFileName());
-		 costModelList.setWxfFilesize(dto.getWxfurl().get(0).getFileSize());
-		 String clfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  clfUrl1;
-		 String wxfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  wxfUrl1;
-		 log.info("导入的材料费详情地址为:{}",clfUrl);
-		 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());
+
+	 	 if(dto.getClfurl()!=null && dto.getClfurl().get(0).getFilePath()!=null){
+			 String clfUrl1 = dto.getClfurl().get(0).getFilePath();
+			 String clfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  clfUrl1;
+			 log.info("导入的材料费详情地址为:{}",clfUrl);
+			 costModelList.setClfUrl(clfUrl1);
+			 costModelList.setClfFilename(dto.getClfurl().get(0).getFileName());
+			 costModelList.setClfFilesize(dto.getClfurl().get(0).getFileSize());
+			 //计算并导入数据
+			 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, wxfUrl, CostModelXmxqWx.class);
-		 CostModelList costModel2 = result2.getResult();
-		 if(costModel2!=null){
-			 costModelList.setMaxWxf(costModel2.getMaxWxf());
-			 costModelList.setMinWxf(costModel2.getMinWxf());
-			 costModelList.setAveWxf(costModel2.getAveWxf());
+
+		 if(dto.getWxfurl()!=null && dto.getWxfurl().get(0).getFilePath()!=null){
+			 String wxfUrl1 = dto.getWxfurl().get(0).getFilePath();
+			 String wxfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  wxfUrl1;
+			 log.info("导入的外协费详情地址为:{}",wxfUrl);
+			 costModelList.setWxfUrl(wxfUrl1);
+			 costModelList.setWxfFilename(dto.getWxfurl().get(0).getFileName());
+			 costModelList.setWxfFilesize(dto.getWxfurl().get(0).getFileSize());
+			 //计算并导入数据
+			 Result<CostModelImportVO> result2 = wxService.importExcel1(xmId, xmName, wxfUrl, CostModelXmxqWx.class);
+			 CostModelList costModel2 = result2.getResult().getCostModel();
+			 msg = msg +result2.getResult().getTishiMsg();
+			 if(costModel2!=null){
+				 costModelList.setMaxWxf(costModel2.getMaxWxf());
+				 costModelList.setMinWxf(costModel2.getMinWxf());
+				 costModelList.setAveWxf(costModel2.getAveWxf());
+			 }
 		 }
 
 		 costModelListService.updateById(costModelList);
 
-		 return Result.OK("添加成功!");
+		 return Result.OK(msg);
 	 }
 
 	/**
@@ -124,33 +137,57 @@ public class CostModelListController extends JeecgController<CostModelList, ICos
 			}
 		}
 
-		String clfUrl1 = dto.getClfurl().get(0).getFilePath();
-		String wxfUrl1 = dto.getWxfurl().get(0).getFilePath();
-		costModelList.setClfUrl(clfUrl1);
-		costModelList.setWxfUrl(wxfUrl1);
-
-		String clfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  clfUrl1;
-		String wxfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  wxfUrl1;
+		String msg ="编辑成功!";
 
-		if(!Objects.equals(clfUrl1,costModelList1.getClfUrl())){
-			Map<String, Object> columnMap = new HashMap<>();
-			columnMap.put("xiangmu_id",xmId);
-			clService.removeByMap(columnMap);
-			//计算并导入数据
-			Result<CostModelList> result1 = clService.importExcel1(xmId, xmName, clfUrl, CostModelXmxqCl.class);
+		if(dto.getClfurl()!=null && dto.getClfurl().get(0).getFilePath()!=null){
+			String clfUrl1 = dto.getClfurl().get(0).getFilePath();
+			costModelList.setClfUrl(clfUrl1);
+			costModelList.setClfFilename(dto.getClfurl().get(0).getFileName());
+			costModelList.setClfFilesize(dto.getClfurl().get(0).getFileSize());
+			String clfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  clfUrl1;
+			if(!Objects.equals(clfUrl1,costModelList1.getClfUrl())){
+				Map<String, Object> columnMap = new HashMap<>();
+				columnMap.put("xiangmu_id",xmId);
+				clService.removeByMap(columnMap);
+				//计算并导入数据
+				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());
+				}
+			}
 		}
 
-		if(!Objects.equals(wxfUrl1,costModelList1.getWxfUrl())){
-			Map<String, Object> columnMap = new HashMap<>();
-			columnMap.put("xiangmu_id",xmId);
-			wxService.removeByMap(columnMap);
-			//计算并导入数据
-			Result<CostModelList> result2 = wxService.importExcel1(xmId, xmName, wxfUrl, CostModelXmxqWx.class);
+		if(dto.getWxfurl()!=null && dto.getWxfurl().get(0).getFilePath()!=null){
+			String wxfUrl1 = dto.getWxfurl().get(0).getFilePath();
+			costModelList.setWxfUrl(wxfUrl1);
+			costModelList.setWxfFilename(dto.getWxfurl().get(0).getFileName());
+			costModelList.setWxfFilesize(dto.getWxfurl().get(0).getFileSize());
+			String wxfUrl = jeecgBaseConfig.getPath().getUpload() + "/"+  wxfUrl1;
+			if(!Objects.equals(wxfUrl1,costModelList1.getWxfUrl())){
+				Map<String, Object> columnMap = new HashMap<>();
+				columnMap.put("xiangmu_id",xmId);
+				wxService.removeByMap(columnMap);
+				//删除原成本模型导入提示信息
+				modelMsgService.removeByMap(columnMap);
+				//计算并导入数据
+				Result<CostModelImportVO> result2 = wxService.importExcel1(xmId, xmName, wxfUrl, CostModelXmxqWx.class);
+				CostModelList costModel2 = result2.getResult().getCostModel();
+				msg = msg + result2.getResult().getTishiMsg();
+				if(costModel2!=null){
+					costModelList.setMaxWxf(costModel2.getMaxWxf());
+					costModelList.setMinWxf(costModel2.getMinWxf());
+					costModelList.setAveWxf(costModel2.getAveWxf());
+				}
+			}
 		}
 
 		costModelList.setXmName(xmName);
 		costModelListService.updateById(costModelList);
-		return Result.OK("编辑成功!");
+		return Result.OK(msg);
 	}
 
 	/**
@@ -196,13 +233,13 @@ public class CostModelListController extends JeecgController<CostModelList, ICos
 	//@RequiresPermissions("org.jeecg.modules:kzks_cost_model:delete")
 	@DeleteMapping(value = "/delete")
 	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		costModelListService.removeById(id);
+
 		Map<String, Object> columnMap = new HashMap<>();
 		columnMap.put("xiangmu_id",id);
-		clService.removeByMap(columnMap);
-		Map<String, Object> columnMap1 = new HashMap<>();
-		columnMap1.put("xiangmu_id",id);
-		wxService.removeByMap(columnMap1);
-		costModelListService.removeById(id);
+		clService.removeByMap(columnMap);//删材料费详情
+		wxService.removeByMap(columnMap);//删外协费详情
+		modelMsgService.removeByMap(columnMap);//删除原成本模型导入提示信息
 		return Result.OK("删除成功!");
 	}
 

+ 13 - 0
module_kzks/src/main/java/org/jeecg/modules/costModelList/vo/CostModelImportVO.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.costModelList.vo;
+
+import lombok.Data;
+import org.jeecg.modules.costModelList.entity.CostModelList;
+
+@Data
+public class CostModelImportVO {
+
+    private CostModelList costModel;
+
+    private String tishiMsg;
+
+}

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

@@ -3,6 +3,7 @@ package org.jeecg.modules.costModelXmxqWx.service;
 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.costModelList.vo.CostModelImportVO;
 import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 
 /**
@@ -16,6 +17,6 @@ public interface ICostModelXmxqWxService extends IService<CostModelXmxqWx> {
     /**
      * 通过excel导入材料费
      */
-    public Result<CostModelList> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqWx> clazz);
+    public Result<CostModelImportVO> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqWx> clazz);
 
 }

+ 35 - 6
module_kzks/src/main/java/org/jeecg/modules/costModelXmxqWx/service/impl/CostModelXmxqWxServiceImpl.java

@@ -4,6 +4,9 @@ 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.costModelList.vo.CostModelImportVO;
+import org.jeecg.modules.costModelMsg.entity.CostModelMsg;
+import org.jeecg.modules.costModelMsg.service.ICostModelMsgService;
 import org.jeecg.modules.costModelWxPrice.service.ICostModelWxPriceService;
 import org.jeecg.modules.costModelXmxqWx.entity.CostModelXmxqWx;
 import org.jeecg.modules.costModelXmxqWx.mapper.CostModelXmxqWxMapper;
@@ -35,11 +38,14 @@ public class CostModelXmxqWxServiceImpl extends ServiceImpl<CostModelXmxqWxMappe
     @Autowired
     @SuppressWarnings("all")
     private ICostModelWxPriceService costModelwXPriceService;
+    @Autowired
+    @SuppressWarnings("all")
+    private ICostModelMsgService costModelMsgService;
 
     /**
      * 通过excel导入材料费
      */
-    public Result<CostModelList> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqWx> clazz){
+    public Result<CostModelImportVO> importExcel1(String xmId, String xmName, String strUrl, Class<CostModelXmxqWx> clazz){
         CostModelList costModel = new CostModelList();
 
         InputStream inputStream = null;
@@ -61,6 +67,11 @@ public class CostModelXmxqWxServiceImpl extends ServiceImpl<CostModelXmxqWxMappe
             BigDecimal wxfMax = new BigDecimal(0);
             BigDecimal wxfMin = new BigDecimal(0);
             BigDecimal wxfAve = new BigDecimal(0);
+            List<CostModelMsg> modelMsgList = new ArrayList<>();//导入提示信息列表
+            int num1 = 0; //导入的外协费在价格库找不到对应数据的条数
+            int num2 = 0; //导入的外协费缺少必填的条数
+            String msg ="";
+            String msg2 ="";
             for(CostModelXmxqWx wx:list){
                 if(wx.getNumber()!=null && wx.getWxProject()!=null && wx.getUnit()!=null &&wx.getWxCompany()!=null){
                     wx.setXiangmuId(xmId);
@@ -72,25 +83,43 @@ public class CostModelXmxqWxServiceImpl extends ServiceImpl<CostModelXmxqWxMappe
                         wxfMin = wxfMin.add(new BigDecimal(wxxq.getMinPrice()));
                         wxfAve = wxfAve.add(new BigDecimal(wxxq.getAvePrice()));
                     }else {
-                        // todo 找不到对应的外协费 提示先去维护外协价格库
-                        String msg = "外协价格库内找不到外协项目为"+wx.getWxProject()+",外协单位为:"+wx.getWxCompany()+",计量单位为:"+wx.getUnit()+"的数据,先维护外协价格库!";
+                        num1++;
+                        String msg1 = "外协价格库内——外协项目:"+wx.getWxProject()+",外协单位:"+wx.getWxCompany()+",计量单位:"+wx.getUnit()+" 未找到!";
+                        CostModelMsg costModelMsg = new CostModelMsg();
+                        costModelMsg.setXiangmuId(xmId);
+                        costModelMsg.setXiangmuName(xmName);
+                        costModelMsg.setXiangmuMsg(msg1);
+                        modelMsgList.add(costModelMsg);
                     }
                 }else {
-                    // todo 导入的数据不全 提示他该条数据不全
-                    String msg1 = "导入的外协Excel表中缺少必填填数据!";
+                    num2++;
                 }
             }
+            if(num2>0) msg2 = "导入的外协Excel表中有"+num2+"条缺少必填数据!";
+            CostModelMsg costModelMsg = new CostModelMsg();
+            costModelMsg.setXiangmuId(xmId);
+            costModelMsg.setXiangmuName(xmName);
+            costModelMsg.setXiangmuMsg(msg2);
+            modelMsgList.add(costModelMsg);
+
+            if(num1>0) msg = "外协价格库中有"+num1+"条数据未找到!"+msg2;
+
             costModel.setMaxWxf(wxfMax.toString());
             costModel.setMinWxf(wxfMin.toString());
             costModel.setAveWxf(wxfAve.toString());
+
+            CostModelImportVO vo = new CostModelImportVO();
+            vo.setCostModel(costModel);
+            vo.setTishiMsg(msg);
             //update-begin-author:taoyan date:20190528 for:批量插入数据
             long start = System.currentTimeMillis();
             this.saveBatch(list1);
+            costModelMsgService.saveBatch(modelMsgList);
             //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);
+            return Result.OK("文件导入成功!数据行数:" + list.size(),vo);
         } catch (Exception e) {
             //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
             String msg = e.getMessage();