package com.changhong.epc.tenant.service.system.math.impl;
|
|
import com.changhong.epc.bean.count.system.SystemMath;
|
import com.changhong.epc.bean.count.system.SystemMathExtend;
|
import com.changhong.epc.bean.count.system.SystemMathParam;
|
import com.changhong.epc.bean.tenant.cost.CostFromMapping;
|
import com.changhong.epc.constter.count.nomr.CountUrlConst;
|
import com.changhong.epc.constter.system.SystemClients;
|
import com.changhong.epc.constter.system.run.EpcRestInterface;
|
import com.changhong.epc.tenant.mapper.tenant.system.math.SystemMathMapper;
|
import com.changhong.epc.tenant.mapper.tenant.system.math.SystemMathParamMapper;
|
import com.changhong.epc.tenant.service.system.math.SystemMathService;
|
import com.esotericsoftware.minlog.Log;
|
import com.iemsoft.framework.cloud.core.base.ResMsg;
|
import com.iemsoft.framework.cloud.core.thread.Keys;
|
import com.iemsoft.framework.cloud.core.thread.ThreadData;
|
import com.iemsoft.framework.cloud.core.tools.JSONTool;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import com.iemsoft.framework.cloud.ribbon.RestInterface;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.util.CollectionUtils;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
|
/**
|
* 系统变量业务层
|
*
|
* @author liush
|
*/
|
@Service("systemMathServiceImpl")
|
@Slf4j
|
public class SystemMathServiceImpl implements SystemMathService, SystemClients, CountUrlConst {
|
|
@Resource
|
private SystemMathMapper systemMathMapper;
|
|
@Resource
|
private SystemMathParamMapper systemMathParamMapper;
|
|
@Override
|
public List<SystemMathExtend> selectAllSystemMathExtend() {
|
return systemMathMapper.selectAllSystemMathExtend();
|
}
|
|
@Override
|
public List<SystemMath> selectSystemMathNameList() {
|
return systemMathMapper.selectSystemMathNameList();
|
}
|
|
@Transactional
|
@Override
|
public Integer insert(SystemMathExtend systemMathExtend) {
|
int count = 0;
|
systemMathExtend.initParam();
|
count += systemMathMapper.save(systemMathExtend);
|
for (SystemMathParam sys : systemMathExtend.getSystemMathParam()) {
|
sys.setMathId(systemMathExtend.getId());
|
sys.initParam();
|
count += systemMathParamMapper.insert(sys);
|
}
|
return count;
|
}
|
|
@Transactional
|
@Override
|
public Integer updateByPrimaryKey(SystemMathExtend systemMathExtend) {
|
int count = 0;
|
SystemMathParam systemMathParam = new SystemMathParam();
|
systemMathParam.setMathId(systemMathExtend.getId());
|
systemMathParamMapper.delete(systemMathParam);
|
systemMathExtend.initParam();
|
count += systemMathMapper.updateByPrimaryKey(systemMathExtend);
|
for (SystemMathParam sys : systemMathExtend.getSystemMathParam()) {
|
sys.setMathId(systemMathExtend.getId());
|
sys.initParam();
|
count += systemMathParamMapper.insert(sys);
|
}
|
return count;
|
}
|
|
@Transactional
|
@Override
|
public Integer deleteByPrimaryKey(SystemMathExtend systemMathExtend) {
|
int count = 0;
|
SystemMathParam systemMathParam = new SystemMathParam();
|
systemMathParam.setMathId(systemMathExtend.getId());
|
count += systemMathParamMapper.delete(systemMathParam);
|
count += systemMathMapper.delete(systemMathExtend);
|
return count;
|
}
|
|
@SuppressWarnings("unchecked")
|
@Override
|
public List<Map<String, String>> getFunction() {
|
RestInterface restInterface = SpringUtil.getBean(SERVER_COUNT.getBeanName(), RestInterface.class);
|
Object data = restInterface.post(CountUrlConst.COUNT_SYSTEM_FUNC_GETFUNCTION, new HashMap<>(), ResMsg.class, EpcRestInterface.getEpcHeads()).getData();
|
Map<String, List<Map<String, String>>> data1 = JSONTool.toObj(JSONTool.toJson(data), Map.class);
|
List<Map<String, String>> timeFunctions = data1.get("时间函数");
|
List<Map<String, String>> basicFunctions = data1.get("基本函数");
|
List<Map<String, String>> expendFunctions = data1.get("扩展函数");
|
List<Map<String, String>> functions = new ArrayList<Map<String, String>>();
|
functions.addAll(timeFunctions);
|
functions.addAll(basicFunctions);
|
functions.addAll(expendFunctions);
|
return functions;
|
}
|
@Override
|
public Map<String,String> getCostTypeByFormId(Map<String,String> map) {
|
log.debug("传递的map:---------------------------{}",map);
|
String formId = Objects.toString(map.get("fId"),"");
|
String dataRowNum = map.get("dataRowNum");
|
String tenantId = ThreadData.get(Keys.TENANT_ID);
|
String companyId = ThreadData.get(Keys.COMPANY_ID);
|
|
/**
|
费用类型 表名
|
SQ 通用申请单智泽SQa-----------> 需要
|
SQ 通用申请单智泽SQa486
|
筛选出长度最短的表名,同时返回此bean
|
*/
|
Map<String,String> list = systemMathMapper.getCostTypeByFormId(tenantId, companyId, formId,dataRowNum);
|
Map<String,String> costFromMapping1 ;
|
if(!CollectionUtils.isEmpty(list)){
|
log.debug("查询出的费用类型为:{}", list.toString());
|
costFromMapping1 = list;
|
return costFromMapping1;
|
}
|
return null;
|
}
|
}
|