浏览代码

2021-08-13 lrl

lirl 3 年之前
父节点
当前提交
ddb8ae5b37

+ 9 - 1
src/main/java/com/steerinfo/ems/Utils/DateUtils.java

@@ -23,6 +23,14 @@ public class DateUtils {
         return str;
     }
 
+    public static String dateStr(Date date) {
+        if (date == null) {
+            return "";
+        }
+        String str = new SimpleDateFormat("yyyy-mm-dd").format(date);
+        return str;
+    }
+
     /**
      * 时间戳转标准时间
      *
@@ -164,7 +172,7 @@ public class DateUtils {
     public static Date getCurrentTimetoDate(String timeformat) {
         try {
             Date date = new java.sql.Date(new Date().getTime());
-            String datestr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
+            String datestr = new SimpleDateFormat("yyyy-mm-dd").format(date);
             Date time = new SimpleDateFormat(timeformat).parse(datestr);
             return time;
         }

+ 1 - 1
src/main/java/com/steerinfo/ems/formula/service/impl/FormulaServiceImpl.java

@@ -761,7 +761,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<Formula, String> impleme
 							        		items.add(tm.getItemid());
 							        	}
 							        }
-								}else if(code.endsWith("P")){ // 计划影响能源计划单耗
+								} else if(code.endsWith("P")){ // 计划影响能源计划单耗
 									HashMap<String, Object> maps = new HashMap<>();
 							        maps.put("useflag", "1");
 							        maps.put("workprocid", twp.getWorkprocid());

+ 3 - 2
src/main/java/com/steerinfo/ems/ifmesemsswapfile/service/IIfMesEmsSwapfileService.java

@@ -1,14 +1,13 @@
 package com.steerinfo.ems.ifmesemsswapfile.service;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Set;
 
 import com.steerinfo.ems.ifmesemsswapfile.model.IfMesEmsSwapfile;
 import com.steerinfo.framework.service.IBaseService;
-import com.steerinfo.framework.service.pagehelper.PageList;
 
 
 public interface IIfMesEmsSwapfileService extends IBaseService<IfMesEmsSwapfile, String>{
@@ -50,4 +49,6 @@ public interface IIfMesEmsSwapfileService extends IBaseService<IfMesEmsSwapfile,
 	 */
 	public  void  getLgDateProd();
 
+	public  void  getLgDateProd2 () throws ParseException;
+
 }

+ 49 - 11
src/main/java/com/steerinfo/ems/ifmesemsswapfile/service/impl/IfMesEmsSwapfileServiceImpl.java

@@ -13,10 +13,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -65,7 +64,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
 						// 原数据
 						String fid = jo.getString("fid");
 						IfMesEmsSwapfile ime = ifmesemsswapfilemapper.selectByPrimaryKey(fid);
-						if(ime!=null){
+						if(ime != null){
 							ifmesemsswapfilemapper.updateByPrimaryKey(model);
 							updateSize +=1;
 							logger.info("修改数据:" + jo.toJSONString());
@@ -80,7 +79,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
 						}
 						HttpRequestMes.httpRequestMes(url, "post", "[{\"id\":\"" + jo.getString("fid") + "\",\"status\":\"1\"}]");
 					}
-					logger.info("结束一次投入产出数据同步。");
+					     logger.info("结束一次投入产出数据同步。");
 				} else {
 					break;
 				}
@@ -129,7 +128,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
 					model.setMaterialcode(jo3.getString("materialcode"));
 					model.setMaterialname(jo3.getString("materialname"));
 					model.setOrderno(jo3.getString("orderno"));
-					model.setProdate(jo3.getString("prodate")!=null?jo3.getString("prodate").substring(0, 19):"");
+					model.setProdate(jo3.getString("prodate") != null ? jo3.getString("prodate").substring(0, 19):"");
 					model.setProdline(jo3.getString("prodline"));
 					model.setQty(jo3.getBigDecimal("qty"));
 					model.setSendtime(jo3.getString("sendtime")!=null?jo3.getString("sendtime").substring(0, 19):"");
@@ -150,18 +149,57 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
 		List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightByTime();
 		for (LgWeight lgWeight : lgWeights) {
 			IfMesEmsSwapfile model = new IfMesEmsSwapfile();
-			model.setType("2");
+			model.setType(lgWeight.getType());
 			model.setWorks("1036LG1");
 			model.setProdline("1036LG1");
+			model.setMaterialcode(lgWeight.getMaterialcode());
 			model.setProdate(lgWeight.getDate());
-			model.setMaterialname(lgWeight.getType());
-			model.setUnit("吨");
+			model.setMaterialname(lgWeight.getMaterialname());
+			model.setUnit(lgWeight.getUnit());
 			model.setQty(lgWeight.getWeight());
 			model.setCreatetime(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
 			model.setStatus("0");
-			model.setFid(DateUtils.dateStr(new Date(),"yyyyMMddHHmmss"));
-			ifmesemsswapfilemapper.insert(model);
+			model.setFid(lgWeight.getFid());
+			IfMesEmsSwapfile ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(lgWeight.getFid());
+			if (ifMesEmsSwapfile != null ) {
+				ifmesemsswapfilemapper.updateByPrimaryKey(model);
+			}else {
+				ifmesemsswapfilemapper.insert(model);
+			}
+		}
+		System.out.println("接收成功...");
+	}
+
+	//获取炼钢的投入数据
+	public  void  getLgDateProd2() throws ParseException {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		Date dt = sdf.parse(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
+		Calendar rightNow = Calendar.getInstance();
+		rightNow.setTime(dt);
+		rightNow.add(Calendar.DAY_OF_MONTH, -2);
+		Date dt1 = rightNow.getTime();
+		String reStr = sdf.format(dt1);
+		List<LgWeight> lgWeights = lgWeightFeigenService.QueryWeightByTime2(reStr, DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
+		for (LgWeight lgWeight : lgWeights) {
+			IfMesEmsSwapfile model = new IfMesEmsSwapfile();
+			model.setType(lgWeight.getType());
+			model.setWorks("1036LG1");
+			model.setMaterialcode(lgWeight.getMaterialcode());
+			model.setProdate(lgWeight.getDate());
+			model.setMaterialname(lgWeight.getMaterialname());
+			model.setUnit(lgWeight.getUnit());
+			model.setQty(lgWeight.getWeight());
+			model.setCreatetime(DateUtils.dateStr(new Date(),"yyyy-MM-dd"));
+			model.setStatus("0");
+			model.setFid(lgWeight.getFid());
+			IfMesEmsSwapfile ifMesEmsSwapfile = ifmesemsswapfilemapper.selectByPrimaryKey(lgWeight.getFid());
+			if (ifMesEmsSwapfile != null ) {
+				ifmesemsswapfilemapper.updateByPrimaryKey(model);
+			}else {
+				ifmesemsswapfilemapper.insert(model);
+			}
 		}
 		System.out.println("接收成功...");
 	}
 }
+

+ 1 - 1
src/main/java/com/steerinfo/ems/tcm0318/mapper/TCm0318Mapper.xml

@@ -92,7 +92,7 @@
         and SYSTEMNAME = #{systemname, jdbcType=VARCHAR}
       </if>
       <if test="datasource != null and datasource != ''">
-        DATASOURCE = #{datasource,jdbcType=VARCHAR}
+        and DATASOURCE = #{datasource,jdbcType=VARCHAR}
       </if>
       <if test="timegranid != null and timegranid != ''">
         and TIMEGRANID = #{timegranid, jdbcType=VARCHAR}

+ 9 - 9
src/main/java/com/steerinfo/ems/tcm0325/controller/TCm0325Controller.java

@@ -1,5 +1,7 @@
 package com.steerinfo.ems.tcm0325.controller;
 
+import com.steerinfo.auth.utils.JwtUtil;
+import com.steerinfo.ems.tcm0310.model.TCm0310;
 import com.steerinfo.ems.tcm0325.model.TCm0325;
 import com.steerinfo.ems.tcm0325.service.ITCm0325Service;
 import com.steerinfo.framework.controller.BaseRESTfulController;
@@ -56,16 +58,14 @@ public class TCm0325Controller extends BaseRESTfulController {
     //@RequiresPermissions("trmunit:create")
     @PostMapping(value = "/")
     public RESTfulResult add(@ModelAttribute TCm0325 model){
-        if(tCm0325Service.getById(model.getPowercode()) != null){
-            return failed(null, "id已存在,不能新增");
-        }
-        else{
-        	if(model.getSort()==null){
-        		model.setSort(tCm0325Service.getMaxSort()==null? 1 : tCm0325Service.getMaxSort() + 1);
-        	}
+            if (null == model.getPowercode() || "".equals(model.getPowercode())) {
+                Long maxid = tCm0325Service.getMaxId() == null ? 1 : Long.parseLong(tCm0325Service.getMaxId()) + 1;
+                model.setPowercode("P" + String.format("%05d", maxid));
+            }
+            model.setSort(tCm0325Service.getMaxSort()==null? 1 : tCm0325Service.getMaxSort() + 1);
+            model.setPowername(model.getPowername());
             TCm0325 tCm0325 = tCm0325Service.add(model);
-            return success(tCm0325);
-        }
+        	 return success(tCm0325);
     }
 
     @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")

+ 1 - 0
src/main/java/com/steerinfo/ems/tcm0325/mapper/TCm0325Mapper.java

@@ -12,4 +12,5 @@ public interface TCm0325Mapper extends IBaseMapper<TCm0325, String> {
     Set<TCm0325> getCodeAndName();
     TCm0325 getusestate(Map<String, Object> parameters);
     Long getMaxSort();
+    String getMaxId();
 }

+ 3 - 0
src/main/java/com/steerinfo/ems/tcm0325/mapper/TCm0325Mapper.xml

@@ -161,4 +161,7 @@
   <select id="getMaxSort" resultType="java.lang.Long">
     select MAX(SORT) from T_CM_0325
   </select>
+  <select id="getMaxId" resultType="java.lang.String">
+    SELECT MAX(SUBSTR(POWERCODE, LENGTH(POWERCODE) - 4)) from T_CM_0325
+  </select>
 </mapper>

+ 1 - 0
src/main/java/com/steerinfo/ems/tcm0325/service/ITCm0325Service.java

@@ -11,4 +11,5 @@ public interface ITCm0325Service extends IBaseService<TCm0325, String>{
     Set<TCm0325> getCodeAndName();
     TCm0325 getusestate(Map<String, Object> parameters);
     Long getMaxSort();
+    String getMaxId();
 }

+ 5 - 0
src/main/java/com/steerinfo/ems/tcm0325/service/impl/TCm0325ServiceImpl.java

@@ -30,4 +30,9 @@ public class TCm0325ServiceImpl extends BaseServiceImpl<TCm0325, String> impleme
         return tCm0325Mapper.getusestate(parameters);
     }
     synchronized  public Long getMaxSort(){return tCm0325Mapper.getMaxSort();}
+
+    @Override
+    public String getMaxId() {
+        return tCm0325Mapper.getMaxId();
+    }
 }

+ 77 - 77
src/main/java/com/steerinfo/ems/trmworkprocmaterialvalue/service/impl/TRmWorkprocMaterialValueServiceImpl.java

@@ -202,82 +202,82 @@ public class TRmWorkprocMaterialValueServiceImpl extends BaseServiceImpl<TRmWork
 					}
 					String itemid = "";
 					String wid = "";
-					if (mline.endsWith("GX1")) { // 一高线-ZY9102
-						// MES工序与EMS工序没有关联,这里防止修改工序后造成数据错误,增加一次判断,下同
-						TRmWorkproc tw = tRmWorkprocService.getById("ZY9102");
-						if(tw!=null && tw.getName().equalsIgnoreCase("一高线")){
-							wid = "ZY9102";
-							itemid = wid + mid + "R";
-						}
-					} else if (mline.endsWith("GX3")) { // 三高线-ZY9103
-						// MES工序与EMS工序没有关联,这里防止修改工序后造成数据错误,增加一次判断,下同
-						TRmWorkproc tw = tRmWorkprocService.getById("ZY9103");
-						if(tw!=null && tw.getName().equalsIgnoreCase("三高线")){
-							wid = "ZY9103";
-							itemid = wid + mid + "R";
-						}
-					} else if (mline.endsWith("GX2")) { // 二高线-ZY9201
-						// MES工序与EMS工序没有关联,这里防止修改工序后造成数据错误,增加一次判断,下同
-						TRmWorkproc tw = tRmWorkprocService.getById("ZY9201");
-						if(tw!=null && tw.getName().equalsIgnoreCase("二高线")){
-							wid = "ZY9201";
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("GX4") || mline.endsWith("GX5")) { // 四五高线
-						TRmWorkproc tw = tRmWorkprocService.getById("ZY9202");
-						if(tw!=null && tw.getName().equalsIgnoreCase("四五高线")){
-							wid = "ZY9202";
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("QT1")) { // 一球团-ZY6100
-						TRmWorkproc tw = tRmWorkprocService.getById("ZY6100");
-						if(tw!=null && tw.getName().equalsIgnoreCase("一球团")){
-							wid = "ZY6100";
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("QT2")) { // 二球团-ZY6200
-						TRmWorkproc tw = tRmWorkprocService.getById("ZY6200");
-						if(tw!=null && tw.getName().equalsIgnoreCase("二球团")){
-							wid = "ZY6200";
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("BC1")) { // 一棒材-ZY9101
-						wid = "ZY9101";
-						TRmWorkproc tw = tRmWorkprocService.getById(wid);
-						if(tw!=null && tw.getName().equalsIgnoreCase("棒材线")){
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("GL3")) { // 二炼铁2#1280高炉-ZY7202
-						wid = "ZY7202";
-						TRmWorkproc tw = tRmWorkprocService.getById(wid);
-						if(tw!=null && tw.getName().equalsIgnoreCase("二炼铁2#1280高炉")){
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("JH1")) { // 一焦化-ZY4100
-						wid = "ZY4100";
-						TRmWorkproc tw = tRmWorkprocService.getById(wid);
-						if(tw!=null && tw.getName().equalsIgnoreCase("一焦化")){
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("JH2")) { // 二焦化-ZY4200
-						wid = "ZY4200";
-						TRmWorkproc tw = tRmWorkprocService.getById(wid);
-						if(tw!=null && tw.getName().equalsIgnoreCase("二焦化")){
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("LG1")) { // 一炼钢 - ZY8100
-						wid = "ZY8100";
-						TRmWorkproc tw = tRmWorkprocService.getById(wid);
-						if(tw!=null && tw.getName().equalsIgnoreCase("一炼钢")){
-							itemid = wid + mid + "R";
-						}
-					} else if(mline.endsWith("LG2")) { // 二炼钢-ZY8200
-						wid = "ZY8200";
-						TRmWorkproc tw = tRmWorkprocService.getById(wid);
-						if(tw!=null && tw.getName().equalsIgnoreCase("二炼钢")){
-							itemid = wid + mid + "R";
-						}
-					}
+//					if (mline.endsWith("GX1")) { // 一高线-ZY9102
+//						// MES工序与EMS工序没有关联,这里防止修改工序后造成数据错误,增加一次判断,下同
+//						TRmWorkproc tw = tRmWorkprocService.getById("ZY9102");
+//						if(tw!=null && tw.getName().equalsIgnoreCase("一高线")){
+//							wid = "ZY9102";
+//							itemid = wid + mid + "R";
+//						}
+//					} else if (mline.endsWith("GX3")) { // 三高线-ZY9103
+//						// MES工序与EMS工序没有关联,这里防止修改工序后造成数据错误,增加一次判断,下同
+//						TRmWorkproc tw = tRmWorkprocService.getById("ZY9103");
+//						if(tw!=null && tw.getName().equalsIgnoreCase("三高线")){
+//							wid = "ZY9103";
+//							itemid = wid + mid + "R";
+//						}
+//					} else if (mline.endsWith("GX2")) { // 二高线-ZY9201
+//						// MES工序与EMS工序没有关联,这里防止修改工序后造成数据错误,增加一次判断,下同
+//						TRmWorkproc tw = tRmWorkprocService.getById("ZY9201");
+//						if(tw!=null && tw.getName().equalsIgnoreCase("二高线")){
+//							wid = "ZY9201";
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("GX4") || mline.endsWith("GX5")) { // 四五高线
+//						TRmWorkproc tw = tRmWorkprocService.getById("ZY9202");
+//						if(tw!=null && tw.getName().equalsIgnoreCase("四五高线")){
+//							wid = "ZY9202";
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("QT1")) { // 一球团-ZY6100
+//						TRmWorkproc tw = tRmWorkprocService.getById("ZY6100");
+//						if(tw!=null && tw.getName().equalsIgnoreCase("一球团")){
+//							wid = "ZY6100";
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("QT2")) { // 二球团-ZY6200
+//						TRmWorkproc tw = tRmWorkprocService.getById("ZY6200");
+//						if(tw!=null && tw.getName().equalsIgnoreCase("二球团")){
+//							wid = "ZY6200";
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("BC1")) { // 一棒材-ZY9101
+//						wid = "ZY9101";
+//						TRmWorkproc tw = tRmWorkprocService.getById(wid);
+//						if(tw!=null && tw.getName().equalsIgnoreCase("棒材线")){
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("GL3")) { // 二炼铁2#1280高炉-ZY7202
+//						wid = "ZY7202";
+//						TRmWorkproc tw = tRmWorkprocService.getById(wid);
+//						if(tw!=null && tw.getName().equalsIgnoreCase("二炼铁2#1280高炉")){
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("JH1")) { // 一焦化-ZY4100
+//						wid = "ZY4100";
+//						TRmWorkproc tw = tRmWorkprocService.getById(wid);
+//						if(tw!=null && tw.getName().equalsIgnoreCase("一焦化")){
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("JH2")) { // 二焦化-ZY4200
+//						wid = "ZY4200";
+//						TRmWorkproc tw = tRmWorkprocService.getById(wid);
+//						if(tw!=null && tw.getName().equalsIgnoreCase("二焦化")){
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("LG1")) { // 一炼钢 - ZY8100
+//						wid = "ZY8100";
+//						TRmWorkproc tw = tRmWorkprocService.getById(wid);
+//						if(tw!=null && tw.getName().equalsIgnoreCase("一炼钢")){
+//							itemid = wid + mid + "R";
+//						}
+//					} else if(mline.endsWith("LG2")) { // 二炼钢-ZY8200
+//						wid = "ZY8200";
+//						TRmWorkproc tw = tRmWorkprocService.getById(wid);
+//						if(tw!=null && tw.getName().equalsIgnoreCase("二炼钢")){
+//							itemid = wid + mid + "R";
+//						}
+//					}
 					if(!itemid.isEmpty() && !mid.isEmpty()){
 						twm = tRmWorkprocMaterialService.getById(itemid);
 						if(twm!=null){
@@ -326,7 +326,7 @@ public class TRmWorkprocMaterialValueServiceImpl extends BaseServiceImpl<TRmWork
 				} else {
 					twm = relationItem.get(0);
 				}
-                // code = "1" 是由公式生成的项,放弃添加
+                // code = "1" 是由公式生成的项,放弃添加 0不需要  1需要
                 if (twm.getCode()!=null && twm.getCode().equals("1")) {
                     abandon++;
                     logger.info("[放弃添加]" + DateUtils.dateStr(new Date(), "yyyy-MM-dd HH:mm:ss") + " :IF_MES_EMS_SWAPFILE中 FID 为 " + swapfile.getFid() + " 的数据项被配置成由公式自动生成,所以放弃添加。( MES物料编码:" + swapfile.getMaterialcode() + " ,MES物料名称:" + swapfile.getMaterialname() + " ,MES产线编码:" + swapfile.getProdline() + " )");

+ 1 - 0
src/main/java/com/steerinfo/ems/trmworkprocproductvalue/controller/TRmWorkprocProductValueController.java

@@ -70,6 +70,7 @@ public class TRmWorkprocProductValueController extends BaseRESTfulController {
     @GetMapping(value = "/")
     public RESTfulResult list(@RequestParam HashMap<String, Object> parmas,Integer pageNum, Integer pageSize){
         tRmWorkprocProductValueService.setDate(new Date());
+       // ifMesEmsSwapfileService.getLgDateProd();
     	if(parmas.containsKey("productid") && parmas.get("productid") != null && !"".equals(parmas.get("productid").toString())){
             String productid = parmas.get("productid").toString();
             if(productid.indexOf(",") == -1){

+ 37 - 1
src/main/java/com/steerinfo/feigen/model/LgWeight.java

@@ -17,6 +17,42 @@ public class LgWeight {
     private String type;
     private BigDecimal weight;
     private String date;
+    private String materialcode;
+    private String unit;
+    private String materialname;
+    private String fid;
+
+    public String getFid() {
+        return fid;
+    }
+
+    public void setFid(String fid) {
+        this.fid = fid;
+    }
+
+    public String getMaterialcode() {
+        return materialcode;
+    }
+
+    public void setMaterialcode(String materialcode) {
+        this.materialcode = materialcode;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+
+    public String getMaterialname() {
+        return materialname;
+    }
+
+    public void setMaterialname(String materialname) {
+        this.materialname = materialname;
+    }
 
     public String getType() {
         return type;
@@ -42,4 +78,4 @@ public class LgWeight {
         this.date = date;
     }
 
-}
+}

+ 7 - 0
src/main/java/com/steerinfo/feigen/service/LgWeightFeigenService.java

@@ -6,6 +6,10 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 
 @FeignClient(value = "xt-ems-product",url = "192.168.64.1:8888")
@@ -15,4 +19,7 @@ public interface LgWeightFeigenService {
     @GetMapping("v1/lgweight/queryWeightByTime")
     public List<LgWeight> QueryWeightByTime();
 
+    @GetMapping("v1/lgweight/queryWeightByTime2")
+    public List<LgWeight> QueryWeightByTime2(@RequestParam("startTime")String startTime,@RequestParam("endTime")String endTime);
+
 }

+ 6 - 0
src/main/java/com/steerinfo/ftp/uploadfile/service/impl/UploadFileServiceImpl.java

@@ -7,6 +7,10 @@ import com.steerinfo.ftp.uploadfile.mapper.UploadFileMapper;
 import com.steerinfo.ftp.uploadfile.service.IUploadFileService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import java.math.BigDecimal;
 import java.util.Set;
@@ -39,4 +43,6 @@ public class UploadFileServiceImpl extends BaseServiceImpl<UploadFile, String> i
     public Set<UploadFile> getIdAndName() {
         return uploadFileMapper.getIdAndName();
     }
+
 }
+

+ 150 - 175
src/main/java/com/steerinfo/task/SpringCronTask.java

@@ -1,12 +1,12 @@
 package com.steerinfo.task;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledFuture;
 
 import com.steerinfo.ems.ifemsmesactitem.service.IIfEmsMesActitemService;
@@ -31,7 +31,6 @@ import org.springframework.scheduling.support.CronTrigger;
 import org.springframework.stereotype.Service;
 
 import com.steerinfo.ems.Utils.DateUtils;
-import com.steerinfo.ems.emseotiming.service.IEmsEoTimingService;
 import com.steerinfo.ems.emsetiming.service.IEmsETimingService;
 import com.steerinfo.ems.ifmesemsproductorder.service.IIfMesEmsProductorderService;
 import com.steerinfo.ems.ifmesemsswapfile.service.IIfMesEmsSwapfileService;
@@ -49,31 +48,31 @@ import com.steerinfo.ems.zghbjkbzlog.service.IZghbjkbzLogService;
 @EnableScheduling
 @Service(value = "springCronTask")
 public class SpringCronTask implements SchedulingConfigurer{
-	
+
 	private static final Logger logger = LoggerFactory.getLogger(SpringCronTask.class);
-	
+
 	private ScheduledTaskRegistrar taskRegistrar;
-	
+
 	private Map<String, ScheduledFuture<?>> taskFutures = new ConcurrentHashMap<String, ScheduledFuture<?>>();
-	
+
+	@Autowired
+	private JdbcTemplate jdbcTemplate;
 	@Autowired
-    private JdbcTemplate jdbcTemplate;
+	IIfMesEmsSwapfileService ifMesEmsSwapfileService;
+	@Autowired
+	IIfMesEmsProductorderService ifMesEmsProductorderService;
+	@Autowired
+	ITRmWorkprocMaterialValueService tRmWorkprocMaterialValueService;
+	@Autowired
+	ITRmWorkprocProductValueService tRmWorkprocProductValueService;
 	@Autowired
-    IIfMesEmsSwapfileService ifMesEmsSwapfileService;
-    @Autowired
-    IIfMesEmsProductorderService ifMesEmsProductorderService;
-    @Autowired
-    ITRmWorkprocMaterialValueService tRmWorkprocMaterialValueService;
-    @Autowired
-    ITRmWorkprocProductValueService tRmWorkprocProductValueService;
-    @Autowired
 	ITRmCalpointValueService tRmCalpointValueService;
 	@Autowired
-    IUsageDataService usageDataService;
+	IUsageDataService usageDataService;
 	@Autowired
-    ITRmActValueService tRmActValueService;
+	ITRmActValueService tRmActValueService;
 	@Autowired
-    ITRmPlanValueService tRmPlanValueService;
+	ITRmPlanValueService tRmPlanValueService;
 	@Autowired
 	IEmsETimingService emsETimingService;
 	@Autowired
@@ -85,21 +84,19 @@ public class SpringCronTask implements SchedulingConfigurer{
 	@Autowired
 	ITRmIndexValueService tRmIndexValueService;
 	@Autowired
-    ITRmBalanceValueService tRmBalanceValueService;
+	ITRmBalanceValueService tRmBalanceValueService;
 	@Autowired
 	IZghbjkbzLogService zghbjkbzLogService;
 	@Autowired
-    IMesEmsDieseloilService mesEmsDieseloilService;
+	IMesEmsDieseloilService mesEmsDieseloilService;
 	@Autowired
 	ITRmTransfereActValueService tRmTransfereActValueService;
 	@Autowired
-    ITRmDwValueService tRmDwValueService;
-	@Autowired
-    ITRmCalpointService tRmCalpointService;
+	ITRmDwValueService tRmDwValueService;
 	@Autowired
-    ITRmDfValueService tRmDfValueService;
+	ITRmCalpointService tRmCalpointService;
 	@Autowired
-	IEmsEoTimingService emsEoTimingService;
+	ITRmDfValueService tRmDfValueService;
 
 	/**
 	 * SchedulingConfigurer接口的方法实现,加载后自动运行
@@ -108,40 +105,34 @@ public class SpringCronTask implements SchedulingConfigurer{
 	public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
 		ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
 		taskScheduler.setThreadNamePrefix("ems-task-");
-		taskScheduler.setPoolSize(10);
+		taskScheduler.setPoolSize(4);
 		taskScheduler.initialize();
 		taskRegistrar.setTaskScheduler(taskScheduler);
-		taskRegistrar.setScheduler(Executors.newScheduledThreadPool(6));
-		
+
 		this.taskRegistrar = taskRegistrar;
-		logger.info("定时任务已经转移至服务:ems-task");
 		// 初始化任务
-		// String sql = "select * from TASK_CONF order by id";
-		// List<Map<String, Object>> l = jdbcTemplate.queryForList(sql);
-		// logger.info("当前定时任务队列长度:" + taskFutures.size());
-		// if (l!=null && l.size()>0){
-		// for(int i =0; i<l.size(); i++){
-		// Map<String, Object> m = (Map<String, Object>)l.get(i);
-		// String taskId = m.get("ID").toString();
-		// String cron = m.get("CRON").toString();
-		// String status = m.get("STATUS") == null ? "" :
-		// m.get("STATUS").toString();
-		// if(status.equalsIgnoreCase("1") &&
-		// !taskFutures.containsKey(taskId)){
-		// addTask(taskId, cron);
-		// }
-		// if(status.equalsIgnoreCase("0") &&
-		// taskFutures.containsKey(taskId)){
-		// cancelTriggerTask(taskId);
-		// }
-		// logger.info("定时任务" + taskId + " 启动时间表达式:" + cron);
-		// }
-		// }
+		String sql = "select * from TASK_CONF order by id";
+		List<Map<String, Object>> l = jdbcTemplate.queryForList(sql);
+		if (l!=null && l.size()>0){
+			for(int i =0; i<l.size(); i++){
+				Map<String, Object> m = (Map<String, Object>)l.get(i);
+				String taskId = m.get("ID").toString();
+				String cron = m.get("CRON").toString();
+				String status = m.get("STATUS") == null ? "" : m.get("STATUS").toString();
+				if(status.equalsIgnoreCase("1") && !taskFutures.containsKey(taskId)){
+					addTask(taskId, cron);
+				}
+				if(status.equalsIgnoreCase("0") && taskFutures.containsKey(taskId)){
+					cancelTriggerTask(taskId);
+				}
+				logger.info("定时任务-" + taskId + " cron表达式:" + cron);
+			}
+		}
 	}
-	
+
 	/**
 	 * 添加定时任务(初始化)
-	 * 
+	 *
 	 * @param taskId
 	 * @param cron
 	 */
@@ -155,10 +146,10 @@ public class SpringCronTask implements SchedulingConfigurer{
 			throw new SchedulingException("the taskId[" + taskId + "] was added.");
 		}
 	}
-	
+
 	/**
 	 * 添加或者更新定时任务
-	 * 
+	 *
 	 * @param taskId
 	 */
 	public void updateTask(String taskId) {
@@ -170,147 +161,131 @@ public class SpringCronTask implements SchedulingConfigurer{
 		taskFutures.put(taskId, future);
 		logger.info("当前定时任务队列长度:" + taskFutures.size());
 	}
-	
+
 	/**
 	 * 取消任务
 	 * @param taskId
 	 */
 	public void cancelTriggerTask(String taskId){
 		ScheduledFuture<?> future = taskFutures.get(taskId);
-	      if (future != null){
-	         future.cancel(true);
-	      }
-	      taskFutures.remove(taskId);
+		if (future != null){
+			future.cancel(true);
+		}
+		taskFutures.remove(taskId);
 	}
-	
+
 	/**
 	 * 业务处理
-	 * 
+	 *
 	 * @param taskId
 	 * @return
 	 */
 	private Runnable doTask(String taskId) {
 		Properties props = System.getProperties(); // 系统属性
 		return new Runnable() {
-            @Override
-            public void run() {
-            	if(!props.getProperty("os.name").equalsIgnoreCase("linux")){
-					logger.info(taskId + "触发时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
-							.format(new Date()));/*
-													 * try { Thread.sleep(45 * 1000); }catch(InterruptedException e) {
-													 * 
-													 * }
-													 */
-            		System.out.println("操作系统:" + props.getProperty("os.name") + ", 非linux环境不运行定时任务");
-            		return;
-            	}
-				if (taskId.equalsIgnoreCase("101")) { // 定时任务1的业务处理-MES数据同步
-					logger.info("定时任务触发时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
-					long start = new Date().getTime();
-					ifMesEmsSwapfileService.synchronousMesAnEmsData(); // 获取MES投入产出数据
-					ifMesEmsProductorderService.synchronousMesAnEmsData(); // 获取MES生产计划数据
-					usageDataService.getAutoSum(DateUtils.dateStr(new Date(start - 24*3600*1000L), "yyyy-MM-dd")); // 统计自动上传的能源上报数据(昨日)
-					mesEmsDieseloilService.synchronousMesEmsData(); // 获取MES柴油数据
-					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("102")) {
-					// 计量点定时任务
-					long start = new Date().getTime();
-					tRmCalpointValueService.statData(new Date());
-					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("103")) {
-					long start = new Date().getTime();
-					tRmActValueService.statDataforDay();// 每日数据统计(实绩定时任务)
-					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("104")) {
-					long start = new Date().getTime();
-					tRmPlanValueService.state();// 每日数据统计(计划定时任务)
-					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("105")) {
+			@Override
+			public void run() {
+//				if(!props.getProperty("os.name").equalsIgnoreCase("linux")){
+//					System.out.println("操作系统:" + props.getProperty("os.name") + ", 非linux环境不运行定时任务");
+//					return;
+//				}
+//				if (taskId.equalsIgnoreCase("101")) { // 定时任务1的业务处理-MES数据同步
+//					logger.info("定时任务触发时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+//					long start = new Date().getTime();
+//					ifMesEmsSwapfileService.synchronousMesAnEmsData(); // 获取MES投入产出数据
+//					ifMesEmsProductorderService.synchronousMesAnEmsData(); // 获取MES生产计划数据
+//					//usageDataService.getAutoSum(DateUtils.dateStr(new Date(start - 24*3600*1000L), "yyyy-MM-dd")); // 统计自动上传的能源上报数据(昨日)
+//					//mesEmsDieseloilService.synchronousMesEmsData(); // 获取MES柴油数据
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if (taskId.equalsIgnoreCase("102")) {
+//					// 计量点定时任务
+//					long start = new Date().getTime();
+//					tRmCalpointValueService.statData(new Date());
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if (taskId.equalsIgnoreCase("103")) {
+//					long start = new Date().getTime();
+//					tRmActValueService.statDataforDay();// 每日数据统计(实绩定时任务)
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if (taskId.equalsIgnoreCase("104")) {
+//					long start = new Date().getTime();
+//					tRmPlanValueService.state();// 每日数据统计(计划定时任务)
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				}
+				 if (taskId.equalsIgnoreCase("105")) {
 					// 先计算产品,因为原材料计算单耗需要产品实绩数据参与计算
 					long start = new Date().getTime();
+					ifMesEmsSwapfileService.getLgDateProd();
+					try {
+						ifMesEmsSwapfileService.getLgDateProd2();
+					} catch (ParseException e) {
+						e.printStackTrace();
+					}
 					tRmWorkprocProductValueService.setDate(new Date()); // 产品实绩产量、产品计划数据维护
 					tRmWorkprocMaterialValueService.setDate(new Date()); // 原材料数据维护
 					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("106")) {
-					// 获取MES水质监测数据
-					long start = new Date().getTime();
-					ifMesEmsWatermonitorService.synchronousMesAnEmsData();
-					// 生成人工录入监测数据
-					tCm0312Controller.getmanualdata();
-					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("107")) { // 电统计(从南瑞到EMS)
-					long start = new Date().getTime();
-					emsETimingService.getData();
-					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("108")) {
-					// 从IF_MES_EMS_WATERMONITOR表获取水质监测数据到T_CM_0318表
-					tCm0312Controller.synchronousData();
-				} else if (taskId.equalsIgnoreCase("109")) { // 电计量点班数据计算
-					tRmCalpointValueService.statDataShift(new Date());
-				} else if (taskId.equalsIgnoreCase("110")) {
-					// 能耗数据获取
-					ifEmsMesActitemService.getUploadData();
-				} else if (taskId.equalsIgnoreCase("111")) {
-					// 指标管理数据生成
-					long start = new Date().getTime();
-					tRmIndexValueService.statData();
-					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-				} else if (taskId.equalsIgnoreCase("112")) {
-					// 能源上报_晋泰信和
-					usageDataService.autoUpload();
-				} else if(taskId.equalsIgnoreCase("113")){
-				    //平衡数据维护
-					long start = new Date().getTime();
-                    tRmBalanceValueService.state();
-                    // 上报项目数据维护
-                    tRmDwValueService.state(new Date());
-                    logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-                } else if(taskId.equalsIgnoreCase("114")){
-				    // 环保监控记录定时任务
-                	zghbjkbzLogService.record();
-                } else if(taskId.equalsIgnoreCase("115")){
-				    // 月初自动生成宾馆转供电记录
-                	long start = new Date().getTime();
-                	tRmTransfereActValueService.createRecord();
-                	logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-                } else if(taskId.equalsIgnoreCase("116")){
-				    // 动力、水小时表定时统计(自动补全24小时内的小时用量值)
-                	long start = new Date().getTime();
-                	tRmCalpointService.statHourData();
-                	logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-                } else if(taskId.equalsIgnoreCase("117")){
-				    // 财务投入产出数据生成
-                	long start = new Date().getTime();
-                	tRmDfValueService.state(new Date());
-                	logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-                } else if(taskId.equalsIgnoreCase("118")){
-				    // 财务投入产出数据MES产量补全
-                	long start = new Date().getTime();
-                	tRmDfValueService.state1(new Date());
-                	logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-                } else if(taskId.equalsIgnoreCase("119")){
-				    // 转供电仪表自动采集
-                	long start = new Date().getTime();
-                	try {
-                		emsEoTimingService.getData();
-                	}catch(Exception e){
-		            	logger.error(taskId + " 执行失败", e);
-		            }
-                	logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-                } else if(taskId.equalsIgnoreCase("120")){
-				    // 转供电仪表数据补全
-                	long start = new Date().getTime();
-                	try {
-                		//emsEoTimingService.getLaterData();
-                	}catch(Exception e){
-		            	logger.error(taskId + " 执行失败", e);
-		            }
-                	logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
-                }
-            }
-        };
+				}
+//				 else if (taskId.equalsIgnoreCase("106")) {
+//					// 获取MES水质监测数据
+//					long start = new Date().getTime();
+//					ifMesEmsWatermonitorService.synchronousMesAnEmsData();
+//					// 生成人工录入监测数据
+//					tCm0312Controller.getmanualdata();
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if (taskId.equalsIgnoreCase("107")) { // 电统计(从南瑞到EMS)
+//					long start = new Date().getTime();
+//					emsETimingService.getData();
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if (taskId.equalsIgnoreCase("108")) {
+//					// 从IF_MES_EMS_WATERMONITOR表获取水质监测数据到T_CM_0318表
+//					tCm0312Controller.synchronousData();
+//				} else if (taskId.equalsIgnoreCase("109")) { // 电计量点班数据计算
+//					tRmCalpointValueService.statDataShift(new Date());
+//				} else if (taskId.equalsIgnoreCase("110")) {
+//					// 能耗数据获取
+//					ifEmsMesActitemService.getUploadData();
+//				} else if (taskId.equalsIgnoreCase("111")) {
+//					// 指标管理数据生成
+//					long start = new Date().getTime();
+//					tRmIndexValueService.statData();
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if (taskId.equalsIgnoreCase("112")) {
+//					// 能源上报_晋泰信和
+//					usageDataService.autoUpload();
+//				} else if(taskId.equalsIgnoreCase("113")){
+//					//平衡数据维护
+//					long start = new Date().getTime();
+//					tRmBalanceValueService.state();
+//					// 上报项目数据维护
+//					tRmDwValueService.state(new Date());
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if(taskId.equalsIgnoreCase("114")){
+//					// 环保监控记录定时任务
+//					zghbjkbzLogService.record();
+//				} else if(taskId.equalsIgnoreCase("115")){
+//					// 月初自动生成宾馆转供电记录
+//					long start = new Date().getTime();
+//					tRmTransfereActValueService.createRecord();
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if(taskId.equalsIgnoreCase("116")){
+//					// 动力、水小时表定时统计(自动补全24小时内的小时用量值)
+//					long start = new Date().getTime();
+//					tRmCalpointService.statHourData();
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if(taskId.equalsIgnoreCase("117")){
+//					// 财务投入产出数据生成
+//					long start = new Date().getTime();
+//					tRmDfValueService.state(new Date());
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				} else if(taskId.equalsIgnoreCase("118")){
+//					// 财务投入产出数据MES产量补全
+//					long start = new Date().getTime();
+//					tRmDfValueService.state(new Date());
+//					logger.info("定时任务"+taskId+"执行时长:" + (new Date().getTime() - start)/1000 + "秒");
+//				}
+			}
+		};
 	}
-	
+
 	/**
 	 * 获取任务时间表达式
 	 * @param taskId
@@ -319,5 +294,5 @@ public class SpringCronTask implements SchedulingConfigurer{
 	public String getCron(String taskId) {
 		String sql = "select cron from TASK_CONF t where id = ?";
 		return jdbcTemplate.queryForObject(sql, new Object[]{taskId}, String.class);
-    }
+	}
 }