|  |  |  | @ -165,6 +165,40 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 上传保存关联信息 | 
			
		
	
		
			
				
					|  |  |  |  |      * 1、进来先判断是2 还是 3 个层级 | 
			
		
	
		
			
				
					|  |  |  |  |      * 2、 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |  |      * @param file | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |  |     public void xmlUpload2(MultipartFile file) { | 
			
		
	
		
			
				
					|  |  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |  |             String fileName = file.getOriginalFilename(); | 
			
		
	
		
			
				
					|  |  |  |  |             String suffix = FileUtil.getSuffix(fileName); | 
			
		
	
		
			
				
					|  |  |  |  |             if (!"xml".equals(suffix)) { | 
			
		
	
		
			
				
					|  |  |  |  |                 throw new JsonException("仅支持XML,文件类型错误" + suffix); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             log.info(file.getSize() + "文件长度"); | 
			
		
	
		
			
				
					|  |  |  |  |             if (file.getSize() > 5 * 1024 * 1024) { | 
			
		
	
		
			
				
					|  |  |  |  |                 throw new JsonException("上传文件超过5M"); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             Document document = XmlUtil.readXML(file.getInputStream()); | 
			
		
	
		
			
				
					|  |  |  |  |             //获取根
 | 
			
		
	
		
			
				
					|  |  |  |  |             Element rootElement = XmlUtil.getRootElement(document); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException("上传失败:" + e.getMessage()); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 手动添加 | 
			
		
	
		
			
				
					|  |  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  |  | @ -412,4 +446,85 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     void ProcessData(Element rootElement){ | 
			
		
	
		
			
				
					|  |  |  |  |         //截取Relation
 | 
			
		
	
		
			
				
					|  |  |  |  |         NodeList relation = rootElement.getElementsByTagName("Relation"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (relation == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException("XML文件解析错误"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         Element relationE = (Element) relation.item(0); | 
			
		
	
		
			
				
					|  |  |  |  |         //截取Batch
 | 
			
		
	
		
			
				
					|  |  |  |  |         NodeList batch = rootElement.getElementsByTagName("Batch"); | 
			
		
	
		
			
				
					|  |  |  |  |         if (batch == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             throw new JsonException("XML文件解析错误"); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Map<String, List<RelCodeDetail>> codeMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         String productCode = relationE.getAttribute("productCode"); | 
			
		
	
		
			
				
					|  |  |  |  |         String subTypeNo = relationE.getAttribute("subTypeNo"); | 
			
		
	
		
			
				
					|  |  |  |  |         String cascade = relationE.getAttribute("cascade"); | 
			
		
	
		
			
				
					|  |  |  |  |         String packageSpec = relationE.getAttribute("packageSpec"); | 
			
		
	
		
			
				
					|  |  |  |  |         String comment = relationE.getAttribute("comment"); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         AuthAdmin user = customerService.getUserBean(); | 
			
		
	
		
			
				
					|  |  |  |  |         Node batchNode = batch.item(0); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         Element batchE = (Element) batchNode; | 
			
		
	
		
			
				
					|  |  |  |  |         String batchNo = batchE.getAttribute("batchNo"); | 
			
		
	
		
			
				
					|  |  |  |  |         String madeDate = batchE.getAttribute("madeDate"); | 
			
		
	
		
			
				
					|  |  |  |  |         String validateDate = batchE.getAttribute("validateDate"); | 
			
		
	
		
			
				
					|  |  |  |  |         String workShop = batchE.getAttribute("workShop"); | 
			
		
	
		
			
				
					|  |  |  |  |         String lineName = batchE.getAttribute("lineName"); | 
			
		
	
		
			
				
					|  |  |  |  |         String lineManager = batchE.getAttribute("lineManager"); | 
			
		
	
		
			
				
					|  |  |  |  |         String customerId = String.valueOf(user.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         RelCodeBatch relCodeBatch = new RelCodeBatch(); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setProductCode(productCode); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setSubTypeNo(subTypeNo); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setCascadeRatio(cascade); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setPackageSpec(packageSpec); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setComment(comment); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setBatchNo(batchNo); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setMadeDate(madeDate); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setValidateDate(String.valueOf(DateUtil.offsetDay(DateUtil.parse(validateDate, "yyyy-MM-dd"), 1))); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setLineName(lineName); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setWorkShop(workShop); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setLineManager(lineManager); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setCreateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setCreateUser(user.getUserName()); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setUpdateTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setUpdateUser(user.getUserName()); | 
			
		
	
		
			
				
					|  |  |  |  |         relCodeBatch.setErpId(customerId); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         //batch下的节点code
 | 
			
		
	
		
			
				
					|  |  |  |  |         NodeList code = batchNode.getChildNodes(); | 
			
		
	
		
			
				
					|  |  |  |  |         //第一个节点的级别
 | 
			
		
	
		
			
				
					|  |  |  |  |         Integer packLayerP = null; | 
			
		
	
		
			
				
					|  |  |  |  |         for (int j = 0; j < code.getLength(); j++) { | 
			
		
	
		
			
				
					|  |  |  |  |             Node codeNode = code.item(j); | 
			
		
	
		
			
				
					|  |  |  |  |             RelCodeDetail relCodeDetail = new RelCodeDetail(); | 
			
		
	
		
			
				
					|  |  |  |  |             if (codeNode.getNodeType() == Node.ELEMENT_NODE) { | 
			
		
	
		
			
				
					|  |  |  |  |                 Element codeE = (Element) codeNode; | 
			
		
	
		
			
				
					|  |  |  |  |                 String curCode = codeE.getAttribute("curCode"); | 
			
		
	
		
			
				
					|  |  |  |  |                 Integer packLayer = Integer.valueOf(codeE.getAttribute("packLayer")); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (j == 0) { | 
			
		
	
		
			
				
					|  |  |  |  |                     packLayerP = packLayer; | 
			
		
	
		
			
				
					|  |  |  |  |                     relCodeBatch.setParentCode("0"); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |                 relCodeDetail.setBatchIdFk(relCodeBatch.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                 relCodeDetail.setCurCode(curCode); | 
			
		
	
		
			
				
					|  |  |  |  |                 relCodeDetail.setPackLayer(Integer.valueOf(packLayer)); | 
			
		
	
		
			
				
					|  |  |  |  |                 String parentCode = codeE.getAttribute("parentCode"); | 
			
		
	
		
			
				
					|  |  |  |  |                 relCodeDetail.setParentCode(StrUtil.isNotBlank(parentCode) ? parentCode : "0"); | 
			
		
	
		
			
				
					|  |  |  |  |                 String flag = codeE.getAttribute("flag"); | 
			
		
	
		
			
				
					|  |  |  |  |                 relCodeDetail.setFlag(Integer.valueOf(flag)); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | //        relCodeDetailService.saveBatch(relCodeDetails);
 | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |