فهرست منبع

多线程处理;日志文件区分

zhouy 5 سال پیش
والد
کامیت
32265babea
37فایلهای تغییر یافته به همراه1023 افزوده شده و 1308 حذف شده
  1. 57 0
      src/main/java/com/uas/eis/controller/ChipController.java
  2. 0 52
      src/main/java/com/uas/eis/controller/LoginController.java
  3. 0 27
      src/main/java/com/uas/eis/controller/ProductController.java
  4. 0 31
      src/main/java/com/uas/eis/controller/QueryController.java
  5. 0 31
      src/main/java/com/uas/eis/controller/StockController.java
  6. 0 77
      src/main/java/com/uas/eis/controller/YundingController.java
  7. 3 3
      src/main/java/com/uas/eis/core/config/AsyncConfig.java
  8. 56 0
      src/main/java/com/uas/eis/core/support/SpringDynamicCronTask.java
  9. 26 1
      src/main/java/com/uas/eis/dao/BaseDao.java
  10. 5 1
      src/main/java/com/uas/eis/entity/DataChip.java
  11. 71 0
      src/main/java/com/uas/eis/entity/EquipConfig.java
  12. 4 0
      src/main/java/com/uas/eis/service/DataDealService.java
  13. 15 0
      src/main/java/com/uas/eis/service/EDCBakService.java
  14. 0 11
      src/main/java/com/uas/eis/service/ProductService.java
  15. 0 9
      src/main/java/com/uas/eis/service/SaleReturnService.java
  16. 0 9
      src/main/java/com/uas/eis/service/SaleService.java
  17. 0 13
      src/main/java/com/uas/eis/service/StockService.java
  18. 0 17
      src/main/java/com/uas/eis/service/YundingService.java
  19. 7 0
      src/main/java/com/uas/eis/serviceImpl/DataDealServiceImpl.java
  20. 375 0
      src/main/java/com/uas/eis/serviceImpl/EDCBakServiceImpl.java
  21. 0 126
      src/main/java/com/uas/eis/serviceImpl/ProductServiceImpl.java
  22. 0 124
      src/main/java/com/uas/eis/serviceImpl/SaleReturnServiceImpl.java
  23. 0 126
      src/main/java/com/uas/eis/serviceImpl/SaleServiceImpl.java
  24. 0 355
      src/main/java/com/uas/eis/serviceImpl/StockServiceImpl.java
  25. 0 277
      src/main/java/com/uas/eis/serviceImpl/YundingServiceImpl.java
  26. 7 4
      src/main/java/com/uas/eis/task/DataDealTask.java
  27. 58 0
      src/main/java/com/uas/eis/task/EDCBakTask.java
  28. 82 0
      src/main/java/com/uas/eis/task/ScheduleTask.java
  29. 18 9
      src/main/java/com/uas/eis/utils/CollectionUtil.java
  30. 4 0
      src/main/java/com/uas/eis/utils/Constant.java
  31. 2 0
      src/main/java/com/uas/eis/utils/ContextUtil.java
  32. 56 0
      src/main/resources/application-analyse.yml
  33. 54 0
      src/main/resources/application-file.yml
  34. 4 0
      src/main/resources/application.yml
  35. 44 0
      src/main/resources/log/logback-analyse.xml
  36. 44 0
      src/main/resources/log/logback-file.xml
  37. 31 5
      src/test/java/com/uas/eis/UasEisApplicationTests.java

+ 57 - 0
src/main/java/com/uas/eis/controller/ChipController.java

