春风项目四线(合箱线、总装线)
wujian
2024-09-10 51b05b093fa15dd477981372f67ae7b3b2747733
jcdm-main/src/main/java/com/jcdm/main/da/passingStationCollection/service/impl/DaPassingStationCollectionServiceImpl.java
@@ -1,15 +1,8 @@
package com.jcdm.main.da.passingStationCollection.service.impl;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import com.jcdm.common.constant.Constants;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSONObject;
import com.jcdm.common.utils.DateUtils;
import com.jcdm.common.utils.StringUtils;
import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling;
@@ -21,9 +14,17 @@
import com.jcdm.main.da.passingStationCollection.vo.DaPassingStationVO;
import com.jcdm.main.rm.repairRecord.domain.RmRepairRecord;
import com.jcdm.main.rm.repairRecord.mapper.RmRepairRecordMapper;
import com.jcdm.main.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 产品过站采集Service业务层处理
@@ -213,29 +214,72 @@
    @Override
    public void insertRepairRecordByIds(DaPassingStationCollection daPassingStationCollection) {
        Long[] conditions = daPassingStationCollection.getIds();
        String sfcCode = "";
        List<RmRepairRecord> save = new ArrayList<>();
        for (int i = 0; i < conditions.length; i++) {
            DaPassingStationCollection result = daPassingStationCollectionMapper.selectDaPassingStationCollectionById(conditions[i]);
            RmRepairRecord rmRepairRecord = new RmRepairRecord();
            rmRepairRecord.setBoxCode(result.getSfcCode());
            rmRepairRecord.setProcessesCode(result.getLocationCode());
            rmRepairRecord.setOriginalResult(result.getOutRsSign());
            rmRepairRecordMapper.insertRmRepairRecord(rmRepairRecord);
            if (i==0){
                if (ObjectUtil.isNotEmpty(result)){
                    sfcCode = result.getSfcCode();
                    rmRepairRecordMapper.deleteRmRepairRecordByCode(sfcCode);
                }
            }
            if (ObjectUtil.isNotEmpty(result)){
                RmRepairRecord rmRepairRecord = new RmRepairRecord();
                rmRepairRecord.setBoxCode(result.getSfcCode());
                rmRepairRecord.setProcessesCode(result.getLocationCode());
                rmRepairRecord.setOriginalResult(result.getOutRsSign());
                rmRepairRecord.setCreateTime(new Date());
                rmRepairRecordMapper.insertRmRepairRecord(rmRepairRecord);
                daPassingStationCollectionMapper.deleteDaPassingStationCollectionById(result.getId());
            }
        }
    }
    @Override
    public String SelectSN(String SNcode){
        return "1";
    public String SelectSN(String SNcode,String node) {
        try {
            Map<String, Object> params = new HashMap<>();
            params.put("SN_CODE",SNcode);
            params.put("Node",node);
            params.put("Success","");
            daPassingStationCollectionMapper.SelectSN(params);
            return (String)params.get("Success");
        } catch (Exception e) {
            return "数据查询失败!";
        }
    }
//        --订单排产
//        select * from bs_order_scheduling where engine_no='2V91Y-F RA182118'
//    public String sendMessage(String message) throws Exception{
//        Map<String,Object> map = new HashMap<>();
//
//        --工艺路线子表信息
//        select * from bs_technology_route_child_info where route_code='H_191S'
//        // 获取当前日期和时间
//        LocalDateTime nowDateTime = LocalDateTime.now();
//        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        System.out.println(dateTimeFormatter.format(nowDateTime));
//        map.put("server_time",dateTimeFormatter.format(nowDateTime));
//        map.put("server_code","200");
//
//        --返修数据
//        select * from rm_repair_record where box_code='2V91Y-F RA182118'
//
//        --过站采集
//        select * from da_passing_station_collection --where sfc_code='2V91Y-F RA182118'
//        map.put("server_message",message);
//        JSONObject jsonObject =  new JSONObject(map);
//        WebSocketServer.sendAllMessage(jsonObject.toString());
//        return jsonObject.toString();
//    }
    public String sendMessage(String message,String userid) throws Exception{
        Map<String,Object> map = new HashMap<>();
        // 获取当前日期和时间
        LocalDateTime nowDateTime = LocalDateTime.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        System.out.println(dateTimeFormatter.format(nowDateTime));
        map.put("server_time",dateTimeFormatter.format(nowDateTime));
        map.put("server_code","200");
        map.put("server_message",message);
        JSONObject jsonObject =  new JSONObject(map);
        WebSocketServer.sendInfo(jsonObject.toString(),userid);
        return jsonObject.toString();
    }
}