Merge branch 'refs/heads/dev' into test

This commit is contained in:
liss
2025-11-17 00:47:56 +08:00
6 changed files with 202 additions and 91 deletions

View File

@@ -36,4 +36,9 @@ public interface ElementMapper extends BaseMapperX<ElementDO> {
.eq(ElementDO::getIsEnable, 1) .eq(ElementDO::getIsEnable, 1)
.orderByDesc(ElementDO::getSort)); .orderByDesc(ElementDO::getSort));
} }
default ElementDO getElementName(String code){
return selectOne(new LambdaQueryWrapperX<ElementDO>()
.eq(ElementDO::getAbbreviation, code));
};
} }

View File

@@ -35,6 +35,8 @@ public class ElementServiceImpl implements ElementService {
public ElementRespVO createElement(ElementSaveReqVO createReqVO) { public ElementRespVO createElement(ElementSaveReqVO createReqVO) {
// 插入 // 插入
ElementDO element = BeanUtils.toBean(createReqVO, ElementDO.class); ElementDO element = BeanUtils.toBean(createReqVO, ElementDO.class);
// 校验存在
validateElementCodeExists(createReqVO.getAbbreviation());
//金属编码自动生成,格式 JSYS-00001,依次新增 //金属编码自动生成,格式 JSYS-00001,依次新增
String maxCode = elementMapper.selectMaxCode(); String maxCode = elementMapper.selectMaxCode();
if (maxCode == null) { if (maxCode == null) {
@@ -55,6 +57,8 @@ public class ElementServiceImpl implements ElementService {
public void updateElement(ElementSaveReqVO updateReqVO) { public void updateElement(ElementSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
validateElementExists(updateReqVO.getId()); validateElementExists(updateReqVO.getId());
// 校验存在
validateElementCodeExists(updateReqVO.getAbbreviation());
// 更新 // 更新
ElementDO updateObj = BeanUtils.toBean(updateReqVO, ElementDO.class); ElementDO updateObj = BeanUtils.toBean(updateReqVO, ElementDO.class);
elementMapper.updateById(updateObj); elementMapper.updateById(updateObj);
@@ -69,12 +73,12 @@ public class ElementServiceImpl implements ElementService {
} }
@Override @Override
public void deleteElementListByIds(List<Long> ids) { public void deleteElementListByIds(List<Long> ids) {
// 校验存在 // 校验存在
validateElementExists(ids); validateElementExists(ids);
// 删除 // 删除
elementMapper.deleteByIds(ids); elementMapper.deleteByIds(ids);
} }
private void validateElementExists(List<Long> ids) { private void validateElementExists(List<Long> ids) {
List<ElementDO> list = elementMapper.selectByIds(ids); List<ElementDO> list = elementMapper.selectByIds(ids);
@@ -89,6 +93,13 @@ public class ElementServiceImpl implements ElementService {
} }
} }
private void validateElementCodeExists(String code) {
ElementDO elementDO = elementMapper.getElementName(code);
if (elementDO == null) {
throw exception(ELEMENT_NOT_EXISTS);
}
}
@Override @Override
public ElementDO getElement(Long id) { public ElementDO getElement(Long id) {
return elementMapper.selectById(id); return elementMapper.selectById(id);
@@ -102,7 +113,7 @@ public class ElementServiceImpl implements ElementService {
@Override @Override
public void enableElementList(List<ElementRespVO> saveReqVOS) { public void enableElementList(List<ElementRespVO> saveReqVOS) {
List<ElementDO> updateObj = BeanUtils.toBean(saveReqVOS, ElementDO.class); List<ElementDO> updateObj = BeanUtils.toBean(saveReqVOS, ElementDO.class);
List<BatchResult> count = elementMapper.updateById(updateObj); List<BatchResult> count = elementMapper.updateById(updateObj);
if (CollUtil.isEmpty(count)) { if (CollUtil.isEmpty(count)) {
throw exception(ELEMENT_NOT_EXISTS); throw exception(ELEMENT_NOT_EXISTS);
} }

View File

@@ -6,6 +6,9 @@ import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCustomerPageReqVO; import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCustomerPageReqVO;
import com.zt.plat.module.erp.dal.dataobject.erp.ErpCustomerDO; import com.zt.plat.module.erp.dal.dataobject.erp.ErpCustomerDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* ERP客商主数据 Mapper * ERP客商主数据 Mapper
@@ -29,4 +32,5 @@ public interface ErpCustomerMapper extends BaseMapperX<ErpCustomerDO> {
.orderByDesc(ErpCustomerDO::getId)); .orderByDesc(ErpCustomerDO::getId));
} }
void updateBatchByNumber(@Param("toUpdate") List<ErpCustomerDO> toUpdate);
} }

View File

@@ -8,4 +8,22 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/ 文档可见https://www.iocoder.cn/MyBatis/x-plugins/
--> -->
<update id="updateBatchByNumber">
<foreach collection="toUpdate" item="item" separator=";" open="BEGIN" close=";END;">
UPDATE sply_erp_cstm
<set>
<if test="item.number != null">NUM = #{item.number},</if>
<if test="item.name != null">NAME = #{item.name},</if>
<if test="item.accountGroup != null">ACCT_GRP = #{item.accountGroup},</if>
<if test="item.description != null">DSP = #{item.description},</if>
<if test="item.centerNumber != null">CTR_NUM = #{item.centerNumber},</if>
<if test="item.createDate != null">CRT_DT = #{item.createDate},</if>
<if test="item.repairDate != null">RPR_DT = #{item.repairDate},</if>
<if test="item.isGiveback != null">IS_GIV = #{item.isGiveback},</if>
<if test="item.isProvisional != null">IS_PRVS = #{item.isProvisional},</if>
<if test="item.taxNumber != null">TAX_NUM = #{item.taxNumber},</if>
</set>
WHERE NUM = #{item.downCenterNumber}
</foreach>
</update>
</mapper> </mapper>