1.0.11 合同物料优化
parent
98f73c452b
commit
f960eb05c4
@ -0,0 +1,144 @@
|
||||
package org.dromara.oa.erp.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.oa.erp.domain.bo.ErpContractMaterialBo;
|
||||
import org.dromara.oa.erp.domain.vo.ErpContractMaterialVo;
|
||||
import org.dromara.oa.erp.domain.ErpContractMaterial;
|
||||
import org.dromara.oa.erp.mapper.ErpContractMaterialMapper;
|
||||
import org.dromara.oa.erp.service.IErpContractMaterialService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 合同物料信息Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-14
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ErpContractMaterialServiceImpl implements IErpContractMaterialService {
|
||||
|
||||
private final ErpContractMaterialMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询合同物料信息
|
||||
*
|
||||
* @param contractMaterialId 主键
|
||||
* @return 合同物料信息
|
||||
*/
|
||||
@Override
|
||||
public ErpContractMaterialVo queryById(Long contractMaterialId) {
|
||||
return baseMapper.selectVoById(contractMaterialId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询合同物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 合同物料信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ErpContractMaterialVo> queryPageList(ErpContractMaterialBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<ErpContractMaterial> lqw = buildQueryWrapper(bo);
|
||||
Page<ErpContractMaterialVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的合同物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 合同物料信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ErpContractMaterialVo> queryList(ErpContractMaterialBo bo) {
|
||||
MPJLambdaWrapper<ErpContractMaterial> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<ErpContractMaterial> buildQueryWrapper(ErpContractMaterialBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<ErpContractMaterial> lqw = JoinWrappers.lambda(ErpContractMaterial.class)
|
||||
.selectAll(ErpContractMaterial.class)
|
||||
.eq(StringUtils.isNotBlank(bo.getPlanFlag()), ErpContractMaterial::getPlanFlag, bo.getPlanFlag())
|
||||
.eq(bo.getContractId() != null, ErpContractMaterial::getContractId, bo.getContractId())
|
||||
.like(StringUtils.isNotBlank(bo.getProductName()), ErpContractMaterial::getProductName, bo.getProductName())
|
||||
.eq(StringUtils.isNotBlank(bo.getSpecificationDescription()), ErpContractMaterial::getSpecificationDescription, bo.getSpecificationDescription())
|
||||
.eq(bo.getMaterialId() != null, ErpContractMaterial::getMaterialId, bo.getMaterialId())
|
||||
.eq(bo.getRelationMaterialId() != null, ErpContractMaterial::getRelationMaterialId, bo.getRelationMaterialId())
|
||||
.eq(bo.getAmount() != null, ErpContractMaterial::getAmount, bo.getAmount())
|
||||
.eq(bo.getUnitId() != null, ErpContractMaterial::getUnitId, bo.getUnitId())
|
||||
.eq(bo.getBeforePrice() != null, ErpContractMaterial::getBeforePrice, bo.getBeforePrice())
|
||||
.eq(bo.getTaxRate() != null, ErpContractMaterial::getTaxRate, bo.getTaxRate())
|
||||
.eq(bo.getIncludingPrice() != null, ErpContractMaterial::getIncludingPrice, bo.getIncludingPrice())
|
||||
.eq(bo.getSubtotal() != null, ErpContractMaterial::getSubtotal, bo.getSubtotal())
|
||||
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ErpContractMaterial::getActiveFlag, bo.getActiveFlag())
|
||||
.orderByAsc(ErpContractMaterial::getContractMaterialId);
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增合同物料信息
|
||||
*
|
||||
* @param bo 合同物料信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ErpContractMaterialBo bo) {
|
||||
ErpContractMaterial add = MapstructUtils.convert(bo, ErpContractMaterial.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setContractMaterialId(add.getContractMaterialId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改合同物料信息
|
||||
*
|
||||
* @param bo 合同物料信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ErpContractMaterialBo bo) {
|
||||
ErpContractMaterial update = MapstructUtils.convert(bo, ErpContractMaterial.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ErpContractMaterial entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除合同物料信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -1,143 +0,0 @@
|
||||
package org.dromara.oa.erp.service.impl;
|
||||
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.oa.erp.domain.bo.ErpContractMaterielBo;
|
||||
import org.dromara.oa.erp.domain.vo.ErpContractMaterielVo;
|
||||
import org.dromara.oa.erp.domain.ErpContractMateriel;
|
||||
import org.dromara.oa.erp.mapper.ErpContractMaterielMapper;
|
||||
import org.dromara.oa.erp.service.IErpContractMaterielService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 合同物料信息Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-10-11
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ErpContractMaterielServiceImpl implements IErpContractMaterielService {
|
||||
|
||||
private final ErpContractMaterielMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询合同物料信息
|
||||
*
|
||||
* @param contractMaterielId 主键
|
||||
* @return 合同物料信息
|
||||
*/
|
||||
@Override
|
||||
public ErpContractMaterielVo queryById(Long contractMaterielId){
|
||||
return baseMapper.selectVoById(contractMaterielId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询合同物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 合同物料信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<ErpContractMaterielVo> queryPageList(ErpContractMaterielBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<ErpContractMateriel> lqw = buildQueryWrapper(bo);
|
||||
Page<ErpContractMaterielVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的合同物料信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 合同物料信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<ErpContractMaterielVo> queryList(ErpContractMaterielBo bo) {
|
||||
MPJLambdaWrapper<ErpContractMateriel> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<ErpContractMateriel> buildQueryWrapper(ErpContractMaterielBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
MPJLambdaWrapper<ErpContractMateriel> lqw = JoinWrappers.lambda(ErpContractMateriel.class)
|
||||
.selectAll(ErpContractMateriel.class)
|
||||
.eq(bo.getContractId() != null, ErpContractMateriel::getContractId, bo.getContractId())
|
||||
.like(StringUtils.isNotBlank(bo.getProductName()), ErpContractMateriel::getProductName, bo.getProductName())
|
||||
.eq(StringUtils.isNotBlank(bo.getSpecificationDescription()), ErpContractMateriel::getSpecificationDescription, bo.getSpecificationDescription())
|
||||
.eq(bo.getMaterielId() != null, ErpContractMateriel::getMaterielId, bo.getMaterielId())
|
||||
.eq(bo.getRelationMaterielId() != null, ErpContractMateriel::getRelationMaterielId, bo.getRelationMaterielId())
|
||||
.eq(bo.getAmount() != null, ErpContractMateriel::getAmount, bo.getAmount())
|
||||
.eq(bo.getUnitId() != null, ErpContractMateriel::getUnitId, bo.getUnitId())
|
||||
.eq(bo.getBeforePrice() != null, ErpContractMateriel::getBeforePrice, bo.getBeforePrice())
|
||||
.eq(bo.getTaxRate() != null, ErpContractMateriel::getTaxRate, bo.getTaxRate())
|
||||
.eq(bo.getIncludingPrice() != null, ErpContractMateriel::getIncludingPrice, bo.getIncludingPrice())
|
||||
.eq(bo.getSubtotal() != null, ErpContractMateriel::getSubtotal, bo.getSubtotal())
|
||||
.eq(StringUtils.isNotBlank(bo.getActiveFlag()), ErpContractMateriel::getActiveFlag, bo.getActiveFlag())
|
||||
;
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增合同物料信息
|
||||
*
|
||||
* @param bo 合同物料信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(ErpContractMaterielBo bo) {
|
||||
ErpContractMateriel add = MapstructUtils.convert(bo, ErpContractMateriel.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setContractMaterielId(add.getContractMaterielId());
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改合同物料信息
|
||||
*
|
||||
* @param bo 合同物料信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(ErpContractMaterielBo bo) {
|
||||
ErpContractMateriel update = MapstructUtils.convert(bo, ErpContractMateriel.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(ErpContractMateriel entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除合同物料信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
<?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="org.dromara.oa.erp.mapper.ErpContractMaterialMapper">
|
||||
<resultMap type="org.dromara.oa.erp.domain.vo.ErpContractMaterialVo" id="ErpContractMaterialResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCustomErpContractMaterialVoList" resultMap="ErpContractMaterialResult">
|
||||
select contract_material_id, tenant_id, plan_flag, contract_id, product_name, specification_description, material_id, relation_material_id, amount, unit_id, before_price, tax_rate, including_price, subtotal, remark, active_flag, del_flag, create_dept, create_by, create_time, update_by, update_time from erp_contract_material t
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -1,14 +0,0 @@
|
||||
<?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="org.dromara.oa.erp.mapper.ErpContractMaterielMapper">
|
||||
<resultMap type="org.dromara.oa.erp.domain.vo.ErpContractMaterielVo" id="ErpContractMaterielResult">
|
||||
</resultMap>
|
||||
|
||||
<select id="selectCustomErpContractMaterielVoList" resultMap="ErpContractMaterielResult">
|
||||
select contract_materiel_id, tenant_id, contract_id, product_name, specification_description, materiel_id, relation_materiel_id, amount, unit_id, before_price, tax_rate, including_price, subtotal, remark, active_flag, del_flag, create_dept, create_by, create_time, update_by, update_time from erp_contract_materiel t
|
||||
${ew.getCustomSqlSegment}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue