提交 8b03425a 编写于 作者: misaka's avatar misaka

update

上级 a9958486
...@@ -103,6 +103,7 @@ public class Ir_sequenceExService extends Ir_sequenceServiceImpl { ...@@ -103,6 +103,7 @@ public class Ir_sequenceExService extends Ir_sequenceServiceImpl {
} else { } else {
if (true) if (true)
throw new RuntimeException("暂未实现"); throw new RuntimeException("暂未实现");
Timestamp seq_date = et.get("sequence_date") == null ? null : (Timestamp) et.get("sequence_date");
// 带有时间范围 // 带有时间范围
Ir_sequence_date_rangeSearchContext ctx = new Ir_sequence_date_rangeSearchContext(); Ir_sequence_date_rangeSearchContext ctx = new Ir_sequence_date_rangeSearchContext();
ctx.setN_sequence_id_eq(et.getId()); ctx.setN_sequence_id_eq(et.getId());
......
package cn.ibizlab.businesscentral.core.extensions.service; package cn.ibizlab.businesscentral.core.extensions.service;
import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_users;
import cn.ibizlab.businesscentral.core.odoo_base.service.IRes_usersService;
import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_followers; import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_followers;
import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_followers_mail_message_subtype_rel;
import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_message_subtype;
import cn.ibizlab.businesscentral.core.odoo_mail.filter.Mail_message_subtypeSearchContext;
import cn.ibizlab.businesscentral.core.odoo_mail.service.IMail_followers_mail_message_subtype_relService;
import cn.ibizlab.businesscentral.core.odoo_mail.service.IMail_message_subtypeService;
import cn.ibizlab.businesscentral.core.odoo_mail.service.impl.Mail_followersServiceImpl; import cn.ibizlab.businesscentral.core.odoo_mail.service.impl.Mail_followersServiceImpl;
import cn.ibizlab.businesscentral.util.domain.EntityMP;
import cn.ibizlab.businesscentral.util.security.AuthenticationUser;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j @Slf4j
@Primary @Primary
@Service("Mail_followersExService") @Service("Mail_followersExService")
public class Mail_followersExService extends Mail_followersServiceImpl { public class Mail_followersExService extends Mail_followersServiceImpl {
@Autowired
IMail_followers_mail_message_subtype_relService mail_followers_mail_message_subtype_relService;
@Autowired
IRes_usersService res_usersService;
@Autowired
IMail_message_subtypeService mail_message_subtypeService;
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
@Override @Override
public boolean create(Mail_followers et) { public boolean create(Mail_followers et) {
Mail_followers exists = new Mail_followers(); Mail_followers exists = new Mail_followers();
...@@ -26,10 +52,36 @@ public class Mail_followersExService extends Mail_followersServiceImpl { ...@@ -26,10 +52,36 @@ public class Mail_followersExService extends Mail_followersServiceImpl {
return super.create(et); return super.create(et);
} }
public <T> void add_default_followers(T et) { public <T extends EntityMP> void add_default_followers(T et) {
if (et.get("id") == null) {
return;
}
if (et.get("mail_create_nosubscribe") != null) {
return;
}
AuthenticationUser user = AuthenticationUser.getAuthenticationUser();
Res_users res_users = res_usersService.get(Long.parseLong(user.getUserid()));
Mail_followers follower = new Mail_followers();
follower.setResModel(et.getIrModel());
follower.setResId(Integer.parseInt(et.get("id").toString()));
follower.setPartnerId(res_users.getPartnerId());
this.create(follower);
//关注消息类型
Mail_message_subtypeSearchContext ctx = new Mail_message_subtypeSearchContext();
ctx.set("res_model", et.getIrModel());
List<Mail_message_subtype> message_subtypes = mail_message_subtypeService.searchDefaultEx(ctx).getContent();
for (Mail_message_subtype message_subtype : message_subtypes) {
Mail_followers_mail_message_subtype_rel rel = new Mail_followers_mail_message_subtype_rel();
rel.setMailFollowersId(follower.getId());
rel.setMailMessageSubtypeId(message_subtype.getId());
mail_followers_mail_message_subtype_relService.create(rel);
}
} }
public <T> void add_followers(T et) { public <T> void add_followers(T et) {
} }
......
...@@ -10,5 +10,9 @@ import org.springframework.stereotype.Service; ...@@ -10,5 +10,9 @@ import org.springframework.stereotype.Service;
@Service("Mail_messageExService") @Service("Mail_messageExService")
public class Mail_messageExService extends Mail_messageServiceImpl { public class Mail_messageExService extends Mail_messageServiceImpl {
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
}
} }
package cn.ibizlab.businesscentral.core.extensions.service; package cn.ibizlab.businesscentral.core.extensions.service;
import cn.ibizlab.businesscentral.core.odoo_ir.domain.Ir_model_fields;
import cn.ibizlab.businesscentral.core.odoo_ir.filter.Ir_model_fieldsSearchContext;
import cn.ibizlab.businesscentral.core.odoo_ir.service.IIr_model_fieldsService;
import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_message;
import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_message_subtype;
import cn.ibizlab.businesscentral.core.odoo_mail.service.impl.Mail_tracking_valueServiceImpl; import cn.ibizlab.businesscentral.core.odoo_mail.service.impl.Mail_tracking_valueServiceImpl;
import cn.ibizlab.businesscentral.core.util.helper.EBSServiceImpl;
import cn.ibizlab.businesscentral.util.domain.EntityMP;
import cn.ibizlab.businesscentral.util.helper.CaseFormatMethod;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_tracking_value; import cn.ibizlab.businesscentral.core.odoo_mail.domain.Mail_tracking_value;
import org.apache.commons.lang3.StringUtils;
import org.javers.core.JaversBuilder;
import org.javers.core.diff.Change;
import org.javers.core.diff.Diff;
import org.javers.core.diff.changetype.ValueChange;
import org.javers.core.metamodel.clazz.EntityDefinitionBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 实体[邮件跟踪值] 自定义服务对象 * 实体[邮件跟踪值] 自定义服务对象
...@@ -16,6 +33,9 @@ import java.util.*; ...@@ -16,6 +33,9 @@ import java.util.*;
@Service("Mail_tracking_valueExService") @Service("Mail_tracking_valueExService")
public class Mail_tracking_valueExService extends Mail_tracking_valueServiceImpl { public class Mail_tracking_valueExService extends Mail_tracking_valueServiceImpl {
@Autowired
IIr_model_fieldsService ir_model_fieldsService;
@Override @Override
protected Class currentModelClass() { protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1); return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
...@@ -23,6 +43,7 @@ public class Mail_tracking_valueExService extends Mail_tracking_valueServiceImpl ...@@ -23,6 +43,7 @@ public class Mail_tracking_valueExService extends Mail_tracking_valueServiceImpl
/** /**
* 自定义行为[A]用户扩展 * 自定义行为[A]用户扩展
*
* @param et * @param et
* @return * @return
*/ */
...@@ -31,5 +52,103 @@ public class Mail_tracking_valueExService extends Mail_tracking_valueServiceImpl ...@@ -31,5 +52,103 @@ public class Mail_tracking_valueExService extends Mail_tracking_valueServiceImpl
public Mail_tracking_value a(Mail_tracking_value et) { public Mail_tracking_value a(Mail_tracking_value et) {
return super.a(et); return super.a(et);
} }
@Transactional
public <T extends EntityMP> void add_default_create_message(EBSServiceImpl service, T et) {
Mail_message message = new Mail_message();
message.setModel(et.getIrModel());
message.setResId((Integer) et.get("id"));
message.setBody(et.getIrModel() + " create");
message.setSubtypeId(2l);
message.setMessageType("notification");
// SpringContextHolder.getBean(IMail_messageService.class).create(null);
}
@Transactional
public <T extends EntityMP> List<Mail_tracking_value> message_track(EBSServiceImpl service, T _old, T _new) {
List<Mail_tracking_value> tracking_values = new ArrayList<>();
List<Ir_model_fields> fields = this.getIr_fields(_old);
if (fields.size() == 0)
return tracking_values;
List<String> strCodeFields = fields.stream().map(u -> CaseFormatMethod.exec(u.getName(), "l_u2lC")).collect(Collectors.toList());
strCodeFields.add("id");
JaversBuilder javersBuilder = JaversBuilder.javers();
EntityDefinitionBuilder entityDefinitionBuilder = EntityDefinitionBuilder.entityDefinition(_old.getClass());
entityDefinitionBuilder.withIdPropertyName("id");
entityDefinitionBuilder.withIncludedProperties(strCodeFields);
javersBuilder.registerType(entityDefinitionBuilder.build());
Diff diff = javersBuilder.build().compare(_old, _new);
if (!diff.hasChanges())
return tracking_values;
Mail_message_subtype message_subtype = service.getMessageSubType(_new, diff);
Mail_message message = new Mail_message();
message.setModel(_old.getIrModel());
message.setResId((Integer) _old.get("id"));
message.setBody("");
message.setSubtypeId(message_subtype.getId());
message.setMessageType("notification");
for (Change change : diff.getChanges()) {
if (change instanceof ValueChange) {
ValueChange vchange = (ValueChange) change;
String str_ir_model_fields = CaseFormatMethod.exec(vchange.getPropertyName(), "lC2l_u");
Ir_model_fields ir_model_fields = fields.stream().filter(s -> {
return s.getName().equals(str_ir_model_fields);
}).findAny().get();
Mail_tracking_value tracking_value = new Mail_tracking_value();
tracking_value.setMailMessageId(0l);
tracking_value.setField(ir_model_fields.getName());
tracking_value.setFieldDesc(ir_model_fields.getFieldDescription());
tracking_value.setFieldType(ir_model_fields.getTtype());
tracking_value.setTrackSequence(ir_model_fields.getTracking());
setTrackingValue(tracking_value, ir_model_fields, vchange);
tracking_values.add(tracking_value);
}
}
return tracking_values;
}
private void setTrackingValue(Mail_tracking_value mail_tracking_value, Ir_model_fields ir_model_fields, ValueChange vchange) {
if (StringUtils.compare(ir_model_fields.getTtype(), "date") == 0 || StringUtils.compare(ir_model_fields.getTtype(), "datetime") == 0) {
mail_tracking_value.set("oldValueDatetime", vchange.getLeft());
mail_tracking_value.set("newValueDatetime", vchange.getRight());
} else if (StringUtils.compare(ir_model_fields.getTtype(), "integer") == 0 || StringUtils.compare(ir_model_fields.getTtype(), "many2one") == 0) {
mail_tracking_value.set("oldValueInteger", vchange.getLeft());
mail_tracking_value.set("newValueInteger", vchange.getRight());
} else if (StringUtils.compare(ir_model_fields.getTtype(), "float") == 0) {
mail_tracking_value.set("oldValueFloat", vchange.getLeft());
mail_tracking_value.set("newValueFloat", vchange.getRight());
} else if (StringUtils.compare(ir_model_fields.getTtype(), "monetary") == 0) {
mail_tracking_value.set("oldValueMonetary", vchange.getLeft());
mail_tracking_value.set("newValueMonetary", vchange.getRight());
} else if (StringUtils.compare(ir_model_fields.getTtype(), "selection") == 0) {
mail_tracking_value.set("oldValueChar", vchange.getLeft());
mail_tracking_value.set("newValueChar", vchange.getRight());
} else if (StringUtils.compare(ir_model_fields.getTtype(), "text") == 0) {
mail_tracking_value.set("oldValueText", vchange.getLeft());
mail_tracking_value.set("newValueText", vchange.getRight());
} else {
mail_tracking_value.set("oldValueChar", vchange.getLeft());
mail_tracking_value.set("newValueChar", vchange.getRight());
}
}
private Map<String, List<Ir_model_fields>> ir_model_fieldsMap = new HashMap<>();
private <T extends EntityMP> List<Ir_model_fields> getIr_fields(T et) {
if (ir_model_fieldsMap.containsKey(et.getIrModel()))
return ir_model_fieldsMap.get(et.getIrModel());
Ir_model_fieldsSearchContext ctx = new Ir_model_fieldsSearchContext();
ctx.setN_model_eq(et.getIrModel());
List<Ir_model_fields> fields = ir_model_fieldsService.searchTrackingFields(ctx).getContent();
ir_model_fieldsMap.put(et.getIrModel(), fields);
return fields;
}
} }
...@@ -176,7 +176,14 @@ public class Purchase_requisitionExService extends Purchase_requisitionServiceIm ...@@ -176,7 +176,14 @@ public class Purchase_requisitionExService extends Purchase_requisitionServiceIm
et.setOrderCount(purchaseOrderService.count(new QueryWrapper<Purchase_order>().setEntity(order))); et.setOrderCount(purchaseOrderService.count(new QueryWrapper<Purchase_order>().setEntity(order)));
} }
// Mail_followersExService.add_default_followers(et);
return super.masterTabCount(et); return super.masterTabCount(et);
} }
@Autowired
Mail_followersExService Mail_followersExService ;
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册