package com.oying.modules.fee.service.impl;
|
|
import com.oying.modules.fee.domain.WeightSurchargeRules;
|
import com.oying.utils.FileUtil;
|
import lombok.RequiredArgsConstructor;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.oying.modules.fee.service.WeightSurchargeRulesService;
|
import com.oying.modules.fee.domain.dto.WeightSurchargeRulesQueryCriteria;
|
import com.oying.modules.fee.mapper.WeightSurchargeRulesMapper;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import com.oying.utils.PageUtil;
|
import java.util.List;
|
import java.util.Map;
|
import java.io.IOException;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.ArrayList;
|
import java.util.LinkedHashMap;
|
import com.oying.utils.PageResult;
|
|
/**
|
* @description 服务实现
|
* @author lixin
|
* @date 2025-10-07
|
**/
|
@Service
|
@RequiredArgsConstructor
|
public class WeightSurchargeRulesServiceImpl extends ServiceImpl<WeightSurchargeRulesMapper, WeightSurchargeRules> implements WeightSurchargeRulesService {
|
|
private final WeightSurchargeRulesMapper weightSurchargeRulesMapper;
|
|
@Override
|
public PageResult<WeightSurchargeRules> queryAll(WeightSurchargeRulesQueryCriteria criteria, Page<Object> page){
|
return PageUtil.toPage(weightSurchargeRulesMapper.findAll(criteria, page));
|
}
|
|
@Override
|
public List<WeightSurchargeRules> queryAll(WeightSurchargeRulesQueryCriteria criteria){
|
return weightSurchargeRulesMapper.findAll(criteria);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void create(WeightSurchargeRules resources) {
|
weightSurchargeRulesMapper.insert(resources);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void update(WeightSurchargeRules resources) {
|
WeightSurchargeRules weightSurchargeRules = getById(resources.getWeightRuleId());
|
weightSurchargeRules.copy(resources);
|
weightSurchargeRulesMapper.updateById(weightSurchargeRules);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void deleteAll(List<Long> ids) {
|
weightSurchargeRulesMapper.deleteBatchIds(ids);
|
}
|
|
@Override
|
public void download(List<WeightSurchargeRules> all, HttpServletResponse response) throws IOException {
|
List<Map<String, Object>> list = new ArrayList<>();
|
for (WeightSurchargeRules weightSurchargeRules : all) {
|
Map<String, Object> map = new LinkedHashMap<>();
|
map.put("基础重量 (公斤)", weightSurchargeRules.getBaseWeight());
|
map.put("每公斤加价金额", weightSurchargeRules.getFeePerKg());
|
map.put("生效日期", weightSurchargeRules.getEffectiveDate());
|
map.put("创建者", weightSurchargeRules.getCreateBy());
|
map.put("更新者", weightSurchargeRules.getUpdateBy());
|
map.put("创建日期", weightSurchargeRules.getCreateTime());
|
map.put("更新时间", weightSurchargeRules.getUpdateTime());
|
list.add(map);
|
}
|
FileUtil.downloadExcel(list, response);
|
}
|
}
|