导入月份改为string
This commit is contained in:
parent
8be9f46291
commit
f82b3d0ffd
@ -6,10 +6,13 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.common.core.enums.FormatsType;
|
||||
import org.dromara.common.core.utils.DateUtils;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -33,7 +36,7 @@ import org.dromara.mps.listener.MpsImportHeatImportListener;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 导入取暖费信息
|
||||
* 取暖费信息
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-15
|
||||
@ -56,14 +59,14 @@ public class MpsImportHeatController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出导入取暖费信息列表
|
||||
* 导出取暖费信息列表
|
||||
*/
|
||||
@SaCheckPermission("mps:importHeat:export")
|
||||
@Log(title = "导入取暖费信息", businessType = BusinessType.EXPORT)
|
||||
@Log(title = "取暖费信息", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(MpsImportHeatBo bo, HttpServletResponse response) {
|
||||
List<MpsImportHeatVo> list = mpsImportHeatService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "导入取暖费信息", MpsImportHeatVo.class, response);
|
||||
ExcelUtil.exportExcel(list, "取暖费信息", MpsImportHeatVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +74,7 @@ public class MpsImportHeatController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
ExcelUtil.exportExcel(new ArrayList<>(), "导入取暖费信息", MpsImportHeatImportVo.class, response);
|
||||
ExcelUtil.exportExcel(new ArrayList<>(), "取暖费信息", MpsImportHeatImportVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,24 +82,18 @@ public class MpsImportHeatController extends BaseController {
|
||||
*
|
||||
* @param file 导入文件
|
||||
* @param updateSupport 是否更新已存在数据
|
||||
*
|
||||
*/
|
||||
@Log(title = "导入取暖费信息", businessType = BusinessType.IMPORT)
|
||||
@Log(title = "取暖费信息", businessType = BusinessType.IMPORT)
|
||||
@SaCheckPermission("mps:importHeat:import")
|
||||
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public R<Void> importData(@RequestPart("file") MultipartFile file,
|
||||
boolean updateSupport,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM") Date importMonth) throws Exception {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(importMonth);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
//把导入月份的旧数据删除
|
||||
mpsImportHeatService.deleteDataByMonth(calendar.getTime());
|
||||
|
||||
ExcelResult<MpsImportHeatImportVo> result = ExcelUtil.importExcel(file.getInputStream(), MpsImportHeatImportVo.class, new MpsImportHeatImportListener(updateSupport, calendar.getTime()));
|
||||
String importTime = DateUtils.parseDateToStr(FormatsType.YYYY_MM,importMonth);
|
||||
//把导入月份的旧数据删除
|
||||
mpsImportHeatService.deleteDataByMonth(importTime);
|
||||
ExcelResult<MpsImportHeatImportVo> result = ExcelUtil.importExcel(file.getInputStream(), MpsImportHeatImportVo.class, new MpsImportHeatImportListener(updateSupport, importTime));
|
||||
return R.ok(result.getAnalysis());
|
||||
}
|
||||
|
||||
@ -116,7 +113,7 @@ public class MpsImportHeatController extends BaseController {
|
||||
* 新增取暖费信息
|
||||
*/
|
||||
@SaCheckPermission("mps:importHeat:add")
|
||||
@Log(title = "导入取暖费信息", businessType = BusinessType.INSERT)
|
||||
@Log(title = "取暖费信息", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody MpsImportHeatBo bo) {
|
||||
@ -127,7 +124,7 @@ public class MpsImportHeatController extends BaseController {
|
||||
* 修改取暖费信息
|
||||
*/
|
||||
@SaCheckPermission("mps:importHeat:edit")
|
||||
@Log(title = "导入取暖费信息", businessType = BusinessType.UPDATE)
|
||||
@Log(title = "取暖费信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody MpsImportHeatBo bo) {
|
||||
@ -135,12 +132,12 @@ public class MpsImportHeatController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导入取暖费信息
|
||||
* 删除取暖费信息
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("mps:importHeat:remove")
|
||||
@Log(title = "导入取暖费信息", businessType = BusinessType.DELETE)
|
||||
@Log(title = "取暖费信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable BigDecimal[] ids) {
|
||||
|
@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 导入取暖费信息对象 mps_import_heat
|
||||
* 取暖费信息对象 mps_import_heat
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-15
|
||||
@ -73,7 +73,7 @@ public class MpsImportHeat extends TenantEntity {
|
||||
/**
|
||||
* 计价月份
|
||||
*/
|
||||
private Date importTime;
|
||||
private String importTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
* 导入取暖费信息业务对象 mps_import_heat
|
||||
* 取暖费信息业务对象 mps_import_heat
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-15
|
||||
@ -73,8 +73,8 @@ public class MpsImportHeatBo extends BaseEntity {
|
||||
/**
|
||||
* 计价月份
|
||||
*/
|
||||
@NotNull(message = "计价月份不能为空", groups = { AddGroup.class })
|
||||
private Date importTime;
|
||||
@NotBlank(message = "计价月份不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String importTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 导入取暖费信息视图对象 mps_import_heat
|
||||
* 取暖费信息视图对象 mps_import_heat
|
||||
*
|
||||
* 自行按照业务需要修改模板列
|
||||
*
|
||||
@ -91,8 +91,7 @@ public class MpsImportHeatImportVo implements Serializable {
|
||||
* 计价月份
|
||||
*/
|
||||
@ExcelProperty(value = "计价月份")
|
||||
@DateTimeFormat(pattern = "yyyy-MM")
|
||||
private Date importTime;
|
||||
private String importTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 导入取暖费信息视图对象 mps_import_heat
|
||||
* 取暖费信息视图对象 mps_import_heat
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-15
|
||||
@ -89,7 +89,7 @@ public class MpsImportHeatVo implements Serializable {
|
||||
* 计价月份
|
||||
*/
|
||||
@ExcelProperty(value = "计价月份")
|
||||
private Date importTime;
|
||||
private String importTime;
|
||||
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class MpsImportHeatImportListener extends AnalysisEventListener<MpsImport
|
||||
private final Boolean isUpdateSupport;
|
||||
private final Long operUserId;
|
||||
private int countN = 1;
|
||||
private final Date importMonth;
|
||||
private final String importMonth;
|
||||
// 存储所有解析成功的对象
|
||||
private final Collection<MpsImportHeat> successList = new ArrayList<>();
|
||||
|
||||
@ -45,7 +45,7 @@ public class MpsImportHeatImportListener extends AnalysisEventListener<MpsImport
|
||||
//private final Collection<Pair<MpsImportHeatImportVo, String>> failureList = new ArrayList<>();
|
||||
private final Collection<Pair<Integer, String>> failureList = new ArrayList<>();
|
||||
|
||||
public MpsImportHeatImportListener(Boolean isUpdateSupport, Date importMonth) {
|
||||
public MpsImportHeatImportListener(Boolean isUpdateSupport, String importMonth) {
|
||||
this.mpsImportHeatService = SpringUtils.getBean(IMpsImportHeatService.class);
|
||||
this.isUpdateSupport = isUpdateSupport;
|
||||
this.operUserId = LoginHelper.getUserId();
|
||||
|
@ -11,7 +11,7 @@ import org.dromara.common.mybatis.annotation.DataColumn;
|
||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||
|
||||
/**
|
||||
* 导入取暖费信息Mapper接口
|
||||
* 取暖费信息Mapper接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-15
|
||||
|
@ -14,7 +14,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 导入取暖费信息Service接口
|
||||
* 取暖费信息Service接口
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-15
|
||||
@ -26,48 +26,48 @@ public interface IMpsImportHeatService {
|
||||
void batchInsertOrUpdate(Collection<MpsImportHeat> list, Boolean isUpdateSupport);
|
||||
|
||||
/**
|
||||
* 查询导入取暖费信息
|
||||
* 查询取暖费信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 导入取暖费信息
|
||||
* @return 取暖费信息
|
||||
*/
|
||||
MpsImportHeatVo queryById(BigDecimal id);
|
||||
|
||||
/**
|
||||
* 分页查询导入取暖费信息列表
|
||||
* 分页查询取暖费信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 导入取暖费信息分页列表
|
||||
* @return 取暖费信息分页列表
|
||||
*/
|
||||
TableDataInfo<MpsImportHeatVo> queryPageList(MpsImportHeatBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询符合条件的导入取暖费信息列表
|
||||
* 查询符合条件的取暖费信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 导入取暖费信息列表
|
||||
* @return 取暖费信息列表
|
||||
*/
|
||||
List<MpsImportHeatVo> queryList(MpsImportHeatBo bo);
|
||||
|
||||
/**
|
||||
* 新增导入取暖费信息
|
||||
* 新增取暖费信息
|
||||
*
|
||||
* @param bo 导入取暖费信息
|
||||
* @param bo 取暖费信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByBo(MpsImportHeatBo bo);
|
||||
|
||||
/**
|
||||
* 修改导入取暖费信息
|
||||
* 修改取暖费信息
|
||||
*
|
||||
* @param bo 导入取暖费信息
|
||||
* @param bo 取暖费信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(MpsImportHeatBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除导入取暖费信息信息
|
||||
* 校验并批量删除取暖费信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
@ -75,5 +75,5 @@ public interface IMpsImportHeatService {
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<BigDecimal> ids, Boolean isValid);
|
||||
|
||||
Boolean deleteDataByMonth(Date importMonth);
|
||||
Boolean deleteDataByMonth(String importMonth);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 导入取暖费信息Service业务层处理
|
||||
* 取暖费信息Service业务层处理
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2025-08-15
|
||||
@ -66,10 +66,10 @@ public class MpsImportHeatServiceImpl implements IMpsImportHeatService {
|
||||
} */
|
||||
|
||||
/**
|
||||
* 查询导入取暖费信息
|
||||
* 查询取暖费信息
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 导入取暖费信息
|
||||
* @return 取暖费信息
|
||||
*/
|
||||
@Override
|
||||
public MpsImportHeatVo queryById(BigDecimal id){
|
||||
@ -77,11 +77,11 @@ public class MpsImportHeatServiceImpl implements IMpsImportHeatService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询导入取暖费信息列表
|
||||
* 分页查询取暖费信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 导入取暖费信息分页列表
|
||||
* @return 取暖费信息分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<MpsImportHeatVo> queryPageList(MpsImportHeatBo bo, PageQuery pageQuery) {
|
||||
@ -91,10 +91,10 @@ public class MpsImportHeatServiceImpl implements IMpsImportHeatService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的导入取暖费信息列表
|
||||
* 查询符合条件的取暖费信息列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 导入取暖费信息列表
|
||||
* @return 取暖费信息列表
|
||||
*/
|
||||
@Override
|
||||
public List<MpsImportHeatVo> queryList(MpsImportHeatBo bo) {
|
||||
@ -119,9 +119,9 @@ public class MpsImportHeatServiceImpl implements IMpsImportHeatService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增导入取暖费信息
|
||||
* 新增取暖费信息
|
||||
*
|
||||
* @param bo 导入取暖费信息
|
||||
* @param bo 取暖费信息
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@ -136,9 +136,9 @@ public class MpsImportHeatServiceImpl implements IMpsImportHeatService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改导入取暖费信息
|
||||
* 修改取暖费信息
|
||||
*
|
||||
* @param bo 导入取暖费信息
|
||||
* @param bo 取暖费信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
@ -156,7 +156,7 @@ public class MpsImportHeatServiceImpl implements IMpsImportHeatService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除导入取暖费信息信息
|
||||
* 校验并批量删除取暖费信息信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
@ -171,7 +171,7 @@ public class MpsImportHeatServiceImpl implements IMpsImportHeatService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteDataByMonth(Date importMonth) {
|
||||
public Boolean deleteDataByMonth(String importMonth) {
|
||||
|
||||
return baseMapper.delete(new LambdaQueryWrapper<MpsImportHeat>().eq(MpsImportHeat::getImportTime, importMonth))>0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user