Browse Source

git-svn-id: https://192.168.57.71/svn/lyggkj@135 1a6f6e3a-4066-fe46-b609-79c204482ece

xt_xuhao 8 năm trước cách đây
mục cha
commit
8e0c425706

+ 39 - 19
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/controller/BaseController.java

@@ -39,6 +39,7 @@ import com.jtgh.yjpt.common.PredicateModel.Operator;
 import com.jtgh.yjpt.common.ReportExportHelper;
 import com.jtgh.yjpt.common.SysException;
 import com.jtgh.yjpt.common.Utils;
+import com.jtgh.yjpt.dao.jyr.JyrDao;
 import com.jtgh.yjpt.entity.BaseEntity;
 import com.jtgh.yjpt.entity.auth.UserEntity;
 
@@ -61,7 +62,8 @@ public abstract class BaseController {
 	protected Logger logger = Logger.getLogger(getClass());
 	@Autowired
 	protected JdbcTemplate jdbcTemplate;
-
+	@Autowired
+	private JyrDao jyrDao;
 	/**
 	 * jasper打印文件
 	 */
@@ -81,7 +83,8 @@ public abstract class BaseController {
 
 			if ("FF".equals(getBrowser(request))) {
 				// 针对火狐浏览器处理方式不一样了
-				//fileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
+				// fileName = new String(fileName.getBytes("UTF-8"),
+				// "iso-8859-1");
 			} else {
 				fileName = URLEncoder.encode(fileName, "UTF-8");
 			}
@@ -124,11 +127,11 @@ public abstract class BaseController {
 	/**
 	 * 时间格式化2
 	 */
-	public  SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+	public SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 	/**
 	 * 时间格式化3
 	 */
-	public  SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+	public SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
 	/**
 	 * 时间格式化4
 	 */
@@ -136,7 +139,7 @@ public abstract class BaseController {
 	/**
 	 * 时间格式化5
 	 */
-	public  SimpleDateFormat sdf5 = new SimpleDateFormat("HH:mm:ss");
+	public SimpleDateFormat sdf5 = new SimpleDateFormat("HH:mm:ss");
 	/**
 	 * 日历
 	 */
@@ -552,7 +555,7 @@ public abstract class BaseController {
 				&& !GlobalData.adminID.equals(Utils.getCurrentUser().getId())) {
 			List<PredicateModel> orList = new ArrayList<PredicateModel>();
 			String role = getCurrentRoleCode(functionId);
-			// 行政人员可以查找所有比自己低级的数据,以及经营人、建设单位、评价机构的数据
+			// 行政人员可以查找所有比自己低级的数据,以及经 营人、建设单位、评价机构的数据
 			if (Constants.NO.equals(Utils.getCurrentUser().getSfjyr())) {
 				// 行政人员按照所在地过滤
 				if (Utils.getCurrentUser().getSzd() != null)
@@ -571,19 +574,35 @@ public abstract class BaseController {
 				orList.add(new PredicateModel("tbdyid", null, Operator.NNL));
 			} else {
 				// 经营人可以看自己及自己下级经营人的数据,非行政人员的建设方和评价机构只能看自己所在企业的数据
-				if (Utils.getCurrentUser().getJyrjcxx() != null
-						&& Utils.getSession().getAttribute(
-								GlobalData.USER_SESSION_JYR) != null) {
-					if (!StringUtils.isEmpty(jyr)) {
-						orList.add(new PredicateModel(jyr + ".id", Utils
-								.getSession().getAttribute(
-										GlobalData.USER_SESSION_JYR),
-								Operator.IN));
-					} else {
-						orList.add(new PredicateModel(user + "jyrjcxx.id",
-								Utils.getSession().getAttribute(
-										GlobalData.USER_SESSION_JYR),
-								Operator.IN));
+				if (Utils.getCurrentUser().getJyrjcxx() != null) {
+					
+					//session!=null  invoke from web
+					if (Utils.getSession() != null
+							&& Utils.getSession().getAttribute(
+									GlobalData.USER_SESSION_JYR) != null) {
+						if (!StringUtils.isEmpty(jyr)) {
+							orList.add(new PredicateModel(jyr + ".id", Utils
+									.getSession().getAttribute(
+											GlobalData.USER_SESSION_JYR),
+									Operator.IN));
+						} else {
+							orList.add(new PredicateModel(user + "jyrjcxx.id",
+									Utils.getSession().getAttribute(
+											GlobalData.USER_SESSION_JYR),
+									Operator.IN));
+						}
+					}
+					else if(Utils.getSession() == null){//invoke from webservice
+						//session.setAttribute(GlobalData.USER_SESSION_JYR,jyrDao.findByParentJyr(user.getJyrjcxx().getId()));
+						List<BigDecimal> jyr_sub = jyrDao.findByParentJyr(Utils.getCurrentUser().getJyrjcxx().getId());
+						if (!StringUtils.isEmpty(jyr)) {
+							orList.add(new PredicateModel(jyr + ".id", jyr_sub,
+									Operator.IN));
+						} else {
+							orList.add(new PredicateModel(user + "jyrjcxx.id",
+									jyr_sub,
+									Operator.IN));
+						}
 					}
 				}
 				if (Utils.getCurrentUser().getJsdw() != null) {
@@ -595,6 +614,7 @@ public abstract class BaseController {
 							.getCurrentUser().getAqpjjg().getId(), Operator.EQ));
 				}
 			}
+
 			if (orList != null && orList.size() > 0) {
 				filterList.add(new PredicateModel(JoinType.OR, orList));
 			}

+ 4 - 5
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/service/impl/auth/AuthenticateServiceImpl.java

@@ -43,16 +43,15 @@ public class AuthenticateServiceImpl implements AuthenticateService {
 		if (l != null && l.size() > 0) {
 			UserEntity user = l.get(0);
 			if (user != null && Constants.YES.equals(user.getSfyxdl())
-					&& BaseEntity.RECORD_STATE_DELETE != user.getRecordStatus()
-					&& BaseEntity.RECORD_STATE_DRAFT != user.getRecordStatus()
-					&& Utils.pwdEquals(password, user.getPassword())) {
+							  && BaseEntity.RECORD_STATE_DELETE != user.getRecordStatus()
+							  && BaseEntity.RECORD_STATE_DRAFT != user.getRecordStatus()
+							  && Utils.pwdEquals(password, user.getPassword())) {
 				// HttpSession session =
 				// FlexContext.getHttpRequest().getSession();
 				HttpSession session = Utils.getSession();
 				if (user.getJyrjcxx() != null) {
 					user.getJyrjcxx().getGkjyr();
-					session.setAttribute(GlobalData.USER_SESSION_JYR,
-							jyrDao.findByParentJyr(user.getJyrjcxx().getId()));
+					session.setAttribute(GlobalData.USER_SESSION_JYR,jyrDao.findByParentJyr(user.getJyrjcxx().getId()));
 				}
 				if (user.getAddUser() != null)
 					user.getAddUser().getCode();

+ 5 - 7
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/bagl/BaglWebService.java

@@ -1180,9 +1180,7 @@ public class BaglWebService extends BaseController {
 	 * @param pageCount
 	 * @return
 	 */
-	public List<AqpjjgbaEntity> getAqpjjgbaPageListByParams(String jgmc,
-			String zzzsbh, String jglx, String dh, Date yxqz, int n,
-			int pageCount) {
+	public List<AqpjjgbaEntity> getAqpjjgbaPageListByParams(String jgmc,String zzzsbh, String jglx, String dh, Date yxqz, int n,int pageCount) {
 		List<PredicateModel> filterList = new ArrayList<PredicateModel>();
 		yxqz = Utils.getDateLastTime(yxqz);
 		addNotEmptyModel(filterList, "jgmc", jgmc, Operator.LIKE);
@@ -1193,14 +1191,14 @@ public class BaglWebService extends BaseController {
 		addNotEmptyModel(filterList, "sfqxzg", Constants.YES, Operator.NEQ);
 		// 行政人员根据权限过滤(安全评价机构备案列表菜单ID=35)
 		addRecordCodeFilter(35l, filterList);
-		SinglePageRequest pageable = new SinglePageRequest(pageCount, n,
-				"desc", "id");
-		Specification<AqpjjgbaEntity> spec = SpecificationCreater
-				.searchByPredicateModels(filterList);
+		SinglePageRequest pageable = new SinglePageRequest(pageCount, n,"desc", "id");
+		Specification<AqpjjgbaEntity> spec = SpecificationCreater.searchByPredicateModels(filterList);
 		Page<AqpjjgbaEntity> page = aqpjjgbaService.findAll(spec, pageable);
+		
 		if (page == null || page.getTotalPages() <= pageCount) {
 			return new ArrayList<AqpjjgbaEntity>();
 		}
+		
 		return page.getContent();
 	}
 

+ 12 - 19
gkaq/yjpt-java/trunk/java_src/com/jtgh/yjpt/webService/common/AuthHandler.java

@@ -49,8 +49,7 @@ public class AuthHandler implements SOAPHandler<SOAPMessageContext> {
 
 	@Override
 	public boolean handleMessage(SOAPMessageContext context) {
-		Boolean outbound = (Boolean) context
-				.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+		Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
 		if (!outbound.booleanValue()) {
 			try {
 				InetSocketAddress addr = ((HttpExchange) context
@@ -61,37 +60,30 @@ public class AuthHandler implements SOAPHandler<SOAPMessageContext> {
 						+ addr.getPort() + " AND WSDL_INTERFACE:"
 						+ context.get(MessageContext.WSDL_INTERFACE));
 				SOAPMessage soapMessage = context.getMessage();
-				SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart()
-						.getEnvelope();
+				SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
 				SOAPHeader soapHeader = soapEnvelope.getHeader();
 				if (soapHeader == null) {
 					generateSoapFault(soapMessage, "No SoapMessage Header");
 					return false;
 				}
-				Iterator<?> it = soapHeader
-						.extractHeaderElements(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
+				Iterator<?> it = soapHeader.extractHeaderElements(SOAPConstants.URI_SOAP_1_2_ROLE_NEXT);
 				if (it == null || !it.hasNext()) {
-					generateSoapFault(soapMessage,
-							"No Header block for role next");
+					generateSoapFault(soapMessage,"No Header block for role next");
 					return false;
 				}
 				Node node = (Node) it.next();
-				String value = node == null ? null : node.getValue();
+				String value = (node == null ? null : node.getValue());
 				if (value == null) {
 					generateSoapFault(soapMessage, "No Authenticate info");
 					return false;
 				}
 				String[] infos = value.split("&");
 				if (infos.length == 2) {
-					UserService userService = (UserService) ApplicationContextHelper
-							.getBean(UserService.class);
-					List<UserEntity> l = userService.findByCode(infos[0]);
-					if (l != null && l.size() > 0) {
-						UserEntity user = l.get(0);
-						if (user.getPassword() != null
-								&& user.getPassword().equals(infos[1]))
-						// Utils.encrypt(infos[1])))
-						{
+					UserService userService = (UserService) ApplicationContextHelper.getBean(UserService.class);
+					List<UserEntity> list = userService.findByCode(infos[0]);
+					if (list != null && list.size() > 0) {
+						UserEntity user = list.get(0);
+						if (user.getPassword() != null&& user.getPassword().equals(infos[1])) {
 							userLocal.set(user);
 							return true;
 						}
@@ -102,7 +94,8 @@ public class AuthHandler implements SOAPHandler<SOAPMessageContext> {
 						+ context.get(SOAPMessageContext.WSDL_INTERFACE));
 				e.printStackTrace();
 			}
-		} else {
+		}
+		else {
 			userLocal.remove();
 		}
 		return false;