package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.busi.bu3;

import cn.estsh.i3plus.ext.mes.api.busi.bu3.ISxProdDataPushNotifyStrategyService;
import cn.estsh.i3plus.ext.mes.pojo.model.bu3.SxAssistOutAndEnterPushDingInfoModel;
import cn.estsh.i3plus.pojo.model.platform.PushDataNotifyModel;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * @Description 援进援出确认信息推送通知数据处理
 * @author jiaqi.hou
 * @date 2023-08-15 16:13
 **/
@Slf4j
@Service
public class SxProdDataPushAssistOutAndEnterConfirmService implements ISxProdDataPushNotifyStrategyService {

    @Override
    public List<PushDataNotifyModel> exec(PushDataNotifyModel data) {
        log.info("援进援出确认提醒推送通知数据处理 --- SxProdDataPushAssistOutAndEnterConfirmService --- START --- DATA:{} --- THREAD:{}", JSONObject.toJSONString(data), Thread.currentThread().getName());

        SxAssistOutAndEnterPushDingInfoModel param = JSONObject.parseObject(data.getApiParam(),SxAssistOutAndEnterPushDingInfoModel.class);
        List<PushDataNotifyModel> resultList = new ArrayList<>();

        LinkedHashMap<String, String> dataMap = new LinkedHashMap<>();
        dataMap.put("产线代码",param.getWorkCenterCode());
        dataMap.put("责任部门", param.getOwnerDepartment());
        dataMap.put("工作内容", param.getWorkContent());
        dataMap.put("影响人数", param.getInfluenceNumber()+"");
        dataMap.put("影响时间", param.getInfluenceTime()+"");
        dataMap.put("影响日期", param.getInfluenceDate()+"");
        dataMap.put("金额", param.getAmount()+"");
        dataMap.put("备注", param.getCooperation());
        data.setUserNames(param.getUserNames());
        data.addListDing(dataMap).title("援进援出确认信息");
        resultList.add(data);

        dataMap = new LinkedHashMap<>();
        dataMap.put("详情内容可在SFP管理端MES模块【援入援出明细记录】页面查看","TITLE");
        data.addListDing(dataMap);

        log.info("援进援出确认提醒推送通知数据处理 --- SxProdDataPushAssistOutAndEnterConfirmService --- END --- DATA:{} --- THREAD:{}", JSONObject.toJSONString(data), Thread.currentThread().getName());

        return resultList;
    }
}
