parent
8859d6ec8b
commit
c03e3f7814
13 changed files with 378 additions and 9 deletions
@ -0,0 +1,26 @@ |
|||||||
|
package org.springblade.desk.oem.pojo.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.core.mp.base.BaseEntity; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("MES_OEM_STATEMENT_CATEGORY") |
||||||
|
@Schema(description = "OemStatementCategory对象") |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class OemStatementCategoryEntity extends BaseEntity { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
/** |
||||||
|
* 结算大类 |
||||||
|
*/ |
||||||
|
@Schema(description = "结算大类") |
||||||
|
private String statementCategory; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
package org.springblade.desk.oem.pojo.excel; |
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||||
|
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||||
|
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||||
|
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类模板导入 |
||||||
|
* |
||||||
|
* @author maxg |
||||||
|
* @since 2026-04-29 |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@ColumnWidth(25) |
||||||
|
@HeadRowHeight(20) |
||||||
|
@ContentRowHeight(18) |
||||||
|
public class OemStatementCategoryExcel implements Serializable { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("结算大类") |
||||||
|
private String statementCategory; |
||||||
|
} |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
package org.springblade.desk.oem.pojo.vo; |
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.desk.oem.pojo.entity.OemStatementCategoryEntity; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
|
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class OemStatementCategoryVO extends OemStatementCategoryEntity { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@Schema(description = "维护人") |
||||||
|
private String updateUserName; |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,162 @@ |
|||||||
|
package org.springblade.desk.oem.controller; |
||||||
|
|
||||||
|
import com.alibaba.nacos.shaded.com.google.common.collect.Lists; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||||
|
import jakarta.validation.Valid; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import org.apache.commons.lang3.StringUtils; |
||||||
|
import org.springblade.core.excel.util.ExcelUtil; |
||||||
|
import org.springblade.core.mp.support.Condition; |
||||||
|
import org.springblade.core.mp.support.Query; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.Func; |
||||||
|
import org.springblade.desk.basic.util.ExcelExtUtil; |
||||||
|
import org.springblade.desk.oem.pojo.entity.OemStatementCategoryEntity; |
||||||
|
import org.springblade.desk.oem.pojo.excel.OemStatementCategoryExcel; |
||||||
|
import org.springblade.desk.oem.pojo.vo.OemStatementCategoryVO; |
||||||
|
import org.springblade.desk.oem.service.IOemStatementCategoryService; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.core.io.Resource; |
||||||
|
import org.springframework.http.ResponseEntity; |
||||||
|
import org.springframework.util.CollectionUtils; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
import org.springframework.web.multipart.MultipartFile; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 控制器 |
||||||
|
* |
||||||
|
* @author maxg |
||||||
|
* @since 2026-04-29 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@AllArgsConstructor |
||||||
|
@RequestMapping("/mesOemStatementCategory") |
||||||
|
@Tag(name = "外协结算大类", description = "外协结算大类接口") |
||||||
|
public class OemStatementCategoryController { |
||||||
|
|
||||||
|
private final IOemStatementCategoryService oemStatementCategoryService; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 自定义分页 |
||||||
|
*/ |
||||||
|
@GetMapping("/page") |
||||||
|
@Operation(summary = "分页", description = "传入oemStandardProcess") |
||||||
|
public R<IPage<OemStatementCategoryVO>> page(OemStatementCategoryVO oemStatementCategory, Query query) { |
||||||
|
IPage<OemStatementCategoryVO> pages = oemStatementCategoryService.selectOemStatementCategoryPage(Condition.getPage(query), oemStatementCategory); |
||||||
|
return R.data(pages); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 新增或修改 |
||||||
|
* |
||||||
|
* @param oemStatementCategory |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/submit") |
||||||
|
@Operation(summary = "新增或修改", description = "传入bsEfficiencyTempList") |
||||||
|
public R submit(@Valid @RequestBody OemStatementCategoryEntity oemStatementCategory) { |
||||||
|
LambdaQueryWrapper<OemStatementCategoryEntity> wrapper = new LambdaQueryWrapper<OemStatementCategoryEntity>().eq(OemStatementCategoryEntity::getStatementCategory, oemStatementCategory.getStatementCategory()); |
||||||
|
if (oemStatementCategory.getId() != null) { |
||||||
|
wrapper.ne(OemStatementCategoryEntity::getId, oemStatementCategory.getId()); |
||||||
|
} |
||||||
|
List<OemStatementCategoryEntity> list = oemStatementCategoryService.list(wrapper); |
||||||
|
if (!CollectionUtils.isEmpty(list)) { |
||||||
|
return R.fail("数据已存在"); |
||||||
|
} |
||||||
|
return R.status(oemStatementCategoryService.saveOrUpdate(oemStatementCategory)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 删除 |
||||||
|
*/ |
||||||
|
@PostMapping("/remove") |
||||||
|
@Operation(summary = "逻辑删除", description = "传入ids") |
||||||
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
||||||
|
return R.status(oemStatementCategoryService.deleteLogic(Func.toLongList(ids))); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 下载模板 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@GetMapping("/download-excel-template") |
||||||
|
@Operation(summary = "下载Excel模板", description = "") |
||||||
|
public ResponseEntity<Resource> downloadExcelTemplate() { |
||||||
|
return ExcelExtUtil.downloadXlsTemplate("Excel/oem/结算大类.xls", "导入模版-结算大类.xls"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 导入Excel |
||||||
|
* |
||||||
|
* @param file |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@PostMapping("/import-excel") |
||||||
|
@Operation(summary = "导入Excel", description = "MultipartFile") |
||||||
|
public R importExcel(@RequestParam("file") MultipartFile file) { |
||||||
|
R checkR = ExcelExtUtil.importExcelCheck(file); |
||||||
|
if (checkR != null) { |
||||||
|
return checkR; |
||||||
|
} |
||||||
|
List<OemStatementCategoryExcel> importList = ExcelUtil.read(file, 0, 1, OemStatementCategoryExcel.class); |
||||||
|
if (CollectionUtils.isEmpty(importList)) { |
||||||
|
return R.fail("导入数据不能为空"); |
||||||
|
} |
||||||
|
Set<String> excelUniqueSet = new HashSet<>(); |
||||||
|
List<OemStatementCategoryEntity> entityList = new ArrayList<>(); |
||||||
|
for (int i = 0; i < importList.size(); i++) { |
||||||
|
int rowNum = i + 2; |
||||||
|
OemStatementCategoryExcel row = importList.get(i); |
||||||
|
if (StringUtils.isEmpty(row.getStatementCategory())) { |
||||||
|
return R.fail(String.format("[%]行结算大类未填写", rowNum)); |
||||||
|
} |
||||||
|
String uniqueStr = row.getStatementCategory(); |
||||||
|
if (!excelUniqueSet.add(uniqueStr)) { |
||||||
|
return R.fail(String.format("[%]行在Excel中重复", rowNum)); |
||||||
|
} |
||||||
|
OemStatementCategoryEntity entity = new OemStatementCategoryEntity(); |
||||||
|
BeanUtils.copyProperties(row, entity); |
||||||
|
entityList.add(entity); |
||||||
|
} |
||||||
|
Set<String> dbExistSet = new HashSet<>(); |
||||||
|
final int batchSize = 500; |
||||||
|
List<List<String>> splits = Lists.partition(new ArrayList<>(excelUniqueSet), batchSize); |
||||||
|
for (List<String> subs : splits) { |
||||||
|
List<OemStatementCategoryEntity> batchList = oemStatementCategoryService.list(new LambdaQueryWrapper<OemStatementCategoryEntity>().in(OemStatementCategoryEntity::getStatementCategory, subs)); |
||||||
|
batchList.stream().map(OemStatementCategoryEntity::getStatementCategory).forEach(dbExistSet::add); |
||||||
|
} |
||||||
|
if (!CollectionUtils.isEmpty(dbExistSet)) { |
||||||
|
for (int i = 0; i < importList.size(); i++) { |
||||||
|
int rowNum = i + 2; |
||||||
|
String name = importList.get(i).getStatementCategory(); |
||||||
|
if (dbExistSet.contains(name)) { |
||||||
|
R.fail(String.format("[%]行错误,[%]已存在不可重复导入", rowNum, name)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return R.status(oemStatementCategoryService.saveBatch(entityList)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类下拉选择 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@GetMapping("/listForSelect") |
||||||
|
@Operation(summary = "list下拉选择", description = "") |
||||||
|
public R<List<OemStatementCategoryEntity>> listForSelect() { |
||||||
|
List<OemStatementCategoryEntity> list = oemStatementCategoryService.list(); |
||||||
|
return R.data(list); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,27 @@ |
|||||||
|
package org.springblade.desk.oem.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.desk.efficiency.pojo.vo.BsEfficiencyTaskVO; |
||||||
|
import org.springblade.desk.oem.pojo.entity.OemStatementCategoryEntity; |
||||||
|
import org.springblade.desk.oem.pojo.vo.OemStatementCategoryVO; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 Mapper 接口 |
||||||
|
* |
||||||
|
* @author qyl |
||||||
|
* @since 2026-02-12 |
||||||
|
*/ |
||||||
|
public interface OemStatementCategoryMapper extends BaseMapper<OemStatementCategoryEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义分页 |
||||||
|
* |
||||||
|
* @param page |
||||||
|
* @param oemStatementCategory |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<OemStatementCategoryVO> selectOemStatementCategoryPage(IPage page, OemStatementCategoryVO oemStatementCategory); |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
<?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.springblade.desk.oem.mapper.OemStatementCategoryMapper"> |
||||||
|
|
||||||
|
<!-- 通用查询映射结果 --> |
||||||
|
<resultMap id="mesOemStatementCategoryVOResultMap" type="org.springblade.desk.oem.pojo.vo.OemStatementCategoryVO"> |
||||||
|
<result column="ID" property="id"/> |
||||||
|
<result column="STATEMENT_CATEGORY" property="statementCategory"/> |
||||||
|
<result column="CREATE_USER" property="createUser"/> |
||||||
|
<result column="CREATE_TIME" property="createTime"/> |
||||||
|
<result column="CREATE_DEPT" property="createDept"/> |
||||||
|
<result column="UPDATE_USER" property="updateUser"/> |
||||||
|
<result column="UPDATE_TIME" property="updateTime"/> |
||||||
|
<result column="STATUS" property="status"/> |
||||||
|
<result column="IS_DELETED" property="isDeleted"/> |
||||||
|
<result column="UPDATE_USER_NAME" property="updateUserName"/> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
<select id="selectOemStatementCategoryPage" resultMap="mesOemStatementCategoryVOResultMap"> |
||||||
|
SELECT t.*,bu.REAL_NAME as UPDATE_USER_NAME FROM MES_OEM_STATEMENT_CATEGORY t |
||||||
|
LEFT JOIN BLADE_USER bu ON t.update_user = bu.id |
||||||
|
<where> |
||||||
|
t.IS_DELETED = 0 |
||||||
|
</where> |
||||||
|
ORDER BY t.UPDATE_TIME DESC |
||||||
|
</select> |
||||||
|
|
||||||
|
</mapper> |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
package org.springblade.desk.oem.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
import org.springblade.desk.oem.pojo.entity.OemStatementCategoryEntity; |
||||||
|
import org.springblade.desk.oem.pojo.vo.OemStatementCategoryVO; |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 服务类 |
||||||
|
* |
||||||
|
* @author maxg |
||||||
|
* @since 2026-04-29 |
||||||
|
*/ |
||||||
|
public interface IOemStatementCategoryService extends BaseService<OemStatementCategoryEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义分页 |
||||||
|
* |
||||||
|
* @param page |
||||||
|
* @param oemStatementCategory |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
IPage<OemStatementCategoryVO> selectOemStatementCategoryPage(IPage<OemStatementCategoryVO> page, OemStatementCategoryVO oemStatementCategory); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,25 @@ |
|||||||
|
package org.springblade.desk.oem.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springblade.desk.oem.mapper.OemStatementCategoryMapper; |
||||||
|
import org.springblade.desk.oem.pojo.entity.OemStatementCategoryEntity; |
||||||
|
import org.springblade.desk.oem.pojo.vo.OemStatementCategoryVO; |
||||||
|
import org.springblade.desk.oem.service.IOemStatementCategoryService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* 外协结算大类 服务实现类 |
||||||
|
* |
||||||
|
* @author maxg |
||||||
|
* @since 2026-04-29 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class OemStatementCategoryServiceImpl extends BaseServiceImpl<OemStatementCategoryMapper, OemStatementCategoryEntity> implements IOemStatementCategoryService { |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public IPage<OemStatementCategoryVO> selectOemStatementCategoryPage(IPage<OemStatementCategoryVO> page, OemStatementCategoryVO oemStatementCategory) { |
||||||
|
return page.setRecords(baseMapper.selectOemStatementCategoryPage(page, oemStatementCategory)); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue