com.mg.common.metadata.service.MHistoryServiceImpl Maven / Gradle / Ivy
package com.mg.common.metadata.service;
import com.mg.common.metadata.util.MetaDataUtils;
import com.mg.framework.entity.metadata.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 生成任职履历、变更记录等。
* Created by liukefu on 2015/10/19.
*/
@Service
public class MHistoryServiceImpl implements MHistoryService {
@Autowired
MetaDataService metaDataService;
@Autowired
private MetaDataQueryService metaDataManageService;
@Autowired
MetaDataQueryService metaDataQueryService;
@Autowired
private MetaDataExpressService metaDataExpressionService;
public boolean createHistory(String mObjectName,String propertyName,String historyPropertyName,Map param){
return createHistory(mObjectName,propertyName,historyPropertyName,null,param);
}
public boolean createHistory(String mObjectName,String propertyName,String historyPropertyName,String startDatePropertyName,Map param){
MObjectEntity mObjectEntity = metaDataManageService.findMObjectByName(mObjectName);
if(mObjectEntity!=null){
MirrorPropertyEntity mirrorPropertyEntity = metaDataManageService.findMPropertyByName(mObjectEntity, propertyName);
MirrorPropertyEntity historyPropertyEntity = metaDataManageService.findMPropertyByName(mObjectEntity, historyPropertyName);
if(historyPropertyEntity==null){
return false;
}
if(mirrorPropertyEntity==null){
return false;
}
MirrorPropertyEntity startDatePropertyEntity = null;
if(StringUtils.isNotBlank(startDatePropertyName)){
startDatePropertyEntity = metaDataManageService.findMPropertyByName(mObjectEntity, startDatePropertyName);
}
MirrorPropertyEntity pkPropertyEntity = metaDataManageService.findPrimaryKeyMPropertyByBelongMObject(mObjectEntity);
String objPKValue = (String)param.get(pkPropertyEntity.getPropertyPath());
//变更的值
Object changeValue = param.get(mirrorPropertyEntity.getPropertyPath());
//结构化对象
MPropertyEntity mappedByProperty = historyPropertyEntity.getMetaProperty().getMappedByProperty();
MObjectEntity joinedMObjet = historyPropertyEntity.getMetaProperty().getMetaObject();
MirrorPropertyEntity foreignkeyProperty = metaDataManageService.findMPropertyByBelongMObjectAndFieldName(joinedMObjet,mappedByProperty.getFieldName());
//生成简单表达式
MExpressionEntity expression = metaDataExpressionService.createSimpleEqExpress(foreignkeyProperty, objPKValue);
MExpressGroupEntity expressGroup = new MExpressGroupEntity(expression);
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy