package com.changhong.epc.rely.api.epc.admin;
|
|
import com.alibaba.fastjson.TypeReference;
|
import com.changhong.epc.bean.admin.InitCompany;
|
import com.changhong.epc.constter.admin.AdminUrlConst;
|
import com.changhong.epc.constter.base.Context;
|
import com.changhong.epc.constter.cache.admin.InitCompanyCache;
|
import com.changhong.epc.constter.form.utf.FormUrlConst;
|
import com.changhong.epc.constter.system.SystemClients;
|
import com.changhong.epc.constter.system.run.EpcRestInterface;
|
import com.changhong.epc.rely.api.bean.TenantnameAndCompanyname;
|
import com.changhong.epc.rely.api.epc.BaseApi;
|
import com.iemsoft.framework.cloud.core.base.ResMsg;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import com.iemsoft.framework.cloud.redis.annotation.CacheRm;
|
import com.iemsoft.framework.cloud.redis.annotation.CacheSave;
|
import com.iemsoft.framework.cloud.ribbon.RestInterface;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
import org.springframework.ui.ModelMap;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Service
|
@Slf4j
|
public class InitCompanyApi extends BaseApi implements SystemClients, InitCompanyCache {
|
|
@CacheSave(value = INIT_COMPANY_INFO, tenant = false, company = false)
|
public InitCompany getInitCompany(Integer tenantId, Integer companyId) {
|
InitCompany initCompany = new InitCompany();
|
initCompany.setCompanyId(companyId);
|
initCompany.setTenantId(tenantId);
|
ResMsg<List<InitCompany>> resMsg =
|
(ResMsg<List<InitCompany>>)
|
SpringUtil.getBean(SERVER_ADMIN.getBeanName(), RestInterface.class)
|
.post(AdminUrlConst.SELECT_INITCOMPANY
|
, initCompany
|
, new TypeReference<ResMsg<List<InitCompany>>>() {
|
}.getType()
|
, EpcRestInterface.getEpcHeads()
|
);
|
assertSuccess(resMsg);
|
return ObjectUtil.empty(resMsg.getData()) ? new InitCompany() : resMsg.getData().stream().findFirst().orElse(new InitCompany());
|
}
|
public Map<String,String> getInitCompanynameAndTenantname(Integer tenantId, Integer companyId) {
|
ResMsg<List<Map<String,String>>> resMsg =
|
(ResMsg<List<Map<String,String>>>)
|
SpringUtil.getBean(SERVER_ADMIN.getBeanName(), RestInterface.class)
|
.post(AdminUrlConst.SELECT_INITCOMPANY_COMPANYNAME_TENANTNAME
|
, new ModelMap("tenantId",tenantId)
|
.addAttribute("companyId",companyId)
|
, new TypeReference<ResMsg<List<Map<String,String>>>>() {
|
}.getType()
|
, EpcRestInterface.getEpcHeads()
|
);
|
assertSuccess(resMsg);
|
return ObjectUtil.empty(resMsg.getData()) ? new HashMap<>(): resMsg.getData().stream().findFirst().orElse(new HashMap<>());
|
}
|
|
public InitCompany getInitCompany() {
|
// 此方法调用触发缓存
|
return SpringUtil.getBean(InitCompanyApi.class)
|
.getInitCompany(Context.getTenantId(), Context.getCompanyId());
|
}
|
|
@CacheSave(value = INIT_COMPANY_INFO_LIST, tenant = false, company = false)
|
public List<InitCompany> getAllInitCompany() {
|
ResMsg<List<InitCompany>> resMsg =
|
(ResMsg<List<InitCompany>>)
|
SpringUtil.getBean(SERVER_ADMIN.getBeanName(), RestInterface.class)
|
.post(AdminUrlConst.SELECT_INITCOMPANY
|
, new InitCompany()
|
, new TypeReference<ResMsg<List<InitCompany>>>() {
|
}.getType()
|
, EpcRestInterface.getEpcHeads()
|
);
|
assertSuccess(resMsg);
|
return resMsg.getData() == null ? new ArrayList<>() : resMsg.getData();
|
}
|
|
@CacheRm(value = {INIT_COMPANY_INFO, INIT_COMPANY_INFO_LIST}, tenant = false, company = false)
|
public void removeInte() {
|
System.out.println("清除了");
|
}
|
|
/**
|
* @Author WangYX
|
* @Description 初始化菜单列表,添加初始化公司数据
|
* @Date 2019/4/1 1:54 PM
|
*/
|
@CacheRm(value = {INIT_COMPANY_INFO, INIT_COMPANY_INFO_LIST}, tenant = false, company = false)
|
public void initCompany(InitCompany initCompany) {
|
ResMsg resMsg = SpringUtil.getBean(
|
SERVER_ADMIN.getBeanName(), RestInterface.class)
|
.post(AdminUrlConst.ADD_INITCOMPANY
|
, initCompany
|
, ResMsg.class
|
, EpcRestInterface.getEpcHeads()
|
);
|
assertSuccess(resMsg);
|
}
|
|
public void addOperationLog(String formId,String dataRowNum ,String operationoNum,String userName) {
|
ResMsg resMsg = SpringUtil.getBean(SERVER_FORM.getBeanName(), RestInterface.class)
|
.post(FormUrlConst.OPERATION_LOG_ADD,
|
new ModelMap().addAttribute("operationNum", operationoNum)
|
.addAttribute("formId", formId)
|
.addAttribute("dataRowNum",dataRowNum)
|
.addAttribute("userName",userName)
|
, null
|
, EpcRestInterface.getEpcHeads()
|
);
|
assertSuccess(resMsg);
|
}
|
}
|