春风项目四线(合箱线、总装线)
wujian
2024-10-25 9906e6b188bf2c36dddc0d5adadbf02e69ea3e4b
add -sap
已修改9个文件
已添加5个文件
611 ■■■■■ 文件已修改
jcdm-framework/src/main/java/com/jcdm/framework/config/SecurityConfig.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/Query/SAPQuery.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/vo/ReportVO.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/mapper/DaCollectionParamConfMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/service/IDaCollectionParamConfService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/service/impl/DaCollectionParamConfServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/vo/ChartVO.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/vo/Options.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/controller/DaParamCollectionController.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-main/src/main/resources/mapper/da/collectionParamConf/DaCollectionParamConfMapper.xml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-quartz/src/main/java/com/jcdm/quartz/task/RyTask.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-ui/src/api/main/da/paramCollection/paramCollection.js 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-ui/src/views/main/da/spcDataAnalyse/index.vue 354 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jcdm-framework/src/main/java/com/jcdm/framework/config/SecurityConfig.java
@@ -116,6 +116,7 @@
                .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
                .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                .antMatchers("/bs/technologyRouteChild/ttest").permitAll()
                .antMatchers("/bs/orderScheduling/engine-report").permitAll()
                .antMatchers("/websocket/**").anonymous()
                // é™¤ä¸Šé¢å¤–的所有请求全部需要鉴权认证
                .anyRequest().authenticated()
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/Query/SAPQuery.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,9 @@
package com.jcdm.main.bs.orderScheduling.Query;
import lombok.Data;
@Data
public class SAPQuery {
    private String IV_ZFDJM;
}
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/controller/BsOrderSchedulingController.java
@@ -1,6 +1,7 @@
package com.jcdm.main.bs.orderScheduling.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
@@ -17,11 +18,13 @@
import com.jcdm.common.exception.ServiceException;
import com.jcdm.common.utils.StringUtils;
import com.jcdm.common.utils.poi.ExcelUtil;
import com.jcdm.main.bs.orderScheduling.Query.SAPQuery;
import com.jcdm.main.bs.orderScheduling.common.Constants;
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService;
import com.jcdm.main.bs.orderScheduling.vo.FollowReportVO;
import com.jcdm.main.bs.orderScheduling.vo.LineChartVO;
import com.jcdm.main.bs.orderScheduling.vo.ReportVO;
import com.jcdm.main.bs.orderScheduling.vo.SumDataVO;
import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
@@ -499,4 +502,36 @@
            return R.fail("未查找到该发动机号对应的箱体");
        }
    }
    @PostMapping("/engine-report")
    public R getReportDetail(SAPQuery sapQuery){
        ReportVO reportVO = new ReportVO();
        if (StrUtil.isBlank(sapQuery.getIV_ZFDJM())){
            reportVO.setEV_STATUS("E");
            reportVO.setEV_MESSAGE("发动机号不能为空");
        }
        BsOrderScheduling query = new BsOrderScheduling();
        query.setEngineNo(sapQuery.getIV_ZFDJM());
        List<BsOrderScheduling> bsOrderSchedulingList = bsOrderSchedulingService.selectBsOrderSchedulingList(query);
        if (CollUtil.isNotEmpty(bsOrderSchedulingList)){
            BsOrderScheduling bsOrderScheduling = bsOrderSchedulingList.get(0);
            if (StrUtil.isBlank(bsOrderScheduling.getReport20())){
                reportVO.setEV_STATUS("0");
                reportVO.setEV_MESSAGE("未报工");
            } else {
                if ("1".equals(bsOrderScheduling.getReport20())){
                    reportVO.setEV_STATUS("1");
                    reportVO.setEV_MESSAGE("已报工");
                } else if ("3".equals(bsOrderScheduling.getReport20())){
                    reportVO.setEV_STATUS("E");
                    reportVO.setEV_MESSAGE(bsOrderScheduling.getRemarks());
                }
            }
        } else {
            reportVO.setEV_STATUS("E");
            reportVO.setEV_MESSAGE("未查询到此发动机信息");
        }
        return R.ok(reportVO);
    }
}
jcdm-main/src/main/java/com/jcdm/main/bs/orderScheduling/vo/ReportVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.jcdm.main.bs.orderScheduling.vo;
import lombok.Data;
@Data
public class ReportVO {
    private String EV_STATUS;
    private String EV_MESSAGE;
}
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/mapper/DaCollectionParamConfMapper.java
@@ -26,6 +26,7 @@
     * @return é‡‡é›†å‚数配置集合
     */
    public List<DaCollectionParamConf> selectDaCollectionParamConfList(DaCollectionParamConf daCollectionParamConf);
    public List<DaCollectionParamConf> getSelectOption(DaCollectionParamConf daCollectionParamConf);
    /**
     * æ–°å¢žé‡‡é›†å‚数配置
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/service/IDaCollectionParamConfService.java
@@ -26,6 +26,7 @@
     * @return é‡‡é›†å‚数配置集合
     */
    public List<DaCollectionParamConf> selectDaCollectionParamConfList(DaCollectionParamConf daCollectionParamConf);
    public List<DaCollectionParamConf> getSelectOption(DaCollectionParamConf daCollectionParamConf);
    /**
     * æ–°å¢žé‡‡é›†å‚数配置
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/service/impl/DaCollectionParamConfServiceImpl.java
@@ -44,6 +44,11 @@
        return daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf);
    }
    @Override
    public List<DaCollectionParamConf> getSelectOption(DaCollectionParamConf daCollectionParamConf) {
        return daCollectionParamConfMapper.getSelectOption(daCollectionParamConf);
    }
    /**
     * æ–°å¢žé‡‡é›†å‚数配置
     * 
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/vo/ChartVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package com.jcdm.main.da.collectionParamConf.vo;
import lombok.Data;
import java.util.List;
@Data
public class ChartVO {
    private List<Options> locationList;
    private List<Options> paramCodeList;
}
jcdm-main/src/main/java/com/jcdm/main/da/collectionParamConf/vo/Options.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
package com.jcdm.main.da.collectionParamConf.vo;
import lombok.Data;
@Data
public class Options {
    private String label;
    private String value;
}
jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/controller/DaParamCollectionController.java
@@ -1,10 +1,20 @@
package com.jcdm.main.da.paramCollection.controller;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.jcdm.common.core.domain.R;
import com.jcdm.common.utils.DateUtils;
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf;
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService;
import com.jcdm.main.da.collectionParamConf.vo.ChartVO;
import com.jcdm.main.da.collectionParamConf.vo.Options;
import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -37,6 +47,9 @@
    @Autowired
    private IDaParamCollectionService daParamCollectionService;
    @Resource
    private IDaCollectionParamConfService daCollectionParamConfService;
    /**
     * æŸ¥è¯¢è®¾å¤‡äº§å“è¿‡ç¨‹å‚数采集列表
     */
