Browse Source

lrl -2021-11-12

lirl 3 years ago
parent
commit
8d0fc1669c

+ 1 - 2
src/main/java/com/steerinfo/ems/emsgmpcjh/mapper/EmsGmPcJhMapper.xml

@@ -774,7 +774,7 @@
               </if>
                 and state in ('2','3')
             </where>
-       order by t1.id desc
+        order by t1.JH_TIME desc
   </select>
   <!--国贸计划查询-->
 <select id="getXsDdDate" parameterType="java.util.HashMap" resultType="Map">
@@ -849,7 +849,6 @@
         <if test="state != null and state != ''">
           and t.state in (${state})
         </if>
-
         and t.id like '%G-%'
       </where>
       order by t.jh_time desc,t.id asc

+ 115 - 0
src/main/java/com/steerinfo/ems/emsprodplanyear/controller/EmsProdplanYearController.java

@@ -340,6 +340,121 @@ public class EmsProdplanYearController extends BaseRESTfulController {
             }
             // 因为一行数据由多条数据组成,所以这里为了确保数据准确性,应该再根据编号查询一次新的数据
             EmsProdplanYear emsProdplanYear = emsProdplanYearService.getById(model.getNo());
+//            Calendar c = Calendar.getInstance();
+//            int dayMax = 0;
+//            try {
+//                dayMax = emsProdplanYearService.getDaysOfMonth(emsProdplanYear.getYearmonth());
+//            } catch (ParseException e) {
+//                e.printStackTrace();
+//            }
+//            Integer sumWeight = 0;
+//            EmsProdplanMonth maxSqno =  emsProdplanMonthService.getMaxSqno();
+//            String unit = "008";
+//            String productid = "";
+//            String workProcid = "";
+//            switch (model.getParentid()) {
+//                case "LG":
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="钢坯";
+//                    unit="008";
+//                    workProcid = "AT2004";
+//                    break;
+//                case "LT":
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="生铁";
+//                    unit="008";
+//                    break;
+//                case "SJ":
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="烧结矿";
+//                    unit="008";
+//                    break;
+//                case "ZG" :
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="线材";
+//                    if(model.getLine().equals("AT2007")) {
+//                        productid="H型钢";
+//                    }
+//                    unit="008";
+//                    break;
+//                case "FDC" :
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="发电量";
+//                    unit="006";
+//                    break;
+//                case "JCS" :
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="白灰";
+//                    unit="008";
+//                    break;
+//                case "JCW" :
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="矿渣粉";
+//                    unit="008";
+//                    workProcid = model.getProductid();
+//                    break;
+//                case "JJZ" :
+//                    sumWeight = model.getWeight1().intValue() + model.getWeight2().intValue();
+//                    productid="焦炭";
+//                    unit="008";
+//                    workProcid = "AT1007";
+//                    break;
+//                case "JJF" :
+//                    sumWeight = model.getWeight().intValue();
+//                    productid="焦油";
+//                    if(model.getLine().equals("AT3009")){
+//                        productid="粗苯";
+//                    }
+//                    if(model.getLine().equals("AT3010")){
+//                        productid="硫铵";
+//                    }
+//                    unit="008";
+//                    //workProcid = "AT1007";
+//                    break;
+//                default: break;
+//            }
+//            int[] avgWeight = emsProdplanYearService.avgWeight(sumWeight,dayMax);
+//            for (int k = 0;k < dayMax;k++) {
+//                EmsProdplanMonth monModel = new EmsProdplanMonth();
+//                c.setTime(model.getYearmonth());
+//                c.add(Calendar.DATE, k);
+//                monModel.setMay(c.getTime());
+//                monModel.setUnit(unit);
+//                monModel.setProductid(productid);
+//                monModel.setWeightMonth(model.getWeight());
+//                if (workProcid.equals("")) {
+//                    monModel.setWorkprocid(model.getLine());
+//                } else {
+//                    monModel.setWorkprocid(workProcid);
+//                    monModel.setWeightMonth(BigDecimal.valueOf(sumWeight));
+//                }
+//                monModel.setWeightDay(BigDecimal.valueOf(avgWeight[k]));
+//                monModel.setKxf_weight(BigDecimal.valueOf(avgWeight[k]));
+//                monModel.setYxf_weight(BigDecimal.valueOf(0));
+//                monModel.setJxdays("0");
+//                monModel.setMemo("根据年计划,系统自动生成。");
+//                monModel.setCreateman("系统");
+//                monModel.setCreatetime(new Date());
+//                monModel.setSqno(maxSqno.getSqno()+k);
+//                Map monMap = new HashMap();
+//                monMap.put("may",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
+//                monMap.put("workprocid","'"+monModel.getWorkprocid()+"'");
+//                monMap.put("productid",monModel.getProductid());
+//                monMap.put("startTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
+//                monMap.put("endTime",new SimpleDateFormat("yyyy-MM-dd").format(monModel.getMay()));
+//                List<EmsProdplanMonth> monList = emsProdplanMonthMapper.selectByParameters(monMap);
+//                if(monList.size()<=0){
+//                    EmsProdplanMonth emsProdplanMonth = emsProdplanMonthService.add(monModel);
+//                } else {
+//                    if(model.getParentid().equals("LG") || model.getParentid().equals("JJZ")) {
+//                        monModel.setKxf_weight(monList.get(0).getKxf_weight().add(monModel.getKxf_weight()));
+//                        monModel.setWeightMonth(monList.get(0).getWeightMonth().add(monModel.getWeightMonth()));
+//                        monModel.setWeightDay(monList.get(0).getWeightDay().add(monModel.getWeightDay()));
+//                        monModel.setId(monList.get(0).getId());
+//                        emsProdplanMonthService.modify(monModel);
+//                    }
+//                }
+//            }
             emsProdplanYear.setWeight(model.getWeight());
             emsProdplanYear.setWeight1(model.getWeight1());
             emsProdplanYear.setWeight2(model.getWeight2());

