jinpengyong
2021-08-17 6f4e852b84c577454a4876f83c7085bd360fe4fb
screen-manage/src/main/java/com/moral/api/service/impl/HistoryHourlyServiceImpl.java
@@ -11,6 +11,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
@@ -34,30 +35,33 @@
    private DeviceService deviceService;
    @Override
    @Transactional
    public void insertHistoryHourly(Map<String, Object> data) {
        Integer version = (Integer) data.remove("ver");
        Map<String, Object> dataAdjust = new HashMap<>(data);
        String mac = data.remove("mac").toString();
        Date time = DateUtils.dataToTimeStampTime(new Date(new Long((String) data.remove("DataTime"))), DateUtils.yyyy_MM_dd_HH_EN);
        Integer version = (Integer) data.remove("ver");
        Map<String, Object> result = new HashMap<>(data);
        Date time = DateUtils.getDate((String) data.remove("DataTime"), DateUtils.yyyyMMddHHmmss_EN);
        Map<String, Object> result = new HashMap<>();
        result.put("mac", mac);
        result.put("time", time);
        result.put("version", version);
        result.put("timeUnits", Constants.UN_ADJUST);
        result.put("value", JSONObject.toJSONString(data));
        //原始数据(未校准)
        historyHourlyMapper.insertHistoryHourlyUnAdjust(result);
        //未校准小时表insert
        historyHourlyMapper.insertHistoryHourly(result);
        //数据校准
        dataAdjust = deviceService.adjustDeviceData(dataAdjust);
        dataAdjust.remove("mac");
        dataAdjust.remove("DataTime");
        dataAdjust.remove("ver");
        HistoryHourly historyHourly = new HistoryHourly();
        historyHourly.setMac(mac);
        historyHourly.setTime(time);
        historyHourly.setVersion(version);
        historyHourly.setValue(JSONObject.toJSONString(dataAdjust));
        //校准后小时表insert
        historyHourlyMapper.insert(historyHourly);
    }
}