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

import com.engine.core.impl.Service;
import com.engine.htsc.financialadjustment.util.BizUtil;
import com.engine.htsc.payment.service.PaymentService;
import com.engine.htsc.payment.service.PurchasingMallService;
import org.apache.commons.lang3.Validate;
import weaver.general.BaseBean;
import weaver.workflow.action.ESBNewAction;

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

public class PurchasingMallServiceImpl extends Service implements PurchasingMallService {
  @Override
  public Map<String, Map<String, String>> getBatchKj(String yskms) throws Exception {
    Validate.notEmpty(yskms, "预算科目为空,查询失败");
    Map<String, Map<String, String>> res = new HashMap<>();
    PaymentService ps = new PaymentServiceImpl();
    Arrays.stream(yskms.split(",")).forEach(item -> {
      Map<String,String> itemMap = new HashMap<>();
      try {
        String accountCode = ps.getAccountCode(item.split("_")[1]);
        String[] split = accountCode.split("@");
        itemMap.put("value", split[0]);
        itemMap.put("name", split[1]);
        res.put(item, itemMap);
      } catch (Exception e) {
        itemMap.put("value", "");
        itemMap.put("name", "");
        res.put(item, itemMap);
        new BaseBean().writeLog(e);
      }
    });
    return res;
  }


}