@@ -0,0 +1,57 @@
+package com.uas.eis.controller;
+
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.entity.DataChip;
+import com.uas.eis.service.DataDealService;
+import com.uas.eis.service.EDCBakService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @Author: zhouy
+ * @Date: 2020/5/28 13:35
+ */
+@RestController
+public class ChipController {
+    @Autowired
+    private DataDealService dataDealService;
+    @Autowired
+    private BaseDao baseDao;
+
+    @PostMapping("/data/analysis")
+    public void dataAnalysis(@RequestBody DataChip  dataChip){
+        final CountDownLatch countDownLatch = new CountDownLatch(1);
+        try {
+            dataDealService.EDCDataDeal(dataChip,countDownLatch);
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+    @PostMapping("/data/analysis/{id}")
+    public void dataAnalysis(@PathVariable("id") Long id){
+        final CountDownLatch countDownLatch = new CountDownLatch(1);
+        List<DataChip> dataChips = baseDao.getJdbcTemplate().query("select id_,chipcode_,counterpath_,datapath_,testdate_ from datacenter$chip where  nvl(readstatus_,0)=0 and id_= "+id,
+                new BeanPropertyRowMapper<>(DataChip.class));
+        if(dataChips.size()>0){
+            try {
+                dataDealService.EDCDataDeal(dataChips.get(0),countDownLatch);
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+
+        }
+
+    }
+
+
+
+}

+ 0 - 52
src/main/java/com/uas/eis/controller/LoginController.java

@@ -1,52 +0,0 @@
-package com.uas.eis.controller;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
-import com.uas.eis.entity.ErrorMsg;
-import com.uas.eis.exception.SystemException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.uas.eis.service.QueryService;
-import com.uas.eis.utils.BaseUtil;
-
-@RestController
-@RequestMapping("/EIS")
-public class LoginController {
-
-	@Autowired
-	private QueryService queryService;
-	
-	/**
-	 * 首次登录请求token
-	 */
-	@RequestMapping("/login")
-	public Object login(HttpServletRequest request, String username, String password){
-		Map<String, Object> res = new HashMap<String, Object>();
-		String token = queryService.login(username, password);
-		request.getSession().removeAttribute("token");
-		if(token != null) {
-			request.getSession().setAttribute("token", token);
-			res.put("success", true);
-			res.put("token", token);
-		}else {
-			throw new SystemException(ErrorMsg.BAD_USERINFO);
-		}
-		return res;
-	}
-	
-	/**
-	 * 退出登录
-	 */
-	@RequestMapping("/logout")
-	public Object logout(HttpServletRequest request){
-		Map<String, Object> res = new HashMap<String, Object>();
-		request.getSession().removeAttribute("token");
-		res.put("success", true);
-		return res;
-	}
-}

+ 0 - 27
src/main/java/com/uas/eis/controller/ProductController.java

@@ -1,27 +0,0 @@
-package com.uas.eis.controller;
-
-import com.uas.eis.service.ProductService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.Map;
-
-/**
- *
- */
-@RestController
-public class ProductController {
-
-    @Autowired
-    private ProductService productService;
-
-
-    @PostMapping(value = "/yunding/product")
-    public Map<String,Object> postProductToYunding(@RequestParam Integer id){
-        return productService.postProductToYunding(id);
-    }
-
-
-}

+ 0 - 31
src/main/java/com/uas/eis/controller/QueryController.java

@@ -1,31 +0,0 @@
-package com.uas.eis.controller;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.uas.eis.service.QueryService;
-
-@RestController
-@RequestMapping("/EIS/")
-public class QueryController {
-
-	@Autowired
-	private QueryService queryService;
-	
-	@RequestMapping("/api/query")
-	public Object query(String code, String param){
-		Map<String, Object> map = new HashMap<String, Object>();
-		return queryService.query(code, param);
-	}
-	
-	@RequestMapping("/api/doAction")
-	public Object doAction(String code, String param){
-		Map<String, Object> map = new HashMap<String, Object>();
-		return queryService.doAction(code, param);
-	}
-	
-}

+ 0 - 31
src/main/java/com/uas/eis/controller/StockController.java

@@ -1,31 +0,0 @@
-package com.uas.eis.controller;
-
-import com.uas.eis.service.StockService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by luhg on 2018/4/19.
- * 出入库相关
- */
-@RestController
-public class StockController {
-
-    @Autowired
-    private StockService stockService;
-
-    @PostMapping(value = "/yunding/stock")
-    public Map<String,Object> postStockToYunding(@RequestParam Integer id){
-        return stockService.postStockToYunding(id);
-    }
-
-
-
-}

+ 0 - 77
src/main/java/com/uas/eis/controller/YundingController.java

@@ -1,77 +0,0 @@
-package com.uas.eis.controller;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
-
-import com.uas.eis.service.YundingService;
-//import com.uas.eis.service.UserService;
-
-@RestController
-public class YundingController {
-
-	@Autowired
-	private YundingService yundingService;
-	
-	/**
-	 * 出入库单审核传云顶数据中心接口
-	 */
-	@RequestMapping("/ProdInOutAuidted.action")
-	@ResponseBody
-	public Map<String, Object> ProdInOutAuidted(int id,String piclass){
-		Map<String, Object> modelMap = new HashMap<String, Object>();
-		yundingService.ProdInOutAuidted(id,piclass);
-		modelMap.put("success", true);
-		return modelMap;
-	} 
-	
-	/**
-	 * 出入库单云顶数据中心传UAS过账接口
-	 */
-	@RequestMapping("/ProdInOutPOST.action")
-	@ResponseBody
-	public Map<String, Object> ProdInOutPOST(String Store){
-		Map<String, Object> modelMap = new HashMap<String, Object>();
-		yundingService.ProdInOutPOST(Store);
-		modelMap.put("success", true);
-		return modelMap;
-	} 
-	
-	/**
-	 * 销售订单云顶数据中心传UAS并生成一张已过账销售出货单接口
-	 */
-	@RequestMapping("/Salereceive.action")
-	@ResponseBody
-	public Map<String, Object> Salereceive(String Store){
-		Map<String, Object> modelMap = new HashMap<String, Object>();
-		yundingService.Salereceive(Store);
-		modelMap.put("success", true);
-		return modelMap;
-	} 
-	/**
-	 * 销售退货单云顶数据中心传UAS并过账接口
-	 */
-	@RequestMapping("/SaleReturn.action")
-	@ResponseBody
-	public Map<String, Object> SaleReturn(String Store){
-		Map<String, Object> modelMap = new HashMap<String, Object>();
-		yundingService.SaleReturn(Store);
-		modelMap.put("success", true);
-		return modelMap;
-	} 
-	/**
-	 * 销售退货单云顶数据中心传UAS反过账删除接口
-	 */
-	@RequestMapping("/SaleReturnDelete.action")
-	@ResponseBody
-	public Map<String, Object> SaleReturnDelete(String Store){
-		Map<String, Object> modelMap = new HashMap<String, Object>();
-		yundingService.SaleReturnDelete(Store);
-		modelMap.put("success", true);
-		return modelMap;
-	} 
-}

+ 3 - 3
src/main/java/com/uas/eis/core/config/AsyncConfig.java

@@ -19,11 +19,11 @@ public class AsyncConfig{
     public Executor asyncExecutor() {
     public Executor asyncExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         //核心线程数10:线程池创建时候初始化的线程数
         //核心线程数10:线程池创建时候初始化的线程数
-        executor.setCorePoolSize(10);
+        executor.setCorePoolSize(2);
         //最大线程数20:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程
         //最大线程数20:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程
-        executor.setMaxPoolSize(50);
+        executor.setMaxPoolSize(20);
         //缓冲队列500:用来缓冲执行任务的队列
         //缓冲队列500:用来缓冲执行任务的队列
-        executor.setQueueCapacity(500);
+        executor.setQueueCapacity(1000);
         //允许线程的空闲时间60秒:当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
         //允许线程的空闲时间60秒:当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
         executor.setKeepAliveSeconds(60);
         executor.setKeepAliveSeconds(60);
         //线程池名的前缀:设置好了之后可以方便我们定位处理任务所在的线程池
         //线程池名的前缀:设置好了之后可以方便我们定位处理任务所在的线程池

+ 56 - 0
src/main/java/com/uas/eis/core/support/SpringDynamicCronTask.java

@@ -0,0 +1,56 @@
+package com.uas.eis.core.support;
+
+
+
+import com.uas.eis.service.EDCBakService;
+import com.uas.eis.task.EDCBakTask;
+import com.uas.eis.task.ScheduleTask;
+import com.uas.eis.utils.ContextUtil;
+import com.uas.eis.utils.StringUtil;
+import org.apache.tomcat.util.buf.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.env.Environment;
+import org.springframework.scheduling.Trigger;
+import org.springframework.scheduling.TriggerContext;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+import org.springframework.scheduling.config.TriggerTask;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+@Configuration
+@EnableScheduling
+public class SpringDynamicCronTask implements SchedulingConfigurer {
+
+	private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+
+	@Autowired
+	private Environment env;
+
+	@Autowired
+	private ScheduleTask scheduleTask;
+
+	@Override
+	public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
+		String activeProFiles = env.getActiveProfiles()[0];
+		if(!"dev".equals(activeProFiles)) {
+			logger.info(String.format("运行环境:%s;注册TASK:%s",activeProFiles,env.getProperty("Task.Method")));
+			taskRegistrar.addCronTask(() -> {
+				//业务逻辑
+				try {
+					Method method = scheduleTask.getClass().getMethod(env.getProperty("Task.Method"));
+					method.invoke(scheduleTask);
+				}catch (Exception e){
+					e.printStackTrace();
+				}
+			}, env.getProperty("Task.Cron"));
+		}
+	}
+}

+ 26 - 1
src/main/java/com/uas/eis/dao/BaseDao.java

@@ -26,7 +26,11 @@ import net.sf.json.JSONObject;
 
 
 @Repository
 @Repository
 public class BaseDao{
 public class BaseDao{
-	
+
+	static final String CREATE_SEQ = "CREATE SEQUENCE ?" + // 创建序列
+			" MINVALUE 1 MAXVALUE 99999999999 INCREMENT BY 1 START WITH 3000 CACHE 20 NOORDER NOCYCLE ";
+
+
 	@Autowired
 	@Autowired
 	private JdbcTemplate jdbcTemplate;
 	private JdbcTemplate jdbcTemplate;
 	
 	
@@ -34,10 +38,31 @@ public class BaseDao{
 		return jdbcTemplate;
 		return jdbcTemplate;
 	}
 	}
 
 
+	public int getSeqId(String seq) {
+		try {
+			String sql = "select " + seq + ".nextval from dual";
+			SqlRowList rs = queryForRowSet(sql);
+			if (rs.next()) {
+				return rs.getInt(1);
+			} else {// 如果不存在就创建序列
+				int count = getCountByCondition("user_sequences", "Sequence_Name='" + seq.toUpperCase() + "'");
+				if (count == 0)
+					getJdbcTemplate().execute(CREATE_SEQ.replace("?", seq));
+				return getSeqId(seq);
+			}
+		} catch (Exception e) {
+			int count = getCountByCondition("user_sequences", "Sequence_Name='" + seq.toUpperCase() + "'");
+			if (count == 0)
+				getJdbcTemplate().execute(CREATE_SEQ.replace("?", seq));
+			return getSeqId(seq);
+		}
+	}
+
 	public List<Map<String, Object>> queryForList(String sql) {
 	public List<Map<String, Object>> queryForList(String sql) {
 		try {
 		try {
 			return jdbcTemplate.queryForList(sql);
 			return jdbcTemplate.queryForList(sql);
 		} catch (EmptyResultDataAccessException e) {
 		} catch (EmptyResultDataAccessException e) {
+			e.printStackTrace();
 			return null;
 			return null;
 		}
 		}
 	}
 	}

+ 5 - 1
src/main/java/com/uas/eis/entity/DataChip.java

@@ -1,16 +1,20 @@
 package com.uas.eis.entity;
 package com.uas.eis.entity;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
 import java.util.Date;
 import java.util.Date;
 
 
 /**
 /**
  * @Author: zhouy
  * @Author: zhouy
  * @Date: 2020/5/26 13:53
  * @Date: 2020/5/26 13:53
  */
  */
-public class DataChip {
+public class DataChip implements Serializable {
     private Integer id_;
     private Integer id_;
     private String chipcode_;
     private String chipcode_;
     private String counterpath_;
     private String counterpath_;
     private String datapath_;
     private String datapath_;
+    @JsonFormat(pattern = "yyyy-MM-dd")
     private Date testdate_;
     private Date testdate_;
     public Integer getId_() {
     public Integer getId_() {
         return id_;
         return id_;

+ 71 - 0
src/main/java/com/uas/eis/entity/EquipConfig.java

@@ -0,0 +1,71 @@
+package com.uas.eis.entity;
+
+/**
+ * @Author: zhouy
+ * @Date: 2020/5/27 15:10
+ */
+public class EquipConfig {
+    private String ec_ip;
+    private String ec_counterpath;
+    private String ec_datapath;
+    private String ec_counterbak;
+    private String ec_databak;
+    private String ed_devcode;
+    private String ed_teststep;
+
+    public String getEc_ip() {
+        return ec_ip;
+    }
+
+    public void setEc_ip(String ec_ip) {
+        this.ec_ip = ec_ip;
+    }
+
+    public String getEc_counterpath() {
+        return ec_counterpath;
+    }
+
+    public void setEc_counterpath(String ec_counterpath) {
+        this.ec_counterpath = ec_counterpath;
+    }
+
+    public String getEc_datapath() {
+        return ec_datapath;
+    }
+
+    public void setEc_datapath(String ec_datapath) {
+        this.ec_datapath = ec_datapath;
+    }
+
+    public String getEc_counterbak() {
+        return ec_counterbak;
+    }
+
+    public void setEc_counterbak(String ec_counterbak) {
+        this.ec_counterbak = ec_counterbak;
+    }
+
+    public String getEc_databak() {
+        return ec_databak;
+    }
+
+    public void setEc_databak(String ec_databak) {
+        this.ec_databak = ec_databak;
+    }
+
+    public String getEd_devcode() {
+        return ed_devcode;
+    }
+
+    public void setEd_devcode(String ed_devcode) {
+        this.ed_devcode = ed_devcode;
+    }
+
+    public String getEd_teststep() {
+        return ed_teststep;
+    }
+
+    public void setEd_teststep(String ed_teststep) {
+        this.ed_teststep = ed_teststep;
+    }
+}

+ 4 - 0
src/main/java/com/uas/eis/service/DataDealService.java

@@ -2,6 +2,7 @@ package com.uas.eis.service;
 
 
 import com.uas.eis.entity.DataChip;
 import com.uas.eis.entity.DataChip;
 
 
+import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CountDownLatch;
 
 
 /**
 /**
@@ -9,5 +10,8 @@ import java.util.concurrent.CountDownLatch;
  * @Date: 2020/5/22 13:54
  * @Date: 2020/5/22 13:54
  */
  */
 public interface DataDealService {
 public interface DataDealService {
+     //Data文件解析
      void EDCDataDeal(DataChip dataChip, CountDownLatch countDownLatch);
      void EDCDataDeal(DataChip dataChip, CountDownLatch countDownLatch);
+     //Counter文件批量解析
+     void EDCCounterDeal(List<String> codes);
 }
 }

+ 15 - 0
src/main/java/com/uas/eis/service/EDCBakService.java

@@ -0,0 +1,15 @@
+package com.uas.eis.service;
+
+import com.uas.eis.entity.EquipConfig;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @Author: zhouy
+ * @Date: 2020/5/27 14:18
+ */
+public interface EDCBakService {
+    void EDCBak(List<EquipConfig> configs, CountDownLatch countDownLatch);
+    Object AnalysisCounterData(String chipcode);
+}

+ 0 - 11
src/main/java/com/uas/eis/service/ProductService.java

@@ -1,11 +0,0 @@
-package com.uas.eis.service;
-
-import java.util.Map;
-
-/**
- * Created by luhg on 2018/4/19.
- * 出入库相关
- */
-public interface ProductService {
-    Map<String,Object> postProductToYunding(Integer id);
-}

+ 0 - 9
src/main/java/com/uas/eis/service/SaleReturnService.java

@@ -1,9 +0,0 @@
-package com.uas.eis.service;
-
-/**
- * Created by luhg on 2018/4/26.
- * 销售退货单
- */
-public interface SaleReturnService {
-    void getSaleReturn();
-}

+ 0 - 9
src/main/java/com/uas/eis/service/SaleService.java

@@ -1,9 +0,0 @@
-package com.uas.eis.service;
-
-/**
- * Created by luhg on 2018/4/26.
- * 销售订单
- */
-public interface SaleService {
-    void getSale();
-}

+ 0 - 13
src/main/java/com/uas/eis/service/StockService.java

@@ -1,13 +0,0 @@
-package com.uas.eis.service;
-
-import java.util.Map;
-
-/**
- * Created by luhg on 2018/4/19.
- * 出入库相关
- */
-public interface StockService {
-    Map<String,Object> postStockToYunding(Integer id);
-    void autoPost();
-    void postConfirmToYunding(String code,int type);
-}

+ 0 - 17
src/main/java/com/uas/eis/service/YundingService.java

@@ -1,17 +0,0 @@
-package com.uas.eis.service;
-
-public interface YundingService {
-	
-	public void  ProdInOutAuidted(int id,String piclass);
-	
-	public void  ProdInOutPOST(String Store);
-	
-	public void  Salereceive(String Store);
-
-	public void  TurnProdIN (int id);
-
-	public void  SaleReturn(String Store);
-	
-	public void  SaleReturnDelete(String Store);
-
-}

+ 7 - 0
src/main/java/com/uas/eis/serviceImpl/DataDealServiceImpl.java

@@ -40,6 +40,7 @@ public class DataDealServiceImpl  implements DataDealService {
     @Async("taskExecutor")
     @Async("taskExecutor")
     public void EDCDataDeal(DataChip dataChip, CountDownLatch countDownLatch) {
     public void EDCDataDeal(DataChip dataChip, CountDownLatch countDownLatch) {
         try {
         try {
+            logger.info(dataChip.getChipcode_()+"Data文件解析开始");
             //读取文件EXCEL解析
             //读取文件EXCEL解析
             String FilePath=dataChip.getDatapath_();
             String FilePath=dataChip.getDatapath_();
             Date testdate = dataChip.getTestdate_();
             Date testdate = dataChip.getTestdate_();
@@ -138,6 +139,7 @@ public class DataDealServiceImpl  implements DataDealService {
                 //文件不存在
                 //文件不存在
                 baseDao.execute("UPDATE DATACENTER$CHIP SET READSTATUS_=-100 WHERE ID_="+dataChip.getId_());
                 baseDao.execute("UPDATE DATACENTER$CHIP SET READSTATUS_=-100 WHERE ID_="+dataChip.getId_());
             }
             }
+            logger.info(dataChip.getChipcode_()+"Data文件解析结束");
 
 
         }catch (Exception e) {
         }catch (Exception e) {
             baseDao.execute("UPDATE DATACENTER$CHIP SET READSTATUS_=-99 WHERE ID_="+dataChip.getId_());
             baseDao.execute("UPDATE DATACENTER$CHIP SET READSTATUS_=-99 WHERE ID_="+dataChip.getId_());
@@ -146,4 +148,9 @@ public class DataDealServiceImpl  implements DataDealService {
             countDownLatch.countDown();
             countDownLatch.countDown();
         }
         }
     }
     }
+
+    @Override
+    public void EDCCounterDeal(List<String> codes) {
+
+    }
 }
 }

+ 375 - 0
src/main/java/com/uas/eis/serviceImpl/EDCBakServiceImpl.java

@@ -0,0 +1,375 @@
+package com.uas.eis.serviceImpl;
+
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.dao.SqlRowList;
+import com.uas.eis.entity.EquipConfig;
+import com.uas.eis.service.EDCBakService;
+import com.uas.eis.utils.Constant;
+import com.uas.eis.utils.DateUtil;
+import com.uas.eis.utils.SmbUtil;
+import jcifs.smb.SmbFile;
+import jcifs.smb.SmbFileInputStream;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @Author: zhouy
+ * @Date: 2020/5/27 14:19
+ */
+@Service
+public class EDCBakServiceImpl implements EDCBakService {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Autowired
+    private BaseDao baseDao;
+
+    @Override
+    @Async("taskExecutor")
+    public void EDCBak(List<EquipConfig> configs, CountDownLatch countDownLatch){
+        //查询所有的设备
+        EquipConfig baseConfig = configs.get(0);
+        /**
+         * 主机相关配置
+         * */
+        String IP = baseConfig.getEc_ip().trim();
+        String counterRootPath = baseConfig.getEc_counterpath().endsWith("/") ? baseConfig.getEc_counterpath() :  baseConfig.getEc_counterpath()+"/";
+        String dataRootPath = baseConfig.getEc_datapath().endsWith("/") ? baseConfig.getEc_datapath() :  baseConfig.getEc_datapath()+"/";
+        String counterbakRootPath = baseConfig.getEc_counterbak().endsWith("/") ? baseConfig.getEc_counterbak() :  baseConfig.getEc_counterbak()+"/";
+        String uploadRootPath = baseConfig.getEc_databak();
+        logger.info(" matchIP:"+IP+" start;");
+        //检测是否连接成功
+        SmbFile smbFile = SmbUtil.getRootFile(IP,counterRootPath);
+        try {
+            smbFile.connect();
+        } catch (Exception e) {
+            baseDao.execute("insert into EDCsyscfaillog(el_id,el_ip,el_devcode,el_teststep,el_synctime,el_reason) values(EDCsyscfaillog_seq.nextval,'"+IP+"','','',sysdate,'"+e.getMessage()+",连接超时')");
+            logger.info(IP+" 连接失败;"+e.getMessage());
+            return;
+        }finally {
+            countDownLatch.countDown();
+        }
+        String counterpath = "";
+        try {
+            for(EquipConfig config : configs){
+                String testStep =  config.getEd_teststep();
+                String devcode = config.getEd_devcode();
+                List<Map<String, Object>> lists=baseDao.getJdbcTemplate().queryForList("SELECT * FROM (SELECT * FROM DATACENTER$MESTEMP WHERE EQPCODE_='"+devcode+"' AND TAB_ ='"+testStep+"' and turn_=0 AND nvl(fail,0)=0 ORDER BY CHIPCODE_,OBJECT_RRN ASC  )  WHERE ROWNUM <= 50");
+                logger.info(" matchIP:"+IP+","+testStep+" start;");
+                logger.info(" matchIP:"+IP+","+testStep+" 待归档数:"+lists.size());
+                if(lists.size()>0){
+                    try {
+                        /**相关路径匹配*/
+                        if(smbFile !=null) {
+                            SmbFile dataFile = SmbUtil.getCurrentFile(IP,dataRootPath);
+                            List <SmbFile> files = SmbUtil.getChildFiles(dataFile, testStep, "xls");
+                            List <SmbFile> files1 = SmbUtil.getChildFiles(dataFile, testStep, "jdf");
+                            List <SmbFile> files2 = SmbUtil.getChildFiles(dataFile, testStep, "njdf");
+                            for(Map<String, Object> map : lists) {
+                                //Counter文件匹配
+                                counterpath = String.valueOf(map.get("COUNTERPATH_"));
+                                final String filename = counterpath.substring(counterpath.lastIndexOf("\\")+1);
+                                smbFile = SmbUtil.getCurrentFile(IP,counterbakRootPath+filename);
+
+                                map.put("COUNTERPATH_", smbFile.getPath());
+                                Optional<SmbFile> optional = files.stream().filter(file -> mappingSuccess(filename,file.getDate())).findFirst();
+                                //遍历到了对应的Data文件存在
+                                if (optional.isPresent()){
+                                    map.put("DATAPATH_", optional.get().getPath());
+                                }
+                                optional = files1.stream().filter(file -> mappingSuccess(filename,file.getDate())).findFirst();
+                                //遍历到了对应的Data文件存在
+                                if (optional.isPresent()){
+                                    map.put("JDFPATH_", optional.get().getPath());
+                                }
+                                optional = files2.stream().filter(file -> mappingSuccess(filename,file.getDate())).findFirst();
+                                if (optional.isPresent()){
+                                    map.put("JDFPATH_", optional.get().getPath());
+                                }
+
+                            }
+                        }
+                    } catch (Exception e) {
+                        baseDao.execute("insert into EDCsyscfaillog(el_id,el_ip,el_devcode,el_teststep,el_synctime,el_reason) values(EDCsyscfaillog_seq.nextval,'"+IP+"','"+devcode+"','"+testStep+"',sysdate,'"+e.getMessage()+"')");
+                        e.printStackTrace();
+                        if(e.getMessage().equals("Plain text passwords are disabled")){
+                            continue;
+                        }
+                    }
+                }
+                else{
+                    logger.info(" matchIP:"+IP+","+testStep+"未匹配有效文件");
+                    continue;
+                }
+                List<String> Sqls = new ArrayList<String>();
+                //匹配到JDF文件或者Data
+                List<Map<String, Object>> datalist=new ArrayList<>();
+                for(Map<String,Object> map : lists){
+                    if(map.get("DATAPATH_")!=null||map.get("JDFPATH_")!=null){
+                        datalist.add(map);
+                    }else {
+                        String chipcode=map.get("CHIPCODE_").toString();
+                        String ID=map.get("OBJECT_RRN").toString();
+                        baseDao.execute("insert into EDCsyscfaillog(el_id,el_ip,el_devcode,el_teststep,el_synctime,el_chipcode,el_reason) values(EDCsyscfaillog_seq.nextval,'"+IP+"','"+devcode+"','"+testStep+"',sysdate,'"+chipcode+"','未匹配到对应JDF文件,无法归档')");
+                        baseDao.execute("update datacenter$mestemp set fail=-1 where OBJECT_RRN="+ID);
+                    }
+                }
+                logger.info(" matchIP:"+IP+","+testStep+" 匹配数:"+datalist.size());
+                baseDao.execute("insert into SYS_SCHEDULETASKLOG(date_,remark_,scheduleid_) values"
+                        + "(sysdate,'执行开始:IP"+IP+"设备"+devcode+"匹配到数量"+datalist.size()+"',7042)");
+                //未设置备份文件夹时记录日志
+                if(uploadRootPath==null)
+                {
+                    baseDao.execute("insert into EDCsyscfaillog(el_id,el_ip,el_devcode,el_teststep,el_synctime,el_reason) values(EDCsyscfaillog_seq.nextval,'"+IP+"','"+devcode+"','"+testStep+"',sysdate,'BackUp文件夹未设置,请检查终端设置')");
+                    continue;
+                }
+                /**
+                 * 文件归档开始
+                 * */
+                String dataPath_ = "";
+                String counterPath_ = "";
+                String jdfPath_="";
+                String currentUploadPath = getUploadPath(uploadRootPath+"/");
+                String centerUploadPath =  getUploadPath(SmbUtil.centerPath+devcode+"/");
+                SmbFile counterFile = null;
+                SmbFile dataFile = null;
+                SmbFile jdfFile = null;
+                String currentKind = null;
+                SmbFile counterBaKFile = null;
+                SmbFile dataBakFile = null;
+                SmbFile jdfBakFile = null;
+                SmbFile counterCenterFile = null;
+                SmbFile dataCenterFile = null;
+                SmbFile jdfCenterFile = null;
+                List<Object> IDS = new ArrayList<>();
+                for(Map<String,Object> map : datalist){
+                    logger.info(map.get("CHIPCODE_")+"开始");
+                    counterPath_ = String.valueOf(map.get("COUNTERPATH_"));
+                    dataPath_ = String.valueOf(map.get("DATAPATH_"));
+                    jdfPath_ = String.valueOf(map.get("JDFPATH_"));
+                    try {
+                        currentKind = map.get("PART_NAME")+"-"+map.get("MAKE_LOT");
+
+                        String path1=""; //数据中心Counter文件
+                        String path2=""; //数据中心Data文件
+                        String path3=""; //本地Counter备份文件
+                        String path4=""; //本地Data备份文件
+                        String path5=""; //数据中心JDF文件
+                        String path6=""; //本地JDF文件
+
+                        //判断本机文件夹是否存在,不存在创建
+                        if(!SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/").exists()){
+                            SmbUtil.getCurrentFile(IP,currentUploadPath+(currentKind+"/SJ/")).mkdirs();
+                            SmbUtil.getCurrentFile(IP,currentUploadPath+(currentKind+"/FP/")).mkdirs();
+                        }
+                        //判断文件服务器文件夹是否存在,不存在创建
+                        if(!SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/").exists()){
+                            SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+(currentKind+"/SJ/")).mkdirs();
+                            SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+(currentKind+"/FP/")).mkdirs();
+                        }
+
+                        //处理Counter文件
+                        counterFile = SmbUtil.getCurrentFile(counterPath_);
+                        counterCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/FP/"+map.get("CHIPCODE_")+".xls");
+                        /**
+                         * counter文件 文件服务器归档
+                         * */
+                        counterFile.copyTo(counterCenterFile);
+
+                        counterBaKFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/FP/"+map.get("CHIPCODE_")+".xls");
+
+                        int Count=1;
+                        while (counterBaKFile.exists()){
+                            String filename= counterBaKFile.getName();
+                            String name = filename.substring(0,filename.indexOf("."));
+                            String newFilename = name+"("+Count+")";
+                            counterBaKFile=SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/FP/"+newFilename+".xls");
+                        }
+                        path1=counterCenterFile.getPath();
+                        path3=counterBaKFile.getPath();
+                        /**
+                         * 本机counter文件移到本机归档目录当前目录删除
+                         * */
+                        counterFile.copyTo(counterBaKFile);
+                        counterFile.delete();
+
+                        //存在Data文件
+                        if(map.get("DATAPATH_")!=null){
+
+                            dataFile = SmbUtil.getCurrentFile(dataPath_);
+                            dataCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
+                            /**
+                             * data文件 文件服务器归档
+                             * */
+                            dataFile.copyTo(dataCenterFile);
+                            dataBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
+                            while (dataBakFile.exists()){
+                                String filename= dataBakFile.getName();
+                                String name = filename.substring(0,filename.indexOf("."));
+                                String newFilename = name+"("+Count+")";
+                                dataBakFile=SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+newFilename+".xls");
+                            }
+                            path2=dataCenterFile.getPath();
+                            path4=dataBakFile.getPath();
+                            /**
+                             * 本机data文件移到本机归档目录当前目录删除
+                             * */
+                            dataFile.copyTo(dataBakFile);
+                            dataFile.delete();
+                        }else{
+                            dataCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
+                            dataBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+".xls");
+                            path2=dataCenterFile.getPath();
+                            path4=dataBakFile.getPath();
+                        }
+
+                        //如果存在JDF文件
+                        if(map.get("JDFPATH_")!=null){
+                            String filesuffix=".jdf";
+                            if(map.get("JDFPATH_").toString().contains("njdf")){
+                                filesuffix=".njdf";
+                            }
+                            jdfFile = SmbUtil.getCurrentFile(jdfPath_);
+                            jdfCenterFile = SmbUtil.getCurrentFile(SmbUtil.centerIP,centerUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+filesuffix);
+                            jdfFile.copyTo(jdfCenterFile);
+                            jdfBakFile = SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+map.get("CHIPCODE_")+filesuffix);
+                            while (jdfBakFile.exists()){
+                                String filename= jdfBakFile.getName();
+                                String name = filename.substring(0,filename.indexOf("."));
+                                String suffix = filename.substring(filename.lastIndexOf("."));
+                                String newFilename = name+"("+Count+")";
+                                jdfBakFile=SmbUtil.getCurrentFile(IP,currentUploadPath+currentKind+"/SJ/"+newFilename+filesuffix);
+                            }
+                            path5=jdfCenterFile.getPath();
+                            path6=jdfBakFile.getPath();
+                            jdfFile.copyTo(jdfBakFile);
+                            jdfFile.delete();
+                        }
+
+                        //数据中心归档
+                        Sqls.add("MERGE INTO DATACENTER$CHIP A USING (SELECT  CHIPCODE_, OBJECT_RRN, PART_NAME, TEST_LOT, MAKE_LOT,CREATEDATE_ FROM  DATACENTER$MESTEMP WHERE OBJECT_RRN = "+map.get("OBJECT_RRN")+") B ON (A.CHIPCODE_= B.CHIPCODE_) " +
+                                " WHEN MATCHED THEN UPDATE SET A.OBJECT_RRN = B.OBJECT_RRN ,A.PART_NAME = B.PART_NAME, A.TEST_LOT = B.TEST_LOT , A.MAKE_LOT = B.MAKE_LOT " +
+                                " WHEN NOT MATCHED THEN INSERT (COUNTERPATH_, DATAPATH_ ,LOCALCOUNTERPATH_ , LOCALDATAPATH_,JDFPATH_,LOCALJDFPATH_,ID_, CHIPCODE_, OBJECT_RRN , PART_NAME ,TEST_LOT, MAKE_LOT,TESTDATE_,DATE_) VALUES ("+
+                                " '"+path1+"','"+path2+"','"+path3+"','"+path4+"','"+path5+"','"+path6+"',DATACENTERCHIP_SEQ.NEXTVAL, B.CHIPCODE_,B.OBJECT_RRN,B.PART_NAME,B.TEST_LOT,B.MAKE_LOT,B.CREATEDATE_,SYSDATE)"
+                        );
+                        IDS.add(map.get("OBJECT_RRN"));
+                        logger.info(map.get("CHIPCODE_")+"结束");
+
+                    } catch (Exception e) {
+                        baseDao.execute("insert into EDCsyscfaillog(el_id,el_ip,el_devcode,el_teststep,el_synctime,el_reason) values(EDCsyscfaillog_seq.nextval,'"+IP+"','"+devcode+"','"+testStep+"',sysdate,'"+e.getMessage()+"')");
+                        e.printStackTrace();
+                    }
+                }
+                if(IDS.size() > 0){
+                    Sqls.add("UPDATE DATACENTER$MESTEMP SET TURN_=-1 WHERE OBJECT_RRN IN ("+ StringUtils.join(IDS,",") +")");
+                    baseDao.execute(Sqls);
+                }
+                //同步做COUNTER文件解析
+                SqlRowList rs1=baseDao.queryForRowSet("select chipcode_ from DATACENTER$CHIP left join  CHIP_EDC_RECORD on DATACENTER$CHIP.CHIPCODE_=CHIP_EDC_RECORD.CER_CHIPCODE where CER_CHIPCODE is null");
+                while(rs1.next()){
+                    AnalysisCounterData(rs1.getString("chipcode_"));
+                }
+
+            }
+
+        } catch (Exception e){
+            e.printStackTrace();
+            logger.info(IP+" 操作失败;");
+        }finally {
+            countDownLatch.countDown();
+        }
+        logger.info(" matchIP:"+IP+" end;");
+    }
+    private boolean mappingSuccess(String fileName , Long time) {
+        boolean match=false;
+        //时间在同一分钟改的可以匹配
+        if(fileName.substring(2).startsWith(DateUtil.format(new Date(time), Constant.YMDHM))){
+            match=true;
+        }else
+        {
+            long time1=10*1000;
+            //如果时间不在同一分钟则直接加10秒再匹配
+            if(fileName.substring(2).startsWith(DateUtil.format(new Date(time+time1), Constant.YMDHM))) {
+                match=true;
+            }else if(fileName.substring(2).startsWith(DateUtil.format(new Date(time-time1), Constant.YMDHM)))
+            {
+                match=true;
+            }
+        }
+        return match;
+    }
+
+    private String getUploadPath(String uploadRootPath) {
+        String[] dateStr = new SimpleDateFormat("yyyy-MM-dd").format(new Date()).toString().split("-");
+        return String.format("%s/%s/%s/%s/", uploadRootPath, dateStr[0], dateStr[0]+dateStr[1],
+                dateStr[0]+dateStr[1]+dateStr[2] );
+    }
+
+    //解析Counter文件
+    public Object AnalysisCounterData(String chip_code){
+        SqlRowList rs=baseDao.queryForRowSet("select counterpath_ from datacenter$chip where chipcode_='"+chip_code+"' order by id_ desc");
+        Object cer_id=null;
+        if(rs.next()){
+            try{
+                String FilePath=rs.getString("counterpath_");
+                //打开文件流
+                SmbFile smbFile = SmbUtil.getCurrentFile(FilePath);
+                InputStream is = new BufferedInputStream(new SmbFileInputStream(smbFile));
+                Workbook book = new HSSFWorkbook(is);
+                cer_id=baseDao.getSeqId("CHIP_EDC_RECORD_SEQ");
+                Sheet st=book.getSheet("Measure");
+                //测试日期
+                Object test_Date= st.getRow(2).getCell(1).getStringCellValue();
+                //测试站位
+                String test_Station= st.getRow(3).getCell(1).getStringCellValue();
+                //测试文件名
+                String test_FileName=st.getRow(4).getCell(1).getStringCellValue();
+                //设备名称
+                String test_DeviceName = st.getRow(5).getCell(1).getStringCellValue();
+                StringBuffer sql=new StringBuffer();
+                //插入主表记录
+                sql.append("insert into CHIP_EDC_RECORD(cer_id,cer_testdate,cer_chipcode,cer_indate,cer_station,cer_spec,cer_device,cer_testfilename,cer_lot,");
+                sql.append("cer_operator,cer_comment) values('"+cer_id+"',to_date('"+test_Date+"','yyyy mm dd hh24 mi ss'),'"+chip_code+"',sysdate,'"+test_Station+"','"+test_FileName.split("-")[0]+"',");
+                sql.append("'"+test_DeviceName+"','"+test_FileName+"','"+chip_code.split("#")[0]+"','','');");
+                //循环详细的测试内容,从11行最后一行
+                for (int i=11;i<=st.getLastRowNum();i++){
+                    double cerd_itemdetno= st.getRow(i).getCell(0).getNumericCellValue();
+                    String cerd_itemname = st.getRow(i).getCell(1).getStringCellValue();
+                    double cred_testnum = st.getRow(i).getCell(2).getNumericCellValue();
+                    double cerd_failnum= st.getRow(i).getCell(3).getNumericCellValue();
+                    Object cerd_precent = "''";
+                    if(st.getRow(i).getCell(4)!=null) {
+                        switch (st.getRow(i).getCell(4).getCellType()) {
+                            case HSSFCell.CELL_TYPE_NUMERIC:
+                                cerd_precent = st.getRow(i).getCell(4).getNumericCellValue();
+                                break;
+                            case HSSFCell.CELL_TYPE_STRING:
+                                cerd_precent = st.getRow(i).getCell(4).getStringCellValue();
+                                break;
+                        }
+                    }
+                    sql.append("insert into CHIP_EDC_RECORDDet(cerd_id,cerd_cerid,cerd_itemdetno,cerd_itemname,cerd_precent,cred_testnum,cerd_failnum)");
+                    sql.append("values(CHIP_EDC_RECORDDet_SEQ.nextval,'"+cer_id+"','"+cerd_itemdetno+"','"+cerd_itemname+"',"+cerd_precent+","+cred_testnum+","+cerd_failnum+");");
+                }
+                baseDao.execute("begin  "+sql.toString()+"  end;");
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+        }
+        return cer_id;
+    }
+}

+ 0 - 126
src/main/java/com/uas/eis/serviceImpl/ProductServiceImpl.java

@@ -1,126 +0,0 @@
-package com.uas.eis.serviceImpl;
-
-import com.uas.eis.dao.BaseDao;
-import com.uas.eis.dao.EdiLogDao;
-import com.uas.eis.dao.EdiSuccessLogDao;
-import com.uas.eis.service.ProductService;
-import com.uas.eis.utils.Constant;
-import com.uas.eis.utils.HttpUtil;
-import com.uas.eis.utils.JacksonUtil;
-import com.uas.eis.utils.LogUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.support.rowset.SqlRowSet;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by zdw
- * 2018-05-15 08:29.
- */
-@Service
-public class ProductServiceImpl implements ProductService{
-
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    private static final String sendProductToYundingUrl = "http://dc.oclean.com/putstorespec?sign";
-
-    @Autowired
-    BaseDao baseDao;
-    @Autowired
-    EdiLogDao ediLogDao;
-    @Autowired
-    EdiSuccessLogDao ediSuccessLogDao;
-
-
-    @Override
-    public Map<String, Object> postProductToYunding(Integer id) {
-        Map<String,Object> data = getMainData(id);
-        List<Map<String,Object>> datas = new LinkedList<Map<String,Object>>();
-        datas.add(data);
-
-        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
-        String outerNo = String.valueOf(data.get("goods_no"));
-
-        Map<String,Object> postMapData = new HashMap<>();
-        postMapData.put("app_key", Constant.yundingAppKey);
-        postMapData.put("time_stamp",timestamp);
-        postMapData.put("spec_list",datas);
-
-        return postData(outerNo,postMapData,timestamp);
-    }
-
-    private Map<String,Object> postData(String outerNo,Map<String,Object> data,String timestamp){
-        Map<String,Object> res = new HashMap<>();
-        String jsonData = JacksonUtil.toSortJson(data);
-        System.out.println(jsonData);
-        try{
-
-            HttpUtil.Response response = HttpUtil.doPostToYunding(sendProductToYundingUrl,jsonData,timestamp);
-
-            String responseText = response.getResponseText();
-
-            logger.info("responseText:" + responseText);
-            logger.info("responseCode:" + response.getStatusCode());
-
-            if(response.getStatusCode()!=200){
-                throw new RuntimeException("yunding server error:" + responseText);
-            }
-
-            Map<String,Object> responseMap = JacksonUtil.fromJson(response.getResponseText());
-
-            if(!"0".equals(String.valueOf(responseMap.get("code")))){
-                res.put("success",false);
-                res.put("remark",responseMap.get("message"));
-            }else{
-                Map<String,Object> msgJson = (Map<String,Object>) responseMap.get("msg_json");
-                List<String> successCodes = (List<String>)msgJson.get("s_no");
-                if(successCodes.contains(outerNo)){
-                    res.put("success",true);
-                    ediLogDao.save(LogUtil.getSendSuccessLog(outerNo,jsonData,"send success"));
-                }else{
-                    res.put("success",false);
-                    res.put("remark","云顶数据中心处理失败!");
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-            logger.error("error",e);
-
-            res.put("success",false);
-            res.put("remark",e.getMessage());
-        }
-        return res;
-    }
-
-    private Map<String,Object> getMainData(Integer id){
-        Map<String,Object> data = new HashMap<>();
-        SqlRowSet rs = baseDao.getJdbcTemplate().queryForRowSet("select pr_code,pr_detail,pr_brand,pr_unit,pr_code,pr_spec,pr_description from Product where pr_id=" + id);
-        if(rs.next()){
-            data.put("goods_no",rs.getString("pr_code"));
-            data.put("goods_name",rs.getString("pr_detail"));
-            data.put("goods_type",1);
-            data.put("class_name","");
-            data.put("brand_name",rs.getString("pr_brand"));
-            data.put("unit_name",rs.getString("pr_unit"));
-            data.put("spec_no",rs.getString("pr_code"));
-            data.put("spec_code","");
-            data.put("spec_name",rs.getString("pr_spec"));
-            data.put("bar_code","");
-            data.put("price","");
-            data.put("guarantee","");
-            data.put("description",rs.getString("pr_description"));
-        }
-        return data;
-    }
-
-
-
-
-
-}

+ 0 - 124
src/main/java/com/uas/eis/serviceImpl/SaleReturnServiceImpl.java

@@ -1,124 +0,0 @@
-package com.uas.eis.serviceImpl;
-
-import com.uas.eis.dao.*;
-import com.uas.eis.entity.EdiSuccessLog;
-import com.uas.eis.entity.SaleReturn;
-import com.uas.eis.service.SaleReturnService;
-import com.uas.eis.service.StockService;
-import com.uas.eis.utils.Constant;
-import com.uas.eis.utils.HttpUtil;
-import com.uas.eis.utils.JacksonUtil;
-import com.uas.eis.utils.LogUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by luhg on 2018/4/26.
- * 销售退货单
- */
-@Service
-public class SaleReturnServiceImpl implements SaleReturnService{
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    public static final String getSaleReturnFromYundingUrl = "http://dc.oclean.com/getoutrefund";
-    //public static final String getSaleReturnFromYundingUrl = "http://127.0.0.1:8008/test/getoutrefund";
-
-    @Autowired
-    BaseDao baseDao;
-    @Autowired
-    EdiLogDao ediLogDao;
-    @Autowired
-    SaleReturnDao saleReturnDao;
-    @Autowired
-    EdiSuccessLogDao ediSuccessLogDao;
-    @Autowired
-    StockService stockService;
-
-    @Override
-    public void getSaleReturn() {
-        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
-
-        Map<String,Object> postMapData = new HashMap<String,Object>();
-        postMapData.put("app_key", Constant.yundingAppKey);
-        postMapData.put("time_stamp",timestamp);
-        postMapData.put("start_time","1970-01-01 00:00:00");
-        postMapData.put("end_time","2099-01-01 00:00:00");
-        postMapData.put("page_size",100);
-        postMapData.put("page_index",0);
-
-        String jsonData = JacksonUtil.toSortJson(postMapData);
-        String responseText = null;
-        try {
-            HttpUtil.Response response = HttpUtil.doPostToYunding(getSaleReturnFromYundingUrl,jsonData,timestamp);
-
-            System.out.println("responseText:" + response.getResponseText());
-
-            if(response.getStatusCode()!=200){
-                responseText = "yunding server error";
-                throw new RuntimeException(response.getResponseText());
-            }
-
-            responseText = response.getResponseText();
-            Map<String,Object> responseMap = JacksonUtil.fromJson(response.getResponseText());
-
-            if(!"0".equals(String.valueOf(responseMap.get("code")))){
-                ediLogDao.save(LogUtil.getRequestFailLog(responseText));
-                return;
-            }
-
-            if(responseMap.get("data")==null){
-                return;
-            }
-
-            List<Map<String,Object>> datas = (List<Map<String,Object>>) responseMap.get("data");
-            if(datas.size()>0){
-                execCreateSaleReturnProcedure(datas,responseText);
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-            logger.error("error",e);
-            ediLogDao.save(LogUtil.getSaleFailLog(responseText,e.getMessage()));
-        }
-    }
-
-    public void execCreateSaleReturnProcedure(List<Map<String,Object>> datas,String responseText){
-        String code = null;
-        String out = null;
-        EdiSuccessLog postSuccessHist = null;
-        String type = "sale_return";
-        for(Map<String,Object> data:datas){
-            code = String.valueOf(data.get("refund_no"));
-
-            postSuccessHist = null;
-            postSuccessHist = ediSuccessLogDao.findByCodeAndType(code,type);
-            if(postSuccessHist!=null){
-                stockService.postConfirmToYunding(code,3);
-                continue;
-            }
-
-            try {
-                SaleReturn saleReturn = JacksonUtil.fromJson(data, SaleReturn.class);
-                saleReturn = saleReturnDao.save(saleReturn);
-
-                out = baseDao.callProcedure("SP_YUNDING_SALERETURN",new Object[]{saleReturn.getId()});
-                if (out!=null){
-                    ediLogDao.save(LogUtil.getSaleReturnFailLog(code,responseText,out));
-                }else{
-                    ediLogDao.save(LogUtil.getSaleReturnSuccessLog(code,responseText));
-                    ediSuccessLogDao.save(LogUtil.getLogToAvoidRepeatPost(code,type));
-                    stockService.postConfirmToYunding(code,3);
-                }
-            }catch (Exception e){
-                e.printStackTrace();
-                logger.error("error",e);
-                ediLogDao.save(LogUtil.getSaleReturnFailLog(code,responseText,e.getMessage()));
-            }
-        }
-    }
-}

+ 0 - 126
src/main/java/com/uas/eis/serviceImpl/SaleServiceImpl.java

@@ -1,126 +0,0 @@
-package com.uas.eis.serviceImpl;
-
-import com.uas.eis.dao.*;
-import com.uas.eis.entity.EdiSuccessLog;
-import com.uas.eis.entity.Sale;
-import com.uas.eis.service.SaleService;
-import com.uas.eis.service.StockService;
-import com.uas.eis.utils.Constant;
-import com.uas.eis.utils.HttpUtil;
-import com.uas.eis.utils.JacksonUtil;
-import com.uas.eis.utils.LogUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by luhg on 2018/4/26.
- * 销售订单
- */
-@Service
-public class SaleServiceImpl implements SaleService{
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    public static final String getSaleFromYundingUrl = "http://dc.oclean.com/getoutstorage";
-    //public static final String getSaleFromYundingUrl = "http://127.0.0.1:8008/test/getoutstorage";
-
-    @Autowired
-    BaseDao baseDao;
-    @Autowired
-    EdiLogDao ediLogDao;
-    @Autowired
-    SaleDao saleDao;
-    @Autowired
-    EdiSuccessLogDao ediSuccessLogDao;
-    @Autowired
-    StockService stockService;
-
-    @Override
-    public void getSale() {
-        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
-
-        Map<String,Object> postMapData = new HashMap<>();
-        postMapData.put("app_key", Constant.yundingAppKey);
-        postMapData.put("time_stamp",timestamp);
-        postMapData.put("start_time","1970-01-01 00:00:00");
-        postMapData.put("end_time","2099-01-01 00:00:00");
-        postMapData.put("page_size",100);
-        postMapData.put("page_index",0);
-
-        String jsonData = JacksonUtil.toSortJson(postMapData);
-        String responseText = null;
-        try {
-            HttpUtil.Response response = HttpUtil.doPostToYunding(getSaleFromYundingUrl,jsonData,timestamp);
-
-            System.out.println("responseText:" + response.getResponseText());
-
-            if(response.getStatusCode()!=200){
-                responseText = "yunding server error";
-                throw new RuntimeException(response.getResponseText());
-            }
-
-            responseText = response.getResponseText();
-            Map<String,Object> responseMap = JacksonUtil.fromJson(response.getResponseText());
-
-            if(!"0".equals(String.valueOf(responseMap.get("code")))){
-                ediLogDao.save(LogUtil.getRequestFailLog(responseText));
-                return;
-            }
-
-            if(responseMap.get("stockout_list")==null){
-                return;
-            }
-
-            List<Map<String,Object>> datas = (List<Map<String,Object>>) responseMap.get("stockout_list");
-            if(datas.size()>0){
-                execCreateSaleProcedure(datas,responseText);
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-            logger.error("error",e);
-            ediLogDao.save(LogUtil.getSaleFailLog(responseText,e.getMessage()));
-        }
-    }
-
-    public void execCreateSaleProcedure(List<Map<String,Object>> datas,String responseText){
-        String code = null;
-        String wmscode = null;
-        String out = null;
-        EdiSuccessLog postSuccessHist = null;
-        String type = "sale";
-        for(Map<String,Object> data:datas){
-            code = String.valueOf(data.get("trade_no"));
-            wmscode = String.valueOf(data.get("order_no"));
-
-            postSuccessHist = null;
-            postSuccessHist = ediSuccessLogDao.findByCodeAndType(code,type);
-            if(postSuccessHist!=null){
-                stockService.postConfirmToYunding(wmscode,2);
-                continue;
-            }
-
-            try {
-                Sale sale = JacksonUtil.fromJson(data, Sale.class);
-                sale = saleDao.save(sale);
-
-                out = baseDao.callProcedure("SP_YUNDING_SALERECEIVE",new Object[]{sale.getId()});
-                if (out!=null){
-                    ediLogDao.save(LogUtil.getSaleFailLog(code,responseText,out));
-                }else{
-                    ediLogDao.save(LogUtil.getSaleSuccessLog(code,responseText));
-                    ediSuccessLogDao.save(LogUtil.getLogToAvoidRepeatPost(code,type));
-                    stockService.postConfirmToYunding(wmscode,2);
-                }
-            }catch (Exception e){
-                e.printStackTrace();
-                logger.error("error",e);
-                ediLogDao.save(LogUtil.getSaleFailLog(code,responseText,e.getMessage()));
-            }
-        }
-    }
-}

+ 0 - 355
src/main/java/com/uas/eis/serviceImpl/StockServiceImpl.java

@@ -1,355 +0,0 @@
-package com.uas.eis.serviceImpl;
-
-import com.uas.eis.dao.*;
-import com.uas.eis.entity.EdiSuccessLog;
-import com.uas.eis.service.StockService;
-import com.uas.eis.utils.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.jdbc.support.rowset.SqlRowSet;
-import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Created by luhg on 2018/4/19.
- * 出入库相关
- */
-@Service
-public class StockServiceImpl implements StockService{
-    private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
-    private static final String sendStockToYundingUrl = "http://dc.oclean.com/putinstorage";
-    private static final String stockGetPostFromYundingUrl = "http://dc.oclean.com/getinstorage";
-    private static final String sendStockPostConfirmToYundingUrl = "http://dc.oclean.com/setconfirmstatus";
-
-    @Autowired
-    BaseDao baseDao;
-    @Autowired
-    EdiLogDao ediLogDao;
-    @Autowired
-    EdiSuccessLogDao ediSuccessLogDao;
-
-    @Override
-    public Map<String, Object> postStockToYunding(Integer id) {
-        Map<String,Object> data = getMainData(id);
-        List<Map<String,Object>> datas = new LinkedList<Map<String,Object>>();
-        datas.add(data);
-
-        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
-        String outerNo = String.valueOf(data.get("outer_no"));
-
-        Map<String,Object> postMapData = new HashMap<>();
-        postMapData.put("app_key", Constant.yundingAppKey);
-        postMapData.put("time_stamp",timestamp);
-        postMapData.put("data",datas);
-
-        return postData(outerNo,postMapData,timestamp);
-    }
-
-    private Map<String,Object> postData(String outerNo,Map<String,Object> data,String timestamp){
-        Map<String,Object> res = new HashMap<>();
-        String jsonData = JacksonUtil.toSortJson(data);
-        try{
-
-            HttpUtil.Response response = HttpUtil.doPostToYunding(sendStockToYundingUrl,jsonData,timestamp);
-
-            String responseText = response.getResponseText();
-
-            logger.info("responseText:" + responseText);
-            logger.info("responseCode:" + response.getStatusCode());
-
-            if(response.getStatusCode()!=200){
-                throw new RuntimeException("yunding server error:" + responseText);
-            }
-
-            Map<String,Object> responseMap = JacksonUtil.fromJson(response.getResponseText());
-
-            if(!"0".equals(String.valueOf(responseMap.get("code")))){
-                res.put("success",false);
-                res.put("remark",responseMap.get("message"));
-            }else{
-                Map<String,Object> msgJson = (Map<String,Object>) responseMap.get("msg_json");
-                List<String> successCodes = (List<String>)msgJson.get("s_no");
-                if(successCodes.contains(outerNo)){
-                    res.put("success",true);
-                    ediLogDao.save(LogUtil.getSendSuccessLog(outerNo,jsonData,"send success"));
-                }else{
-                    res.put("success",false);
-                    res.put("remark","云顶数据中心处理失败!");
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-            logger.error("error",e);
-
-            res.put("success",false);
-            res.put("remark",e.getMessage());
-        }
-        return res;
-    }
-
-    @Override
-    public void autoPost(){
-        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
-
-        Map<String,Object> postMapData = new HashMap<>();
-        postMapData.put("app_key", Constant.yundingAppKey);
-        postMapData.put("time_stamp",timestamp);
-        postMapData.put("start_time","1970-01-01 00:00:00");
-        postMapData.put("end_time","2099-01-01 00:00:00");
-        postMapData.put("status",2);
-        postMapData.put("page_size",100);
-        postMapData.put("page_index",0);
-
-        String jsonData = JacksonUtil.toSortJson(postMapData);
-        String responseText = null;
-        try {
-            HttpUtil.Response response = HttpUtil.doPostToYunding(stockGetPostFromYundingUrl,jsonData,timestamp);
-
-            if(response.getStatusCode()!=200){
-                responseText = "yunding server error";
-                throw new RuntimeException(response.getResponseText());
-            }
-
-            responseText = response.getResponseText();
-
-            logger.info("responseText" + responseText);
-
-            Map<String,Object> responseMap = JacksonUtil.fromJson(response.getResponseText());
-
-            if(!"0".equals(String.valueOf(responseMap.get("code")))){
-                ediLogDao.save(LogUtil.getRequestFailLog(responseText));
-                return;
-            }
-
-            if(responseMap.get("data")==null){
-                return;
-            }
-
-            List<Map<String,Object>> datas = (List<Map<String,Object>>) responseMap.get("data");
-            if(datas.size()>0){
-                execPostProcedure(datas,responseText);
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-            logger.error("error",e);
-            ediLogDao.save(LogUtil.getPostFailLog(responseText,e.getMessage()));
-        }
-    }
-
-    public void execPostProcedure(List<Map<String,Object>> datas,String responseText){
-        String code = null;
-        String piClass = null;
-        EdiSuccessLog postSuccessHist = null;
-        for(Map<String,Object> data:datas){
-            code = String.valueOf(data.get("outer_no"));
-            piClass = String.valueOf(data.get("src_order_type"));
-            postSuccessHist = null;
-            try {
-                postSuccessHist = ediSuccessLogDao.findByCodeAndType(code,piClass);
-                if(postSuccessHist!=null){ //说明之前已经过账成功
-                    postConfirmToYunding(code,1);
-                }else{ //没有记录,说明没有过账成功
-                    String out = baseDao.callProcedure("SP_YUNDING_STOCKPOST",new Object[]{code,piClass});
-                    if (out!=null){
-                        ediLogDao.save(LogUtil.getPostFailLog(code,responseText,out));
-                    }else{
-                        ediLogDao.save(LogUtil.getPostSuccessLog(code,responseText));
-                        ediSuccessLogDao.save(LogUtil.getLogToAvoidRepeatPost(code,piClass));  //记录到edi_post_log,防止调用接口失败,下次重复过账
-                        postConfirmToYunding(code,1);
-                    }
-                }
-
-            }catch (Exception e){
-                e.printStackTrace();
-                logger.error("error",e);
-                ediLogDao.save(LogUtil.getPostFailLog(code,responseText,e.getMessage()));
-            }
-
-        }
-    }
-
-    @Override
-    public void postConfirmToYunding(String code,int type){
-        String timestamp = String.valueOf(System.currentTimeMillis()/1000);
-
-        Map<String,Object> postMapData = new HashMap<>();
-        postMapData.put("app_key", Constant.yundingAppKey);
-        postMapData.put("time_stamp",timestamp);
-        postMapData.put("type",type);
-        postMapData.put("outer_no",code);
-
-        String jsonData = JacksonUtil.toSortJson(postMapData);
-        try{
-            HttpUtil.Response response = HttpUtil.doPostToYunding(sendStockPostConfirmToYundingUrl,jsonData,timestamp);
-            logger.info("confirm response:" + response.getResponseText());
-        }catch (Exception e){
-            e.printStackTrace();
-            logger.error("error",e);
-        }
-    }
-
-    private Map<String,Object> getMainData(Integer id){
-        Map<String,Object> data = new HashMap<>();
-        SqlRowSet rs = baseDao.getJdbcTemplate().queryForRowSet("select pi_id,pi_class,pi_inoutno,pi_whcode,pi_purpose,pi_remark,wh_type,ve_add1,ve_contact,ve_tel,pi_transport from prodinout left join warehouse on pi_whcode=wh_code left join Vendor on pi_cardcode = ve_code where pi_id=" + id);
-        String piClass = null;
-        if(rs.next()){
-            piClass = rs.getString("pi_class");
-            data.put("outer_no",rs.getString("pi_inoutno"));
-            data.put("warehouse_no",getWarehouseCode(piClass,rs.getString("pi_whcode"),rs.getString("pi_purpose")));
-            data.put("out_warehouse_no",rs.getString("pi_whcode"));
-            data.put("remark",rs.getString("pi_remark"));
-            data.put("order_type",getOrderType(piClass));
-            data.put("src_order_type",piClass);
-            data.put("warehouse_type",getWhType(rs.getString("wh_type")));
-            data.put("rec_type",rs.getString("pi_transport"));
-            data.put("rec_address",rs.getString("ve_add1"));
-            data.put("rec_contacts",rs.getString("ve_contact"));
-            data.put("rec_phone",rs.getString("ve_tel"));
-            data.put("details_list",getDetailData(id));
-        }
-        return data;
-    }
-
-    private String getWarehouseCode(String piClass,String piWhCode,String piPurpose){
-        if("拨出单".equals(piClass)){
-            return piPurpose;
-        }
-        return piWhCode;
-    }
-
-    private List<Map<String,Object>> getDetailData(Integer id){
-        List<Map<String,Object>> datas = new LinkedList<>();
-        Map<String,Object> data = new HashMap<>();
-        SqlRowList rs = baseDao.queryForRowSet("select pd_piclass,pd_id,pd_ordercode,pd_orderdetno,pd_batchcode,pd_prodcode,pd_inqty,pd_outqty,pd_description,pd_whcode,pd_inwhcode from prodiodetail where pd_piid=" + id);
-        String piClass = null;
-        String whCode = null;
-        String pdinWhCode = null;
-        while (rs.next()){
-            data = new HashMap<>();
-            piClass = rs.getString("pd_piclass");
-            whCode = rs.getString("pd_whcode");
-            pdinWhCode = rs.getString("pd_inwhcode");
-            data.put("child_no",rs.getString("pd_id"));
-            data.put("purchase_no",rs.getString("pd_ordercode"));
-            data.put("purchase_detno",rs.getString("pd_orderdetno"));
-            data.put("batch_no",rs.getString("pd_batchcode"));
-            data.put("stockin_num",getQty(piClass,rs.getInt("pd_inqty"),rs.getInt("pd_outqty")));
-            data.put("spec_no",rs.getString("pd_prodcode"));
-            data.put("remark",rs.getString("pd_description"));
-            data.put("warehouse_no",getInWarehouseNo(piClass,whCode,pdinWhCode));
-            data.put("out_warehouse_no",getOutWarehouseNo(piClass,whCode));
-
-            datas.add(data);
-        }
-        return datas;
-    }
-
-    private String getInWarehouseNo(String piClass,String whcode,String pdinwhcode){
-        String code = whcode;
-        if("拨出单".equals(piClass)){
-            code = pdinwhcode;
-        }
-        return code;
-    }
-
-    private String getOutWarehouseNo(String piClass,String whcode){
-        String code = null;
-        if("拨出单".equals(piClass)){
-            code = whcode;
-        }
-        return code;
-    }
-
-    private int getQty(String piClass,int inQty,int outQty){
-        int correctQty = 0;
-        switch (piClass){
-            case "采购验收单":
-                correctQty = inQty;
-                break;
-            case "采购验退单":
-                correctQty = outQty;
-                break;
-            case "委外验收单":
-                correctQty = inQty;
-                break;
-            case "委外验退单":
-                correctQty = outQty;
-                break;
-            case "拨出单":
-                correctQty = outQty;
-                break;
-            case "其它出库单":
-                correctQty = outQty;
-                break;
-            case "其它入库单":
-                correctQty = inQty;
-                break;
-            case "借货出货单":
-                correctQty = outQty;
-                break;
-            case "借货归还单":
-                correctQty = inQty;
-                break;
-            default:break;
-        }
-        return correctQty;
-    }
-
-    private int getWhType(String whtype){
-        int whType = -1;
-        switch (whtype){
-            case "良品仓":
-                whType = 1;
-                break;
-            case "不良品仓":
-                whType = 2;
-                break;
-            case "暂收仓":
-                whType = 3;
-                break;
-            default:break;
-        }
-        return whType;
-    }
-
-    private int getOrderType(String piClass){
-        int orderType = -1;
-        switch (piClass){
-            case "采购验收单":
-                orderType = 0;
-                break;
-            case "委外验收单":
-                orderType = 0;
-                break;
-            case "其它入库单":
-                orderType = 0;
-                break;
-            case "借货归还单":
-                orderType = 0;
-                break;
-            case "拨出单":
-                orderType = 1;
-                break;
-            case "采购验退单":
-                orderType = 2;
-                break;
-            case "委外验退单":
-                orderType = 2;
-                break;
-            case "其它出库单":
-                orderType = 2;
-                break;
-            case "借货出货单":
-                orderType = 2;
-                break;
-            default:break;
-        }
-        return orderType;
-    }
-}

+ 0 - 277
src/main/java/com/uas/eis/serviceImpl/YundingServiceImpl.java

@@ -1,277 +0,0 @@
-package com.uas.eis.serviceImpl;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import com.alibaba.fastjson.JSON;
-import com.uas.eis.dao.BaseDao;
-import com.uas.eis.service.YundingService;
-import com.uas.eis.utils.BaseUtil;
-import com.uas.eis.utils.SqlUtil;
-
-
-
-@Service
-public  class YundingServiceImpl implements YundingService  {
-	@Autowired
-	private BaseDao baseDao;
-	
-	
-	/**
-	 * 出入库单审核接口
-	 * 
-	 * @param id
-	 * @param piclass
-	 *            单据主表id
-	 *            单据类型piclass
-	 *            
-	 */
-	@Override
-	public void  ProdInOutAuidted(int id,String piclass) {
-		Map<Object, Object> store = new HashMap<Object, Object>();	
-		//传入查询code、单据ID传回单据主从表信息Map
-		if (piclass=="采购验收单"||piclass=="委外验收单"){
-		//云顶插入采购/委外验收单接口
-		}
-		if (piclass=="采购验退单"||piclass=="委外验退单"){
-			//云顶插入采购/委外验退单接口	
-		}
-		if (piclass=="拨出单"){
-			//云顶插入拨出单接口	
-		}
-		if (piclass=="其他入库单"){
-			//云顶插入其他入库单接口	
-		}
-		if (piclass=="其他出库单"){
-			//云顶插入其他出库单接口	
-		}
-	}
-	
-	
-	/**
-	 * 出入库单云顶数据中心传UAS过账接口
-	 * 
-	 * @param Store
-	 *            单据编号,类型等Json数据 Store
-	 *            
-	 */
-	@Override
-	public void  ProdInOutPOST(String Store) {
-
-
-
-		com.alibaba.fastjson.JSONObject json = JSON.parseObject(Store);
-		String Code=json.getString("xxxxxx").toString();
-		String Piclass=json.getString("xxxxxx").toString();
-		String res=null;
-		baseDao.procedure("SP_GetCostPrice", new Object[] { Piclass, Code });
-		res = baseDao.callProcedure("Sp_SplitProdOut",
-				new Object[] { Piclass, Code, "ADMIN" });
-
-		if (res != null && !res.trim().equals("")) {
-			// 重新添加提示限制信息
-			BaseUtil.showError(res + "  " +Piclass + Code + ",过账失败");
-			// BaseUtil.showError(res);
-		}
-		res = baseDao.callProcedure("Sp_CommitProdInout",
-				new Object[] { Piclass, Code, "ADMIN"});
-		if (res != null && !res.trim().equals("")) {
-			BaseUtil.showError(res);
-		}
-			
-	}
-	
-	
-	
-	/**
-	 * 销售订单云顶数据中心传UAS并生成一张已过账销售出货单接口
-	 * 
-	 * @param Store
-	 *            销售订单主从表Json数据 Store
-	 *            
-	 */
-	@Override
-	public void  Salereceive(String Store) {
-		//销售订单插入
-		com.alibaba.fastjson.JSONObject json = JSON.parseObject(Store);
-		String jsons =json.toString();
-		List<Object[]> mappingList = baseDao.getFieldsDatasByCondition("xxx", new String[] { "TD_FROMFIELD", "TD_TOFIELD" }, "qu_id=1");
-		Map<String, String> resultmap = new HashMap<String, String>();
-		for(Object[] obj : mappingList){
-			resultmap.put(String.valueOf(obj[0]), String.valueOf(obj[1]));
-		}
-		Map<String, Object> njson=BaseUtil.jsonToMap(jsons, resultmap);
-		Map<Object, Object> store = (Map<Object, Object>) njson.get("stockout_list");
-		store.put("sa_status", "已审核");
-		store.put("sa_statuscode", "AUDITED");
-		int id= Integer.valueOf(String.valueOf(baseDao.getFieldDataByCondition("dual", "sale_seq.nextval", "1=1")));
-		store.put("sa_id", id);
-		List<Map<Object, Object>> grid = (List<Map<Object, Object>>) njson.get("details_list");
-		for (Map<Object, Object> map : grid) {
-			map.put("sd_said", id);	
-			map.put("sd_id", "saledetail_seq.nextval");
-			}
-		int count= Integer.valueOf(String.valueOf(baseDao.getFieldDataByCondition("Sale", "count(1)", "sa_code=" + store.get("order_no"))));
-		if (count >0) {
-			// 重新添加提示限制信息
-			BaseUtil.showError(store.get("order_no")  + "编号已存在");
-		}
-		// 保存sale
-		String formSql = SqlUtil.getInsertSqlByMap(store, "Sale");
-		baseDao.execute(formSql);
-		// 保存saleDetail
-		List<String> gridSql = SqlUtil.getInsertSqlbyList(grid, "SaleDetail", "sd_id");
-		baseDao.execute(gridSql);
-		//调用生成出货单方法
-		TurnProdIN(id);
-		//过账生成的出货单
-		String pi_inoutno= String.valueOf(baseDao.getFieldDataByCondition("ProdInOut", "pi_inoutno", "pi_sourcecoe="+store.get("order_no")));
-		String res=null;
-		baseDao.procedure("SP_GetCostPrice", new Object[] { "出货单", pi_inoutno });
-		res = baseDao.callProcedure("Sp_SplitProdOut",
-				new Object[] { "出货单", pi_inoutno, "ADMIN" });
-
-		if (res != null && !res.trim().equals("")) {
-			// 重新添加提示限制信息
-			BaseUtil.showError(res + "  出货单"  + pi_inoutno + ",过账失败");
-			// BaseUtil.showError(res);
-		}
-		res = baseDao.callProcedure("Sp_CommitProdInout",
-				new Object[] { "出货单", pi_inoutno, "ADMIN"});
-		if (res != null && !res.trim().equals("")) {
-			BaseUtil.showError(res);
-		}
-	}
-	
-	
-	
-	
-	
-	/**
-	 * 销售订单形成对应得出货单
-	 * 
-	 * @param id
-	 *            单据类型id
-	 *            
-	 */
-	@Override
-	public void  TurnProdIN(int id) {
-		String code=baseDao.callProcedure("Sp_GetMaxNumber", new Object[] { "ProdInOut!Sale", 2 });
-		int pi_id= Integer.valueOf(String.valueOf(baseDao.getFieldDataByCondition("dual", "ProdInOut_seq.nextval", "1=1")));
-		String contactSql = "insert into ProdInOut (pi_id,pi_inoutno,pi_recordman,pi_operatorcode,pi_recorddate,pi_invostatus,pi_invostatuscode,pi_class,pi_cardid,pi_cardcode,pi_title,pi_status,pi_statuscode,pi_updatedate,pi_updateman,pi_receivecode,pi_receivename,pi_arcode,pi_arname,pi_currency,pi_rate,pi_sellercode,pi_sellername,pi_address,pi_remark,pi_cusaddresssid,pi_paymentcode,pi_cop,pi_departmentcode,pi_departmentname,pi_transport,pi_payment,pi_printstatus,pi_printstatuscode,pi_chargeamount,pi_sourcecoe) "
-						+ "select"+pi_id+","+code+",'admin','ADMIN',sysdate,'在录入','ENTERING','出货单',sa_custid,sa_custcode,sa_custname,'未过账','UNPOST',sysdate,'admin',sa_shcustcode,sa_shcustname,sa_apcustcode,sa_apcustname,sa_currency,sa_rate,sa_sellercode,sa_seller,sa_toplace,sa_remark,sa_cusaddresssid,sa_paymentscode,sa_cop,sa_departmentcode,sa_departmentname,sa_transport,sa_payments,'未打印','UNPRINT',sa_fare,sa_code from sale where sa_id="+id;
-		baseDao.execute(contactSql);
-		contactSql = "insert into ProdIODetail  (pd_id,pd_piid,pd_orderdetno,pd_ordercode,pd_prodcode,pd_sendprice,pd_outqty,pd_beipinoutqty,pd_pocode,pd_piclass,pd_status,pd_auditstatus,pd_taxrate,pd_sdid,pd_remark,pd_custprodcode,pd_custprodspec,pd_discount,pd_inqty,pd_custproddetail,pd_purcprice,pd_commissionrate,pd_whcode,pd_whname) "
-				+ "select ProdIODetail_seq.nextval,"+pi_id+",sd_detno,sa_code,sd_prodcode,sd_price,sd_qty,sd_readyqty,sa_pocode,'出货单',0,'ENTERING',sd_taxrate,sd_id,sd_remark,sd_custprodcode,sd_prodcustcode,sd_discount,0,sd_custproddetail,sd_purcprice,sd_commissionrate,sd_whcode,sd_whcode from saledetail left join sale on sd_said=sa_id where sa_id="+id;
-		baseDao.execute(contactSql);
-		baseDao.execute("update Prodinout set (pi_whcode,pi_whname)=(select pd_whcode,pd_whname from ProdIODetail where pd_piid="
-				+ pi_id + " and pd_pdno=1) where pi_id=" + pi_id + "");
-		
-		baseDao.execute(
-				"update ProdInOut set pi_address=(select cu_add1 from customer where pi_cardcode=cu_code) where pi_id=? and nvl(pi_address,' ')=' '",
-				pi_id);
-		baseDao.execute("update prodinout set pi_purposename=((select max(ca_person) from CustomerAddress left join customer on ca_cuid=cu_id where cu_code=pi_cardcode and ca_address=pi_address))  where pi_purposename is null  and  pi_id="
-				+ pi_id);
-		baseDao.execute("update prodinout set pi_expresscode=((select max(ca_phone) from CustomerAddress left join customer on ca_cuid=cu_id where cu_code=pi_cardcode and ca_address=pi_address))  where pi_expresscode is null  and  pi_id="
-				+ pi_id);
-		baseDao.execute("update prodinout set pi_fax=((select max(ca_fax) from CustomerAddress left join customer on ca_cuid=cu_id where cu_code=pi_cardcode and ca_address=pi_address))  where pi_fax is null  and  pi_id="
-				+ pi_id);
-		baseDao.execute(
-				"update ProdIODetail set pd_netprice=ROUND(pd_sendprice/(1 + pd_taxrate/ 100),6), pd_taxtotal=round(pd_sendprice*pd_outqty/(1+pd_taxrate/100),2), pd_ordertotal=round(pd_outqty*pd_sendprice,2) where pd_piid=?",
-				pi_id);
-		baseDao.execute(
-				"update saleDetail set sdyqty=sd_qty where sd_said=?",
-				id);
-	}
-	
-	
-	
-	
-	
-	
-	/**
-	 * 销售退货单云顶数据中心传UAS并过账接口
-	 * 
-	 * @param Store
-	 *            销售退货单主从表Json数据 Store
-	 *            
-	 */
-	@Override
-	public void  SaleReturn(String Store) {
-		//销售退货单插入
-		com.alibaba.fastjson.JSONObject json = JSON.parseObject(Store);
-		String jsons =json.toString();
-		List<Object[]> mappingList = baseDao.getFieldsDatasByCondition("xxx", new String[] { "TD_FROMFIELD", "TD_TOFIELD" }, "qu_id=1");
-		Map<String, String> resultmap = new HashMap<String, String>();
-		for(Object[] obj : mappingList){
-			resultmap.put(String.valueOf(obj[0]), String.valueOf(obj[1]));
-		}
-		Map<String, Object> njson=BaseUtil.jsonToMap(jsons, resultmap);
-		Map<Object, Object> store = (Map<Object, Object>) njson.get("date");
-		store.put("pi_invostatus", "已审核");
-		store.put("pi_invostatuscode", "AUDITED");
-		int id= Integer.valueOf(String.valueOf(baseDao.getFieldDataByCondition("dual", "ProdInOut_seq.nextval", "1=1")));
-		store.put("pi_id", id);
-		List<Map<Object, Object>> grid = (List<Map<Object, Object>>) njson.get("refund_orders_list");
-		for (Map<Object, Object> map : grid) {
-			map.put("pd_piid", id);	
-			map.put("pd_id", "ProdIODetail_seq.nextval");
-			}
-		int count= Integer.valueOf(String.valueOf(baseDao.getFieldDataByCondition("ProdInOut", "count(1)", "pi_inoutno=" + store.get("refund_no")+"and pi_class='销售退货单'")));
-		if (count >0) {
-			// 重新添加提示限制信息
-			BaseUtil.showError(store.get("refund_no")  + "编号已存在");
-		}
-		// 保存ProdInOut
-		String formSql = SqlUtil.getInsertSqlByMap(store, "ProdInOut");
-		baseDao.execute(formSql);
-		// 保存ProdIODetail
-		List<String> gridSql = SqlUtil.getInsertSqlbyList(grid, "ProdIODetail", "pd_id");
-		baseDao.execute(gridSql);
-		//过账生成的退货单
-		String res=null;
-		baseDao.procedure("SP_GetCostPrice", new Object[] { "出货单", store.get("refund_no") });
-		res = baseDao.callProcedure("Sp_SplitProdOut",
-				new Object[] { "销售退货单", store.get("refund_no"), "ADMIN" });
-
-		if (res != null && !res.trim().equals("")) {
-			// 重新添加提示限制信息
-			BaseUtil.showError(res + "  销售退货单"  + store.get("refund_no") + ",过账失败");
-			// BaseUtil.showError(res);
-		}
-		res = baseDao.callProcedure("Sp_CommitProdInout",
-				new Object[] { "销售退货单", store.get("refund_no"), "ADMIN"});
-		if (res != null && !res.trim().equals("")) {
-			BaseUtil.showError(res);
-		}
-	}
-	
-	
-	/**
-	 * 退货单云顶数据中心传UAS反过账接口
-	 * 
-	 * @param Store
-	 *            单据编号,类型等Json数据 Store
-	 *            
-	 */
-	@Override
-	public void  SaleReturnDelete(String Store) {
-		com.alibaba.fastjson.JSONObject json = JSON.parseObject(Store);
-		String Code=json.getString("refund_no").toString();
-		String Piclass="销售退货单";
-		int piid= Integer.valueOf(String.valueOf(baseDao.getFieldDataByCondition("ProdInOut", "pi_id", "pi_inoutno=" + Code+"and pi_class="+Piclass)));
-		String res=null;
-		res= baseDao.callProcedure("Sp_UnCommitProdInout", Piclass,Code);
-		if (res != null && !res.trim().equals("")) {
-			BaseUtil.showError(res);
-		}
-		baseDao.updateByCondition("ProdInOut", "pi_statuscode='UNPOST',pi_status='未过账',pi_inoutman=null,pi_date1=null", "pi_id=" + piid);
-		//删除反过账销售退货单
-		baseDao.deleteByCondition("ProdIODetail", "pd_piid="+piid);
-		baseDao.deleteByCondition("ProdInOut", "pi_id="+piid);
-		}	
-}

+ 7 - 4
src/main/java/com/uas/eis/task/DataDealTask.java

@@ -3,7 +3,6 @@ package com.uas.eis.task;
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.entity.DataChip;
 import com.uas.eis.entity.DataChip;
 import com.uas.eis.service.DataDealService;
 import com.uas.eis.service.DataDealService;
-import com.uas.eis.service.SaleReturnService;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,10 +27,13 @@ public class DataDealTask {
     @Autowired
     @Autowired
     DataDealService dataDealService;
     DataDealService dataDealService;
 
 
-    @Scheduled(cron = "0 0/5 * * * ?")
+    public void testAnalyse(){
+        logger.info("testFile----");
+    }
+
     public void dataDeal() {
     public void dataDeal() {
-        List<DataChip> dataChips = baseDao.getJdbcTemplate().query("select id_,chipcode_,counterpath_,datapath_,testdate_ from (select id_,chipcode_,counterpath_,datapath_,testdate_ from datacenter$chip where  nvl(readstatus_,0)=0 and testdate_ is  not null order by testdate_  desc) where rownum<=50",
-                new BeanPropertyRowMapper<DataChip>(DataChip.class));
+        List<DataChip> dataChips = baseDao.getJdbcTemplate().query("select id_,chipcode_,counterpath_,datapath_,testdate_ from (select id_,chipcode_,counterpath_,datapath_,testdate_ from datacenter$chip where  nvl(readstatus_,0)=0 and testdate_ is  not null order by testdate_ asc ) where rownum<=50",
+                new BeanPropertyRowMapper<>(DataChip.class));
         logger.info("Data文件解析执行开始:文件数"+dataChips.size());
         logger.info("Data文件解析执行开始:文件数"+dataChips.size());
         Date date = new Date();
         Date date = new Date();
         if(dataChips.size()>0){
         if(dataChips.size()>0){
@@ -47,6 +49,7 @@ public class DataDealTask {
                 e.printStackTrace();
                 e.printStackTrace();
             }
             }
         }
         }
+        baseDao.execute("INSERT INTO DATACENTER$TASKLOG(NAME_,DURATION_) VALUES ('Data文件解析',"+(new Date().getTime()-date.getTime())/1000+")");
         logger.info("Data文件解析执行结束:用时"+((new Date().getTime()-date.getTime())/1000));
         logger.info("Data文件解析执行结束:用时"+((new Date().getTime()-date.getTime())/1000));
     }
     }
 
 

+ 58 - 0
src/main/java/com/uas/eis/task/EDCBakTask.java

@@ -0,0 +1,58 @@
+package com.uas.eis.task;
+
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.entity.DataChip;
+import com.uas.eis.entity.EquipConfig;
+import com.uas.eis.service.EDCBakService;
+import com.uas.eis.utils.CollectionUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * @Author: zhouy
+ * @Date: 2020/5/27 14:30
+ */
+@Component("eDCBakTask")
+public class EDCBakTask {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Autowired
+    private BaseDao baseDao;
+    @Autowired
+    private EDCBakService edcBakService;
+
+    public void testFile(){
+        logger.info("testFile----");
+    }
+    public void edcBak() {
+        logger.info("文件归档开始");
+        Date date = new Date();
+        baseDao.callProcedure("DATACENTER_SYNC",new Object[]{""});
+        //所有设备
+        List<EquipConfig> EquipConfigs = baseDao.getJdbcTemplate().query("select ec_ip,ec_counterpath,ec_datapath,ec_counterbak,ec_databak,ed_devcode,ed_teststep from EQUIPCONFIGDETAIL LEFT JOIN EQUIPCONFIG ON ED_ECID=EC_ID where ec_databak is not null order by ec_ip",
+                new BeanPropertyRowMapper<EquipConfig>(EquipConfig.class));
+        Map<String,List<EquipConfig>> ecMap = CollectionUtil.groupBy(EquipConfigs,EquipConfig::getEc_ip);
+        final CountDownLatch countDownLatch = new CountDownLatch(ecMap.size());
+        try {
+            for(String key : ecMap.keySet()){
+                edcBakService.EDCBak(ecMap.get(key),countDownLatch);
+            }
+            countDownLatch.await();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        baseDao.execute("INSERT INTO DATACENTER$TASKLOG(NAME_,DURATION_) VALUES ('文件归档',"+(new Date().getTime()-date.getTime())/1000+")");
+        logger.info("文件归档结束:用时"+((new Date().getTime()-date.getTime())/1000));
+    }
+}

+ 82 - 0
src/main/java/com/uas/eis/task/ScheduleTask.java

@@ -0,0 +1,82 @@
+package com.uas.eis.task;
+
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.entity.DataChip;
+import com.uas.eis.entity.EquipConfig;
+import com.uas.eis.service.DataDealService;
+import com.uas.eis.service.EDCBakService;
+import com.uas.eis.utils.CollectionUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.stream.Collectors;
+
+/**
+ * @Author: zhouy
+ * @Date: 2020/5/28 11:22
+ */
+@Component("scheduleTask")
+public class ScheduleTask {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    @Autowired
+    private BaseDao baseDao;
+    @Autowired
+    private EDCBakService edcBakService;
+    @Autowired
+    private DataDealService dataDealService;
+    /**
+     * Data文件解析
+     * */
+    public void dataDeal() {
+        List<DataChip> dataChips = baseDao.getJdbcTemplate().query("select id_,chipcode_,counterpath_,datapath_,testdate_ from (select id_,chipcode_,counterpath_,datapath_,testdate_ from datacenter$chip where  nvl(readstatus_,0)=0 and testdate_ is  not null order by testdate_  asc) where rownum<=50",
+                new BeanPropertyRowMapper<DataChip>(DataChip.class));
+        logger.info("Data文件解析执行开始:文件数"+dataChips.size());
+        Date date = new Date();
+        if(dataChips.size()>0){
+            List<Integer> IDS = dataChips.stream().map(DataChip::getId_).collect(Collectors.toList());
+            final CountDownLatch countDownLatch = new CountDownLatch(IDS.size());
+            baseDao.execute("UPDATE DATACENTER$CHIP SET READSTATUS_=-90 WHERE ID_ IN ("+String.join(",", IDS.stream().map(String::valueOf).collect(Collectors.toList()))+")");
+            try {
+                dataChips.stream().forEach(dataChip -> {
+                    dataDealService.EDCDataDeal(dataChip,countDownLatch);
+                });
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        logger.info("Data文件解析执行结束:用时"+((new Date().getTime()-date.getTime())/1000));
+    }
+
+    /**
+     * 文件归档
+     * */
+    public void edcBak() {
+        logger.info("文件归档开始");
+        Date date = new Date();
+        baseDao.callProcedure("DATACENTER_SYNC",new Object[]{""});
+        //所有设备
+        List<EquipConfig> EquipConfigs = baseDao.getJdbcTemplate().query("select ec_ip,ec_counterpath,ec_datapath,ec_counterbak,ec_databak,ed_devcode,ed_teststep from EQUIPCONFIGDETAIL LEFT JOIN EQUIPCONFIG ON ED_ECID=EC_ID where ec_databak is not null order by ec_ip",
+                new BeanPropertyRowMapper<EquipConfig>(EquipConfig.class));
+        Map<String,List<EquipConfig>> ecMap = CollectionUtil.groupBy(EquipConfigs,EquipConfig::getEc_ip);
+        final CountDownLatch countDownLatch = new CountDownLatch(ecMap.size());
+        try {
+            for(String key : ecMap.keySet()){
+                edcBakService.EDCBak(ecMap.get(key),countDownLatch);
+            }
+            countDownLatch.await();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        logger.info("文件归档结束:用时"+((new Date().getTime()-date.getTime())/1000));
+    }
+
+}

+ 18 - 9
src/main/java/com/uas/eis/utils/CollectionUtil.java

@@ -2,15 +2,8 @@ package com.uas.eis.utils;
 
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
+import java.util.function.Function;
 
 
 import net.sf.json.JSONArray;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import net.sf.json.JSONObject;
@@ -332,4 +325,20 @@ public class CollectionUtil {
 		Collections.reverse(lists);
 		Collections.reverse(lists);
 		return lists;
 		return lists;
 	}
 	}
+	public static <K, V> Map<K, List<V>> groupBy(List<V> sources, Function<V, K> keyGetter) {
+		Map<K, List<V>> map = new LinkedHashMap<>(1);
+		if (!isEmpty(sources)) {
+			sources.forEach(source -> {
+				K key = keyGetter.apply(source);
+				if (map.containsKey(key)) {
+					map.get(key).add(source);
+				} else {
+					List<V> childList = new ArrayList<>();
+					childList.add(source);
+					map.put(key, childList);
+				}
+			});
+		}
+		return map;
+	}
 }
 }

+ 4 - 0
src/main/java/com/uas/eis/utils/Constant.java

@@ -18,8 +18,12 @@ public class Constant {
 
 
 	public final static String YMD_HM = "yyyy-MM-dd HH:mm";
 	public final static String YMD_HM = "yyyy-MM-dd HH:mm";
 
 
+	public final static String YMDHM = "yyyy-MM-dd-HH-mm";
+
 	public final static String YMD_HMS = "yyyy-MM-dd HH:mm:ss";
 	public final static String YMD_HMS = "yyyy-MM-dd HH:mm:ss";
 
 
+
+
 	public final static String ORACLE_YMD = "yyyy-MM-dd";
 	public final static String ORACLE_YMD = "yyyy-MM-dd";
 
 
 	public final static String ORACLE_YMD_HMS = "yyyy-MM-dd HH24:mi:ss";
 	public final static String ORACLE_YMD_HMS = "yyyy-MM-dd HH24:mi:ss";

+ 2 - 0
src/main/java/com/uas/eis/utils/ContextUtil.java

@@ -19,6 +19,7 @@ public class ContextUtil {
 				try {
 				try {
 					ContextUtil.class.wait(6000);
 					ContextUtil.class.wait(6000);
 				} catch (InterruptedException ex) {
 				} catch (InterruptedException ex) {
+					ex.printStackTrace();
 				}
 				}
 			}
 			}
 			return applicationContext;
 			return applicationContext;
@@ -35,6 +36,7 @@ public class ContextUtil {
 		try {
 		try {
 			return getApplicationContext().getBean(name);
 			return getApplicationContext().getBean(name);
 		} catch (Exception e) {
 		} catch (Exception e) {
+			e.printStackTrace();
 			return null;
 			return null;
 		}
 		}
 		
 		

+ 56 - 0
src/main/resources/application-analyse.yml

@@ -0,0 +1,56 @@
+spring:
+    datasource:
+        type: com.alibaba.druid.pool.DruidDataSource
+        driverClassName: oracle.jdbc.OracleDriver
+        username: SZSI_P
+        password: select!#%*(
+        url: jdbc:oracle:thin:@172.16.0.22:1521:orcl
+        initialSize: 10
+        maxActive: 80
+        minIdle: 10
+        maxWait: 60000
+        testOnBorrow: true
+        testOnReturn: false
+        testWhileIdle: true
+        validationQuery: SELECT 1 FROM DUAL
+        timeBetweenEvictionRunsMillis: 60000
+        minEvictableIdleTimeMillis: 300000
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 80
+        filters: stat
+        removeAbandoned: true
+        removeAbandonedTimeout: 1800
+    http:
+        encoding:
+            force: true
+            charset: UTF-8
+            enabled: true
+    message:
+        encoding: UTF-8
+    jpa:
+      show-sql: false
+      hibernate:
+        ddl-auto: update
+      database: oracle
+
+server:
+    tomcat:
+        uri_encoding: UTF-8
+    port: 8009
+    context-path: /EIS
+action:
+    api_action: /EIS/api
+    public_actions: /EIS/logout,/EIS/hello1
+logging:
+  level:
+    org:
+      hibernate:
+        type: trace
+  config: classpath:log/logback-analyse.xml
+
+SECURITY_KEY: 435aMe9L5itTrckY35kfcOQvPkBGZtGo
+KEEP: 86400000
+Task:
+  Method: dataDeal
+  Cron: 5 0/10 * * * ?
+

+ 54 - 0
src/main/resources/application-file.yml

@@ -0,0 +1,54 @@
+spring:
+    datasource:
+        type: com.alibaba.druid.pool.DruidDataSource
+        driverClassName: oracle.jdbc.OracleDriver
+        username: SZSI_P
+        password: select!#%*(
+        url: jdbc:oracle:thin:@172.16.0.22:1521:orcl
+        initialSize: 10
+        maxActive: 80
+        minIdle: 10
+        maxWait: 60000
+        testOnBorrow: true
+        testOnReturn: false
+        testWhileIdle: true
+        validationQuery: SELECT 1 FROM DUAL
+        timeBetweenEvictionRunsMillis: 60000
+        minEvictableIdleTimeMillis: 300000
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 80
+        filters: stat
+        removeAbandoned: true
+        removeAbandonedTimeout: 1800
+    http:
+        encoding:
+            force: true
+            charset: UTF-8
+            enabled: true
+    message:
+        encoding: UTF-8
+    jpa:
+      show-sql: false
+      hibernate:
+        ddl-auto: update
+      database: oracle
+
+server:
+    tomcat:
+        uri_encoding: UTF-8
+    port: 8008
+    context-path: /EIS
+action:
+    api_action: /EIS/api
+    public_actions: /EIS/logout,/EIS/hello1
+logging:
+  level:
+    org:
+      hibernate:
+        type: trace
+  config: classpath:log/logback-file.xml
+Task:
+    Method: edcBak
+    Cron: 0 0/5 * * * ?
+
+

+ 4 - 0
src/main/resources/application.yml

@@ -1,4 +1,6 @@
 spring:
 spring:
+    profiles:
+        active: dev
     datasource:
     datasource:
         type: com.alibaba.druid.pool.DruidDataSource
         type: com.alibaba.druid.pool.DruidDataSource
         driverClassName: oracle.jdbc.OracleDriver
         driverClassName: oracle.jdbc.OracleDriver
@@ -49,3 +51,5 @@ logging:
 
 
 SECURITY_KEY: 435aMe9L5itTrckY35kfcOQvPkBGZtGo
 SECURITY_KEY: 435aMe9L5itTrckY35kfcOQvPkBGZtGo
 KEEP: 86400000
 KEEP: 86400000
+
+

+ 44 - 0
src/main/resources/log/logback-analyse.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+	<appender name="FILE"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<File>logs/analyse/log.log</File>
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+			<!-- daily rollover -->
+			<FileNamePattern>logs/analyse/log.%d{yyyy-MM-dd}.log</FileNamePattern>
+			<!-- keep 10 days' worth of history -->
+			<maxHistory>10</maxHistory>
+		</rollingPolicy>
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Console output -->
+	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+		<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<!-- Only log level WARN and above -->
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Enable FILE and STDOUT appenders for all log messages. By default, 
+		only log at level INFO and above. -->
+	<root level="INFO">
+		<appender-ref ref="FILE" />
+		<appender-ref ref="STDOUT" />
+	</root>
+</configuration>

+ 44 - 0
src/main/resources/log/logback-file.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+	<appender name="FILE"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<File>logs/file/log.log</File>
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+			<!-- daily rollover -->
+			<FileNamePattern>logs/file/log.%d{yyyy-MM-dd}.log</FileNamePattern>
+			<!-- keep 10 days' worth of history -->
+			<maxHistory>10</maxHistory>
+		</rollingPolicy>
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Console output -->
+	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+		<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<!-- Only log level WARN and above -->
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Enable FILE and STDOUT appenders for all log messages. By default, 
+		only log at level INFO and above. -->
+	<root level="INFO">
+		<appender-ref ref="FILE" />
+		<appender-ref ref="STDOUT" />
+	</root>
+</configuration>

+ 31 - 5
src/test/java/com/uas/eis/UasEisApplicationTests.java

@@ -2,9 +2,10 @@ package com.uas.eis;
 
 
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.entity.DataChip;
 import com.uas.eis.entity.DataChip;
+import com.uas.eis.entity.EquipConfig;
 import com.uas.eis.service.DataDealService;
 import com.uas.eis.service.DataDealService;
-import com.uas.eis.service.SaleReturnService;
-import com.uas.eis.service.SaleService;
+import com.uas.eis.service.EDCBakService;
+import com.uas.eis.utils.CollectionUtil;
 import org.junit.Test;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
@@ -12,12 +13,11 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
-import org.springframework.jdbc.support.rowset.SqlRowSet;
 import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.context.junit4.SpringRunner;
 
 
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CountDownLatch;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -28,9 +28,12 @@ public class UasEisApplicationTests {
 
 
 	@Autowired
 	@Autowired
 	private DataDealService dataDealService;
 	private DataDealService dataDealService;
+	@Autowired
+	private EDCBakService edcBakService;
+
 	@Autowired
 	@Autowired
 	private BaseDao baseDao;
 	private BaseDao baseDao;
-	@Test
+	//@Test
 	public void contextLoads() {
 	public void contextLoads() {
 		Date date = new Date();
 		Date date = new Date();
 		List<DataChip> dataChips = baseDao.getJdbcTemplate().query("select id_,chipcode_,counterpath_,datapath_,testdate_ from (select id_,chipcode_,counterpath_,datapath_,testdate_ from datacenter$chip where chipcode_='F20025075#04' and  nvl(readstatus_,0)=0 and testdate_ is  not null order by testdate_  desc) where rownum<=50",
 		List<DataChip> dataChips = baseDao.getJdbcTemplate().query("select id_,chipcode_,counterpath_,datapath_,testdate_ from (select id_,chipcode_,counterpath_,datapath_,testdate_ from datacenter$chip where chipcode_='F20025075#04' and  nvl(readstatus_,0)=0 and testdate_ is  not null order by testdate_  desc) where rownum<=50",
@@ -50,6 +53,29 @@ public class UasEisApplicationTests {
 		}
 		}
 		logger.info("Data文件解析执行结束:用时"+((new Date().getTime()-date.getTime())/1000));
 		logger.info("Data文件解析执行结束:用时"+((new Date().getTime()-date.getTime())/1000));
 	}
 	}
+	//@Test
+	public void EDCBak(){
+		logger.info("文件归档开始");
+		Date date = new Date();
+		baseDao.callProcedure("DATACENTER_SYNC",new Object[]{""});
+		//所有设备
+		List<EquipConfig> EquipConfigs = baseDao.getJdbcTemplate().query("select ec_ip,ec_counterpath,ec_datapath,ec_counterbak,ec_databak,ed_devcode,ed_teststep from EQUIPCONFIGDETAIL LEFT JOIN EQUIPCONFIG ON ED_ECID=EC_ID where ec_databak is not null and ec_ip='172.24.3.155' order by ec_ip",
+				new BeanPropertyRowMapper<EquipConfig>(EquipConfig.class));
+		Map<String,List<EquipConfig>> ecMap = CollectionUtil.groupBy(EquipConfigs,EquipConfig::getEc_ip);
+		final CountDownLatch countDownLatch = new CountDownLatch(EquipConfigs.size());
+		try {
+			for(String key : ecMap.keySet()){
+				edcBakService.EDCBak(ecMap.get(key),countDownLatch);
+			}
+			countDownLatch.await();
+		}catch (Exception e){
+			e.printStackTrace();
+		}
+		logger.info("文件归档结束:用时"+((new Date().getTime()-date.getTime())/1000));
+	}
+	@Test
+	public void test(){
 
 
+	}
 
 
 }
 }