Selaa lähdekoodia

Merge branch 'master' of https://git.steerinfo.com/XTEMS/xt-ems-api

QuietShadow 3 vuotta sitten
vanhempi
commit
93e3c9e0cf

+ 3 - 0
src/main/java/com/steerinfo/ems/emsgmpcjh/mapper/EmsGmPcJhMapper.xml

@@ -768,6 +768,9 @@
             <where>
               <if test="workprocType != null and workprocType!= ''">
                 and WORKPROC_TYPE in (${workprocType})
+              </if>
+              <if test="id != null and id != ''">
+                and id = #{id}
               </if>
                 and state in ('2','3')
             </where>

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

@@ -114,8 +114,10 @@ public class FoldTheValuesController extends BaseRESTfulController {
 
     @GetMapping("/aaa")
     public RESTfulResult getdate() throws ScriptException, ParseException {
-        foldTheValuesService.getDate();
-        foldTheValuesService.getMonthDate();
+//        foldTheValuesService.getDate();
+//        foldTheValuesService.getMonthDate();
+        foldTheValuesService.getDataForwl();
+        //foldTheValuesService.insertNewDate();
         return  success();
     }
     @ApiOperation(value="获取列表", notes="分页模糊查询")
@@ -126,6 +128,13 @@ public class FoldTheValuesController extends BaseRESTfulController {
     //@RequiresPermissions("foldthevalues:view")
     @GetMapping(value = "/getDateForPage")
     public RESTfulResult getDateForPage (@RequestParam HashMap<String, Object> parmas,Integer pageNum, Integer pageSize) {
+        if(parmas.get("energyid") != null && !parmas.get("energyid").toString().isEmpty()){
+            String energyid = parmas.get("energyid").toString();
+            if(!energyid.startsWith("'")){
+                energyid = "'" + energyid.replaceAll(",", "','").replaceAll(",", "','") + "'";
+            }
+            parmas.put("energyid", energyid);
+        }
         PageList<Map<String, Object>> forPage = foldTheValuesService.getDateForPage(parmas, pageNum, pageSize);
         return success(forPage);
     }

+ 7 - 2
src/main/java/com/steerinfo/ems/foldthevalues/mapper/FoldTheValuesMapper.java

@@ -23,7 +23,7 @@ public interface FoldTheValuesMapper extends IBaseMapper<FoldTheValues, String>
      * 丛质量数据中获取新的数据
      * @return
      */
-    List<FoldTheValues> getNewDate();
+    List<FoldTheValues> getNewData();
 
     /**
      *  获取最近最新的数据
@@ -48,6 +48,11 @@ public interface FoldTheValuesMapper extends IBaseMapper<FoldTheValues, String>
     /**
      * 查询月折标值数据
      */
-    List<FoldTheValues> getDateForMoth(HashMap<String,Object> hashMap);
+    List<FoldTheValues> getDataForMoth(HashMap<String,Object> hashMap);
+
+    /**
+     * 获取物料得折标值
+     */
+    List<FoldTheValues> getDateForwl(HashMap<String,Object> hashMap);
 
 }

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

@@ -352,8 +352,8 @@
      <if test = "startTime != null and startTime != '' and endTime != null and endTime != '' " >
       and t.clock between #{startTime} and #{endTime}
       </if >
-      <if test = "energyname != null and energyname != '' " >
-      and t1.name = #{energyname}
+      <if test = "energyid != null and energyid != '' " >
+      and t.materialno in  (${energyid})
       </if >
       <if test="timegranid != null and timegranid != ''">
       and t.timegranid = #{timegranid}
@@ -362,10 +362,10 @@
     order by t.clock desc
   </select>
   <!---->
-  <select id="getNewDate" resultMap="BaseResultMap">
+  <select id="getNewData" resultMap="BaseResultMap">
   select t.batchno as id,
           '三电厂' as materialsource,
-          to_char(to_date(t.monitordate, 'yyyymmdd hh24miss'),'yyyy-mm-dd') as clock,
+          to_char(to_date(t.monitordate, 'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd') as clock,
           t.monitoringvalue as estimatedvalue,
           (t.MONITORINGVALUE * 0.03412 / 100) as code,
           t.powersystemname as materialno
@@ -431,7 +431,7 @@
     </where>
   </select>
   <!--获取月指标数据-->
-  <select id="getDateForMoth" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+  <select id="getDataForMoth" parameterType="java.util.HashMap" resultMap="BaseResultMap">
        select sum(t.ESTIMATEDVALUE) as estimatedvalue, t.MATERIALSOURCE,t.MATERIALNO
          from FOLD_THE_VALUES t
         <where>
@@ -442,4 +442,45 @@
         </where>
         group by t.MATERIALNO,MATERIALSOURCE
   </select>
+  <!--获取物料日折标数据-->
+  <select id="getDateForwl" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+select t2.*
+  from (select  to_char(t.id, 'yyyymmdd') || t.MATERIALNO as id,
+               t.code as ESTIMATEDVALUE,
+                to_char(ROUND(((29727 + (10 - t.code) * 334) / 29307.6), 3),
+                '0.999') as code,
+               t.MATERIALNO,
+               MATERIALSOURCE,
+               to_char(t.id, 'yyyy-mm-dd') as clock
+          from (select Dates as id,
+                       code,
+                       MATERIALNO,
+                       '机焦厂' as MATERIALSOURCE
+                  from EMS_SCQK_JJ unpivot(code for MATERIALNO in(A as
+                                                                  'X010'))
+                union all
+                select Dates as id,
+                       code,
+                       MATERIALNO,
+                       '机焦厂' as MATERIALSOURCE
+                  from EMS_SCQK_JJ unpivot(code for MATERIALNO in(JM_HF as
+                                                                  'X005'))
+                union all
+                select Dates as id,
+                       code,
+                       MATERIALNO,
+                       '机焦厂' as MATERIALSOURCE
+                  from EMS_SCQK_JJ unpivot(code for MATERIALNO in(A as
+                                                                  'X018'))) t
+               <where>
+               <if test="clock != null and clock != ''">
+                 and  t.id = to_date(#{clock}, 'yyyy-mm-dd')
+               </if>
+              </where>) t2
+            where t2.id not in
+             (select distinct t.id
+            from FOLD_THE_VALUES t
+            where
+            t.materialno in ('X005', 'X018', 'X010'))
+  </select>
 </mapper>

+ 5 - 2
src/main/java/com/steerinfo/ems/foldthevalues/service/IFoldTheValuesService.java

@@ -9,6 +9,7 @@ import java.text.ParseException;
 import java.util.Date;
 import java.math.BigDecimal;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,10 +26,12 @@ import java.util.Map;
  * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  */
 public interface IFoldTheValuesService extends IBaseService<FoldTheValues, String>{
-    public void getDate()throws ScriptException;
+    public void getData()throws ScriptException;
 
     public PageList<Map<String, Object>> getDateForPage(HashMap<String, Object> parmas, Integer pageNum,
                                                    Integer pageSize);
-    public void getMonthDate() throws ScriptException, ParseException;
+    public void getMonthData() throws ScriptException, ParseException;
+    public void getDataForwl();
+    public void insertNewDate();
 
 }

+ 45 - 7
src/main/java/com/steerinfo/ems/foldthevalues/service/impl/FoldTheValuesServiceImpl.java

@@ -52,8 +52,9 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
         return foldTheValuesMapper;
     }
 
-    public void getDate() throws ScriptException {
-        List<FoldTheValues> newDate = foldTheValuesMapper.getNewDate();
+    // 获取每日得动力折标值
+    public void getData() throws ScriptException {
+        List<FoldTheValues> newDate = foldTheValuesMapper.getNewData();
         DecimalFormat df   = new DecimalFormat("0.000");
         FoldTheValues foldTheValue = new FoldTheValues();
         for (FoldTheValues foldTheValues : newDate) {
@@ -75,7 +76,6 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
 
             }
         }
-        this.insertNewDate();
     }
     public void insertNewDate(){
         Calendar calendar = Calendar.getInstance();
@@ -112,8 +112,8 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
         return null;
     }
 
-    //获取每月的日数据
-    public void getMonthDate() throws ParseException, ScriptException {
+    //获取动力每月的得折标值
+    public void getMonthData() throws ParseException, ScriptException {
         HashMap<String,Object> hashMap =  new HashMap<>();
         //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
         Calendar  cal_1=Calendar.getInstance();//获取当前日期
@@ -129,14 +129,19 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
         int days = DateUtils.getDaysOfMonth(cal_1.getTime());
         hashMap.put("startTime",startTime);
         hashMap.put("endTime",endTime);
-        List<FoldTheValues> dateForMoth = foldTheValuesMapper.getDateForMoth(hashMap);
+        List<FoldTheValues> dateForMoth = foldTheValuesMapper.getDataForMoth(hashMap);
         ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
         DecimalFormat df   = new DecimalFormat("0.000");
         FoldTheValues foldTheValue =  new FoldTheValues();
         for (FoldTheValues foldTheValues : dateForMoth) {
             foldTheValue.setId(month+foldTheValues.getMaterialno());
             foldTheValue.setClock(clock);
-            foldTheValue.setCode(df.format(jse.eval(foldTheValues.getEstimatedvalue()+"/"+days+"*0.03412/100")).toString());
+            if(foldTheValues.getMaterialsource().equals("三电厂")){
+                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.setIsavailable("0");
             foldTheValue.setUnitid("032");
             foldTheValue.setDescription("低热值");
@@ -149,6 +154,39 @@ public class FoldTheValuesServiceImpl extends BaseServiceImpl<FoldTheValues, Str
         }
 
     }
+
+//    //对于不同能介给不同的计算方式
+//    public String getjsz(FoldTheValues foldTheValues){
+//        String str = "";
+//        if(foldTheValues.getMaterialsource().equals("三电厂")){
+//            str = ""
+//        }
+//    }
+
+    //获取物料每日得折标值
+    public void getDataForwl(){
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.DATE, -1);
+        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);
+        FoldTheValues foldTheValue =  new FoldTheValues();
+        for (FoldTheValues foldTheValues : dateForwl) {
+            foldTheValue.setId(foldTheValues.getId());
+            foldTheValue.setMaterialsource(foldTheValues.getMaterialsource());
+            foldTheValue.setMaterialno(foldTheValues.getMaterialno());
+            foldTheValue.setCode(foldTheValues.getCode());
+            foldTheValue.setClock(foldTheValues.getClock());
+            foldTheValue.setEstimatedvalue(foldTheValues.getEstimatedvalue());
+            foldTheValue.setTimegranid("DAY");
+            foldTheValue.setUnitid("032");
+            foldTheValue.setDescription("低热值");
+            foldTheValue.setBz("采用当天热值进行换算,当天无检测结果,则取最近热值进行换算");
+            foldTheValuesMapper.insert(foldTheValue);
+        }
+        
+    }
     //获取折标值
     public String getzbz(EmsCalorificValue emsCalorificValue) throws ScriptException {
         ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");

+ 3 - 2
src/main/java/com/steerinfo/ems/tcm0348/mapper/TCm0348Mapper.xml

@@ -118,7 +118,7 @@
       </if>
       <if test="startTime != null and startTime != '' and endTime != null and endTime !='' ">
         and
-        to_date(MONITORDATE,'yyyymmdd hh24:mi:ss')
+        to_date(MONITORDATE,'yyyy-mm-dd hh24:mi:ss')
         between to_date(#{startTime}, 'yyyy-mm-dd') and to_date(#{endTime}, 'yyyy-mm-dd')
       </if>
     </where>
@@ -912,7 +912,8 @@
          t2.powercode as POWERSYSTEMNAME,
          t1.POWERMONITORCODE as POWERMONITORNAME ,
          t.ITEMNAME as SITEM,
-         BFHYD_HYRQ as MONITORDATE,
+         to_char(to_date(BFHYD_HYRQ, 'yyyymmdd hh24miss'),
+                       'yyyy-mm-dd hh24:mi:ss')  as MONITORDATE,
          t.BFHYD_ZJDH as BATCHNO,
          t.MONITORINGVALUE,
          t3.unit as UNIT,

+ 4 - 2
src/main/java/com/steerinfo/task/SpringCronTask.java

@@ -310,11 +310,13 @@ public class SpringCronTask implements SchedulingConfigurer{
 				else if(taskId.equalsIgnoreCase("124")){
 					 long start = new Date().getTime();
 					 try {
-					 	 foldTheValuesService.getDate();
+					 	 foldTheValuesService.getData();
+					 	 foldTheValuesService.getDataForwl();
 						 Calendar c = Calendar.getInstance();
 						 if(c.get(Calendar.DATE) == 1){
-						 foldTheValuesService.getMonthDate();
+						 foldTheValuesService.getMonthData();
 						 }
+						 foldTheValuesService.insertNewDate();
 					 } catch (Exception e) {
 						 e.printStackTrace();
 					 }

+ 6 - 6
src/main/resources/bootstrap.yml

@@ -10,11 +10,11 @@ spring:
       #默认值为0.1f,现在为了测试设置100%采集
       percentage: 1.0
   cloud:
-    config:
-      fail-fast: true
-      discovery:
-        enabled: true
-        service-id: config-server
+#    config:
+#      fail-fast: true
+#      discovery:
+#        enabled: true
+#        service-id: config-server
     bus:
       trace:
         enabled: false
@@ -41,7 +41,7 @@ server:
 eureka:
   client:
     serviceUrl:
-      defaultZone: http://root:root@${EUREKA_HOST:172.16.90.225}:${EUREKA_PORT:8086}/eureka/
+      defaultZone: http://root:root@${EUREKA_HOST:172.16.90.238}:${EUREKA_PORT:8086}/eureka/
     metadata-map:
       cluster: ribbon
   instance: