Commit ef50c515 by liuyang

2024-06-27 修改app角色权限查询公司

parent 668793de
...@@ -13,6 +13,7 @@ import com.baosight.hggp.hg.sb.domain.HGSB002; ...@@ -13,6 +13,7 @@ import com.baosight.hggp.hg.sb.domain.HGSB002;
import com.baosight.hggp.hg.sb.tools.HGSBTools; import com.baosight.hggp.hg.sb.tools.HGSBTools;
import com.baosight.hggp.hg.sc.domain.HGSC007; import com.baosight.hggp.hg.sc.domain.HGSC007;
import com.baosight.hggp.hg.xs.domain.Company; import com.baosight.hggp.hg.xs.domain.Company;
import com.baosight.hggp.hg.xs.domain.Factory;
import com.baosight.hggp.hg.xs.domain.Org; import com.baosight.hggp.hg.xs.domain.Org;
import com.baosight.hggp.hg.xs.tools.HGXSTools; import com.baosight.hggp.hg.xs.tools.HGXSTools;
import com.baosight.hggp.util.*; import com.baosight.hggp.util.*;
...@@ -26,6 +27,8 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -26,6 +27,8 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/** /**
...@@ -90,15 +93,23 @@ import java.util.*; ...@@ -90,15 +93,23 @@ import java.util.*;
} }
@OperationLogAnnotation(operModul = "生产任务", operType = "APP查询工厂", operDesc = "APP查询当前登录用户角色所属工厂") @OperationLogAnnotation(operModul = "生产任务", operType = "APP查询工厂", operDesc = "APP查询当前登录用户角色所属工厂")
public List<Map> getRoleFactory(EiInfo inInfo) { public List<Factory> getRoleFactory(EiInfo inInfo) {
List<Map> factoryCodes = new ArrayList<>(); List<Org> factoryCodes = new ArrayList<>();
try { try {
List<Map<String,Object>> mapList = getOrg(); List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
factoryCodes.addAll(mapList); Optional.ofNullable(roleCompanyCode).orElse(new ArrayList<>()).stream().forEach( code -> {
factoryCodes.addAll(HGXSTools.XsOrg.queryByParent(code,OrgTypeEnum.FACTORY.getCode()));
});
//List<Map<String,Object>> mapList = getOrg();
//factoryCodes.addAll(mapList);
}catch (Exception e){ }catch (Exception e){
LogUtils.setDetailMsg(inInfo,e,"APP查询工厂失败"); LogUtils.setDetailMsg(inInfo,e,"APP查询工厂失败");
} }
return factoryCodes; return factoryCodes.stream().filter(o-> com.baosight.hggp.util.StringUtils.equals(o.getOrgType(),OrgTypeEnum.FACTORY.getCode())).map(item -> new Factory(item.getCompanyCode(),item.getCompanyName(),item.getFactoryCode(),item.getFactoryName())).collect(Collectors.collectingAndThen(
Collectors.toMap(Factory::getFactoryCode, Function.identity(), (oldValue, newValue) -> oldValue),
// 将Map转回List
m -> new ArrayList<>(m.values())
));
} }
/** /**
...@@ -108,11 +119,11 @@ import java.util.*; ...@@ -108,11 +119,11 @@ import java.util.*;
public EiInfo getProcessSumWt(EiInfo inInfo) { public EiInfo getProcessSumWt(EiInfo inInfo) {
try { try {
EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock); EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock);
UserVO userVO = HGCWTools.HgCw002.getUserCompany(); //UserVO userVO = HGCWTools.HgCw002.getUserCompany();
String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code); /*String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code);
if (StringUtils.isEmpty(companyCode)) { if (StringUtils.isEmpty(companyCode)) {
queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode()); queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode());
} }*/
inInfo = super.query(inInfo,HGSC007.QUERY_SUM_WT); inInfo = super.query(inInfo,HGSC007.QUERY_SUM_WT);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
...@@ -127,11 +138,11 @@ import java.util.*; ...@@ -127,11 +138,11 @@ import java.util.*;
public EiInfo getProcessWt(EiInfo inInfo) { public EiInfo getProcessWt(EiInfo inInfo) {
try { try {
EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock); EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock);
UserVO userVO = HGCWTools.HgCw002.getUserCompany(); /*UserVO userVO = HGCWTools.HgCw002.getUserCompany();
String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code); String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code);
if (StringUtils.isEmpty(companyCode)) { if (StringUtils.isEmpty(companyCode)) {
queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode()); queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode());
} }*/
inInfo = super.query(inInfo,HGSC007.QUERY_WT); inInfo = super.query(inInfo,HGSC007.QUERY_WT);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
...@@ -146,16 +157,16 @@ import java.util.*; ...@@ -146,16 +157,16 @@ import java.util.*;
public EiInfo getProcessDayWt(EiInfo inInfo) { public EiInfo getProcessDayWt(EiInfo inInfo) {
try { try {
EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock); EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock);
UserVO userVO = HGCWTools.HgCw002.getUserCompany(); //UserVO userVO = HGCWTools.HgCw002.getUserCompany();
String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code); //String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code);
String endDate = queryRow.getCellStr(ACConstants.ROW_CODE_0,ACConstants.SQL_END_DATE); String endDate = queryRow.getCellStr(ACConstants.ROW_CODE_0,ACConstants.SQL_END_DATE);
if (StringUtils.isNotEmpty(endDate)) { if (StringUtils.isNotEmpty(endDate)) {
String startDate = DateUtil.dateSubStr(endDate,-7); String startDate = DateUtil.dateSubStr(endDate,-7);
queryRow.setCell(ACConstants.ROW_CODE_0,ACConstants.SQL_START_DATE,startDate); queryRow.setCell(ACConstants.ROW_CODE_0,ACConstants.SQL_START_DATE,startDate);
} }
if (StringUtils.isEmpty(companyCode)) { /*if (StringUtils.isEmpty(companyCode)) {
queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode()); queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode());
} }*/
inInfo = super.query(inInfo,HGSC007.QUERY_DAY_WT); inInfo = super.query(inInfo,HGSC007.QUERY_DAY_WT);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
...@@ -170,16 +181,16 @@ import java.util.*; ...@@ -170,16 +181,16 @@ import java.util.*;
public EiInfo getProcessMonthWt(EiInfo inInfo) { public EiInfo getProcessMonthWt(EiInfo inInfo) {
try { try {
EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock); EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock);
UserVO userVO = HGCWTools.HgCw002.getUserCompany(); //UserVO userVO = HGCWTools.HgCw002.getUserCompany();
String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code); //String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code);
String endDate = queryRow.getCellStr(ACConstants.ROW_CODE_0,ACConstants.SQL_END_DATE); String endDate = queryRow.getCellStr(ACConstants.ROW_CODE_0,ACConstants.SQL_END_DATE);
if (StringUtils.isNotEmpty(endDate)) { if (StringUtils.isNotEmpty(endDate)) {
String startDate = DateUtil.getMonthOfDays(endDate,-6,DateUtil.DATE8_PATTERN); String startDate = DateUtil.getMonthOfDays(endDate,-6,DateUtil.DATE8_PATTERN);
queryRow.setCell(ACConstants.ROW_CODE_0,ACConstants.SQL_START_DATE,startDate); queryRow.setCell(ACConstants.ROW_CODE_0,ACConstants.SQL_START_DATE,startDate);
} }
if (StringUtils.isEmpty(companyCode)) { /*if (StringUtils.isEmpty(companyCode)) {
queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode()); queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode());
} }*/
inInfo = super.query(inInfo,HGSC007.QUERY_MONTH_WT); inInfo = super.query(inInfo,HGSC007.QUERY_MONTH_WT);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
...@@ -194,12 +205,12 @@ import java.util.*; ...@@ -194,12 +205,12 @@ import java.util.*;
public EiInfo getProjCodeWt(EiInfo inInfo) { public EiInfo getProjCodeWt(EiInfo inInfo) {
try { try {
EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock); EiBlock queryRow = inInfo.getBlock(EiConstant.queryBlock);
UserVO userVO = HGCWTools.HgCw002.getUserCompany(); //UserVO userVO = HGCWTools.HgCw002.getUserCompany();
//Map queryRow = EiInfoUtils.getFirstRow(inInfo); //Map queryRow = EiInfoUtils.getFirstRow(inInfo);
String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code); /*String companyCode = queryRow.getCellStr(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code);
if (StringUtils.isEmpty(companyCode)) { if (StringUtils.isEmpty(companyCode)) {
queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode()); queryRow.setCell(ACConstants.ROW_CODE_0,HGSC007.FIELD_company_code,userVO.getUsercode());
} }*/
inInfo = super.query(inInfo,HGSC007.QUERY_PROJ_CODE_WT); inInfo = super.query(inInfo,HGSC007.QUERY_PROJ_CODE_WT);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
......
...@@ -13,10 +13,22 @@ import java.util.Map; ...@@ -13,10 +13,22 @@ import java.util.Map;
*/ */
public class Factory extends DaoEPBase { public class Factory extends DaoEPBase {
public static final String FIELD_COMPANY_CODE = "companyCode"; /* 公司编码*/
public static final String FIELD_COMPANY_NAME = "companyName"; /* 公司名称*/
public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 部门编码*/ public static final String FIELD_FACTORY_CODE = "factoryCode"; /* 部门编码*/
public static final String FIELD_FACTORY_NAME = "factoryName"; /* 部门名称*/ public static final String FIELD_FACTORY_NAME = "factoryName"; /* 部门名称*/
/** /**
* 公司编码
*/
private String companyCode = "";
/**
* 公司名称
*/
private String companyName = "";
/**
* 厂区编码 * 厂区编码
*/ */
private String factoryCode; private String factoryCode;
...@@ -32,6 +44,14 @@ public class Factory extends DaoEPBase { ...@@ -32,6 +44,14 @@ public class Factory extends DaoEPBase {
public void initMetaData() { public void initMetaData() {
EiColumn eiColumn; EiColumn eiColumn;
eiColumn = new EiColumn(FIELD_COMPANY_CODE);
eiColumn.setDescName("公司编码");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_COMPANY_NAME);
eiColumn.setDescName("公司名称");
eiMetadata.addMeta(eiColumn);
eiColumn = new EiColumn(FIELD_FACTORY_CODE); eiColumn = new EiColumn(FIELD_FACTORY_CODE);
eiColumn.setDescName("厂区编码"); eiColumn.setDescName("厂区编码");
eiMetadata.addMeta(eiColumn); eiMetadata.addMeta(eiColumn);
...@@ -52,6 +72,30 @@ public class Factory extends DaoEPBase { ...@@ -52,6 +72,30 @@ public class Factory extends DaoEPBase {
this.factoryName = factoryName; this.factoryName = factoryName;
} }
public Factory(String companyCode,String companyName,String factoryCode, String factoryName) {
initMetaData();
this.companyCode = companyCode;
this.companyName = companyName;
this.factoryCode = factoryCode;
this.factoryName = factoryName;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getFactoryCode() { public String getFactoryCode() {
return factoryCode; return factoryCode;
} }
...@@ -75,7 +119,8 @@ public class Factory extends DaoEPBase { ...@@ -75,7 +119,8 @@ public class Factory extends DaoEPBase {
*/ */
@Override @Override
public void fromMap(Map map) { public void fromMap(Map map) {
setCompanyCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_CODE)), companyCode));
setCompanyName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_COMPANY_NAME)), companyName));
setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode)); setFactoryCode(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_CODE)), factoryCode));
setFactoryName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_NAME)), factoryName)); setFactoryName(StringUtils.defaultIfEmpty(StringUtils.toString(map.get(FIELD_FACTORY_NAME)), factoryName));
} }
...@@ -87,6 +132,8 @@ public class Factory extends DaoEPBase { ...@@ -87,6 +132,8 @@ public class Factory extends DaoEPBase {
public Map toMap() { public Map toMap() {
Map map = new HashMap(); Map map = new HashMap();
map.put(FIELD_COMPANY_CODE, StringUtils.toString(companyCode, eiMetadata.getMeta(FIELD_COMPANY_CODE)));
map.put(FIELD_COMPANY_NAME, StringUtils.toString(companyName, eiMetadata.getMeta(FIELD_COMPANY_NAME)));
map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE))); map.put(FIELD_FACTORY_CODE, StringUtils.toString(factoryCode, eiMetadata.getMeta(FIELD_FACTORY_CODE)));
map.put(FIELD_FACTORY_NAME, StringUtils.toString(factoryName, eiMetadata.getMeta(FIELD_FACTORY_NAME))); map.put(FIELD_FACTORY_NAME, StringUtils.toString(factoryName, eiMetadata.getMeta(FIELD_FACTORY_NAME)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment