Browse Source

lrl -2021-12-09

lirl 3 years ago
parent
commit
0b701c6ccf

+ 1 - 4
src/main/java/com/steerinfo/ems/emsprodplanroundweight/controller/EmsProdplanRoundWeightController.java

@@ -104,8 +104,5 @@ public class EmsProdplanRoundWeightController extends BaseRESTfulController {
     	}
       return success();
     }
-    @GetMapping("/aaa")
-    public void aaa() throws ParseException {
-        emsProdplanRoundWeightService.getWeightForLg();
-    }
+
 }

+ 1 - 0
src/main/java/com/steerinfo/ems/emsprodplanroundweight/service/IEmsProdplanRoundWeightService.java

@@ -20,5 +20,6 @@ import java.text.ParseException;
  */
 public interface IEmsProdplanRoundWeightService extends IBaseService<EmsProdplanRoundWeight, String>{
     public void getWeightForLg() throws ParseException;
+    public void getWeightForGx() throws ParseException;
 
 }

+ 34 - 0
src/main/java/com/steerinfo/ems/emsprodplanroundweight/service/impl/EmsProdplanRoundWeightServiceImpl.java

@@ -1,7 +1,9 @@
 package com.steerinfo.ems.emsprodplanroundweight.service.impl;
 
 import com.steerinfo.ems.Utils.DateUtils;
+import com.steerinfo.feigen.model.GxWeight;
 import com.steerinfo.feigen.model.LgWeight;
+import com.steerinfo.feigen.service.GxWeightFeigenService;
 import com.steerinfo.feigen.service.LgWeightFeigenService;
 import com.steerinfo.framework.mapper.IBaseMapper;
 import com.steerinfo.framework.service.impl.BaseServiceImpl;
@@ -38,6 +40,8 @@ public class EmsProdplanRoundWeightServiceImpl extends BaseServiceImpl<EmsProdpl
     private EmsProdplanRoundWeightMapper emsProdplanRoundWeightMapper;
     @Autowired
     private LgWeightFeigenService lgWeightFeigenService;
+    @Autowired
+    private GxWeightFeigenService gxWeightFeigenService;
 
     @Override
     protected IBaseMapper<EmsProdplanRoundWeight, String> getMapper() {
@@ -73,4 +77,34 @@ public class EmsProdplanRoundWeightServiceImpl extends BaseServiceImpl<EmsProdpl
         });
 
     }
+    //获取高线计划的重量
+    @Override
+    public void getWeightForGx() 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, -7);
+        Date dt1 = rightNow.getTime();
+        String reStr = sdf.format(dt1);
+        List<GxWeight> gxWeights = gxWeightFeigenService.QueryWeightforRound(reStr, DateUtils.dateStr(new Date(), "yyyy-MM-dd"));
+        gxWeights.forEach(item -> {
+            EmsProdplanRoundWeight model = new EmsProdplanRoundWeight();
+            model.setFid(item.getFid());
+            model.setLcId(item.getRoundid());
+            model.setQty(item.getWeight());
+            model.setMaterialcode(item.getMaterialcode());
+            model.setMaterialname(item.getMaterialname());
+            model.setProdate(item.getProdate());
+            model.setUnit(item.getUnit());
+            EmsProdplanRoundWeight emsProdplanRoundWeight = emsProdplanRoundWeightMapper.selectByPrimaryKey(model.getFid());
+            if(emsProdplanRoundWeight !=  null){
+                emsProdplanRoundWeightMapper.updateByPrimaryKeySelective(model);
+            }
+            else {
+                emsProdplanRoundWeightMapper.insert(model);
+            }
+        });
+    }
+
 }

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

@@ -176,7 +176,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
 			model.setWorks("AT2004");
 			model.setProdline("1036LG1");
 			model.setMaterialcode(lgWeight.getMaterialcode());
-			model.setProdate(lgWeight.getDate());
+			model.setProdate(lgWeight.getProdate());
 			model.setMaterialname(lgWeight.getMaterialname());
 			model.setUnit(lgWeight.getUnit());
 			model.setQty(lgWeight.getWeight());
@@ -209,7 +209,7 @@ public class IfMesEmsSwapfileServiceImpl extends BaseServiceImpl<IfMesEmsSwapfil
 			model.setWorks("AT2004");
 			model.setProdline("1036LG1");
 			model.setMaterialcode(lgWeight.getMaterialcode());
-			model.setProdate(lgWeight.getDate());
+			model.setProdate(lgWeight.getProdate());
 			model.setMaterialname(lgWeight.getMaterialname());
 			model.setUnit(lgWeight.getUnit());
 			model.setQty(lgWeight.getWeight());

+ 154 - 153
src/main/java/com/steerinfo/ems/trmactvalue/service/impl/TRmActValueServiceImpl.java

@@ -72,14 +72,14 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
 
     @Override
     public List<Map<String, Object>> getDate6121ForPage(HashMap<String, Object> parmas, Integer pageNum,
-                                                            Integer pageSize) {
+                                                        Integer pageSize) {
         List<Map<String, Object>> rows = tRmActValueMapper.getDate6121(parmas);
         return rows;
     }
 
     @Override
     public List<Map<String, Object>> getDate6122ForPage(HashMap<String, Object> parmas, Integer pageNum,
-                                                            Integer pageSize) {
+                                                        Integer pageSize) {
         List<Map<String, Object>> rows = tRmActValueMapper.getDate6122(parmas);
         return rows;
     }
@@ -105,11 +105,12 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
     @Override
     public void StateTimegranidforDay() {
         List<TRmActItem> tRmActItemsDay = tRmActItemService.getforsj("DAY");
-		this.getTRmActValueByFormula(tRmActItemsDay, "2021-11-05", "DAY");
-		this.getMonthRmActValue(tRmActItemsDay);
-		this.getYearRmActValue(tRmActItemsDay);
+        this.getTRmActValueByFormula(tRmActItemsDay, DateTypeEnum.getMethod("yesterday").getDate(), "DAY");
+        this.getMonthRmActValue(tRmActItemsDay);
+        this.getYearRmActValue(tRmActItemsDay);
         logger.info("供需实绩粒度为天定时任务结束......");
     }
+
     /**
      * 最小粒度为月的定时任务
      */
@@ -152,7 +153,7 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
 
     /**
      * 计算累计值(月时间粒度的计算值为当月日累计值)
-     * 
+     *
      * @param itemid 项目ID
      * @param clock 累计值来源时间
      * @param timegranid 累计值来源时间粒度
@@ -172,34 +173,34 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
 
     /**
      * 通过公式,实绩项目数据录入(Timegranid为最小时间粒度时候用该方法)
-     * 
+     *
      * @param tRmActItems 实绩项目
      * @param clock 时间
      * @param Timegranid 时间粒度
      */
     public void getTRmActValueByFormula(List<TRmActItem> tRmActItems,String clock,String Timegranid) {
         for (TRmActItem tRmActItem : tRmActItems) {
-        	HashMap<String, Object> id = new HashMap<String, Object>();
-    		id.put("clock", clock);
-    		id.put("timegranid", Timegranid);
-    		id.put("itemid", tRmActItem.getItemid());
-    		// 数据是否已存在
-    		TRmActValue t = tRmActValueMapper.selectByPrimaryKey(id);
-			if(t!=null){
-				logger.error("原数据已存在:" + clock + ",itemid:"+ tRmActItem.getItemid());
-				continue;
-			}
-			Short digits = tRmActItem.getDigits() == null ? 2 : tRmActItem.getDigits();
+            HashMap<String, Object> id = new HashMap<String, Object>();
+            id.put("clock", clock);
+            id.put("timegranid", Timegranid);
+            id.put("itemid", tRmActItem.getItemid());
+            // 数据是否已存在
+            TRmActValue t = tRmActValueMapper.selectByPrimaryKey(id);
+            if(t!=null){
+                logger.error("原数据已存在:" + clock + ",itemid:"+ tRmActItem.getItemid());
+                continue;
+            }
+            Short digits = tRmActItem.getDigits() == null ? 2 : tRmActItem.getDigits();
             // 折标系数
             Double zbxs = formulaService.getValByItemid(tRmActItem.getEnergyid(),Timegranid, clock, 0);
             if (zbxs==null){
                 zbxs=0.0;
             }
             Double actualvalue = formulaService.getValByItemid(tRmActItem.getItemid(), Timegranid, clock, 0);
-			// if(actualvalue<0){
-			// actualvalue=0.0;
-			// logger.info("id为"+tRmActItem.getItemid()+"计算错误");
-			// }
+            // if(actualvalue<0){
+            // actualvalue=0.0;
+            // logger.info("id为"+tRmActItem.getItemid()+"计算错误");
+            // }
             TRmActValue tRmActValue = new TRmActValue();
             tRmActValue.setItemid(tRmActItem.getItemid());
             tRmActValue.setClock(clock);
@@ -241,25 +242,25 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
      * @param tRmActItems 项目
      */
     public void getMonthRmActValue(List<TRmActItem> tRmActItems) {
-        if(DateTypeEnum.getMethod("dm").getDate().equals("21")){
+        if(DateTypeEnum.getMethod("dm").getDate().equals("1")){
             for (TRmActItem tRmActItem : tRmActItems) {
-            	HashMap<String, Object> id = new HashMap<String, Object>();
-        		id.put("clock", "2021-09");
-        		id.put("timegranid", "MONTH");
-        		id.put("itemid", tRmActItem.getItemid());
-        		// 数据是否已存在
-        		TRmActValue t = tRmActValueMapper.selectByPrimaryKey(id);
-    			if(t!=null){
-    				logger.error("原数据已存在:" + DateTypeEnum.getMethod("lastMonth").getDate() + ",itemid:"+ tRmActItem.getItemid());
-    				continue;
-    			}
-    			Short digits = tRmActItem.getDigits() == null ? 2 : tRmActItem.getDigits();
-            	TRmActValue MonthtRmActValue = new TRmActValue();
+                HashMap<String, Object> id = new HashMap<String, Object>();
+                id.put("clock", DateTypeEnum.getMethod("lastMonth").getDate());
+                id.put("timegranid", "MONTH");
+                id.put("itemid", tRmActItem.getItemid());
+                // 数据是否已存在
+                TRmActValue t = tRmActValueMapper.selectByPrimaryKey(id);
+                if(t!=null){
+                    logger.error("原数据已存在:" + DateTypeEnum.getMethod("lastMonth").getDate() + ",itemid:"+ tRmActItem.getItemid());
+                    continue;
+                }
+                Short digits = tRmActItem.getDigits() == null ? 2 : tRmActItem.getDigits();
+                TRmActValue MonthtRmActValue = new TRmActValue();
                 MonthtRmActValue.setItemid(tRmActItem.getItemid());
-                MonthtRmActValue.setClock("2021-09");
+                MonthtRmActValue.setClock(DateTypeEnum.getMethod("lastMonth").getDate());
                 MonthtRmActValue.setTimegranid("MONTH");
                 //获取计算值(上月数据累加)
-                Double MonthActualvalue = this.getSumvalue(tRmActItem.getItemid(),"2021-11","DAY");
+                Double MonthActualvalue = this.getSumvalue(tRmActItem.getItemid(),DateTypeEnum.getMethod("lastMonth").getDate(),"DAY");
 //                if(MonthActualvalue<0){
 //                    MonthActualvalue=0.0;
 //                    logger.info("id为"+tRmActItem.getItemid()+"计算错误");
@@ -307,23 +308,23 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
 
     /**
      * 年粒度数据录入(月数据累加)
-     * 
+     *
      * @param tRmActItems
      */
     public void getYearRmActValue(List<TRmActItem> tRmActItems) {
         if(DateTypeEnum.getMethod("dy").getDate().equals("1")){
             for (TRmActItem tRmActItem : tRmActItems) {
-            	HashMap<String, Object> id = new HashMap<String, Object>();
-        		id.put("clock", DateTypeEnum.getMethod("lastYear").getDate());
-        		id.put("timegranid", "YEAR");
-        		id.put("itemid", tRmActItem.getItemid());
-        		// 数据是否已存在
-        		TRmActValue t = tRmActValueMapper.selectByPrimaryKey(id);
-    			if(t!=null){
-    				logger.error("原数据已存在:" + DateTypeEnum.getMethod("lastYear").getDate() + ",itemid:"+ tRmActItem.getItemid());
-    				continue;
-    			}
-            	TRmActValue YeartRmActValue = new TRmActValue();
+                HashMap<String, Object> id = new HashMap<String, Object>();
+                id.put("clock", DateTypeEnum.getMethod("lastYear").getDate());
+                id.put("timegranid", "YEAR");
+                id.put("itemid", tRmActItem.getItemid());
+                // 数据是否已存在
+                TRmActValue t = tRmActValueMapper.selectByPrimaryKey(id);
+                if(t!=null){
+                    logger.error("原数据已存在:" + DateTypeEnum.getMethod("lastYear").getDate() + ",itemid:"+ tRmActItem.getItemid());
+                    continue;
+                }
+                TRmActValue YeartRmActValue = new TRmActValue();
                 //年累计
                 YeartRmActValue.setItemid(tRmActItem.getItemid());
                 YeartRmActValue.setClock(DateTypeEnum.getMethod("lastYear").getDate());
@@ -355,14 +356,14 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
         }
     }
 
-	@Override
-	/**
-	 *  每日数据统计(实绩定时任务、计划定时任务,根据项目生成日、月、年粒度数据)
-	 */
-	public void statDataforDay() {
-		//获取实绩项目
+    @Override
+    /**
+     *  每日数据统计(实绩定时任务、计划定时任务,根据项目生成日、月、年粒度数据)
+     */
+    public void statDataforDay() {
+        //获取实绩项目
         List<TRmActItem> rs = tRmActItemService.getitems("R");
-        
+
         Calendar c = Calendar.getInstance();
         c.add(Calendar.DAY_OF_YEAR, -1); // 减1天昨天
         String clockd = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
@@ -374,61 +375,61 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
         String clocky = new SimpleDateFormat("yyyy").format(c.getTime());
         c.add(Calendar.YEAR, 1); // 回到现在
         // 生成昨日数据
-		for (TRmActItem tRmActItem : rs) {
-			if(tRmActItem.getMintimegranid().equalsIgnoreCase("DAY")) {
-				this.restatData(tRmActItem.getItemid(), clockd, "DAY", "系统");
-			}
-		}
-		// 每月前5天生成上月数据
-		if(c.get(Calendar.DAY_OF_MONTH) <= 5){
-			for (TRmActItem tRmActItem : rs) {
-				this.restatData(tRmActItem.getItemid(), clockm, "MONTH", "系统");
-			}
-		}
-		// 每年前5天生成去年数据
-		if(c.get(Calendar.DAY_OF_YEAR) <= 5){
-			for (TRmActItem tRmActItem : rs) {
-				this.restatData(tRmActItem.getItemid(), clocky, "YEAR", "系统");
-			}
-		}
-		tRmPlanValueService.state();
-	}
+        for (TRmActItem tRmActItem : rs) {
+            if(tRmActItem.getMintimegranid().equalsIgnoreCase("DAY")) {
+                this.restatData(tRmActItem.getItemid(), clockd, "DAY", "系统");
+            }
+        }
+        // 每月前5天生成上月数据
+        if(c.get(Calendar.DAY_OF_MONTH) <= 5){
+            for (TRmActItem tRmActItem : rs) {
+                this.restatData(tRmActItem.getItemid(), clockm, "MONTH", "系统");
+            }
+        }
+        // 每年前5天生成去年数据
+        if(c.get(Calendar.DAY_OF_YEAR) <= 5){
+            for (TRmActItem tRmActItem : rs) {
+                this.restatData(tRmActItem.getItemid(), clocky, "YEAR", "系统");
+            }
+        }
+        tRmPlanValueService.state();
+    }
 
-	@Override
-	public String restatData(String itemid, String clock, String timegranid, String opuser) {
-		if(!itemid.endsWith("R")){
-			return "项目编号错误";
-		}
-		TRmActItem t = tRmActItemService.getById(itemid);
-		if(t!=null){
-			Short digits = t.getDigits() == null ? 2 : t.getDigits();
-			Short digits2 = digits < 2 ? 2 : digits; // 单耗精度最少为2
-			HashMap<String, Object> id = new HashMap<String, Object>();
-    		id.put("clock", clock);
-    		id.put("timegranid", timegranid);
-    		id.put("itemid", itemid);
+    @Override
+    public String restatData(String itemid, String clock, String timegranid, String opuser) {
+        if(!itemid.endsWith("R")){
+            return "项目编号错误";
+        }
+        TRmActItem t = tRmActItemService.getById(itemid);
+        if(t!=null){
+            Short digits = t.getDigits() == null ? 2 : t.getDigits();
+            Short digits2 = digits < 2 ? 2 : digits; // 单耗精度最少为2
+            HashMap<String, Object> id = new HashMap<String, Object>();
+            id.put("clock", clock);
+            id.put("timegranid", timegranid);
+            id.put("itemid", itemid);
             // 计算值
             Double actualvalue = 0d;
             if(!TimegranidUtils.getTimegranidList(t.getMintimegranid()).contains(timegranid.toUpperCase())){
-            	return "时间粒度错误";
+                return "时间粒度错误";
             }else if(t.getMintimegranid().equalsIgnoreCase(timegranid)){
-				actualvalue = formulaService.getValByItemid(itemid, timegranid, clock, 0);
-			}else{
-				// 实绩数据-高粒度公式计算还是累加?当前使用累加。有公式为 比例类型(除法)的需要改成公式计算。
-				// actualvalue = formulaService.getValByItemid(itemid, timegranid, clock, 0);
-				// 此时计算值为小粒度累加
-				HashMap<String, Object> maps = new HashMap<>();
-            	if(timegranid.equalsIgnoreCase("MONTH")){
-    	            maps.put("itemid", itemid);
-    	            maps.put("clock", clock);
-    	            maps.put("timegranid", "DAY");
-            	}else if(timegranid.equalsIgnoreCase("YEAR")){
-            		maps.put("itemid", itemid);
-    	            maps.put("clock", clock);
-    	            maps.put("timegranid", "MONTH");
-            	}
-            	actualvalue = tRmActValueMapper.getSumvalue(maps);
-			}
+                actualvalue = formulaService.getValByItemid(itemid, timegranid, clock, 0);
+            }else{
+                // 实绩数据-高粒度公式计算还是累加?当前使用累加。有公式为 比例类型(除法)的需要改成公式计算。
+                // actualvalue = formulaService.getValByItemid(itemid, timegranid, clock, 0);
+                // 此时计算值为小粒度累加
+                HashMap<String, Object> maps = new HashMap<>();
+                if(timegranid.equalsIgnoreCase("MONTH")){
+                    maps.put("itemid", itemid);
+                    maps.put("clock", clock);
+                    maps.put("timegranid", "DAY");
+                }else if(timegranid.equalsIgnoreCase("YEAR")){
+                    maps.put("itemid", itemid);
+                    maps.put("clock", clock);
+                    maps.put("timegranid", "MONTH");
+                }
+                actualvalue = tRmActValueMapper.getSumvalue(maps);
+            }
             // 折标系数
             Double zbxs = formulaService.getValByItemid(t.getEnergyid(),timegranid, clock, 0);
             if (zbxs==null){
@@ -439,51 +440,51 @@ public class TRmActValueServiceImpl extends BaseServiceImpl<TRmActValue, HashMap
             Double  sjcl  = dh.get("SJCL").doubleValue();
             //累计产量
             // Double  ljcl = dh.get("LJCL").doubleValue();
-    		// 数据是否已存在
-    		TRmActValue tv = tRmActValueMapper.selectByPrimaryKey(id);
-    		try {
-    			if(tv!=null){
-    	            tv.setActualvalue(new BigDecimal(actualvalue));
-    	            tv.setApportvalue(BigDecimalUtil.add(tv.getCorrectvalue()!=null?tv.getCorrectvalue().doubleValue():0d, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
-    	            // 折标值
-    	            tv.setStdvalue(BigDecimalUtil.mul(zbxs, tv.getApportvalue().doubleValue()).setScale(digits, BigDecimal.ROUND_HALF_UP));
-    	            //单耗值
-    	            tv.setUcvalue(BigDecimalUtil.divide(tv.getApportvalue().doubleValue(), sjcl, digits2.intValue()));
-    	            tv.setUptime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
-    	            tv.setUserid(opuser);
-    	            tRmActValueMapper.updateByPrimaryKeySelective(tv);
-    			}else{
-    	            TRmActValue tRmActValue = new TRmActValue();
-    	            tRmActValue.setItemid(itemid);
-    	            tRmActValue.setClock(clock);
-    	            tRmActValue.setTimegranid(timegranid);
-    	            //计算值
-    	            tRmActValue.setActualvalue(new BigDecimal(actualvalue));
-    	            //修正值
-    	            tRmActValue.setCorrectvalue(new BigDecimal(0));
-    	            //最终值
-    	            tRmActValue.setApportvalue(new BigDecimal(actualvalue));
-    	            //折标值
-    	            tRmActValue.setStdvalue(BigDecimalUtil.mul(zbxs, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
-    	            //单耗值
-    	            tRmActValue.setUcvalue(BigDecimalUtil.divide(actualvalue, sjcl, digits2.intValue()));
-    	            tRmActValue.setCrman(opuser);
-    	            tRmActValue.setRecTime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
-    	            //修改次数
-    	            // tRmActValue.setModifyflag(new Short("0"));
-    	            tRmActValueMapper.insert(tRmActValue);
-    			}
-    		} catch (Exception e) {
-				logger.error("实绩数据计算错误:itemid-" + itemid + ",clock-" + clock);
-				logger.error("--:" + e.getMessage());
-				e.printStackTrace();
-			}
-		}
-		return null;
-	}
+            // 数据是否已存在
+            TRmActValue tv = tRmActValueMapper.selectByPrimaryKey(id);
+            try {
+                if(tv!=null){
+                    tv.setActualvalue(new BigDecimal(actualvalue));
+                    tv.setApportvalue(BigDecimalUtil.add(tv.getCorrectvalue()!=null?tv.getCorrectvalue().doubleValue():0d, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
+                    // 折标值
+                    tv.setStdvalue(BigDecimalUtil.mul(zbxs, tv.getApportvalue().doubleValue()).setScale(digits, BigDecimal.ROUND_HALF_UP));
+                    //单耗值
+                    tv.setUcvalue(BigDecimalUtil.divide(tv.getApportvalue().doubleValue(), sjcl, digits2.intValue()));
+                    tv.setUptime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
+                    tv.setUserid(opuser);
+                    tRmActValueMapper.updateByPrimaryKeySelective(tv);
+                }else{
+                    TRmActValue tRmActValue = new TRmActValue();
+                    tRmActValue.setItemid(itemid);
+                    tRmActValue.setClock(clock);
+                    tRmActValue.setTimegranid(timegranid);
+                    //计算值
+                    tRmActValue.setActualvalue(new BigDecimal(actualvalue));
+                    //修正值
+                    tRmActValue.setCorrectvalue(new BigDecimal(0));
+                    //最终值
+                    tRmActValue.setApportvalue(new BigDecimal(actualvalue));
+                    //折标值
+                    tRmActValue.setStdvalue(BigDecimalUtil.mul(zbxs, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
+                    //单耗值
+                    tRmActValue.setUcvalue(BigDecimalUtil.divide(actualvalue, sjcl, digits2.intValue()));
+                    tRmActValue.setCrman(opuser);
+                    tRmActValue.setRecTime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
+                    //修改次数
+                    // tRmActValue.setModifyflag(new Short("0"));
+                    tRmActValueMapper.insert(tRmActValue);
+                }
+            } catch (Exception e) {
+                logger.error("实绩数据计算错误:itemid-" + itemid + ",clock-" + clock);
+                logger.error("--:" + e.getMessage());
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
 
-	@Override
-	public int getCount(Map<String, Object> params) {
-		return tRmActValueMapper.getCount(params);
-	}
-}
+    @Override
+    public int getCount(Map<String, Object> params) {
+        return tRmActValueMapper.getCount(params);
+    }
+}

+ 128 - 126
src/main/java/com/steerinfo/ems/trmbalancevalue/service/impl/TRmBalanceValueServiceImpl.java

@@ -40,56 +40,58 @@ import org.springframework.transaction.annotation.Transactional;
  */
 @Service(value = "tRmBalanceValueService")
 public class TRmBalanceValueServiceImpl extends BaseServiceImpl<TRmBalanceValue, HashMap<String, Object>> implements ITRmBalanceValueService {
-    private static final Logger logger = LoggerFactory.getLogger(TRmBalanceValueServiceImpl.class);
-    @Autowired
-    private TRmBalanceValueMapper tRmBalanceValueMapper;
+	private static final Logger logger = LoggerFactory.getLogger(TRmBalanceValueServiceImpl.class);
+	@Autowired
+	private TRmBalanceValueMapper tRmBalanceValueMapper;
 
-    @Override
-    protected IBaseMapper<TRmBalanceValue, HashMap<String, Object>> getMapper() {
-        return tRmBalanceValueMapper;
-    }
-    @Autowired
-    private ITRmActItemService tRmActItemService;
+	@Override
+	protected IBaseMapper<TRmBalanceValue, HashMap<String, Object>> getMapper() {
+		return tRmBalanceValueMapper;
+	}
+	@Autowired
+	private ITRmActItemService tRmActItemService;
 
-    @Autowired
-    private IFormulaService formulaService;
-    @Autowired
-    private ITRmWorkprocProductValueService tRmWorkprocProductValueService;
+	@Autowired
+	private IFormulaService formulaService;
+	@Autowired
+	private ITRmWorkprocProductValueService tRmWorkprocProductValueService;
 
-    @Override
+	@Override
 	public PageList<Map<String, Object>> getBalanceitemForPage(Map<String, Object> parameters, Integer pageNum, Integer pageSize) {
-        PageHelper.startPage(pageNum, pageSize);
-        List<Map<String, Object>> rows = tRmBalanceValueMapper.getBalanceitemList(parameters);
-        PageList<Map<String, Object>> pageInfo = new PageList<Map<String, Object>>(rows);
-        return pageInfo;
-    }
+		PageHelper.startPage(pageNum, pageSize);
+		List<Map<String, Object>> rows = tRmBalanceValueMapper.getBalanceitemList(parameters);
+		PageList<Map<String, Object>> pageInfo = new PageList<Map<String, Object>>(rows);
+		return pageInfo;
+	}
 
-    @Override
-    public void state(){
-    	//获取平衡项目
-        List<TRmActItem> bs = tRmActItemService.getitems("B");
-        Calendar c = Calendar.getInstance();
-        c.add(Calendar.DAY_OF_YEAR, -1); // 减1天昨天
-        String clockd = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
-        c.add(Calendar.DAY_OF_YEAR, 1); // 回到今天
-        c.add(Calendar.MONTH, -1); // 减1月获得上月
-        String clockm = new SimpleDateFormat("yyyy-MM").format(c.getTime());
-        c.add(Calendar.MONTH, 1); // 回到当前月
-        c.add(Calendar.YEAR, -1); // 去年
-        String clocky = new SimpleDateFormat("yyyy").format(c.getTime());
-        c.add(Calendar.YEAR, 1); // 回到现在
-        // 生成昨日数据
- 		for (TRmActItem tRmActItem : bs) {
- 			if(tRmActItem.getMintimegranid().equalsIgnoreCase("DAY")) {
- 				this.restatData(tRmActItem.getItemid(), clockd, "DAY");
- 			}
- 		}
- 		// 每月前3天生成上月数据
+	@Override
+	public void state(){
+		//获取平衡项目
+		List<TRmActItem> bs = tRmActItemService.getitems("B");
+		Calendar c = Calendar.getInstance();
+		c.add(Calendar.DAY_OF_YEAR, -1); // 减1天昨天
+		String clockd = new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
+		c.add(Calendar.DAY_OF_YEAR, 1); // 回到今天
+		c.add(Calendar.MONTH, -1); // 减1月获得上月
+		String clockm = new SimpleDateFormat("yyyy-MM").format(c.getTime());
+		c.add(Calendar.MONTH, 1); // 回到当前月
+		c.add(Calendar.YEAR, -1); // 去年
+		String clocky = new SimpleDateFormat("yyyy").format(c.getTime());
+		c.add(Calendar.YEAR, 1); // 回到现在
+		// 生成昨日数据
+		for (TRmActItem tRmActItem : bs) {
+			if(tRmActItem.getMintimegranid().equalsIgnoreCase("DAY")) {
+				this.restatData(tRmActItem.getItemid(), clockd, "DAY");
+			}
+		}
+		// 每月前3天生成上月数据
+		if(c.get(Calendar.DAY_OF_MONTH) <= 3){
 			for (TRmActItem tRmActItem : bs) {
 				if(TimegranidUtils.getTimegranidList(tRmActItem.getMintimegranid()).contains("MONTH")){
 					this.restatData(tRmActItem.getItemid(), clockm, "MONTH");
 				}
 			}
+		}
 		// 每年前3天生成去年数据
 		if(c.get(Calendar.DAY_OF_YEAR) <= 3){
 			for (TRmActItem tRmActItem : bs) {
@@ -97,29 +99,29 @@ public class TRmBalanceValueServiceImpl extends BaseServiceImpl<TRmBalanceValue,
 			}
 		}
 		logger.info("平衡维护数据定时任务结束....");
-    }
-    
+	}
+
 	@Override
 	public TRmBalanceValue updateForUKey(TRmBalanceValue tRmBalanceValue) {
-        this.getMapper().updateByPrimaryKeySelective(tRmBalanceValue);
-        return tRmBalanceValueMapper.selectByUPrimaryKey(tRmBalanceValue);
+		this.getMapper().updateByPrimaryKeySelective(tRmBalanceValue);
+		return tRmBalanceValueMapper.selectByUPrimaryKey(tRmBalanceValue);
 	}
 
-    @Override
-    public List<Map<String, Object>> getBalanceitemList(Map<String, Object> parameters) {
-        return tRmBalanceValueMapper.getBalanceitemList(parameters);
-    }
+	@Override
+	public List<Map<String, Object>> getBalanceitemList(Map<String, Object> parameters) {
+		return tRmBalanceValueMapper.getBalanceitemList(parameters);
+	}
 
-    public Double getSumvalue(String clock,String itemid) {
-    	HashMap<String, Object>maps = new HashMap<String, Object>();
-    	 maps.put("clock", clock);
-    	 maps.put("itemid", itemid);
-    	 Double sumvalue = tRmBalanceValueMapper.getSumvalue(maps);
-    	 if(null == sumvalue) {
-    		 return 0.0;
-    	 }
-    	 return sumvalue;
-    }
+	public Double getSumvalue(String clock,String itemid) {
+		HashMap<String, Object>maps = new HashMap<String, Object>();
+		maps.put("clock", clock);
+		maps.put("itemid", itemid);
+		Double sumvalue = tRmBalanceValueMapper.getSumvalue(maps);
+		if(null == sumvalue) {
+			return 0.0;
+		}
+		return sumvalue;
+	}
 
 	@Override
 	public List<Map<String, Object>> getItem(HashMap<String, Object> parameters) {
@@ -136,74 +138,74 @@ public class TRmBalanceValueServiceImpl extends BaseServiceImpl<TRmBalanceValue,
 		if(t!=null){
 			Short digits = t.getDigits() == null ? 2 : t.getDigits();
 			HashMap<String, Object> id = new HashMap<String, Object>();
-    		id.put("clock", clock);
-    		id.put("timegranid", timegranid);
-    		id.put("itemid", itemid);
-            // 计算值
-            Double actualvalue = 0d;
-            if(!TimegranidUtils.getTimegranidList(t.getMintimegranid()).contains(timegranid.toUpperCase())){
-            	return "时间粒度错误";
-            }else if(t.getMintimegranid().equalsIgnoreCase(timegranid)){
-            	actualvalue = formulaService.getValByItemid(t.getItemid(), timegranid, clock, 0);
+			id.put("clock", clock);
+			id.put("timegranid", timegranid);
+			id.put("itemid", itemid);
+			// 计算值
+			Double actualvalue = 0d;
+			if(!TimegranidUtils.getTimegranidList(t.getMintimegranid()).contains(timegranid.toUpperCase())){
+				return "时间粒度错误";
+			}else if(t.getMintimegranid().equalsIgnoreCase(timegranid)){
+				actualvalue = formulaService.getValByItemid(t.getItemid(), timegranid, clock, 0);
 			}else{
-            	// 此时计算值为小粒度累加
-            	HashMap<String, Object> maps = new HashMap<>();
-            	if(timegranid.equalsIgnoreCase("MONTH")){
-    	            maps.put("itemid", itemid);
-    	            maps.put("clock", clock);
-    	            maps.put("timegranid", "DAY");
-            	}else if(timegranid.equalsIgnoreCase("YEAR")){
-            		maps.put("itemid", itemid);
-    	            maps.put("clock", clock);
-    	            maps.put("timegranid", "MONTH");
-            	}
-            	actualvalue = tRmBalanceValueMapper.getSumvalue(maps);
-            }
-            // 折标系数
-            Double zbxs = formulaService.getValByItemid(t.getEnergyid(),timegranid, clock, 0);
-            if (zbxs==null){
-                zbxs=0.0;
-            }
-            Map<String, BigDecimal> dh = tRmWorkprocProductValueService.getOutPut(t.getWorkprocid(), clock, timegranid,"R");
-            //实绩产量
-            Double  sjcl  = dh.get("SJCL").doubleValue();
-            //累计产量
-            //Double  ljcl = dh.get("LJCL").doubleValue();
-            try{
-	    		// 数据是否已存在
-	    		TRmBalanceValue tv = tRmBalanceValueMapper.selectByPrimaryKey(id);
-	    		if(tv!=null){
-		            tv.setActualvalue(new BigDecimal(actualvalue));
-		            tv.setApportvalue(BigDecimalUtil.add(tv.getCorrectvalue()!=null?tv.getCorrectvalue().doubleValue():0d, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
-		            // 折标值
-		            tv.setStdvalue(BigDecimalUtil.mul(zbxs, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
-		            //单耗值
-		            tv.setUcvalue(BigDecimalUtil.divide(actualvalue, sjcl, digits.intValue()));
-		            tv.setUptime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
-		            tv.setUserid(JwtUtil.getUseridByToken());
-		            tRmBalanceValueMapper.updateByPrimaryKeySelective(tv);
-	    		}else{
-	    			tv = new TRmBalanceValue();
-	    			tv.setItemid(itemid);
-	    			tv.setClock(clock);
-	    			tv.setTimegranid(timegranid);
-		            //计算值
-	    			tv.setActualvalue(new BigDecimal(actualvalue));
-		            //修正值
-	    			tv.setCorrectvalue(new BigDecimal(0));
-		            //最终值
-	    			tv.setApportvalue(new BigDecimal(actualvalue));
-		            //折标值
-	    			tv.setStdvalue(BigDecimalUtil.mul(zbxs, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
-		            //单耗值
-	    			tv.setUcvalue(BigDecimalUtil.divide(actualvalue, sjcl, digits.intValue()));
-	    			tv.setRecTime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
-	    			tv.setCrman(JwtUtil.getUseridByToken());
-		            //修改次数
-		            // trm.setModifyflag(new Short("0"));
-		            tRmBalanceValueMapper.insert(tv);
-	    		}
-            } catch (Exception e) {
+				// 此时计算值为小粒度累加
+				HashMap<String, Object> maps = new HashMap<>();
+				if(timegranid.equalsIgnoreCase("MONTH")){
+					maps.put("itemid", itemid);
+					maps.put("clock", clock);
+					maps.put("timegranid", "DAY");
+				}else if(timegranid.equalsIgnoreCase("YEAR")){
+					maps.put("itemid", itemid);
+					maps.put("clock", clock);
+					maps.put("timegranid", "MONTH");
+				}
+				actualvalue = tRmBalanceValueMapper.getSumvalue(maps);
+			}
+			// 折标系数
+			Double zbxs = formulaService.getValByItemid(t.getEnergyid(),timegranid, clock, 0);
+			if (zbxs==null){
+				zbxs=0.0;
+			}
+			Map<String, BigDecimal> dh = tRmWorkprocProductValueService.getOutPut(t.getWorkprocid(), clock, timegranid,"R");
+			//实绩产量
+			Double  sjcl  = dh.get("SJCL").doubleValue();
+			//累计产量
+			//Double  ljcl = dh.get("LJCL").doubleValue();
+			try{
+				// 数据是否已存在
+				TRmBalanceValue tv = tRmBalanceValueMapper.selectByPrimaryKey(id);
+				if(tv!=null){
+					tv.setActualvalue(new BigDecimal(actualvalue));
+					tv.setApportvalue(BigDecimalUtil.add(tv.getCorrectvalue()!=null?tv.getCorrectvalue().doubleValue():0d, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
+					// 折标值
+					tv.setStdvalue(BigDecimalUtil.mul(zbxs, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
+					//单耗值
+					tv.setUcvalue(BigDecimalUtil.divide(actualvalue, sjcl, digits.intValue()));
+					tv.setUptime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
+					tv.setUserid(JwtUtil.getUseridByToken());
+					tRmBalanceValueMapper.updateByPrimaryKeySelective(tv);
+				}else{
+					tv = new TRmBalanceValue();
+					tv.setItemid(itemid);
+					tv.setClock(clock);
+					tv.setTimegranid(timegranid);
+					//计算值
+					tv.setActualvalue(new BigDecimal(actualvalue));
+					//修正值
+					tv.setCorrectvalue(new BigDecimal(0));
+					//最终值
+					tv.setApportvalue(new BigDecimal(actualvalue));
+					//折标值
+					tv.setStdvalue(BigDecimalUtil.mul(zbxs, actualvalue).setScale(digits, BigDecimal.ROUND_HALF_UP));
+					//单耗值
+					tv.setUcvalue(BigDecimalUtil.divide(actualvalue, sjcl, digits.intValue()));
+					tv.setRecTime(DateUtils.dateStr(new Date(),"yyyy-MM-dd HH:mm:ss"));
+					tv.setCrman(JwtUtil.getUseridByToken());
+					//修改次数
+					// trm.setModifyflag(new Short("0"));
+					tRmBalanceValueMapper.insert(tv);
+				}
+			} catch (Exception e) {
 				logger.error("平衡数据计算错误:itemid-" + itemid + ",clock-" + clock);
 				logger.error("--:" + e.getMessage());
 				e.printStackTrace();
@@ -216,4 +218,4 @@ public class TRmBalanceValueServiceImpl extends BaseServiceImpl<TRmBalanceValue,
 	public int getCount(Map<String, Object> params) {
 		return tRmBalanceValueMapper.getCount(params);
 	}
-}
+}

+ 88 - 0
src/main/java/com/steerinfo/feigen/model/GxWeight.java

@@ -0,0 +1,88 @@
+package com.steerinfo.feigen.model;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+public class GxWeight {
+    @ApiModelProperty(value="主键ID",required=true)
+    private String id;
+    public String getId() {
+        return id;
+    }
+    public void setId(String id) {
+        this.id = id == null ? null : id.trim();
+    }
+    private String type;
+    private BigDecimal weight;
+    private String prodate;
+    private String materialcode;
+    private String unit;
+    private String materialname;
+    private String fid;
+    private String roundid;
+
+    public String getRoundid() {
+        return roundid;
+    }
+
+    public void setRoundid(String roundid) {
+        this.roundid = roundid;
+    }
+
+    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;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public BigDecimal getWeight() {
+        return weight;
+    }
+
+    public void setWeight(BigDecimal weight) {
+        this.weight = weight;
+    }
+
+    public String getProdate() {
+        return prodate;
+    }
+
+    public void setProdate(String prodate) {
+        this.prodate = prodate;
+    }
+}

+ 5 - 6
src/main/java/com/steerinfo/feigen/model/LgWeight.java

@@ -15,7 +15,7 @@ public class LgWeight {
     }
     private String type;
     private BigDecimal weight;
-    private String date;
+    private String prodate;
     private String materialcode;
     private String unit;
     private String materialname;
@@ -78,12 +78,11 @@ public class LgWeight {
         this.weight = weight;
     }
 
-    public String getDate() {
-        return date;
+    public String getProdate() {
+        return prodate;
     }
 
-    public void setDate(String date) {
-        this.date = date;
+    public void setProdate(String prodate) {
+        this.prodate = prodate;
     }
-
 }

+ 17 - 0
src/main/java/com/steerinfo/feigen/service/GxWeightFeigenService.java

@@ -0,0 +1,17 @@
+package com.steerinfo.feigen.service;
+
+import com.steerinfo.feigen.model.GxWeight;
+import com.steerinfo.feigen.model.LgWeight;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+@FeignClient("xt-ems-datasource")
+@Component
+public interface GxWeightFeigenService {
+    @GetMapping("v1/gxweight/QueryWeightforRound")
+    public List<GxWeight> QueryWeightforRound(@RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime);
+}

+ 1 - 0
src/main/java/com/steerinfo/task/SpringCronTask.java

@@ -348,6 +348,7 @@ public class SpringCronTask implements SchedulingConfigurer{
 					 long start = System.currentTimeMillis();
 					 try {
 						 emsProdplanRoundWeightService.getWeightForLg();
+						 emsProdplanRoundWeightService.getWeightForGx();
 					 } catch (Exception e) {
 						 e.printStackTrace();
 					 }