package com.engine.htsc.ityssq.service.impl;

import com.engine.core.impl.Service;
import com.engine.htsc.ityssq.service.ItAcceptanceApplyService;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;

import java.util.HashMap;
import java.util.Map;

public class ItAcceptanceApplyServiceImpl extends Service implements ItAcceptanceApplyService {
    @Override
    public Map<String, Object> detailSummary(Map<String, Object> params) {
        Map<String,Object> datas = new HashMap<>();
        try{
            RecordSet rs = new RecordSet();
            ResourceComInfo resourceComInfo = new ResourceComInfo();
            String tablename = "formtable_main_" + Util.null2String(params.get("formid"));
            String detailname = tablename +"_dt4";
            String requestid = Util.null2String(params.get("requestid"));
            String xtsxsfyxzc = Util.null2String(params.get("xtsxsfyxzc"));
            String tjclsfqb = Util.null2String(params.get("tjclsfqb"));
            String xtmzysyq = Util.null2String(params.get("xtmzysyq"));
            String bcyj = Util.null2String(params.get("bcyj"));
            String clr = Util.null2String(params.get("clr"));
            String hqbm = resourceComInfo.getDepartmentID(clr);
            String id = "";
            rs.executeQuery("select id from "+tablename+" where requestid = ?",requestid);
            if (rs.next()){
                id = Util.null2String(rs.getString("id"));
            }
            String sql = "insert into "+detailname+"(mainid,hqbm,clr,xtsxsfyxzc,tjclsfqb,xtmzysyq,bcyj) " +
                    " values(?,?,?,?,?,?,?)";
            rs.executeUpdate(sql,new Object[]{id,hqbm,clr,xtsxsfyxzc,tjclsfqb,xtmzysyq,bcyj});

        }catch (Exception e){
            e.printStackTrace();
        }
        return datas;
    }
}
