@ -0,0 +1,45 @@ | |||||
package com.digiwin.athena.app.infra.entity; | |||||
import java.math.BigDecimal; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import com.digiwin.athena.opt.persistence.domain.BaseMgrEntity; | |||||
import com.google.gson.annotations.SerializedName; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.Builder; | |||||
import lombok.Data; | |||||
import lombok.NoArgsConstructor; | |||||
/** | |||||
* 品号供应商对象 cim_item_supplier | |||||
* | |||||
* @author zhenggl | |||||
* @date 2023-08-31 | |||||
*/ | |||||
@Data | |||||
@AllArgsConstructor | |||||
@NoArgsConstructor | |||||
@Builder | |||||
@TableName(value = "cim_item_supplier", autoResultMap = true) | |||||
public class ItemSupplierEntity extends BaseMgrEntity<ItemSupplierEntity> { | |||||
/** 品号 */ | |||||
@SerializedName(value = "item_no") | |||||
private String itemNo; | |||||
/** 品名 */ | |||||
@SerializedName(value = "item_name") | |||||
private String itemName; | |||||
/** 供应商编号 */ | |||||
@SerializedName(value = "supplier_no") | |||||
private String supplierNo; | |||||
/** 供应商名称 */ | |||||
@SerializedName(value = "supplier_name") | |||||
private String supplierName; | |||||
/** 单价 */ | |||||
@SerializedName(value = "price") | |||||
private BigDecimal price; | |||||
} |
@ -0,0 +1,11 @@ | |||||
package com.digiwin.athena.app.infra.repository; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import com.digiwin.athena.opt.persistence.repository.BaseRepository; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/9/1 | |||||
*/ | |||||
public interface SupplierRepository extends BaseRepository<ItemSupplierEntity> { | |||||
} |
@ -0,0 +1,16 @@ | |||||
package com.digiwin.athena.app.infra.service.Impl; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import com.digiwin.athena.app.infra.repository.SupplierRepository; | |||||
import com.digiwin.athena.app.infra.service.SupplierService; | |||||
import com.digiwin.athena.opt.persistence.service.impl.AbsBaseService; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/9/1 | |||||
*/ | |||||
@Service | |||||
public class SupplierServiceImpl extends AbsBaseService<SupplierRepository, ItemSupplierEntity> implements SupplierService { | |||||
} |
@ -0,0 +1,11 @@ | |||||
package com.digiwin.athena.app.infra.service; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import com.digiwin.athena.opt.persistence.service.IBaseService; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/9/1 | |||||
*/ | |||||
public interface SupplierService extends IBaseService<ItemSupplierEntity> { | |||||
} |
@ -0,0 +1,56 @@ | |||||
package com.digiwin.athena.app.provider; | |||||
import com.digiwin.app.service.DWEAIResult; | |||||
import com.digiwin.app.service.DWService; | |||||
import com.digiwin.app.service.eai.EAIService; | |||||
import com.digiwin.athena.app.service.supplier.SupplierUtil; | |||||
import java.util.Map; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/9/1 | |||||
*/ | |||||
public interface SupplierEAIService extends DWService { | |||||
/** | |||||
* 品号供应商修改 | |||||
* @param headers | |||||
* @param messageBody | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
@EAIService(id = SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_UPDATE) | |||||
DWEAIResult update(Map<String, String> headers, String messageBody) throws Exception; | |||||
/** | |||||
* 品号供应商获取 | |||||
* @param headers | |||||
* @param messageBody | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
@EAIService(id = SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_GET) | |||||
DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception; | |||||
/** | |||||
* 品号供应商新增 | |||||
* @param headers | |||||
* @param messageBody | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
@EAIService(id = SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_CREATE) | |||||
DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception; | |||||
/** | |||||
* 品号供应商删除 | |||||
* @param headers | |||||
* @param messageBody | |||||
* @return | |||||
* @throws Exception | |||||
*/ | |||||
@EAIService(id = SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_DELETE) | |||||
DWEAIResult delete(Map<String, String> headers, String messageBody) throws Exception; | |||||
} |
@ -0,0 +1,40 @@ | |||||
package com.digiwin.athena.app.provider.impl; | |||||
import com.digiwin.app.service.DWEAIResult; | |||||
import com.digiwin.athena.app.provider.SupplierEAIService; | |||||
import com.digiwin.athena.app.service.supplier.SupplierUtil; | |||||
import com.digiwin.athena.opt.common.eai.service.EAIServiceContext; | |||||
import javax.annotation.Resource; | |||||
import java.util.Map; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/9/1 | |||||
*/ | |||||
public class SupplierEAIServiceImpl implements SupplierEAIService { | |||||
@Resource | |||||
private EAIServiceContext eaiServiceContext; | |||||
@Override | |||||
public DWEAIResult update(Map<String, String> headers, String messageBody) throws Exception { | |||||
return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_UPDATE,headers,messageBody); | |||||
} | |||||
@Override | |||||
public DWEAIResult get(Map<String, String> headers, String messageBody) throws Exception { | |||||
return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_GET,headers,messageBody); | |||||
} | |||||
@Override | |||||
public DWEAIResult create(Map<String, String> headers, String messageBody) throws Exception { | |||||
return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_CREATE,headers,messageBody); | |||||
} | |||||
@Override | |||||
public DWEAIResult delete(Map<String, String> headers, String messageBody) throws Exception { | |||||
return eaiServiceContext.execute(SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_DELETE,headers,messageBody); | |||||
} | |||||
} |
@ -0,0 +1,40 @@ | |||||
package com.digiwin.athena.app.service.supplier; | |||||
import com.digiwin.app.service.DWEAIResult; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import com.digiwin.athena.app.infra.service.SupplierService; | |||||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||||
import com.digiwin.athena.opt.common.eai.EAIUtil; | |||||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||||
import lombok.extern.log4j.Log4j2; | |||||
import org.springframework.stereotype.Service; | |||||
import javax.annotation.Resource; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/9/1 | |||||
*/ | |||||
@Log4j2 | |||||
@Service | |||||
public class SupplierCreateEAIService extends AbsEAIService { | |||||
@Resource | |||||
private SupplierService supplierService; | |||||
@Override | |||||
public String getServiceName() { | |||||
return SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_CREATE; | |||||
} | |||||
@Override | |||||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||||
EAIRequest eaiRequest = EAIRequest.build(messageBody); | |||||
List<ItemSupplierEntity> supplierInfo = eaiRequest.getObject("item_supplier_info", SupplierUtil.LIST_ENTITY_SUPPLIER); | |||||
supplierService.saveBatch(supplierInfo); | |||||
return EAIUtil.buildEAIResult(new HashMap<>()); | |||||
} | |||||
} |
@ -0,0 +1,46 @@ | |||||
package com.digiwin.athena.app.service.supplier; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.digiwin.app.service.DWEAIResult; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import com.digiwin.athena.app.infra.service.SupplierService; | |||||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||||
import com.digiwin.athena.opt.common.eai.EAIUtil; | |||||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||||
import lombok.extern.log4j.Log4j2; | |||||
import org.springframework.stereotype.Service; | |||||
import javax.annotation.Resource; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/8/31 | |||||
*/ | |||||
@Service | |||||
@Log4j2 | |||||
public class SupplierDeleteEAIService extends AbsEAIService { | |||||
@Resource | |||||
private SupplierService supplierService; | |||||
@Override | |||||
public String getServiceName() { | |||||
return SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_DELETE; | |||||
} | |||||
@Override | |||||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||||
EAIRequest eaiRequest = EAIRequest.build(messageBody); | |||||
List<ItemSupplierEntity> supplierInfo = eaiRequest.getObject("item_supplier_info", SupplierUtil.LIST_ENTITY_SUPPLIER); | |||||
List<Long> collect = supplierInfo.stream().map(ItemSupplierEntity::getId).collect(Collectors.toList()); | |||||
LambdaQueryWrapper<ItemSupplierEntity> lmq = new LambdaQueryWrapper<>(); | |||||
lmq.in(ItemSupplierEntity::getId,collect); | |||||
supplierService.remove(lmq); | |||||
return EAIUtil.buildEAIResult(new HashMap<>()); | |||||
} | |||||
} |
@ -0,0 +1,58 @@ | |||||
package com.digiwin.athena.app.service.supplier; | |||||
import com.alibaba.fastjson.JSONObject; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.digiwin.app.service.DWEAIResult; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import com.digiwin.athena.app.infra.service.SupplierService; | |||||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||||
import com.digiwin.athena.opt.common.eai.EAIUtil; | |||||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||||
import com.digiwin.athena.opt.common.security.SecurityUtil; | |||||
import lombok.extern.log4j.Log4j2; | |||||
import org.springframework.stereotype.Service; | |||||
import javax.annotation.Resource; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/8/31 | |||||
*/ | |||||
@Service | |||||
@Log4j2 | |||||
public class SupplierGetEAIService extends AbsEAIService { | |||||
@Resource | |||||
private SupplierService supplierService; | |||||
@Override | |||||
public String getServiceName() { | |||||
return SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_GET; | |||||
} | |||||
@Override | |||||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||||
EAIRequest eaiRequest = EAIRequest.build(messageBody); | |||||
List<ItemSupplierEntity> supplierInfo = eaiRequest.getObject("item_supplier_info", SupplierUtil.LIST_ENTITY_SUPPLIER); | |||||
LambdaQueryWrapper<ItemSupplierEntity> lmq = new LambdaQueryWrapper<>(); | |||||
lmq.eq(ItemSupplierEntity::getTenantId, SecurityUtil.getUserProfile().getTenantId()); | |||||
lmq.and( | |||||
queryWrapperInner -> { | |||||
for (ItemSupplierEntity itemSupplierEntity : supplierInfo) { | |||||
queryWrapperInner.or( | |||||
wrapper -> wrapper | |||||
.eq(ItemSupplierEntity::getItemNo, itemSupplierEntity.getItemNo()) | |||||
.eq(ItemSupplierEntity::getItemName, itemSupplierEntity.getItemName()) | |||||
.eq(ItemSupplierEntity::getSupplierNo, itemSupplierEntity.getSupplierNo()) | |||||
.eq(ItemSupplierEntity::getSupplierName, itemSupplierEntity.getSupplierName()) | |||||
); | |||||
} | |||||
}); | |||||
List<ItemSupplierEntity> list = supplierService.list(lmq); | |||||
return EAIUtil.buildEAIResult(new JSONObject().fluentPut("item_supplier_info", list)); | |||||
} | |||||
} |
@ -0,0 +1,40 @@ | |||||
package com.digiwin.athena.app.service.supplier; | |||||
import com.digiwin.app.service.DWEAIResult; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import com.digiwin.athena.app.infra.service.SupplierService; | |||||
import com.digiwin.athena.opt.common.eai.EAIRequest; | |||||
import com.digiwin.athena.opt.common.eai.EAIUtil; | |||||
import com.digiwin.athena.opt.common.eai.service.AbsEAIService; | |||||
import lombok.extern.log4j.Log4j2; | |||||
import org.springframework.stereotype.Service; | |||||
import javax.annotation.Resource; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/8/31 | |||||
*/ | |||||
@Service | |||||
@Log4j2 | |||||
public class SupplierUpdateEAIService extends AbsEAIService { | |||||
@Resource | |||||
private SupplierService supplierService; | |||||
@Override | |||||
public String getServiceName() { | |||||
return SupplierUtil.DEMO_ITEM_SUPPLIER_INFO_UPDATE; | |||||
} | |||||
@Override | |||||
public DWEAIResult execute(Map<String, String> headers, String messageBody) throws Exception { | |||||
EAIRequest eaiRequest = EAIRequest.build(messageBody); | |||||
List<ItemSupplierEntity> supplierInfo = eaiRequest.getObject("item_supplier_info", SupplierUtil.LIST_ENTITY_SUPPLIER); | |||||
supplierService.updateBatchById(supplierInfo); | |||||
return EAIUtil.buildEAIResult(new HashMap<>()); | |||||
} | |||||
} |
@ -0,0 +1,27 @@ | |||||
package com.digiwin.athena.app.service.supplier; | |||||
import com.alibaba.fastjson.TypeReference; | |||||
import com.digiwin.athena.app.infra.entity.ItemSupplierEntity; | |||||
import java.util.List; | |||||
/** | |||||
* @auther: zhenggl | |||||
* @date: 2023/8/31 | |||||
*/ | |||||
public class SupplierUtil { | |||||
/** | |||||
* 品号供应商get,update,delete | |||||
*/ | |||||
public static final String DEMO_ITEM_SUPPLIER_INFO_UPDATE = "demo.item.supplier.info.update"; | |||||
public static final String DEMO_ITEM_SUPPLIER_INFO_GET = "demo.item.supplier.info.get"; | |||||
public static final String DEMO_ITEM_SUPPLIER_INFO_DELETE = "demo.item.supplier.info.delete"; | |||||
public static final String DEMO_ITEM_SUPPLIER_INFO_CREATE = "demo.item.supplier.info.create"; | |||||
public static final TypeReference<List<ItemSupplierEntity>> LIST_ENTITY_SUPPLIER = new TypeReference<List<ItemSupplierEntity>>() { | |||||
}; | |||||
} |