@@ -57,6 +70,80 @@
        return getDataTable(list);
    }
    @GetMapping("/queryChart")
    public R queryChart(DaParamCollection daParamCollection)
    {
        if(daParamCollection.getDateConditions()!=null){
            String[] conditions = daParamCollection.getDateConditions();
            daParamCollection.setStartTime(conditions[0]);
            daParamCollection.setEndTime(conditions[1]);
        } else {
            return R.fail("请选择日期范围");
        }
        if (StrUtil.isBlank(daParamCollection.getLocationCode())){
            return R.fail("请输入工位编号");
        }
        if (StrUtil.isBlank(daParamCollection.getParamName())){
            return R.fail("请选择数据类型");
        }
        if (StrUtil.isBlank(daParamCollection.getParamCode())){
            return R.fail("请选择螺栓");
        }
        List<DaParamCollection> list = daParamCollectionService.queryDaParamCollectionListForSearch(daParamCollection);
        String[] array = list.stream().map(DaParamCollection::getParamValue).toArray(String[]::new);
        return R.ok(array);
    }
    @GetMapping("/getSelectOption")
    public R getSelectOption(DaParamCollection daParamCollection){
        ChartVO chartVO = new ChartVO();
        List<Options> locationList = new ArrayList<>();
        List<Options> paramCodeList = new ArrayList<>();
        DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf();
        if (StrUtil.isBlank(daParamCollection.getLocationCode())){
            List<DaCollectionParamConf> selectOption = daCollectionParamConfService.getSelectOption(daCollectionParamConf);
            List<String> collect = selectOption.stream().map(DaCollectionParamConf::getProcessesCode).distinct().collect(Collectors.toList());
            if (CollUtil.isNotEmpty(collect)){
                for (String s : collect) {
                    Options options = new Options();
                    options.setLabel(s);
                    options.setValue(s);
                    locationList.add(options);
                }
            }
        } else {
            List<DaCollectionParamConf> selectOption2 = daCollectionParamConfService.getSelectOption(daCollectionParamConf);
            List<String> collect = selectOption2.stream().map(DaCollectionParamConf::getProcessesCode).distinct().collect(Collectors.toList());
            if (CollUtil.isNotEmpty(collect)){
                for (String s : collect) {
                    Options options = new Options();
                    options.setLabel(s);
                    options.setValue(s);
                    locationList.add(options);
                }
            }
            daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode());
            if (StrUtil.isNotBlank(daParamCollection.getParamName())){
                daCollectionParamConf.setCollectParameterName(daParamCollection.getParamName());
                List<DaCollectionParamConf> selectOption = daCollectionParamConfService.getSelectOption(daCollectionParamConf);
                if (CollUtil.isNotEmpty(selectOption)){
                    for (DaCollectionParamConf collectionParamConf : selectOption) {
                        Options options = new Options();
                        options.setLabel(collectionParamConf.getParameterSetName());
                        options.setValue(collectionParamConf.getParameterSetCode());
                        paramCodeList.add(options);
                    }
                }
            }
        }
        chartVO.setLocationList(locationList);
        chartVO.setParamCodeList(paramCodeList);
        return R.ok(chartVO);
    }
    /**
     * å¯¼å‡ºè®¾å¤‡äº§å“è¿‡ç¨‹å‚数采集列表
     */
