提交 fbcda33c 编写于 作者: ibizdev's avatar ibizdev

xignzi006 发布系统代码

上级 41d5ca05
...@@ -79,6 +79,21 @@ export default class AccountServiceBase extends EntityService { ...@@ -79,6 +79,21 @@ export default class AccountServiceBase extends EntityService {
} }
} }
masterData.opportunities = opportunitiesData; masterData.opportunities = opportunitiesData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
let listaccountsData:any = []; let listaccountsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts'),'undefined')){ if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts'),'undefined')){
listaccountsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts') as any); listaccountsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts') as any);
...@@ -109,21 +124,6 @@ export default class AccountServiceBase extends EntityService { ...@@ -109,21 +124,6 @@ export default class AccountServiceBase extends EntityService {
} }
} }
masterData.contacts = contactsData; masterData.contacts = contactsData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
Object.assign(data,masterData); Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){ if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null; data[this.APPDEKEY] = null;
...@@ -134,9 +134,9 @@ export default class AccountServiceBase extends EntityService { ...@@ -134,9 +134,9 @@ export default class AccountServiceBase extends EntityService {
let tempContext:any = JSON.parse(JSON.stringify(context)); let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/accounts`,data,isloading); let res:any = await Http.getInstance().post(`/accounts`,data,isloading);
this.tempStorage.setItem(tempContext.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities)); this.tempStorage.setItem(tempContext.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities));
this.tempStorage.setItem(tempContext.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(tempContext.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts)); this.tempStorage.setItem(tempContext.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts));
this.tempStorage.setItem(tempContext.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts)); this.tempStorage.setItem(tempContext.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts));
this.tempStorage.setItem(tempContext.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res; return res;
} }
...@@ -166,6 +166,21 @@ export default class AccountServiceBase extends EntityService { ...@@ -166,6 +166,21 @@ export default class AccountServiceBase extends EntityService {
} }
} }
masterData.opportunities = opportunitiesData; masterData.opportunities = opportunitiesData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
let listaccountsData:any = []; let listaccountsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts'),'undefined')){ if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts'),'undefined')){
listaccountsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts') as any); listaccountsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts') as any);
...@@ -196,27 +211,12 @@ export default class AccountServiceBase extends EntityService { ...@@ -196,27 +211,12 @@ export default class AccountServiceBase extends EntityService {
} }
} }
masterData.contacts = contactsData; masterData.contacts = contactsData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
Object.assign(data,masterData); Object.assign(data,masterData);
let res:any = await Http.getInstance().put(`/accounts/${context.account}`,data,isloading); let res:any = await Http.getInstance().put(`/accounts/${context.account}`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities)); this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts)); this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts));
this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts)); this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res; return res;
} }
...@@ -245,9 +245,9 @@ export default class AccountServiceBase extends EntityService { ...@@ -245,9 +245,9 @@ export default class AccountServiceBase extends EntityService {
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> { public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/accounts/${context.account}`,isloading); let res:any = await Http.getInstance().get(`/accounts/${context.account}`,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities)); this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts)); this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts));
this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts)); this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res; return res;
} }
...@@ -264,9 +264,9 @@ export default class AccountServiceBase extends EntityService { ...@@ -264,9 +264,9 @@ export default class AccountServiceBase extends EntityService {
let res:any = await Http.getInstance().get(`/accounts/getdraft`,isloading); let res:any = await Http.getInstance().get(`/accounts/getdraft`,isloading);
res.data.account = data.account; res.data.account = data.account;
this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities)); this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts)); this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts));
this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts)); this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res; return res;
} }
...@@ -352,6 +352,21 @@ export default class AccountServiceBase extends EntityService { ...@@ -352,6 +352,21 @@ export default class AccountServiceBase extends EntityService {
} }
} }
masterData.opportunities = opportunitiesData; masterData.opportunities = opportunitiesData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
let listaccountsData:any = []; let listaccountsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts'),'undefined')){ if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts'),'undefined')){
listaccountsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts') as any); listaccountsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_listaccounts') as any);
...@@ -382,27 +397,12 @@ export default class AccountServiceBase extends EntityService { ...@@ -382,27 +397,12 @@ export default class AccountServiceBase extends EntityService {
} }
} }
masterData.contacts = contactsData; masterData.contacts = contactsData;
let leadsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_leads'),'undefined')){
leadsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_leads') as any);
if(leadsData && leadsData.length && leadsData.length > 0){
leadsData.forEach((item:any) => {
if(item.srffrontuf){
if(Object.is(item.srffrontuf,"0")){
item.leadid = null;
}
delete item.srffrontuf;
}
});
}
}
masterData.leads = leadsData;
Object.assign(data,masterData); Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/accounts/${context.account}/save`,data,isloading); let res:any = await Http.getInstance().post(`/accounts/${context.account}/save`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities)); this.tempStorage.setItem(context.srfsessionkey+'_opportunities',JSON.stringify(res.data.opportunities));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts)); this.tempStorage.setItem(context.srfsessionkey+'_listaccounts',JSON.stringify(res.data.listaccounts));
this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts)); this.tempStorage.setItem(context.srfsessionkey+'_contacts',JSON.stringify(res.data.contacts));
this.tempStorage.setItem(context.srfsessionkey+'_leads',JSON.stringify(res.data.leads));
return res; return res;
} }
......
...@@ -157,42 +157,6 @@ export class QuickCreateEditFormBase extends EditFormControlBase { ...@@ -157,42 +157,6 @@ export class QuickCreateEditFormBase extends EditFormControlBase {
}; };
/**
* 表单逻辑
*
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof QuickCreateEditFormBase
*/
public formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
if (Object.is(name, 'owneridyominame')) {
const details: string[] = [];
this.updateFormItems('FillOwn', this.data, details, true);
}
}
/** /**
* 新建默认值 * 新建默认值
* @memberof QuickCreateEditFormBase * @memberof QuickCreateEditFormBase
......
...@@ -44,6 +44,9 @@ import org.springframework.util.StringUtils; ...@@ -44,6 +44,9 @@ import org.springframework.util.StringUtils;
@Service("ProductServiceImpl") @Service("ProductServiceImpl")
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService { public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
@Autowired
@Lazy
protected cn.ibizlab.businesscentral.core.sales.service.ICompetitorProductService competitorproductService;
@Autowired @Autowired
@Lazy @Lazy
protected cn.ibizlab.businesscentral.core.service.service.IContractDetailService contractdetailService; protected cn.ibizlab.businesscentral.core.service.service.IContractDetailService contractdetailService;
......
package cn.ibizlab.businesscentral.core.sales.domain;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.util.ObjectUtils;
import org.springframework.util.DigestUtils;
import cn.ibizlab.businesscentral.util.domain.EntityBase;
import cn.ibizlab.businesscentral.util.annotation.DEField;
import cn.ibizlab.businesscentral.util.enums.DEPredefinedFieldType;
import cn.ibizlab.businesscentral.util.enums.DEFieldDefaultValueType;
import java.io.Serializable;
import lombok.*;
import org.springframework.data.annotation.Transient;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.baomidou.mybatisplus.annotation.*;
import cn.ibizlab.businesscentral.util.domain.EntityMP;
/**
* 实体[竞争对手产品]
*/
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(value = "handler")
@TableName(value = "RELATIONSHIPS",resultMap = "CompetitorProductResultMap")
public class CompetitorProduct extends EntityMP implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 建立时间
*/
@DEField(preType = DEPredefinedFieldType.CREATEDATE)
@TableField(value = "createdate" , fill = FieldFill.INSERT)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "createdate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
private Timestamp createdate;
/**
* 建立人
*/
@DEField(preType = DEPredefinedFieldType.CREATEMAN)
@TableField(value = "createman" , fill = FieldFill.INSERT)
@JSONField(name = "createman")
@JsonProperty("createman")
private String createman;
/**
* 关系标识
*/
@DEField(isKeyField=true)
@TableId(value= "relationshipsid",type=IdType.ASSIGN_UUID)
@JSONField(name = "relationshipsid")
@JsonProperty("relationshipsid")
private String relationshipsid;
/**
* 关系名称
*/
@TableField(value = "relationshipsname")
@JSONField(name = "relationshipsname")
@JsonProperty("relationshipsname")
private String relationshipsname;
/**
* 关系类型
*/
@DEField(defaultValue = "COMPETITORPRODUCT")
@TableField(value = "relationshipstype")
@JSONField(name = "relationshipstype")
@JsonProperty("relationshipstype")
private String relationshipstype;
/**
* 更新时间
*/
@DEField(preType = DEPredefinedFieldType.UPDATEDATE)
@TableField(value = "updatedate")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
private Timestamp updatedate;
/**
* 更新人
*/
@DEField(preType = DEPredefinedFieldType.UPDATEMAN)
@TableField(value = "updateman")
@JSONField(name = "updateman")
@JsonProperty("updateman")
private String updateman;
/**
* 竞争对手
*/
@TableField(value = "entityid")
@JSONField(name = "entityid")
@JsonProperty("entityid")
private String entityid;
/**
* 产品
*/
@TableField(value = "entity2id")
@JSONField(name = "entity2id")
@JsonProperty("entity2id")
private String entity2id;
/**
* 竞争对手
*/
@TableField(value = "entityname")
@JSONField(name = "entityname")
@JsonProperty("entityname")
private String entityname;
/**
*
*/
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
private cn.ibizlab.businesscentral.core.sales.domain.Competitor competitor;
/**
*
*/
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
private cn.ibizlab.businesscentral.core.product.domain.Product product;
/**
* 设置 [关系名称]
*/
public void setRelationshipsname(String relationshipsname){
this.relationshipsname = relationshipsname ;
this.modify("relationshipsname",relationshipsname);
}
/**
* 设置 [关系类型]
*/
public void setRelationshipstype(String relationshipstype){
this.relationshipstype = relationshipstype ;
this.modify("relationshipstype",relationshipstype);
}
/**
* 设置 [竞争对手]
*/
public void setEntityid(String entityid){
this.entityid = entityid ;
this.modify("entityid",entityid);
}
/**
* 设置 [产品]
*/
public void setEntity2id(String entity2id){
this.entity2id = entity2id ;
this.modify("entity2id",entity2id);
}
/**
* 设置 [竞争对手]
*/
public void setEntityname(String entityname){
this.entityname = entityname ;
this.modify("entityname",entityname);
}
}
package cn.ibizlab.businesscentral.core.sales.filter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import cn.ibizlab.businesscentral.util.filter.QueryWrapperContext;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.ibizlab.businesscentral.core.sales.domain.CompetitorProduct;
/**
* 关系型数据实体[CompetitorProduct] 查询条件对象
*/
@Slf4j
@Data
public class CompetitorProductSearchContext extends QueryWrapperContext<CompetitorProduct> {
private String n_relationshipsname_like;//[关系名称]
public void setN_relationshipsname_like(String n_relationshipsname_like) {
this.n_relationshipsname_like = n_relationshipsname_like;
if(!ObjectUtils.isEmpty(this.n_relationshipsname_like)){
this.getSearchCond().like("relationshipsname", n_relationshipsname_like);
}
}
private String n_relationshipstype_eq;//[关系类型]
public void setN_relationshipstype_eq(String n_relationshipstype_eq) {
this.n_relationshipstype_eq = n_relationshipstype_eq;
if(!ObjectUtils.isEmpty(this.n_relationshipstype_eq)){
this.getSearchCond().eq("relationshipstype", n_relationshipstype_eq);
}
}
private String n_entityid_eq;//[竞争对手]
public void setN_entityid_eq(String n_entityid_eq) {
this.n_entityid_eq = n_entityid_eq;
if(!ObjectUtils.isEmpty(this.n_entityid_eq)){
this.getSearchCond().eq("entityid", n_entityid_eq);
}
}
private String n_entity2id_eq;//[产品]
public void setN_entity2id_eq(String n_entity2id_eq) {
this.n_entity2id_eq = n_entity2id_eq;
if(!ObjectUtils.isEmpty(this.n_entity2id_eq)){
this.getSearchCond().eq("entity2id", n_entity2id_eq);
}
}
private String n_entityname_eq;//[竞争对手]
public void setN_entityname_eq(String n_entityname_eq) {
this.n_entityname_eq = n_entityname_eq;
if(!ObjectUtils.isEmpty(this.n_entityname_eq)){
this.getSearchCond().eq("entityname", n_entityname_eq);
}
}
private String n_entityname_like;//[竞争对手]
public void setN_entityname_like(String n_entityname_like) {
this.n_entityname_like = n_entityname_like;
if(!ObjectUtils.isEmpty(this.n_entityname_like)){
this.getSearchCond().like("entityname", n_entityname_like);
}
}
/**
* 启用快速搜索
*/
public void setQuery(String query)
{
this.query=query;
if(!StringUtils.isEmpty(query)){
this.getSearchCond().and( wrapper ->
wrapper.like("relationshipsname", query)
);
}
}
}
package cn.ibizlab.businesscentral.core.sales.mapper;
import java.util.List;
import org.apache.ibatis.annotations.*;
import java.util.Map;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import java.util.HashMap;
import org.apache.ibatis.annotations.Select;
import cn.ibizlab.businesscentral.core.sales.domain.CompetitorProduct;
import cn.ibizlab.businesscentral.core.sales.filter.CompetitorProductSearchContext;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.alibaba.fastjson.JSONObject;
public interface CompetitorProductMapper extends BaseMapper<CompetitorProduct>{
Page<CompetitorProduct> searchDefault(IPage page, @Param("srf") CompetitorProductSearchContext context, @Param("ew") Wrapper<CompetitorProduct> wrapper) ;
@Override
CompetitorProduct selectById(Serializable id);
@Override
int insert(CompetitorProduct entity);
@Override
int updateById(@Param(Constants.ENTITY) CompetitorProduct entity);
@Override
int update(@Param(Constants.ENTITY) CompetitorProduct entity, @Param("ew") Wrapper<CompetitorProduct> updateWrapper);
@Override
int deleteById(Serializable id);
/**
* 自定义查询SQL
* @param sql
* @return
*/
@Select("${sql}")
List<JSONObject> selectBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义更新SQL
* @param sql
* @return
*/
@Update("${sql}")
boolean updateBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义插入SQL
* @param sql
* @return
*/
@Insert("${sql}")
boolean insertBySQL(@Param("sql") String sql, @Param("et")Map param);
/**
* 自定义删除SQL
* @param sql
* @return
*/
@Delete("${sql}")
boolean deleteBySQL(@Param("sql") String sql, @Param("et")Map param);
List<CompetitorProduct> selectByEntityid(@Param("competitorid") Serializable competitorid) ;
List<CompetitorProduct> selectByEntity2id(@Param("productid") Serializable productid) ;
}
package cn.ibizlab.businesscentral.core.sales.service;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
import java.math.BigInteger;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.alibaba.fastjson.JSONObject;
import org.springframework.cache.annotation.CacheEvict;
import cn.ibizlab.businesscentral.core.sales.domain.CompetitorProduct;
import cn.ibizlab.businesscentral.core.sales.filter.CompetitorProductSearchContext;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[CompetitorProduct] 服务对象接口
*/
public interface ICompetitorProductService extends IService<CompetitorProduct>{
boolean create(CompetitorProduct et) ;
void createBatch(List<CompetitorProduct> list) ;
boolean update(CompetitorProduct et) ;
void updateBatch(List<CompetitorProduct> list) ;
boolean remove(String key) ;
void removeBatch(Collection<String> idList) ;
CompetitorProduct get(String key) ;
CompetitorProduct getDraft(CompetitorProduct et) ;
boolean checkKey(CompetitorProduct et) ;
boolean save(CompetitorProduct et) ;
void saveBatch(List<CompetitorProduct> list) ;
Page<CompetitorProduct> searchDefault(CompetitorProductSearchContext context) ;
List<CompetitorProduct> selectByEntityid(String competitorid) ;
void removeByEntityid(String competitorid) ;
List<CompetitorProduct> selectByEntity2id(String productid) ;
void removeByEntity2id(String productid) ;
/**
*自定义查询SQL
* @param sql select * from table where id =#{et.param}
* @param param 参数列表 param.put("param","1");
* @return select * from table where id = '1'
*/
List<JSONObject> select(String sql, Map param);
/**
*自定义SQL
* @param sql update table set name ='test' where id =#{et.param}
* @param param 参数列表 param.put("param","1");
* @return update table set name ='test' where id = '1'
*/
boolean execute(String sql, Map param);
List<CompetitorProduct> getCompetitorproductByIds(List<String> ids) ;
List<CompetitorProduct> getCompetitorproductByEntities(List<CompetitorProduct> entities) ;
}
package cn.ibizlab.businesscentral.core.sales.service.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import cn.ibizlab.businesscentral.core.sales.domain.CompetitorProduct;
import cn.ibizlab.businesscentral.core.sales.filter.CompetitorProductSearchContext;
import cn.ibizlab.businesscentral.core.sales.service.ICompetitorProductService;
import cn.ibizlab.businesscentral.util.helper.CachedBeanCopier;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ibizlab.businesscentral.core.sales.mapper.CompetitorProductMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils;
/**
* 实体[竞争对手产品] 服务对象接口实现
*/
@Slf4j
@Service("CompetitorProductServiceImpl")
public class CompetitorProductServiceImpl extends ServiceImpl<CompetitorProductMapper, CompetitorProduct> implements ICompetitorProductService {
@Autowired
@Lazy
protected cn.ibizlab.businesscentral.core.sales.service.ICompetitorService competitorService;
@Autowired
@Lazy
protected cn.ibizlab.businesscentral.core.product.service.IProductService productService;
protected int batchSize = 500;
@Override
@Transactional
public boolean create(CompetitorProduct et) {
fillParentData(et);
if(!this.retBool(this.baseMapper.insert(et)))
return false;
CachedBeanCopier.copy(get(et.getRelationshipsid()),et);
return true;
}
@Override
public void createBatch(List<CompetitorProduct> list) {
list.forEach(item->fillParentData(item));
this.saveBatch(list,batchSize);
}
@Override
@Transactional
public boolean update(CompetitorProduct et) {
fillParentData(et);
if(!update(et,(Wrapper) et.getUpdateWrapper(true).eq("relationshipsid",et.getRelationshipsid())))
return false;
CachedBeanCopier.copy(get(et.getRelationshipsid()),et);
return true;
}
@Override
public void updateBatch(List<CompetitorProduct> list) {
list.forEach(item->fillParentData(item));
updateBatchById(list,batchSize);
}
@Override
@Transactional
public boolean remove(String key) {
boolean result=removeById(key);
return result ;
}
@Override
public void removeBatch(Collection<String> idList) {
removeByIds(idList);
}
@Override
@Transactional
public CompetitorProduct get(String key) {
CompetitorProduct et = getById(key);
if(et==null){
et=new CompetitorProduct();
et.setRelationshipsid(key);
}
else{
}
return et;
}
@Override
public CompetitorProduct getDraft(CompetitorProduct et) {
fillParentData(et);
return et;
}
@Override
public boolean checkKey(CompetitorProduct et) {
return (!ObjectUtils.isEmpty(et.getRelationshipsid()))&&(!Objects.isNull(this.getById(et.getRelationshipsid())));
}
@Override
@Transactional
public boolean save(CompetitorProduct et) {
if(!saveOrUpdate(et))
return false;
return true;
}
@Override
@Transactional(
rollbackFor = {Exception.class}
)
public boolean saveOrUpdate(CompetitorProduct et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
}
@Override
public boolean saveBatch(Collection<CompetitorProduct> list) {
list.forEach(item->fillParentData(item));
saveOrUpdateBatch(list,batchSize);
return true;
}
@Override
public void saveBatch(List<CompetitorProduct> list) {
list.forEach(item->fillParentData(item));
saveOrUpdateBatch(list,batchSize);
}
@Override
public List<CompetitorProduct> selectByEntityid(String competitorid) {
return baseMapper.selectByEntityid(competitorid);
}
@Override
public void removeByEntityid(String competitorid) {
this.remove(new QueryWrapper<CompetitorProduct>().eq("entityid",competitorid));
}
@Override
public List<CompetitorProduct> selectByEntity2id(String productid) {
return baseMapper.selectByEntity2id(productid);
}
@Override
public void removeByEntity2id(String productid) {
this.remove(new QueryWrapper<CompetitorProduct>().eq("entity2id",productid));
}
/**
* 查询集合 DEFAULT
*/
@Override
public Page<CompetitorProduct> searchDefault(CompetitorProductSearchContext context) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<CompetitorProduct> pages=baseMapper.searchDefault(context.getPages(),context,context.getSelectCond());
return new PageImpl<CompetitorProduct>(pages.getRecords(), context.getPageable(), pages.getTotal());
}
/**
* 为当前实体填充父数据(外键值文本、外键值附加数据)
* @param et
*/
private void fillParentData(CompetitorProduct et){
//实体关系[DER1N_COMPETITORPRODUCT_COMPETITOR_ENTITYID]
if(!ObjectUtils.isEmpty(et.getEntityid())){
cn.ibizlab.businesscentral.core.sales.domain.Competitor competitor=et.getCompetitor();
if(ObjectUtils.isEmpty(competitor)){
cn.ibizlab.businesscentral.core.sales.domain.Competitor majorEntity=competitorService.get(et.getEntityid());
et.setCompetitor(majorEntity);
competitor=majorEntity;
}
et.setEntityname(competitor.getCompetitorname());
}
}
@Override
public List<JSONObject> select(String sql, Map param){
return this.baseMapper.selectBySQL(sql,param);
}
@Override
@Transactional
public boolean execute(String sql , Map param){
if (sql == null || sql.isEmpty()) {
return false;
}
if (sql.toLowerCase().trim().startsWith("insert")) {
return this.baseMapper.insertBySQL(sql,param);
}
if (sql.toLowerCase().trim().startsWith("update")) {
return this.baseMapper.updateBySQL(sql,param);
}
if (sql.toLowerCase().trim().startsWith("delete")) {
return this.baseMapper.deleteBySQL(sql,param);
}
log.warn("暂未支持的SQL语法");
return true;
}
@Override
public List<CompetitorProduct> getCompetitorproductByIds(List<String> ids) {
return this.listByIds(ids);
}
@Override
public List<CompetitorProduct> getCompetitorproductByEntities(List<CompetitorProduct> entities) {
List ids =new ArrayList();
for(CompetitorProduct entity : entities){
Serializable id=entity.getRelationshipsid();
if(!ObjectUtils.isEmpty(id)){
ids.add(id);
}
}
if(ids.size()>0)
return this.listByIds(ids);
else
return entities;
}
}
...@@ -44,6 +44,9 @@ import org.springframework.util.StringUtils; ...@@ -44,6 +44,9 @@ import org.springframework.util.StringUtils;
@Service("CompetitorServiceImpl") @Service("CompetitorServiceImpl")
public class CompetitorServiceImpl extends ServiceImpl<CompetitorMapper, Competitor> implements ICompetitorService { public class CompetitorServiceImpl extends ServiceImpl<CompetitorMapper, Competitor> implements ICompetitorService {
@Autowired
@Lazy
protected cn.ibizlab.businesscentral.core.sales.service.ICompetitorProductService competitorproductService;
@Autowired @Autowired
@Lazy @Lazy
protected cn.ibizlab.businesscentral.core.sales.service.ICompetitorSalesLiteratureService competitorsalesliteratureService; protected cn.ibizlab.businesscentral.core.sales.service.ICompetitorSalesLiteratureService competitorsalesliteratureService;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.ibizlab.businesscentral.core.sales.mapper.CompetitorProductMapper">
<!--该方法用于重写mybatis中selectById方法,以实现查询逻辑属性-->
<select id="selectById" resultMap="CompetitorProductResultMap" databaseId="mysql">
<![CDATA[select t1.* from (SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`ENTITY2ID`, t1.`ENTITYID`, t1.`RELATIONSHIPSID`, t1.`RELATIONSHIPSNAME`, t1.`RELATIONSHIPSTYPE`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `RELATIONSHIPS` t1 ) t1 where relationshipsid=#{id}]]>
</select>
<!--通过mybatis将查询结果注入到entity中,通过配置autoMapping="true"由mybatis自动处理映射关系 -->
<resultMap id="CompetitorProductResultMap" type="cn.ibizlab.businesscentral.core.sales.domain.CompetitorProduct" autoMapping="true">
<id property="relationshipsid" column="relationshipsid" /><!--主键字段映射-->
<result property="entityid" column="entityid" />
<result property="entity2id" column="entity2id" />
<!--通过mybatis自动注入关系属性[主实体],fetchType="lazy"为懒加载配置 -->
<association property="competitor" javaType="cn.ibizlab.businesscentral.core.sales.domain.Competitor" column="entityid" select="cn.ibizlab.businesscentral.core.sales.mapper.CompetitorMapper.selectById" fetchType="lazy"></association>
<!--通过mybatis自动注入关系属性[主实体],fetchType="lazy"为懒加载配置 -->
<association property="product" javaType="cn.ibizlab.businesscentral.core.product.domain.Product" column="entity2id" select="cn.ibizlab.businesscentral.core.product.mapper.ProductMapper.selectById" fetchType="lazy"></association>
</resultMap>
<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_COMPETITORPRODUCT_COMPETITOR_ENTITYID] -->
<select id="selectByEntityid" resultMap="CompetitorProductResultMap">
select t1.* from (
<include refid="Default" />
) t1
where entityid=#{competitorid}
</select>
<!--关系实体暴露select方法供主实体通过外键查询关系实体数据[实体关系名称:DER1N_COMPETITORPRODUCT_PRODUCT_ENTITY2ID] -->
<select id="selectByEntity2id" resultMap="CompetitorProductResultMap">
select t1.* from (
<include refid="Default" />
) t1
where entity2id=#{productid}
</select>
<!--数据集合[Default]-->
<select id="searchDefault" parameterType="cn.ibizlab.businesscentral.core.sales.filter.CompetitorProductSearchContext" resultMap="CompetitorProductResultMap">
select t1.* from (
<include refid="Default" />
)t1
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<!--数据查询[Default]-->
<sql id="Default" databaseId="mysql">
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`ENTITY2ID`, t1.`ENTITYID`, t1.`RELATIONSHIPSID`, t1.`RELATIONSHIPSNAME`, t1.`RELATIONSHIPSTYPE`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `RELATIONSHIPS` t1
WHERE ( t1.`RELATIONSHIPSTYPE` = '' )
]]>
</sql>
<!--数据查询[View]-->
<sql id="View" databaseId="mysql">
<![CDATA[ SELECT t1.`CREATEDATE`, t1.`CREATEMAN`, t1.`ENTITY2ID`, t1.`ENTITYID`, t1.`RELATIONSHIPSID`, t1.`RELATIONSHIPSNAME`, t1.`RELATIONSHIPSTYPE`, t1.`UPDATEDATE`, t1.`UPDATEMAN` FROM `RELATIONSHIPS` t1
WHERE ( t1.`RELATIONSHIPSTYPE` = '' )
]]>
</sql>
</mapper>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册