批量插入
This commit is contained in:
@@ -1,24 +1,19 @@
|
|||||||
package com.czg.service.account.service.impl;
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.czg.account.dto.PageDTO;
|
import com.czg.account.dto.PageDTO;
|
||||||
import com.czg.account.dto.register.MerchantRegisterDTO;
|
import com.czg.account.dto.register.MerchantRegisterDTO;
|
||||||
import com.czg.account.entity.MerchantRegister;
|
import com.czg.account.entity.MerchantRegister;
|
||||||
import com.czg.account.service.MerchantRegisterService;
|
import com.czg.account.service.MerchantRegisterService;
|
||||||
import com.czg.account.vo.MerchantRegisterVO;
|
|
||||||
import com.czg.service.account.mapper.MerchantRegisterMapper;
|
import com.czg.service.account.mapper.MerchantRegisterMapper;
|
||||||
import com.czg.utils.PageUtil;
|
import com.czg.utils.PageUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 激活码 服务层实现。
|
* 激活码 服务层实现。
|
||||||
@@ -27,7 +22,7 @@ import java.util.List;
|
|||||||
* @since 2025-02-11
|
* @since 2025-02-11
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MerchantRegisterServiceImpl extends ServiceImpl<MerchantRegisterMapper, MerchantRegister> implements MerchantRegisterService {
|
public class MerchantRegisterServiceImpl extends ServiceImpl<MerchantRegisterMapper, MerchantRegister> implements MerchantRegisterService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<MerchantRegister> get(PageDTO pageDTO, Integer state, String startTime, String endTime) {
|
public Page<MerchantRegister> get(PageDTO pageDTO, Integer state, String startTime, String endTime) {
|
||||||
@@ -46,6 +41,7 @@ public class MerchantRegisterServiceImpl extends ServiceImpl<MerchantRegisterMap
|
|||||||
tbMerchantRegister.setPeriodMonth(merchantRegisterDTO.periodMonth());
|
tbMerchantRegister.setPeriodMonth(merchantRegisterDTO.periodMonth());
|
||||||
registers.add(tbMerchantRegister);
|
registers.add(tbMerchantRegister);
|
||||||
}
|
}
|
||||||
return saveBatch(registers);
|
int i = mapper.insertBatchSelective(registers, 50);
|
||||||
|
return i > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class ShopExtendServiceImpl extends ServiceImpl<ShopExtendMapper, ShopExt
|
|||||||
newRecord.initAutoKey(key, shopId);
|
newRecord.initAutoKey(key, shopId);
|
||||||
newRecords.add(newRecord);
|
newRecords.add(newRecord);
|
||||||
}
|
}
|
||||||
saveBatch(newRecords);
|
mapper.insertBatchSelective(newRecords,50);
|
||||||
return newRecords;
|
return newRecords;
|
||||||
} else {
|
} else {
|
||||||
for (ShopExtend shopExtend : shopExtendList) {
|
for (ShopExtend shopExtend : shopExtendList) {
|
||||||
@@ -97,7 +97,7 @@ public class ShopExtendServiceImpl extends ServiceImpl<ShopExtendMapper, ShopExt
|
|||||||
newRecords.add(newRecord);
|
newRecords.add(newRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveBatch(newRecords);
|
mapper.insertBatchSelective(newRecords,50);
|
||||||
|
|
||||||
shopExtendList.addAll(newRecords);
|
shopExtendList.addAll(newRecords);
|
||||||
return shopExtendList;
|
return shopExtendList;
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
|||||||
tableArrayList.add(shopTable);
|
tableArrayList.add(shopTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveBatch(tableArrayList);
|
mapper.insertBatchSelective(tableArrayList, 50);
|
||||||
if (StrUtil.isNotBlank(msg.toString())) {
|
if (StrUtil.isNotBlank(msg.toString())) {
|
||||||
msg.append("台桌名已存在,未添加");
|
msg.append("台桌名已存在,未添加");
|
||||||
throw new CzgException(msg.toString());
|
throw new CzgException(msg.toString());
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import static com.mybatisflex.core.query.QueryMethods.column;
|
|||||||
* @since 2025-02-08
|
* @since 2025-02-08
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
||||||
@Resource
|
@Resource
|
||||||
private SysMenuService sysMenuService;
|
private SysMenuService sysMenuService;
|
||||||
@Resource
|
@Resource
|
||||||
@@ -87,7 +87,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
return apiInfoItemDTOS.stream()
|
return apiInfoItemDTOS.stream()
|
||||||
.map(pattern -> StrUtil.format("({} LIKE '{}' ESCAPE '\\\\' and method = '{}')" , columnName, toSqlLikePattern(pattern.getUrl()), pattern.getMethod()))
|
.map(pattern -> StrUtil.format("({} LIKE '{}' ESCAPE '\\\\' and method = '{}')", columnName, toSqlLikePattern(pattern.getUrl()), pattern.getMethod()))
|
||||||
.collect(Collectors.joining(" OR "));
|
.collect(Collectors.joining(" OR "));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
|
|||||||
public Page<SysRole> getList(Long shopId, PageDTO pageDTO, String key, String startTime, String endTime) {
|
public Page<SysRole> getList(Long shopId, PageDTO pageDTO, String key, String startTime, String endTime) {
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
// if (!StpKit.USER.isAdmin()) {
|
// if (!StpKit.USER.isAdmin()) {
|
||||||
queryWrapper.eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong());
|
queryWrapper.eq(SysRole::getCreateUserId, StpKit.USER.getLoginIdAsLong());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(key)) {
|
if (StrUtil.isNotBlank(key)) {
|
||||||
@@ -180,11 +180,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> imp
|
|||||||
|
|
||||||
|
|
||||||
// Step 4: 批量保存(如有数据)
|
// Step 4: 批量保存(如有数据)
|
||||||
return rolesMenus.isEmpty() || sysRolesMenusService.saveBatch(rolesMenus);
|
return rolesMenus.isEmpty() || sysRolesMenusService.getMapper().insertBatchSelective(rolesMenus, 50) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Boolean editPermission(long userId, RolePermissionDTO rolePermissionDTO) {
|
public Boolean editPermission(long userId, RolePermissionDTO rolePermissionDTO) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class MkCouponGiftServiceImpl extends ServiceImpl<MkCouponGiftMapper, MkC
|
|||||||
public void addCouponGift(Long sourceId, String sourceName, Integer type, List<MkCouponGiftDTO> couponGiftList) {
|
public void addCouponGift(Long sourceId, String sourceName, Integer type, List<MkCouponGiftDTO> couponGiftList) {
|
||||||
remove(new QueryWrapper().eq(MkCouponGift::getSourceId, sourceId).eq(MkCouponGift::getType, type));
|
remove(new QueryWrapper().eq(MkCouponGift::getSourceId, sourceId).eq(MkCouponGift::getType, type));
|
||||||
if (CollUtil.isNotEmpty(couponGiftList)) {
|
if (CollUtil.isNotEmpty(couponGiftList)) {
|
||||||
List newCoupons = new ArrayList<>();
|
List<MkCouponGift> newCoupons = new ArrayList<>();
|
||||||
for (MkCouponGiftDTO giftDTO : couponGiftList) {
|
for (MkCouponGiftDTO giftDTO : couponGiftList) {
|
||||||
ShopCoupon coupon = couponMapper.selectOneByQuery(new QueryWrapper().eq(ShopCoupon::getId, giftDTO.getCouponId()));
|
ShopCoupon coupon = couponMapper.selectOneByQuery(new QueryWrapper().eq(ShopCoupon::getId, giftDTO.getCouponId()));
|
||||||
if (coupon == null) {
|
if (coupon == null) {
|
||||||
@@ -64,7 +64,7 @@ public class MkCouponGiftServiceImpl extends ServiceImpl<MkCouponGiftMapper, MkC
|
|||||||
couponGift.setNum(giftDTO.getNum());
|
couponGift.setNum(giftDTO.getNum());
|
||||||
newCoupons.add(couponGift);
|
newCoupons.add(couponGift);
|
||||||
}
|
}
|
||||||
saveBatch(newCoupons);
|
mapper.insertBatchSelective(newCoupons, 50);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
|
|||||||
recordList.add(record);
|
recordList.add(record);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveBatch(recordList);
|
mapper.insertBatchSelective(recordList, 50);
|
||||||
QueryWrapper queryWrapper = new QueryWrapper();
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
ShopCoupon newCoupon = new ShopCoupon();
|
ShopCoupon newCoupon = new ShopCoupon();
|
||||||
newCoupon.setGiftNum(coupon.getGiftNum());
|
newCoupon.setGiftNum(coupon.getGiftNum());
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class ShopProdStatisticServiceImpl extends ServiceImpl<ShopProdStatisticM
|
|||||||
if (exists) {
|
if (exists) {
|
||||||
remove(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
|
remove(QueryWrapper.create().eq(ShopProdStatistic::getShopId, shopId).eq(ShopProdStatistic::getCreateDay, day));
|
||||||
}
|
}
|
||||||
saveBatch(realTimeData);
|
mapper.insertBatchSelective(realTimeData, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class ShopTableOrderStatisticServiceImpl extends ServiceImpl<ShopTableOrd
|
|||||||
.toList();
|
.toList();
|
||||||
if (CollUtil.isNotEmpty(realTimeData)) {
|
if (CollUtil.isNotEmpty(realTimeData)) {
|
||||||
remove(QueryWrapper.create().eq(ShopTableOrderStatistic::getShopId, shopId).eq(ShopTableOrderStatistic::getCreateDay, day));
|
remove(QueryWrapper.create().eq(ShopTableOrderStatistic::getShopId, shopId).eq(ShopTableOrderStatistic::getCreateDay, day));
|
||||||
saveBatch(realTimeData);
|
mapper.insertBatchSelective(realTimeData, 50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@
|
|||||||
consInfo.setStockNumber(consStockFlow.getAfterNumber());
|
consInfo.setStockNumber(consStockFlow.getAfterNumber());
|
||||||
updateStockList.add(consInfo);
|
updateStockList.add(consInfo);
|
||||||
}
|
}
|
||||||
super.saveBatch(insertList);
|
mapper.insertBatchSelective(insertList, 50);
|
||||||
for (ConsInfo consInfo : updateStockList) {
|
for (ConsInfo consInfo : updateStockList) {
|
||||||
consInfoMapper.update(consInfo);
|
consInfoMapper.update(consInfo);
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@
|
|||||||
consInfo.setStockNumber(entity.getAfterNumber());
|
consInfo.setStockNumber(entity.getAfterNumber());
|
||||||
updateStockList.add(consInfo);
|
updateStockList.add(consInfo);
|
||||||
}
|
}
|
||||||
super.saveBatch(insertList);
|
mapper.insertBatchSelective(insertList, 50);
|
||||||
for (ConsInfo consInfo : updateStockList) {
|
for (ConsInfo consInfo : updateStockList) {
|
||||||
consInfoMapper.update(consInfo);
|
consInfoMapper.update(consInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class ProdConsRelationServiceImpl extends ServiceImpl<ProdConsRelationMap
|
|||||||
|
|
||||||
private QueryWrapper buildQueryWrapper(ProdConsRelationDTO param) {
|
private QueryWrapper buildQueryWrapper(ProdConsRelationDTO param) {
|
||||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId();
|
||||||
queryWrapper.eq(ProdConsRelation::getShopId, shopId);
|
queryWrapper.eq(ProdConsRelation::getShopId, shopId);
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class ProdConsRelationServiceImpl extends ServiceImpl<ProdConsRelationMap
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void saveProdConsRelation(ProdConsBindDTO dto) {
|
public void saveProdConsRelation(ProdConsBindDTO dto) {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId();
|
||||||
long count = productMapper.selectCountByQuery(query().eq(Product::getShopId, shopId).eq(Product::getId, dto.getId()));
|
long count = productMapper.selectCountByQuery(query().eq(Product::getShopId, shopId).eq(Product::getId, dto.getId()));
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
throw new CzgException("商品不存在");
|
throw new CzgException("商品不存在");
|
||||||
@@ -72,7 +72,7 @@ public class ProdConsRelationServiceImpl extends ServiceImpl<ProdConsRelationMap
|
|||||||
throw new CzgException("非法操作,绑定关系商品不一致");
|
throw new CzgException("非法操作,绑定关系商品不一致");
|
||||||
}
|
}
|
||||||
List<ProdConsRelation> entityList = BeanUtil.copyToList(consList, ProdConsRelation.class);
|
List<ProdConsRelation> entityList = BeanUtil.copyToList(consList, ProdConsRelation.class);
|
||||||
super.saveBatch(entityList);
|
mapper.insertBatchSelective(entityList, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -733,7 +733,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CollUtil.isNotEmpty(addList)) {
|
if (CollUtil.isNotEmpty(addList)) {
|
||||||
prodGroupRelationService.saveBatch(addList, 100);
|
prodGroupRelationService.getMapper().insertBatchSelective(addList, 100);
|
||||||
}
|
}
|
||||||
if (CollUtil.isNotEmpty(upList)) {
|
if (CollUtil.isNotEmpty(upList)) {
|
||||||
prodGroupRelationService.updateBatch(addList, 100);
|
prodGroupRelationService.updateBatch(addList, 100);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class ShopVendorServiceImpl extends ServiceImpl<ShopVendorMapper, ShopVen
|
|||||||
throw new CzgException("批量付款应全部付款");
|
throw new CzgException("批量付款应全部付款");
|
||||||
}
|
}
|
||||||
|
|
||||||
consPayRecordService.saveBatch(records);
|
consPayRecordService.getMapper().insertBatchSelective(records, 50);
|
||||||
return consStockFlowService.updateBatch(stockFlows);
|
return consStockFlowService.updateBatch(stockFlows);
|
||||||
}else {
|
}else {
|
||||||
ConsStockFlow stockFlow = consStockFlowMapper.selectOneByQuery(new QueryWrapper().eq(ConsStockFlow::getShopId, shopId).eq(ConsStockFlow::getId, payDTO.getFlowIdList().getFirst()));
|
ConsStockFlow stockFlow = consStockFlowMapper.selectOneByQuery(new QueryWrapper().eq(ConsStockFlow::getShopId, shopId).eq(ConsStockFlow::getId, payDTO.getFlowIdList().getFirst()));
|
||||||
|
|||||||
Reference in New Issue
Block a user