package nccloud.web.ic.pub.action;

import nc.vo.ic.general.define.ICBillVO;
import nc.vo.pubapp.res.NCModule;
import nccloud.base.reflect.NCClass;
import nccloud.dto.ic.pub.entity.GeneralSumPrintInfo;
import nccloud.framework.core.json.IJson;
import nccloud.framework.web.container.SessionContext;
import nccloud.framework.web.json.JsonFactory;
import nccloud.framework.web.processor.template.BillCardConvertProcessor;
import nccloud.framework.web.ui.pattern.billcard.BillCard;
import nccloud.pubitf.platform.print.IPrintInfo;
import nccloud.pubitf.uap.print.vo.ExtendsBatchPrintVO;
import nccloud.uap.print.action.AbstractNoPreviewPrintAction;
/**
 * @description 出入库汇总打印
 * @author zhegnxinm
 * @date 2018-12-16 上午10:48:39
 * @version ncc1.0
 */
public class GeneralSumPrintAction extends AbstractNoPreviewPrintAction {

    @Override
    public IPrintInfo convertPrintInfo(ExtendsBatchPrintVO info) {
        IJson json = JsonFactory.create();
        GeneralSumPrintInfo newinfo = json.fromJson(info.getUserjson(), GeneralSumPrintInfo.class);
        newinfo.setFilename((info.getFilename() == null) ? "download-"
                + String.valueOf(System.currentTimeMillis()) : info
                .getFilename());

        String appcode = info.getAppcode();
        String billcardStr = newinfo.getBillcard();
        //注释此代码，如需放开请修改前端"./src/ic/ic/components/sumPrintModal/index.js"里扩展的列表汇总billcard传值
//        BillCard billcard = json.fromJson(billcardStr,BillCard.class);

        if (appcode == null) {
            appcode = SessionContext.getInstance().getAppcode();
        }
//		BillCardConvertProcessor processor = new BillCardConvertProcessor();
//		ICBillVO bill = processor.fromBillCard(billcard);
        newinfo.setAppcode(appcode);
        newinfo.setIds(info.getOids());
        newinfo.setNodeKey(info.getNodekey());
        NCClass printServiceClazz = new NCClass();
        printServiceClazz.setModule(getPrintServiceModule());
        printServiceClazz.setName(getPrintServiceName());
        newinfo.setPrintServiceClazz(printServiceClazz);
        newinfo.setPrintTemplateID(info.getPrintTemplateID());
//		newinfo.setData(new Object[] { bill });
        newinfo.setRealData("true");
        newinfo.setTotalPage(info.getTotalPage());
        return newinfo;
    }

    @Override
    public String getPrintServiceModule() {
        return NCModule.IC.getName();
    }

    @Override
    public String getPrintServiceName() {
        return "nccloud.pubimpl.ic.inbound.generalin.operator.GeneralSumPrintOperator";
    }

}