+ 2 - 2
src/main/java/com/steerinfo/ems/foldthevalues/controller/FoldTheValuesController.java

@@ -115,8 +115,8 @@ public class FoldTheValuesController extends BaseRESTfulController {
     @GetMapping("/aaa")
     public RESTfulResult getdate() throws ScriptException, ParseException {
 //        foldTheValuesService.getDate();
-//        foldTheValuesService.getMonthDate();
-        foldTheValuesService.getDataForwl();
+         //foldTheValuesService.getMonthData();
+           //foldTheValuesService.getDataForwl();
         //foldTheValuesService.insertNewDate();
         return  success();
     }

+ 5 - 0
src/main/java/com/steerinfo/ems/foldthevalues/mapper/FoldTheValuesMapper.java

@@ -55,4 +55,9 @@ public interface FoldTheValuesMapper extends IBaseMapper<FoldTheValues, String>
      */
     List<FoldTheValues> getDateForwl(HashMap<String,Object> hashMap);
 
+    /**
+     * 获取这个月的平均值项
+     */
+    public String getavgDate(HashMap<String,Object> hashMap);
+
 }

+ 13 - 0
src/main/java/com/steerinfo/ems/foldthevalues/mapper/FoldTheValuesMapper.xml

@@ -483,4 +483,17 @@ select t2.*
             where
             t.materialno in ('X005', 'X018', 'X010'))
   </select>
+  <select id="getavgDate" parameterType="java.util.HashMap" resultType="String">
+    select  listagg(t.ESTIMATEDVALUE,',') as avg  from
+    (select distinct t.estimatedvalue
+          from FOLD_THE_VALUES t
+          <where>
+            <if test="startTime != null and startTime != '' and endTime != null and endTime !=''">
+              and t.clock between #{startTime} and #{endTime}
+            </if>
+            <if test="materialno != null and materialno != ''">
+              and t.materialno = #{materialno}
+            </if>
+          </where>) t
+  </select>
 </mapper>

+ 40 - 39
src/main/java/com/steerinfo/ems/foldthevalues/service/impl/FoldTheValuesServiceImpl.java

@@ -140,12 +140,13 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
                 foldTheValue.setCode(df.format(jse.eval(foldTheValues.getEstimatedvalue()+"/"+days+"*0.03412/100")).toString());
             }
             if(foldTheValues.getMaterialsource().equals("机焦厂")){
-                foldTheValue.setCode(df.format(jse.eval("(29727 + (10 - "+foldTheValues.getEstimatedvalue()+") * 334) / 29307.6")).toString());
+                foldTheValue.setCode(df.format(jse.eval("(29727+(10-"+foldTheValues.getEstimatedvalue()+"/"+days+")*334)/29307.6")));
             }
             foldTheValue.setIsavailable("0");
             foldTheValue.setUnitid("032");
