package com.changhong.epc.form.execute.impl;
|
|
import com.changhong.autoform.entity.ProcessBudget;
|
import com.changhong.epc.bean.admin.extend.CorresElFieldExtendFind;
|
import com.changhong.epc.bean.form.*;
|
import com.changhong.epc.bean.tenant.cost.budgetlog.IBillCostLog;
|
import com.changhong.epc.bean.tenant.cost.budgetlog.MoneyExpendLog;
|
import com.changhong.epc.bean.tenant.cost.extend.CostFromMappingExtend;
|
import com.changhong.epc.constter.admin.AdminUrlConst;
|
import com.changhong.epc.constter.system.SystemClients;
|
import com.changhong.epc.constter.system.businesscode.BudgetBusinessMeaningCode;
|
import com.changhong.epc.constter.system.run.EpcRestInterface;
|
import com.changhong.epc.constter.tenant.TenantUrlConst;
|
import com.changhong.epc.form.execute.BudgetRecord.BudgetMoney;
|
import com.changhong.epc.form.execute.IFormOthersOperation;
|
import com.changhong.epc.form.service.budget.impl.RecordLog;
|
import com.changhong.epc.form.service.data.FormDataService;
|
import com.changhong.epc.form.service.field.FormFieldService;
|
import com.changhong.epc.form.tool.FormNameTool;
|
import com.iemsoft.framework.cloud.core.base.ResMsg;
|
import com.iemsoft.framework.cloud.core.tools.JSONTool;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import com.iemsoft.framework.cloud.ribbon.RestInterface;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
|
/**
|
* 回写预算需要 依赖的相关资源
|
* @author wangZX
|
*
|
*/
|
@Service("formOthersOperation")
|
public class FormOthersOperationImpl implements IFormOthersOperation, SystemClients, BudgetBusinessMeaningCode{
|
private ConstantMdCode constantMdCode = new ConstantMdCode();
|
|
@Resource
|
private FormFieldService formFieldService;
|
|
@Resource
|
private FormDataService formDataService;
|
|
@Override
|
public FormType getBillType(ProcessBudget processBudget) {
|
HashMap<String,Object> hashMap = new HashMap<>();
|
hashMap.put("fId", processBudget.getFormId());
|
// Object postRest = getPostRestTen(TenantUrlConst.REST_TENANT_COSTFORM_SELECTONE, hashMap);
|
Object postRest = null;
|
try {
|
RestInterface restInterface = SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class);
|
postRest = restInterface.post(TenantUrlConst.REST_TENANT_COSTFORM_SELECTONE, hashMap, ResMsg.class, EpcRestInterface.getEpcHeads()).getData();
|
} catch (Exception e) {
|
//e.printStackTrace();
|
}
|
//CostFromMappingExtend obj = JSONTool.toObj(JSONTool.toJson(postRest), CostFromMappingExtend.class);
|
|
// return FormType.valueOf(obj.getType());
|
return FormType.YS;
|
|
}
|
|
|
@Override
|
public String getBillCostType(ProcessBudget processBudget) {
|
HashMap<String,Object> hashMap = new HashMap<>();
|
hashMap.put("fId", processBudget.getFormId());
|
// Object postRest = getPostRestTen(TenantUrlConst.REST_TENANT_COSTFORM_SELECTONE, hashMap);
|
|
Object data = null;
|
try {
|
RestInterface restInterface = SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class);
|
data = restInterface.post(TenantUrlConst.REST_TENANT_COSTFORM_SELECTONE, hashMap, ResMsg.class, EpcRestInterface.getEpcHeads()).getData();
|
} catch (Exception e) {
|
}
|
|
CostFromMappingExtend obj = JSONTool.toObj(JSONTool.toJson(data), CostFromMappingExtend.class);
|
//如果是根目录直接返回费用类型名称 --lym
|
return obj.getCostType().getNodeName();
|
}
|
|
@Override
|
public void updateFormFieldProperty(ProcessBudget processBudget, BudgetMoney data) {
|
/**
|
* 记录日志
|
*/
|
RecordLog.recordFormUpdateLog(FormType.valueOf(processBudget.getFormType()), modelBillCostLog(processBudget, data));
|
|
Map<String,Object> param = new HashMap<>();
|
param.put(data.alias, data.money);
|
FormDataEntity formData = new FormDataEntity();
|
|
|
formData.setFormId(processBudget.getFormId());
|
formData.setTenantId(processBudget.getTenantID());
|
formData.setDataRowNum(processBudget.getDataRowNUm());
|
formData.setChildAlias(processBudget.getAlias());
|
|
List<Map<String, Object>> arrayList = new ArrayList<>();
|
arrayList.add(param);
|
formData.setData(arrayList);
|
formDataService.updateFormData(formData );
|
}
|
|
|
/**
|
* 转换成日志实体 以便记录
|
* @param processBudget
|
* @param data
|
* @return
|
*/
|
private IBillCostLog modelBillCostLog(ProcessBudget processBudget, BudgetMoney data) {
|
MoneyExpendLog moneyLog = new MoneyExpendLog();
|
|
String formName = FormNameTool.getSubFormTableName(processBudget.getTenantID(), processBudget.getFormId(), processBudget.getAlias());
|
moneyLog.setFormId(formName);
|
moneyLog.setRowId(processBudget.getDataRowNUm());
|
|
moneyLog.setOperatorMsg("回写预算");
|
moneyLog.setAlterAlias(data.alias);
|
|
moneyLog.setAlterContentOld(data.oldMoney.toString());
|
moneyLog.setAlterContentNew(data.money.toString());
|
|
return moneyLog;
|
}
|
|
@Transactional
|
@Override
|
public void updateFormFieldProperty(ProcessBudget processBudget,Map<String,Object> param ,FormType formType ,IBillCostLog IBillCostLog) {
|
|
RecordLog.recordFormUpdateLog(formType,IBillCostLog);
|
|
FormDataEntity formData = new FormDataEntity();
|
|
formData.setFormId(processBudget.getFormId());
|
formData.setTenantId(processBudget.getTenantID());
|
formData.setDataRowNum(processBudget.getDataRowNUm());
|
formData.setChildAlias(processBudget.getAlias());
|
List<Map<String, Object>> arrayList = new ArrayList<>();
|
arrayList.add(param);
|
formData.setData(arrayList);
|
formDataService.updateFormData(formData );
|
}
|
|
|
@Override
|
public Object recordLog(Object log) {
|
return null;
|
}
|
|
@Override
|
public Map<String, Object> getFromInfo(ProcessBudget processBudget) {
|
FormDataEntity formData = new FormDataEntity();
|
formData.setFormId(processBudget.getFormId());
|
formData.setChildAlias(processBudget.getAlias());
|
formData.setDataRowNum(processBudget.getDataRowNUm());
|
formData.setTenantId(processBudget.getTenantID());
|
Map<String, Object> searchFormData = formDataService.searchFormData(formData );
|
return searchFormData;
|
}
|
|
@Override
|
public List<BugetSubForm> queryBudgetByCostTypeAndParentId(ProcessBudget processBudget,HashSet<String> costType) {
|
FormDataEntity formData = new FormDataEntity();
|
formData.setChildAlias(processBudget.getAlias());
|
formData.setFormId(processBudget.getFormId());
|
return formDataService.searchBudgetSubForm(formData, costType);
|
|
|
}
|
|
@Override
|
public Fieldsets getFormFieldProperty(ProcessBudget processBudget) {
|
FormKey formKey = new FormKey();
|
formKey.setFormId(processBudget.getFormId());
|
formKey.setTenantId(processBudget.getTenantID());
|
formKey.setToken(processBudget.getToken());
|
FormBaseEntity selectFormFieldProperty = formFieldService.selectFormFieldProperty(formKey);
|
// System.err.println(JSONTool.toJson(selectFormFieldProperty));
|
|
return formData(selectFormFieldProperty);
|
}
|
|
|
private Fieldsets formData(FormBaseEntity formBaseEntity) {
|
return new Fieldsets(formBaseEntity);
|
}
|
|
|
@Override
|
public String getMoneyCpnMdCode() {
|
CorresElFieldExtendFind constEl = getConstEl();
|
return constEl.findCode(BX_AMOUNT).getMdCode();
|
}
|
|
@Override
|
public String getBudgetSumMoneyMdCode() {
|
CorresElFieldExtendFind constEl = getConstEl();
|
return constEl.findCode(YS_SUM_AMOUNT).getMdCode();
|
}
|
|
@Override
|
public String getBudgetBalanceMdCode() {
|
CorresElFieldExtendFind constEl = getConstEl();
|
return constEl.findCode(YS_SURPLUS_AMOUNT).getMdCode();
|
}
|
|
@Override
|
public String getMoneyAppleyMoneyMdCode() {
|
CorresElFieldExtendFind constEl = getConstEl();
|
return constEl.findCode(SQ_AMOUNT).getMdCode();
|
}
|
|
private static Map<String, Object> cache = new HashMap<>();
|
|
public Object getPostRestTen(String url,Map<String,Object> parm){
|
RestInterface restInterface = SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class);
|
Object data = restInterface.post(url, parm, ResMsg.class, EpcRestInterface.getEpcHeads()).getData();
|
|
return data;
|
}
|
|
public CorresElFieldExtendFind getConstEl(){
|
Object postRest = constantMdCode.getPostRest(AdminUrlConst.REST_ADMIN_CORRESELFIELD_SELECT,
|
new HashMap<>());
|
return JSONTool.toObj(JSONTool.toJson(postRest), CorresElFieldExtendFind.class);
|
}
|
|
|
@Override
|
public Map<String, Object> selectFormDataInfo(ProcessBudget processBudget) {
|
|
FormDataEntity formData = new FormDataEntity();
|
formData.setChildAlias(processBudget.getAlias());
|
formData.setFormId(processBudget.getFormId());
|
formData.setDataRowNum(processBudget.getDataRowNUm());
|
formData.setTenantId(processBudget.getTenantID());
|
return formDataService.searchFormInfo(formData );
|
}
|
|
|
|
}
|