package com.zfire.jiasm.syncdata.service.impl;

import com.zfire.jiasm.syncdata.service.SettlementService;
import com.zfire.jiasm.syncdata.utils.OLDSystemUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;


@Slf4j
@Service
public class SettlementServiceImpl implements SettlementService {
    @Autowired
    private OLDSystemUtil oldSystemTask;

    @Override
    public void syncData() {

        processSettlementInstallJY();

        processSettlementInstallRepair();

        processSettlementInstallSH();

        processSettlementInstallSY();

    }


    private void processSettlementInstallJY() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        log.info("开始家用空调数据同步: \uF0B7{}",sdf.format(new Date()));

        oldSystemTask.process("家用空调", "itf_installitem", "installItem",
                new Object[] { "itf_tblazwgmxjykt", "tblazwgmxjykt", new String[] { "itf_tblazwgmxjyktfj" },
                        new String[] { "tblAzWgmxJyktFj" }, "\"tblAzWgmxJyktSpecial\":[],\"tblAzWgmxOtherinfo\":[]", "",
                        "" },
                new Object[] { "itf_tblazwgmxjykt", "tblazwgmxjykt", new String[] { "itf_tblazwgmxjyktfj" },
                        new String[] { "tblAzWgmxJyktFj" }, "\"tblAzWgmxJyktSpecial\":[],\"tblAzWgmxOtherinfo\":[]",
                        "", "" },
                true, 1, "id");

        log.info("家用空调数据同步结束: \uF0B7{}",sdf.format(new Date()));
    }

    private void processSettlementInstallRepair() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        log.info("开始维修结算数据同步: \uF0B7{}",sdf.format(new Date()));

        oldSystemTask.process("维修", "itf_tblwxjsjykt", "tblWxjsJykt", new Object[] { "itf_tblwxjsjykt", "tblWxjsJykt",
                        new String[] { "itf_tblwxjsfjjykt", "itf_tblwxjswxxmjykt", "itf_tblwxjsxxyyjykt",
                                "itf_tblwxjspjmxjykt" },
                        new String[] { "tblWxjsFjJykt", "tblWxjsWxxmJykt", "tblWxjsXxyyJykt", "tblWxjsPjmxJykt" }, "", "", "" },
                new Object[] { "itf_tblwxjsjykt", "tblWxjsJykt", new String[] {}, new String[] {}, "", "", "" }, false,
                4, "id");

        log.info("维修结算数据同步结束: \uF0B7{}",sdf.format(new Date()));
    }

    private void processSettlementInstallSH() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        log.info("开始生活电器数据同步: \uF0B7{}",sdf.format(new Date()));

        oldSystemTask.process("生活电器", "itf_installitem", "installItem",
                new Object[] { "itf_tblazwgmxqita", "tblAzWgmxQita", new String[] { "itf_tblazwgmxqitafj" },
                        new String[] { "tblAzWgmxQitaFj" }, "", "", "" },
                new Object[] { "itf_tblazwgmxqita", "tblAzWgmxQita", new String[] { "itf_tblazwgmxqitafj" },
                        new String[] { "tblAzWgmxQitaFj" }, "", "", "" },
                true, 3, "id");

        log.info("生活电器数据同步结束: \uF0B7{}",sdf.format(new Date()));
    }

    private void processSettlementInstallSY() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        log.info("开始商用空调数据同步: \uF0B7{}",sdf.format(new Date()));

        oldSystemTask.process("商用空调", "itf_installitem", "installItem",
                new Object[] { "itf_tblazwgmxsykt", "tblAzWgmxSykt",
                        new String[] { "itf_tblazwgmxsyktfj", "itf_tblazwgmxsykttmmxls" },
                        new String[] { "tblAzWgmxSyktFj", "tblAzWgmxSyktTmmxLs"}, "", "", "" },
                new Object[] { "itf_tblazwgmxsykt", "tblAzWgmxSykt",
                        new String[] { "itf_tblazwgmxsyktfj", "itf_tblazwgmxsykttmmxls" },
                        new String[] { "tblAzWgmxSyktFj", "tblAzWgmxSyktTmmxLs" }, "", "",
                        "" },
                true, 2, "id");

        log.info("商用空调数据同步结束: \uF0B7{}",sdf.format(new Date()));
    }
}
