|
@@ -8,20 +8,14 @@ import com.aspose.cells.SaveFormat;
|
|
|
import com.aspose.cells.Workbook;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.rongwei.bscommon.sys.service.ZhcxItpProjectNodesService;
|
|
|
-import com.rongwei.bscommon.sys.service.ZhcxItpTemplateService;
|
|
|
-import com.rongwei.bscommon.sys.service.ZhcxProjectDeviceNumberService;
|
|
|
+import com.rongwei.bscommon.sys.service.*;
|
|
|
import com.rongwei.bscommon.sys.utils.CxConstants;
|
|
|
import com.rongwei.bscommon.sys.utils.ExcelService;
|
|
|
import com.rongwei.bscommon.sys.utils.ImportITPHelp;
|
|
|
import com.rongwei.bscommon.sys.utils.ZhcxCommon;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxItpProjectNodesDo;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxItpTemplateDo;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxItpTemplateNodesDo;
|
|
|
+import com.rongwei.bsentity.domain.*;
|
|
|
import com.rongwei.bscommon.sys.dao.ZhcxItpTemplateNodesDao;
|
|
|
-import com.rongwei.bscommon.sys.service.ZhcxItpTemplateNodesService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.rongwei.bsentity.domain.ZhcxProjectDeviceNumberDo;
|
|
|
import com.rongwei.bsentity.dto.node.*;
|
|
|
import com.rongwei.bsentity.vo.CopyNodeVo;
|
|
|
import com.rongwei.bsentity.vo.ZhcxItpTemplateNodeSyncProjectVo;
|
|
@@ -35,6 +29,7 @@ import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
+import lombok.val;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -80,6 +75,14 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
|
|
|
@Autowired
|
|
|
private SysOrganizationService sysOrganizationService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZhcxCoreInspectionIndicatorsTemplateService zhcxCoreInspectionIndicatorsTemplateService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxCheckBeforeQualifiedService zhcxCheckBeforeQualifiedService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZhcxCoreInspectionDetailService zhcxCoreInspectionDetailService;
|
|
|
/**
|
|
|
* 新增的ITP模板节点同步到指定项目
|
|
|
* @param zhcxItpTemplateNodeSyncProjectVo
|
|
@@ -558,6 +561,98 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void templateExcelImport(MultipartFile file) {
|
|
|
+ final List<JSONObject> rowList = excelService.parseMF(file); //excel数据
|
|
|
+ // 获取当前用户信息
|
|
|
+ SysUserVo user = zhcxCommon.getCurrentUser();
|
|
|
+ if (Objects.isNull(user)){
|
|
|
+ throw new CustomException("无法获取当前用户");
|
|
|
+ }
|
|
|
+ String tenantid = user.getTenantid();
|
|
|
+ // 校验信息反聩
|
|
|
+ List<String> msgList = new ArrayList<>();
|
|
|
+ List<ImportInspectionIndicatorsBO> relt = new ArrayList<>();
|
|
|
+ // 结果集
|
|
|
+ List<ZhcxCoreInspectionIndicatorsTemplateDo> result1 = new ArrayList<>();
|
|
|
+ List<ZhcxCheckBeforeQualifiedDo> result2 = new ArrayList<>();
|
|
|
+ List<ZhcxCoreInspectionDetailDo> result3 = new ArrayList<>();
|
|
|
+ if(!rowList.isEmpty()){
|
|
|
+ // 导入操作
|
|
|
+ for(int m = 0, n = rowList.size(); m < n; m++) { //遍历每行数据
|
|
|
+ JSONObject row = rowList.get(m);
|
|
|
+ final ImportInspectionIndicatorsBO nodeBO = row.toJavaObject(ImportInspectionIndicatorsBO.class);
|
|
|
+ //参数校验
|
|
|
+ List<String> requiredList = ImportITPHelp.checkExcelRequiredTemplate(nodeBO);
|
|
|
+ if(ObjectUtil.isNotEmpty(requiredList)) {
|
|
|
+ String sb = "第" +
|
|
|
+ (m + 1) +
|
|
|
+ "行: " +
|
|
|
+ StringUtils.join(requiredList, ",");
|
|
|
+ msgList.add(sb);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ relt.add(nodeBO);
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isNotEmpty(msgList)) {
|
|
|
+ throw new CustomException(StringUtils.join(msgList, ";"));
|
|
|
+ }
|
|
|
+ // 业务操作
|
|
|
+ Map<String, List<ImportInspectionIndicatorsBO>> resultMap = relt.stream()
|
|
|
+ .collect(Collectors.groupingBy(ImportInspectionIndicatorsBO::getInspection_code));
|
|
|
+ for (Map.Entry<String, List<ImportInspectionIndicatorsBO>> entry : resultMap.entrySet()) {
|
|
|
+ // 检验点编号
|
|
|
+ String code = entry.getKey();
|
|
|
+ // 查询编号是否重复
|
|
|
+ int count = zhcxCoreInspectionIndicatorsTemplateService.count(
|
|
|
+ new LambdaQueryWrapper<ZhcxCoreInspectionIndicatorsTemplateDo>()
|
|
|
+ .eq(ZhcxCoreInspectionIndicatorsTemplateDo::getDeleted,"0")
|
|
|
+ .eq(ZhcxCoreInspectionIndicatorsTemplateDo::getInspection_code, code));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new CustomException("检验点编号:"+code +"已存在,请修改");
|
|
|
+ }
|
|
|
+ // 去构建主子表
|
|
|
+ List<ImportInspectionIndicatorsBO> indicatorsBOS = entry.getValue();
|
|
|
+ // 主表
|
|
|
+ ZhcxCoreInspectionIndicatorsTemplateDo templateDo = new ZhcxCoreInspectionIndicatorsTemplateDo();
|
|
|
+ templateDo.setId(SecurityUtil.getUUID());
|
|
|
+ templateDo.setDeleted("0");
|
|
|
+ templateDo.setTenantid(tenantid);
|
|
|
+ templateDo.setInspection_code(code);
|
|
|
+ templateDo.setInspection_name(indicatorsBOS.get(0).getInspection_name());
|
|
|
+ templateDo.setProduct_type(indicatorsBOS.get(0).getProduct_type());
|
|
|
+ result1.add(templateDo);
|
|
|
+ for (ImportInspectionIndicatorsBO indicatorsBO : indicatorsBOS) {
|
|
|
+ // 子表1
|
|
|
+ ZhcxCheckBeforeQualifiedDo qualifiedDo = new ZhcxCheckBeforeQualifiedDo();
|
|
|
+ qualifiedDo.setId(SecurityUtil.getUUID());
|
|
|
+ qualifiedDo.setDeleted("0");
|
|
|
+ qualifiedDo.setPid(templateDo.getId());
|
|
|
+ qualifiedDo.setAll_qualified(indicatorsBO.getAll_qualified());
|
|
|
+ result2.add(qualifiedDo);
|
|
|
+ // 子表2
|
|
|
+ ZhcxCoreInspectionDetailDo detailDo = new ZhcxCoreInspectionDetailDo();
|
|
|
+ detailDo.setId(SecurityUtil.getUUID());
|
|
|
+ detailDo.setDeleted("0");
|
|
|
+ detailDo.setPid(templateDo.getId());
|
|
|
+ BeanUtil.copyProperties(indicatorsBO, detailDo);
|
|
|
+ result3.add(detailDo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 保存操作
|
|
|
+ if(!result1.isEmpty()) {
|
|
|
+ zhcxCoreInspectionIndicatorsTemplateService.saveBatch(result1);
|
|
|
+ }
|
|
|
+ if(!result2.isEmpty()) {
|
|
|
+ zhcxCheckBeforeQualifiedService.saveBatch(result2);
|
|
|
+ }
|
|
|
+ if(!result3.isEmpty()) {
|
|
|
+ zhcxCoreInspectionDetailService.saveBatch(result3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导入辅助
|
|
|
*
|