Commit ce864f52 by 宋祥

Merge branch 'master' of http://git.pseer.com:8800/platform/hg-smart into dev

 Conflicts:
	src/main/java/com/baosight/hggp/hg/sc/sql/HGSC007.xml
	src/main/resources/application.properties
	src/main/resources/quartz.properties
parents 9332d21d 2d47037c
...@@ -133,6 +133,27 @@ public class UserSessionUtils extends UserSession { ...@@ -133,6 +133,27 @@ public class UserSessionUtils extends UserSession {
} }
/** /**
* 获取登录用户的所有组
*
* @return
*/
public static List<String> getAllGroupCode() {
List<Org> orgs = HGXSTools.XsOrg.queryByUser();
if (CollectionUtils.isEmpty(orgs)) {
return new ArrayList<>();
}
List<String> prodGroupCodes = new ArrayList<>();
for (Org org : orgs) {
if (OrgTypeEnum.PROD_GROUP.getCode().equals(org.getOrgType())
|| OrgTypeEnum.CUT_GROUP.getCode().equals(org.getOrgType())
|| OrgTypeEnum.SYN_GROUP.getCode().equals(org.getOrgType())) {
prodGroupCodes.add(org.getOrgId());
}
}
return prodGroupCodes;
}
/**
* 获取登录用户所有角色 * 获取登录用户所有角色
* *
* @return * @return
......
package com.baosight.hggp.hg.sc.service; package com.baosight.hggp.hg.sc.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation; import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.common.DdynamicEnum;
import com.baosight.hggp.core.dao.DaoBase; import com.baosight.hggp.core.dao.DaoBase;
import com.baosight.hggp.core.dao.DaoUtils;
import com.baosight.hggp.core.enums.OrgTypeEnum; import com.baosight.hggp.core.enums.OrgTypeEnum;
import com.baosight.hggp.core.security.UserSessionUtils; import com.baosight.hggp.core.security.UserSessionUtils;
import com.baosight.hggp.hg.constant.HGSqlConstant; import com.baosight.hggp.hg.constant.HGSqlConstant;
import com.baosight.hggp.hg.cw.tools.HGCWTools;
import com.baosight.hggp.hg.cw.vo.UserVO;
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.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.DateUtil;
import com.baosight.hggp.util.EiInfoUtils;
import com.baosight.hggp.util.LogUtils;
import com.baosight.hggp.util.MapUtils;
import com.baosight.hggp.util.StringUtil;
import com.baosight.hggp.util.contants.ACConstants; import com.baosight.hggp.util.contants.ACConstants;
import com.baosight.iplat4j.core.ei.EiBlock; import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant; import com.baosight.iplat4j.core.ei.EiConstant;
...@@ -26,16 +25,46 @@ import com.baosight.iplat4j.core.service.impl.ServiceEPBase; ...@@ -26,16 +25,46 @@ import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* @author Zhang JiHui * @author Zhang JiHui
* @version 1.0 2024/5/24 * @version 1.0 2024/5/24
*/ */
public class ServiceHGSC007 extends ServiceEPBase { public class ServiceHGSC007 extends ServiceEPBase {
public static List<Map<String, Object>> getOrg() {
List<Map<String, Object>> list = new ArrayList<>();
List<Org> orgList = HGXSTools.XsOrg.queryByUser();
if (CollectionUtils.isNotEmpty(orgList)) {
for (Org org : orgList) {
Map<String, Object> objectMap = new HashMap<>();
if (!org.getOrgType().equals(OrgTypeEnum.COMPANY.getCode())) {
//Org org1 = HGXSTools.XsOrg.queryCompany(org.getOrgId());
objectMap.put(Org.FIELD_FACTORY_CODE, org.getFactoryCode());
objectMap.put(Org.FIELD_FACTORY_NAME, org.getFactoryName());
} else {
Map<String, Object> map = new HashMap<String, Object>();
map.put(Org.FIELD_PARENT_ORG_ID, org.getOrgId());
List<Map> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_BY_FACTORY, map);
if (results.size() > 0) {
Map org1 = results.get(0);
objectMap.put(Org.FIELD_FACTORY_CODE, org1.get(Org.FIELD_ORG_ID));
objectMap.put(Org.FIELD_FACTORY_NAME, org1.get(Org.FIELD_ORG_CNAME));
}
}
list.add(objectMap);
}
}
return list;
}
@OperationLogAnnotation(operModul = "生产任务", operType = "查询", operDesc = "初始化页面") @OperationLogAnnotation(operModul = "生产任务", operType = "查询", operDesc = "初始化页面")
public EiInfo initLoad(EiInfo inInfo) { public EiInfo initLoad(EiInfo inInfo) {
...@@ -48,26 +77,29 @@ import java.util.stream.Collectors; ...@@ -48,26 +77,29 @@ import java.util.stream.Collectors;
return inInfo; return inInfo;
} }
/* /**
* 查询*/ * 查询
*
* @param inInfo
* @return
*/
@OperationLogAnnotation(operModul = "生产任务", operType = "查询", operDesc = "查询") @OperationLogAnnotation(operModul = "生产任务", operType = "查询", operDesc = "查询")
public EiInfo query(EiInfo inInfo) { public EiInfo query(EiInfo inInfo) {
try { try {
EiBlock block = inInfo.getBlock(EiConstant.queryBlock); Map queryMap = EiInfoUtils.getFirstRow(inInfo);
String creatTime = block.getCellStr(ACConstants.ROW_CODE_0, HGSC007.FIELD_created_time); String creatTime = MapUtils.getString(queryMap, HGSC007.FIELD_created_time);
if (StringUtils.isNotBlank(creatTime)) { if (StringUtils.isNotBlank(creatTime)) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HGSC007.FIELD_created_time, StringUtil.removeHorizontalLine(creatTime)); queryMap.put(HGSC007.FIELD_created_time, StringUtil.removeHorizontalLine(creatTime));
} }
// 仅查询自己所在组的任务
inInfo = super.query(inInfo,HGSC007.QUERY,new HGSC007() ); queryMap.put("groupCodes", UserSessionUtils.getAllGroupCode());
inInfo = super.query(inInfo, HGSC007.QUERY, new HGSC007());
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
} }
return inInfo; return inInfo;
} }
@OperationLogAnnotation(operModul = "生产任务", operType = "查询", operDesc = "APP查询数量") @OperationLogAnnotation(operModul = "生产任务", operType = "查询", operDesc = "APP查询数量")
public Integer count(EiInfo inInfo) { public Integer count(EiInfo inInfo) {
Integer count = null; Integer count = null;
...@@ -75,10 +107,11 @@ import java.util.stream.Collectors; ...@@ -75,10 +107,11 @@ import java.util.stream.Collectors;
EiBlock block = inInfo.getBlock(EiConstant.queryBlock); EiBlock block = inInfo.getBlock(EiConstant.queryBlock);
String creatTime = block.getCellStr(ACConstants.ROW_CODE_0, HGSC007.FIELD_created_time); String creatTime = block.getCellStr(ACConstants.ROW_CODE_0, HGSC007.FIELD_created_time);
if (StringUtils.isNotBlank(creatTime)) { if (StringUtils.isNotBlank(creatTime)) {
inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0,HGSC007.FIELD_created_time, StringUtil.removeHorizontalLine(creatTime)); inInfo.setCell(EiConstant.queryBlock, ACConstants.ROW_CODE_0, HGSC007.FIELD_created_time,
StringUtil.removeHorizontalLine(creatTime));
} }
Map paramMap = EiInfoUtils.getFirstRow(inInfo); Map paramMap = EiInfoUtils.getFirstRow(inInfo);
count = super.count(HGSC007.COUNT,paramMap); count = super.count(HGSC007.COUNT, paramMap);
} catch (PlatException e) { } catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "查询失败"); LogUtils.setDetailMsg(inInfo, e, "查询失败");
...@@ -97,16 +130,20 @@ import java.util.stream.Collectors; ...@@ -97,16 +130,20 @@ import java.util.stream.Collectors;
List<Org> factoryCodes = new ArrayList<>(); List<Org> factoryCodes = new ArrayList<>();
try { try {
List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode(); List<String> roleCompanyCode = HGSBTools.getRoleCompanyCode();
Optional.ofNullable(roleCompanyCode).orElse(new ArrayList<>()).stream().forEach( code -> { Optional.ofNullable(roleCompanyCode).orElse(new ArrayList<>()).stream().forEach(code -> {
factoryCodes.addAll(HGXSTools.XsOrg.queryByParent(code,OrgTypeEnum.FACTORY.getCode())); factoryCodes.addAll(HGXSTools.XsOrg.queryByParent(code, OrgTypeEnum.FACTORY.getCode()));
}); });
//List<Map<String,Object>> mapList = getOrg(); //List<Map<String,Object>> mapList = getOrg();
//factoryCodes.addAll(mapList); //factoryCodes.addAll(mapList);
}catch (Exception e){ } catch (Exception e) {
LogUtils.setDetailMsg(inInfo,e,"APP查询工厂失败"); LogUtils.setDetailMsg(inInfo, e, "APP查询工厂失败");
} }
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( return factoryCodes.stream()
Collectors.toMap(Factory::getFactoryCode, Function.identity(), (oldValue, newValue) -> oldValue), .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 // 将Map转回List
m -> new ArrayList<>(m.values()) m -> new ArrayList<>(m.values())
)); ));
...@@ -124,7 +161,7 @@ import java.util.stream.Collectors; ...@@ -124,7 +161,7 @@ import java.util.stream.Collectors;
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, "查询失败");
} }
...@@ -143,7 +180,7 @@ import java.util.stream.Collectors; ...@@ -143,7 +180,7 @@ import java.util.stream.Collectors;
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, "查询失败");
} }
...@@ -159,15 +196,15 @@ import java.util.stream.Collectors; ...@@ -159,15 +196,15 @@ import java.util.stream.Collectors;
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, "查询失败");
} }
...@@ -183,15 +220,15 @@ import java.util.stream.Collectors; ...@@ -183,15 +220,15 @@ import java.util.stream.Collectors;
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, "查询失败");
} }
...@@ -211,40 +248,13 @@ import java.util.stream.Collectors; ...@@ -211,40 +248,13 @@ import java.util.stream.Collectors;
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, "查询失败");
} }
return inInfo; return inInfo;
} }
public static List<Map<String,Object>> getOrg() {
List<Map<String,Object>> list = new ArrayList<>();
List<Org> orgList = HGXSTools.XsOrg.queryByUser();
if (CollectionUtils.isNotEmpty(orgList)) {
for (Org org: orgList) {
Map<String,Object> objectMap = new HashMap<>();
if (!org.getOrgType().equals(OrgTypeEnum.COMPANY.getCode())) {
//Org org1 = HGXSTools.XsOrg.queryCompany(org.getOrgId());
objectMap.put(Org.FIELD_FACTORY_CODE,org.getFactoryCode());
objectMap.put(Org.FIELD_FACTORY_NAME,org.getFactoryName());
} else {
Map<String, Object> map = new HashMap<String, Object>();
map.put(Org.FIELD_PARENT_ORG_ID, org.getOrgId());
List<Map> results = DaoBase.getInstance().query(HGSqlConstant.HgXsOrg.QUERY_BY_FACTORY,map);
if (results.size()>0) {
Map org1 = results.get(0);
objectMap.put(Org.FIELD_FACTORY_CODE,org1.get(Org.FIELD_ORG_ID));
objectMap.put(Org.FIELD_FACTORY_NAME,org1.get(Org.FIELD_ORG_CNAME));
}
}
list.add(objectMap);
}
}
return list;
}
} }
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