jcdm-main/src/main/resources/mapper/da/collectionParamConf/DaCollectionParamConfMapper.xml
@@ -35,6 +35,9 @@
    <sql id="selectDaCollectionParamConfVo">
        select id, processes_code, parameter_set_code, parameter_set_name, collect_parameter_id, collect_parameter_name, contrast_parameter_flag, collect_parameter_type, collect_parameter_unit, Descriptives, param_upper, param_lower, param_Central, product_code, gather_address, gather_sequence, remarks, create_user, create_time, update_user, update_time, spare_field_1, spare_field_2, spare_field_3, spare_field_4 from da_collection_param_conf
    </sql>
    <sql id="selectOptionVo">
        select id, processes_code, parameter_set_code, parameter_set_name, collect_parameter_id, collect_parameter_name, remarks from da_collection_param_conf
    </sql>
    <select id="selectDaCollectionParamConfList" parameterType="DaCollectionParamConf" resultMap="DaCollectionParamConfResult">
        <include refid="selectDaCollectionParamConfVo"/>
@@ -56,7 +59,17 @@
        <include refid="selectDaCollectionParamConfVo"/>
        where id = #{id}
    </select>
    <select id="getSelectOption"
            resultMap="DaCollectionParamConfResult">
        <include refid="selectOptionVo"/>
        <where>
            remarks = '1' and collect_parameter_name in ('角度','扭矩')
            <if test="processesCode != null  and processesCode != ''"> and processes_code like concat('%', #{processesCode}, '%')</if>
            <if test="parameterSetCode != null  and parameterSetCode != ''"> and parameter_set_code like concat('%', #{parameterSetCode}, '%')</if>
            <if test="collectParameterName != null  and collectParameterName != ''"> and collect_parameter_name like concat('%', #{collectParameterName}, '%')</if>
        </where>
    </select>
    <insert id="insertDaCollectionParamConf" parameterType="DaCollectionParamConf">
        insert into da_collection_param_conf
        <trim prefix="(" suffix=")" suffixOverrides=",">
jcdm-quartz/src/main/java/com/jcdm/quartz/task/RyTask.java
@@ -114,7 +114,7 @@
        if (CollUtil.isNotEmpty(bsOrderSchedulings)){
            BsOrderScheduling orderScheduling = bsOrderSchedulings.get(0);
            try {
                String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0010"));
                String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(),orderScheduling.getEngineNo(), "0010"));
                ev_meassage=ReceivingServices.xmlToJSON1(xmlResult);
                status = ReceivingServices.xmlToJSON3(xmlResult);
            } catch (Exception e) {
@@ -124,6 +124,7 @@
                orderScheduling.setReport10("1");
                int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                logger.info("{}合箱报工成功",orderScheduling.getOrderNo());
                orderScheduling.setRemarks("合箱报工成功");
            }else {
                if(StringUtils.isEmpty(orderScheduling.getSpareField1())){
                    orderScheduling.setSpareField1("1");
@@ -136,12 +137,16 @@
                    }else {
                        orderScheduling.setSpareField1(String.valueOf(Integer.valueOf(orderScheduling.getSpareField1()) + 1));
                    }
                    if(status.equals("3")){
                        orderScheduling.setRemarks("合箱报工因为网络原因,报工失败");
                        logger.info("{}合箱报工因为网络原因,报工失败!",orderScheduling.getOrderNo());
                    } else{
                        orderScheduling.setRemarks("合箱报工失败"+ev_meassage);
                        logger.info("{}合箱报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage);
                    }
                    bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                }
                if(status.equals("3"))
                    logger.info("{}合箱报工因为网络原因,报工失败!",orderScheduling.getOrderNo());
                else
                    logger.info("{}合箱报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage);
            }
        }
    }
@@ -155,7 +160,7 @@
        if (CollUtil.isNotEmpty(bsOrderSchedulings)){
            BsOrderScheduling orderScheduling = bsOrderSchedulings.get(0);
            try {
                String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), "0020"));
                String xmlResult = ReceivingServices.getInterfaceInformationXml(url, getProductionPlanInformationXml(orderScheduling.getOrderNo(), orderScheduling.getEngineNo(),"0020"));
                ev_meassage=ReceivingServices.xmlToJSON1(xmlResult);
                status = ReceivingServices.xmlToJSON3(xmlResult);
            } catch (Exception e) {
@@ -165,6 +170,7 @@
                orderScheduling.setReport20("1");
                int i = bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                logger.info("{}总装报工成功",orderScheduling.getOrderNo());
                orderScheduling.setRemarks("总装报工成功");
            }else {
                if(StringUtils.isEmpty(orderScheduling.getSpareField2())){
                    orderScheduling.setSpareField2("1");
@@ -177,11 +183,14 @@
                    }else{
                        orderScheduling.setSpareField2(String.valueOf(Integer.valueOf(orderScheduling.getSpareField2()) + 1));
                    }
                    bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                    if(status.equals("3"))
                    if(status.equals("3")){
                        logger.info("{}总装报工因为网络原因,报工失败!",orderScheduling.getOrderNo());
                    else
                        orderScheduling.setRemarks("总装报工因为网络原因,报工失败");
                    } else{
                        logger.info("{}总装报工失败,原因:{}",orderScheduling.getOrderNo(),ev_meassage);
                        orderScheduling.setRemarks("总装报工失败,"+ev_meassage);
                    }
                    bsOrderSchedulingService.updateBsOrderScheduling(orderScheduling);
                }
            }
        }
@@ -244,17 +253,18 @@
                    //更新
                    //判断是否需要更新
                    ProductNumTable productNumTable = collect1.get(0);
                    Integer hxOnlineNum = productNumTable.getHxOnlineNum();
                    Integer zzOnlineNum = productNumTable.getZzOnlineNum();
                    Integer zzOfflineNum = productNumTable.getZzOfflineNum();
                    if (!hxOnlineNum.equals((int)count1) || !zzOnlineNum.equals((int) count2) || !zzOfflineNum.equals((int)count3)){
                        //更新
                        productNumTable.setHxOnlineNum((int) count1);
                        productNumTable.setZzOnlineNum((int) count2);
                        productNumTable.setZzOfflineNum((int) count3);
                        productNumTable.setProductNumTheory(productNumTheory);
                        productNumTableService.updateProductNum(productNumTable);
                    }
//                    Integer hxOnlineNum = productNumTable.getHxOnlineNum();
//                    Integer zzOnlineNum = productNumTable.getZzOnlineNum();
//                    Integer zzOfflineNum = productNumTable.getZzOfflineNum();
//                    if (!hxOnlineNum.equals((int)count1) || !zzOnlineNum.equals((int) count2) || !zzOfflineNum.equals((int)count3)){
//
//                    }
                    //更新
                    productNumTable.setHxOnlineNum((int) count1);
                    productNumTable.setZzOnlineNum((int) count2);
                    productNumTable.setZzOfflineNum((int) count3);
                    productNumTable.setProductNumTheory(productNumTheory);
                    productNumTableService.updateProductNum(productNumTable);
                }
            }
            if (CollUtil.isNotEmpty(saveDate)){
@@ -377,13 +387,14 @@
        return productNumTheory;
    }
    public static String getProductionPlanInformationXml(String orderNo,String location){
    public static String getProductionPlanInformationXml(String orderNo,String engineNo,String location){
        String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" +
                "   <soapenv:Header/>\n" +
                "   <soapenv:Body>\n" +
                "      <urn:ZPP_BC_001>\n" +
                "         <IV_AUFNR>"+orderNo+"</IV_AUFNR>\n" +
                "          <IV_VORNR>"+location+"</IV_VORNR>\n" +
                "          <IV_ZFDJM>"+engineNo+"</IV_ZFDJM>\n" +
                "           <IV_LMNGA>1</IV_LMNGA>\n" +
                "           <IV_XMNGA>0</IV_XMNGA>   \n" +
                "         <IV_STATU>1</IV_STATU>  \n" +
jcdm-ui/src/api/main/da/paramCollection/paramCollection.js
@@ -50,3 +50,17 @@
    method: 'delete'
  })
}
export function queryChart(query) {
  return request({
    url: '/main/paramCollection/queryChart',
    method: 'get',
    params: query
  })
}
export function getSelectOption(query) {
  return request({
    url: '/main/paramCollection/getSelectOption',
    method: 'get',
    params: query
  })
}
jcdm-ui/src/views/main/da/spcDataAnalyse/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,354 @@
<template>
  <div class="app-container">
    <el-card class="box-card">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="日期范围" prop="dateConditions">
        <el-date-picker
          v-model="queryParams.dateConditions"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          @change="handleDateChange">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="工位编号" prop="locationCode">
        <el-select v-model="queryParams.locationCode" placeholder="请选择工位编号" clearable>
          <el-option
            v-for="item in locationOption"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="数据类型" prop="paramName">
        <el-select v-model="queryParams.paramName" @change="getSelectOptionMethod" placeholder="请选择数据类型" clearable>
          <el-option
            v-for="item in dataTypeList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="螺栓名称" prop="paramCode">
        <el-select v-model="queryParams.paramCode" placeholder="请选择螺栓名称" clearable>
          <el-option
            v-for="item in screwNameList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item style="float: right">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryChartMethod">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    </el-card>
    <el-card style="margin-top: 10px" class="box-card">
    <el-row :gutter="10" class="mb8">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="用户管理" name="first">用户管理</el-tab-pane>
        <el-tab-pane label="配置管理" name="second">配置管理</el-tab-pane>
        <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane>
      </el-tabs>
    </el-row>
    <el-table v-loading="loading" border :data="paramCollectionList" @selection-change="handleSelectionChange" v-if="paramCollectionList.length > 0">
    </el-table>
      <el-empty v-else>
        <span slot="description">暂无数据</span>
      </el-empty>
    </el-card>
  </div>
</template>
<script>
import { listParamCollection, getParamCollection, delParamCollection, addParamCollection, updateParamCollection } from "@/api/main/da/paramCollection/paramCollection";
import {queryDaParamCollectionListForSearch, getSelectOption, queryChart} from "../../../../api/main/da/paramCollection/paramCollection";
export default {
  name: "ParamCollection",
  data() {
    return {
      activeName: 'second',
      dataTypeList:[
        {
          value: "扭矩",
          label: "扭矩"
        },
        {
          value: "角度",
          label: "角度"
        },
      ],
      locationOption:[],
      screwNameList:[],
      maxDate: '',
      // é®ç½©å±‚
      loading: true,
      // é€‰ä¸­æ•°ç»„
      ids: [],
      // éžå•ä¸ªç¦ç”¨
      single: true,
      // éžå¤šä¸ªç¦ç”¨
      multiple: true,
      // æ˜¾ç¤ºæœç´¢æ¡ä»¶
      showSearch: true,
      // æ€»æ¡æ•°
      total: 0,
      // è®¾å¤‡äº§å“è¿‡ç¨‹å‚数采集表格数据
      paramCollectionList: [],
      // å¼¹å‡ºå±‚标题
      title: "",
      // æ˜¯å¦æ˜¾ç¤ºå¼¹å‡ºå±‚
      open: false,
      // æŸ¥è¯¢å‚æ•°
      queryParams: {
        dateConditions: [],
        pageNum: 1,
        pageSize: 10,
        workOrderNo: null,
        sfcCode: null,
        productCode: null,
        productionLine: null,
        locationCode: null,
        equipmentNo: null,
        paramCode: null,
      },
      // è¡¨å•å‚æ•°
      form: {},
      // è¡¨å•æ ¡éªŒ
      rules: {
        id: [
          { required: true, message: "主键id不能为空", trigger: "blur" }
        ],
        // workOrderNo: [
        //   { required: true, message: "工单编号不能为空", trigger: "blur" }
        // ],
        sfcCode: [
          { required: true, message: "总成序列号不能为空", trigger: "blur" }
        ],
        productCode: [
          { required: true, message: "产品编号不能为空", trigger: "blur" }
        ],
        // productionLine: [
        //   { required: true, message: "产线编号不能为空", trigger: "blur" }
        // ],
        locationCode: [
          { required: true, message: "工位编号不能为空", trigger: "blur" }
        ],
        paramCode: [
          { required: true, message: "参数编码不能为空", trigger: "blur" }
        ],
        paramValue: [
          { required: true, message: "参数值不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    // this.getList();
  },
  mounted() {
    this.getSelectOptionMethod()
  },
  methods: {
    getSelectOptionMethod(){
      getSelectOption(this.queryParams).then(res => {
        console.log('rrrrrrr',res)
        if (res.code === 200){
          this.locationOption = res.data.locationList
          this.screwNameList = res.data.paramCodeList
        }
      })
    },
    queryChartMethod(){
      queryChart(this.queryParams).then(res => {
        if (res.code === 200){
          console.log('res',res)
          let dataArray = []
          if (res.data.length > 0){
            res.data.forEach(x => {
              let num = parseInt(x)
              dataArray.push(num)
            })
          }
          console.log('res222',dataArray)
          let array=dataArray
          console.log('arra',array)
          // å¹³å‡å€¼
          let mean=(array.reduce((a,b)=>a+b))/array.length
          console.log('mean',mean)
          // æ–¹å·®
          let variance=array.map(x=>{
            return Math.pow(x-mean,2)
          }).reduce((a,b)=>a+b)/array.length
          console.log('variance',variance)
          // æ ‡å‡†å·®
          let StandardDeviation = Math.sqrt(variance)
          console.log('StandardDeviation',StandardDeviation)
          //计算方式可以百度
          let convertedData=[]
          for(let x=mean-3*StandardDeviation;x<=mean + 3*StandardDeviation;x++){
            //for循环中的条件代表你要生成几个标准差的数据,
            //  å†å¸¦å…¥æ­£æ€åˆ†å¸ƒå…¬å¼ï¼Œå°±å¯ä»¥ç”Ÿæˆä¸€æ¡æ•´æ¡åˆ†å¸ƒæ›²çº¿çš„数据
            let y=1/(StandardDeviation*Math.sqrt(2*(Math.PI)))*Math.exp(-(Math.pow(x-mean,2))/(2*(Math.pow(StandardDeviation,2))))
            convertedData.push([x,y])
          }
        }
      })
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    handleDateChange(value) {
      if (value && value.length === 2) {
        const startDate = value[0];
        const endDate = value[1];
        const dayCount = this.daysBetween(startDate, endDate);
        if (dayCount + 1 > 7) {
          this.$message.error('请选择连续的7天!');
          this.queryParams.dateConditions = []; // é‡ç½®æ—¥æœŸèŒƒå›´
        }
      }
    },
    daysBetween(startDate, endDate) {
      const oneDay = 24 * 60 * 60 * 1000; // æ¯å¤©çš„毫秒数
      const startTime = new Date(startDate).getTime();
      const endTime = new Date(endDate).getTime();
      return Math.round(Math.abs((startTime - endTime) / oneDay));
    },
    /** æŸ¥è¯¢è®¾å¤‡äº§å“è¿‡ç¨‹å‚数采集列表 */
    getList() {
      this.loading = true;
      if ((this.queryParams.sfcCode == null || this.queryParams.sfcCode === '') && this.queryParams.dateConditions.length === 0){
        this.$message({
          message: '请输入发动机号码或者选择查询日期',
          type: 'info'
        });
      } else {
        queryDaParamCollectionListForSearch(this.queryParams).then(response => {
          this.paramCollectionList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      }
    },
    // å–消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // è¡¨å•é‡ç½®
    reset() {
      this.form = {
        id: null,
        workOrderNo: null,
        sfcCode: null,
        productCode: null,
        productionLine: null,
        locationCode: null,
        equipmentNo: null,
        paramCode: null,
        paramValue: null,
        paramUpper: null,
        paramLower: null,
        paramStandard: null,
        collectionTime: null,
        spareField1: null,
        spareField2: null,
        createUser: null,
        createTime: null,
        updateUser: null,
        updateTime: null,
        state: null,
        paramName: null,
        unit: null,
        type: null
      };
      this.resetForm("form");
    },
    /** æœç´¢æŒ‰é’®æ“ä½œ */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** é‡ç½®æŒ‰é’®æ“ä½œ */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // å¤šé€‰æ¡†é€‰ä¸­æ•°æ®
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** æ–°å¢žæŒ‰é’®æ“ä½œ */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加设备产品过程参数采集";
    },
    /** ä¿®æ”¹æŒ‰é’®æ“ä½œ */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getParamCollection(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改设备产品过程参数采集";
      });
    },
    /** æäº¤æŒ‰é’® */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateParamCollection(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addParamCollection(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** åˆ é™¤æŒ‰é’®æ“ä½œ */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除设备产品过程参数采集编号为"' + ids + '"的数据项?').then(function() {
        return delParamCollection(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** å¯¼å‡ºæŒ‰é’®æ“ä½œ */
    handleExport() {
      this.download('main/paramCollection/export', {
        ...this.queryParams
      }, `paramCollection_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>