-            foldTheValue.setDescription("低热值");
-            foldTheValue.setBz("取本月热值检测结果平均值进行热值换算");
+            foldTheValue.setDescription("灰分");
+            hashMap.put("materialno",foldTheValues.getMaterialno());
+            foldTheValue.setBz("取本月热值检测结果平均值("+foldTheValuesMapper.getavgDate(hashMap)+")进行热值换算");
             foldTheValue.setMaterialno(foldTheValues.getMaterialno());
             foldTheValue.setMaterialsource(foldTheValues.getMaterialsource());
             foldTheValue.setTimegranid("MONTH");
@@ -170,7 +171,7 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
         String clock  = DateUtils.dateStr(calendar.getTime(),"yyyy-MM-dd");
         HashMap<String,Object> hashMap =  new HashMap<>();
           hashMap.put("clock",clock);
-        List<FoldTheValues> dateForwl = foldTheValuesMapper.getDateForwl(null);
+        List<FoldTheValues> dateForwl = foldTheValuesMapper.getDateForwl(hashMap);
         FoldTheValues foldTheValue =  new FoldTheValues();
         for (FoldTheValues foldTheValues : dateForwl) {
             foldTheValue.setId(foldTheValues.getId());
@@ -181,44 +182,44 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
             foldTheValue.setEstimatedvalue(foldTheValues.getEstimatedvalue());
             foldTheValue.setTimegranid("DAY");
             foldTheValue.setUnitid("032");
-            foldTheValue.setDescription("低热值");
+            foldTheValue.setDescription("灰分");
             foldTheValue.setBz("采用当天热值进行换算,当天无检测结果,则取最近热值进行换算");
             foldTheValuesMapper.insert(foldTheValue);
         }
         
     }
-    //获取折标值
-    public String getzbz(EmsCalorificValue emsCalorificValue) throws ScriptException {
-        ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
-        //首先获取公式
-        NjFormula njFormula = njFormulaMapper.getByMateralNo(emsCalorificValue.getMaterialno());
-        String formula = njFormula.getCode();
-        if (null == formula ){
-            return  null;
-        }
-        HashMap map =  new HashMap();
-        map.put("wtbh",emsCalorificValue.getWtbh());
-        if(formula.contains("CO") == true){
-            map.put("item","CO");
-            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" : emsCalorificValueMapper.getValue(map);
-            formula = formula.replace("CO", value);
-        }
-        if (formula.contains("H2") == true){
-            map.put("item","H2");
-            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" : emsCalorificValueMapper.getValue(map);
-            formula = formula.replace("H2", value);
-        }
-        if (formula.contains("CH4") == true){
-            map.put("item","CH4");
-            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" : emsCalorificValueMapper.getValue(map);
-            formula = formula.replace("CH4", value);
-        }
-        if (formula.contains("N2") == true){
-            map.put("item","N2");
-            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" :emsCalorificValueMapper.getValue(map);
-            formula = formula.replace("N2", value);
-        }
-        DecimalFormat df   = new DecimalFormat("0.00");
-        return  df.format(jse.eval(formula)).toString();
-    }
+//    //获取折标值 (该方法已经弃用)
+//    public String getzbz(EmsCalorificValue emsCalorificValue) throws ScriptException {
+//        ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
+//        //首先获取公式
+//        NjFormula njFormula = njFormulaMapper.getByMateralNo(emsCalorificValue.getMaterialno());
+//        String formula = njFormula.getCode();
+//        if (null == formula ){
+//            return  null;
+//        }
+//        HashMap map =  new HashMap();
+//        map.put("wtbh",emsCalorificValue.getWtbh());
+//        if(formula.contains("CO") == true){
+//            map.put("item","CO");
+//            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" : emsCalorificValueMapper.getValue(map);
+//            formula = formula.replace("CO", value);
+//        }
+//        if (formula.contains("H2") == true){
+//            map.put("item","H2");
+//            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" : emsCalorificValueMapper.getValue(map);
+//            formula = formula.replace("H2", value);
+//        }
+//        if (formula.contains("CH4") == true){
+//            map.put("item","CH4");
+//            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" : emsCalorificValueMapper.getValue(map);
+//            formula = formula.replace("CH4", value);
+//        }
+//        if (formula.contains("N2") == true){
+//            map.put("item","N2");
+//            String value = emsCalorificValueMapper.getValue(map) == null ? "0.00" :emsCalorificValueMapper.getValue(map);
+//            formula = formula.replace("N2", value);
+//        }
+//        DecimalFormat df   = new DecimalFormat("0.00");
+//        return  df.format(jse.eval(formula)).toString();
+//    }
 }