commit
6576183b13
22 changed files with 801 additions and 19 deletions
@ -0,0 +1,55 @@ |
|||||||
|
package org.springblade.job.processor.device; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||||
|
import jakarta.annotation.Resource; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.desk.device.feign.LimsMeaToolTaskClient; |
||||||
|
import org.springblade.desk.device.feign.MesMeasuringToolClient; |
||||||
|
import org.springblade.desk.device.pojo.entity.MeasurementRecordsEntity; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
import org.springframework.util.CollectionUtils; |
||||||
|
import tech.powerjob.worker.core.processor.ProcessResult; |
||||||
|
import tech.powerjob.worker.core.processor.TaskContext; |
||||||
|
import tech.powerjob.worker.core.processor.sdk.BasicProcessor; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
@Component |
||||||
|
@Slf4j |
||||||
|
public class LimsMeasuringToolProcessor implements BasicProcessor { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private LimsMeaToolTaskClient limsMeaToolTaskClient; |
||||||
|
@Resource |
||||||
|
private MesMeasuringToolClient mesMeasuringToolClient; |
||||||
|
|
||||||
|
@Override |
||||||
|
public ProcessResult process(TaskContext context) throws Exception { |
||||||
|
log.info("同步lims检验量具任务开始"); |
||||||
|
List<MesMeasuringToolEntity> checkToolList = mesMeasuringToolClient.selectCheckTool(); |
||||||
|
if (!CollectionUtils.isEmpty(checkToolList)) { |
||||||
|
List<MeasurementRecordsEntity> limsList = limsMeaToolTaskClient.selectSyncMeasurementRecordsTask(); |
||||||
|
List<MesMeasuringToolEntity> updList = new ArrayList<>(); |
||||||
|
if (!CollectionUtils.isEmpty(limsList)) { |
||||||
|
for (MesMeasuringToolEntity mesMeasuringToolEntity : checkToolList) { |
||||||
|
MeasurementRecordsEntity lims = limsList.stream().filter(e -> StringUtils.isNotEmpty(e.getMcCode()) && e.getMcCode().equals(mesMeasuringToolEntity.getToolCode())).findFirst().orElse(null); |
||||||
|
if (lims != null) { |
||||||
|
MesMeasuringToolEntity upd = new MesMeasuringToolEntity(); |
||||||
|
upd.setId(mesMeasuringToolEntity.getId()); |
||||||
|
upd.setDueDate(lims.getDueDate()); |
||||||
|
updList.add(upd); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (!CollectionUtils.isEmpty(updList)) { |
||||||
|
mesMeasuringToolClient.saveOrUpdateBatch(updList); |
||||||
|
} |
||||||
|
} |
||||||
|
log.info("同步lims检验量具任务结束"); |
||||||
|
return new ProcessResult(true); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
package org.springblade.desk.device.feign; |
||||||
|
|
||||||
|
import oracle.jdbc.proxy.annotation.Post; |
||||||
|
import org.springblade.core.launch.constant.AppConstant; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@FeignClient( |
||||||
|
value = AppConstant.APPLICATION_DESK_NAME |
||||||
|
) |
||||||
|
public interface MesMeasuringToolClient { |
||||||
|
|
||||||
|
String API_PREFIX = "/feign/client/mes_measuring_tool"; |
||||||
|
|
||||||
|
String SELECT_CHECK_TOOL = API_PREFIX + "/select-check-tool"; |
||||||
|
|
||||||
|
String SAVE_OR_UPDATE_BATCH = API_PREFIX + "/save-or-update-batch"; |
||||||
|
|
||||||
|
@GetMapping(SELECT_CHECK_TOOL) |
||||||
|
List<MesMeasuringToolEntity> selectCheckTool(); |
||||||
|
|
||||||
|
@PostMapping(SAVE_OR_UPDATE_BATCH) |
||||||
|
boolean saveOrUpdateBatch(@RequestBody List<MesMeasuringToolEntity> list); |
||||||
|
} |
||||||
@ -0,0 +1,50 @@ |
|||||||
|
package org.springblade.desk.device.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; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@TableName("MES_MEASURING_TOOL") |
||||||
|
@Schema(description = "MesMeasuringTool对象") |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class MesMeasuringToolEntity extends BaseEntity { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
/** |
||||||
|
* 量具编码 |
||||||
|
*/ |
||||||
|
@Schema(description = "量具编码") |
||||||
|
private String toolCode; |
||||||
|
|
||||||
|
/** |
||||||
|
* 量具名称 |
||||||
|
*/ |
||||||
|
@Schema(description = "量具名称") |
||||||
|
private String toolName; |
||||||
|
|
||||||
|
/** |
||||||
|
* 量具尺寸 |
||||||
|
*/ |
||||||
|
@Schema(description = "量具尺寸") |
||||||
|
private String toolSize; |
||||||
|
|
||||||
|
/** |
||||||
|
* 量具类型:1-工艺量具, 2-检验量具 |
||||||
|
*/ |
||||||
|
@Schema(description = "量具类型") |
||||||
|
private String toolType; |
||||||
|
|
||||||
|
/** |
||||||
|
* 到期日 |
||||||
|
*/ |
||||||
|
@Schema(description = "到期日") |
||||||
|
private Date dueDate; |
||||||
|
} |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
package org.springblade.desk.device.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; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@ColumnWidth(25) |
||||||
|
@HeadRowHeight(20) |
||||||
|
@ContentRowHeight(18) |
||||||
|
public class MesMeasuringToolCheckExcel implements Serializable { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("量具编码") |
||||||
|
private String toolCode; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("到期日期") |
||||||
|
private Date dueDate; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("维护人") |
||||||
|
private String updateUserName; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("维护时间") |
||||||
|
private Date updateTime; |
||||||
|
} |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
package org.springblade.desk.device.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 org.springframework.format.annotation.DateTimeFormat; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
import java.io.Serializable; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@ColumnWidth(25) |
||||||
|
@HeadRowHeight(20) |
||||||
|
@ContentRowHeight(18) |
||||||
|
public class MesMeasuringToolImportExcel implements Serializable { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("量具编码") |
||||||
|
private String toolCode; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("量具名称") |
||||||
|
private String toolName; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("到期日期") |
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||||
|
private Date dueDate; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("尺寸") |
||||||
|
private String toolSize; |
||||||
|
} |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
package org.springblade.desk.device.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; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
@ColumnWidth(25) |
||||||
|
@HeadRowHeight(20) |
||||||
|
@ContentRowHeight(18) |
||||||
|
public class MesMeasuringToolProcessExcel implements Serializable { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("量具名称") |
||||||
|
private String toolName; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("尺寸") |
||||||
|
private String toolSize; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("维护人") |
||||||
|
private String updateUserName; |
||||||
|
|
||||||
|
@ColumnWidth(20) |
||||||
|
@ExcelProperty("维护时间") |
||||||
|
private Date updateTime; |
||||||
|
} |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package org.springblade.desk.device.pojo.vo; |
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
|
||||||
|
import java.io.Serial; |
||||||
|
|
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = true) |
||||||
|
public class MesMeasuringToolVO extends MesMeasuringToolEntity { |
||||||
|
|
||||||
|
@Serial |
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
@Schema(description = "维护人") |
||||||
|
private String updateUserName; |
||||||
|
} |
||||||
@ -0,0 +1,212 @@ |
|||||||
|
package org.springblade.desk.device.controller; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||||
|
import io.swagger.v3.oas.annotations.Parameter; |
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||||
|
import jakarta.validation.Valid; |
||||||
|
import lombok.AllArgsConstructor; |
||||||
|
import org.springblade.core.boot.ctrl.BladeController; |
||||||
|
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.secure.BladeUser; |
||||||
|
import org.springblade.core.secure.annotation.IsAdmin; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.DateUtil; |
||||||
|
import org.springblade.core.tool.utils.Func; |
||||||
|
import org.springblade.desk.basic.util.ExcelExtUtil; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
import org.springblade.desk.device.pojo.excel.MesMeasuringToolCheckExcel; |
||||||
|
import org.springblade.desk.device.pojo.excel.MesMeasuringToolImportExcel; |
||||||
|
import org.springblade.desk.device.pojo.excel.MesMeasuringToolProcessExcel; |
||||||
|
import org.springblade.desk.device.pojo.vo.MesMeasuringToolVO; |
||||||
|
import org.springblade.desk.device.service.IMesMeasuringToolService; |
||||||
|
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; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备量具控制类 |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@AllArgsConstructor |
||||||
|
@RequestMapping("/mesMeasuringTool") |
||||||
|
@Tag(name = "设备量具", description = "设备量具接口") |
||||||
|
public class MesMeasuringToolController extends BladeController { |
||||||
|
|
||||||
|
private final IMesMeasuringToolService mesMeasuringToolService; |
||||||
|
|
||||||
|
@GetMapping("/page") |
||||||
|
@Operation(summary = "分页", description = "传入bsEnergyQuota") |
||||||
|
public R<IPage<MesMeasuringToolVO>> page(MesMeasuringToolEntity mesMeasuringTool, Query query) { |
||||||
|
IPage<MesMeasuringToolVO> pages = mesMeasuringToolService.selectMeaToolPage(Condition.getPage(query), mesMeasuringTool); |
||||||
|
return R.data(pages); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 能源定额 新增或修改 |
||||||
|
*/ |
||||||
|
@PostMapping("/submit") |
||||||
|
@Operation(summary = "新增或修改", description = "传入bsEnergyQuota") |
||||||
|
public R submit(@Valid @RequestBody MesMeasuringToolEntity mesMeasuringTool) { |
||||||
|
LambdaQueryWrapper<MesMeasuringToolEntity> qw = new LambdaQueryWrapper<MesMeasuringToolEntity>().eq(MesMeasuringToolEntity::getToolType, mesMeasuringTool.getToolType()); |
||||||
|
if (StringUtils.isEmpty(mesMeasuringTool.getToolType()) || !("1".equals(mesMeasuringTool.getToolType()) || "2".equals(mesMeasuringTool.getToolType()))) { |
||||||
|
return R.fail("未知量具类型"); |
||||||
|
} |
||||||
|
if ("1".equals(mesMeasuringTool.getToolType())) { |
||||||
|
if (StringUtils.isEmpty(mesMeasuringTool.getToolName())) { |
||||||
|
return R.fail("名称为空"); |
||||||
|
} |
||||||
|
qw.eq(MesMeasuringToolEntity::getToolName, mesMeasuringTool.getToolName()); |
||||||
|
} else if ("2".equals(mesMeasuringTool.getToolType())) { |
||||||
|
if (StringUtils.isEmpty(mesMeasuringTool.getToolCode())) { |
||||||
|
return R.fail("编码为空"); |
||||||
|
} |
||||||
|
qw.eq(MesMeasuringToolEntity::getToolCode, mesMeasuringTool.getToolCode()); |
||||||
|
} |
||||||
|
if (mesMeasuringTool.getId() != null) { |
||||||
|
qw.ne(MesMeasuringToolEntity::getId, mesMeasuringTool.getId()); |
||||||
|
} |
||||||
|
List<MesMeasuringToolEntity> exist = mesMeasuringToolService.list(qw); |
||||||
|
if (!CollectionUtils.isEmpty(exist)) { |
||||||
|
return R.fail("量具已存在"); |
||||||
|
} |
||||||
|
return R.status(mesMeasuringToolService.saveOrUpdate(mesMeasuringTool)); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/remove") |
||||||
|
@Operation(summary = "逻辑删除", description = "传入ids") |
||||||
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
||||||
|
return R.status(mesMeasuringToolService.deleteLogic(Func.toLongList(ids))); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 导出数据 |
||||||
|
*/ |
||||||
|
@IsAdmin |
||||||
|
@GetMapping("/export-process") |
||||||
|
@Operation(summary = "导出数据", description = "传入bsEnergyMonitor") |
||||||
|
public void exportProcess(MesMeasuringToolEntity mesMeasuringTool, BladeUser bladeUser, HttpServletResponse response) { |
||||||
|
mesMeasuringTool.setToolType("1"); |
||||||
|
List<MesMeasuringToolVO> list = mesMeasuringToolService.selectMeaTool(mesMeasuringTool); |
||||||
|
List<MesMeasuringToolProcessExcel> excels = new ArrayList<>(); |
||||||
|
for (MesMeasuringToolVO vo : list) { |
||||||
|
MesMeasuringToolProcessExcel excel = new MesMeasuringToolProcessExcel(); |
||||||
|
BeanUtils.copyProperties(vo, excel); |
||||||
|
excels.add(excel); |
||||||
|
} |
||||||
|
ExcelUtil.export(response, "工艺量具" + DateUtil.time(), "工艺量具", excels, MesMeasuringToolProcessExcel.class); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 导出数据 |
||||||
|
*/ |
||||||
|
@IsAdmin |
||||||
|
@GetMapping("/export-check") |
||||||
|
@Operation(summary = "导出数据", description = "传入bsEnergyMonitor") |
||||||
|
public void exportCheck(MesMeasuringToolEntity mesMeasuringTool, BladeUser bladeUser, HttpServletResponse response) { |
||||||
|
mesMeasuringTool.setToolType("2"); |
||||||
|
List<MesMeasuringToolVO> list = mesMeasuringToolService.selectMeaTool(mesMeasuringTool); |
||||||
|
List<MesMeasuringToolCheckExcel> excels = new ArrayList<>(); |
||||||
|
for (MesMeasuringToolVO vo : list) { |
||||||
|
MesMeasuringToolCheckExcel excel = new MesMeasuringToolCheckExcel(); |
||||||
|
BeanUtils.copyProperties(vo, excel); |
||||||
|
excels.add(excel); |
||||||
|
} |
||||||
|
ExcelUtil.export(response, "检验量具" + DateUtil.time(), "检验量具", excels, MesMeasuringToolCheckExcel.class); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/process-download-excel-template") |
||||||
|
@Operation(summary = "下载Excel模板", description = "") |
||||||
|
public ResponseEntity<Resource> processDownloadExcelTemplate() { |
||||||
|
return ExcelExtUtil.downloadXlsTemplate( |
||||||
|
"Excel/device/工艺量具.xls", |
||||||
|
"导入模版-工艺量具.xls"); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/check-download-excel-template") |
||||||
|
@Operation(summary = "下载Excel模板", description = "") |
||||||
|
public ResponseEntity<Resource> checkDownloadExcelTemplate() { |
||||||
|
return ExcelExtUtil.downloadXlsTemplate( |
||||||
|
"Excel/device/检验量具.xls", |
||||||
|
"导入模版-检验量具.xls"); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/process-import-excel") |
||||||
|
@Operation(summary = "导入Excel", description = "MultipartFile") |
||||||
|
public R processImportExcel(@RequestParam("file") MultipartFile file) { |
||||||
|
R checkR = ExcelExtUtil.importExcelCheck(file); |
||||||
|
if (checkR != null) { |
||||||
|
return checkR; |
||||||
|
} |
||||||
|
List<MesMeasuringToolImportExcel> importList = ExcelUtil.read( |
||||||
|
file, 0, 1, MesMeasuringToolImportExcel.class |
||||||
|
); |
||||||
|
Set<String> existSet = new HashSet<>(); |
||||||
|
List<MesMeasuringToolEntity> list = new ArrayList<>(); |
||||||
|
for (MesMeasuringToolImportExcel excel : importList) { |
||||||
|
if (existSet.contains(excel.getToolName())) { |
||||||
|
return R.fail("Excel里量具【" + excel.getToolName() + "】重复了"); |
||||||
|
} |
||||||
|
existSet.add(excel.getToolName()); |
||||||
|
MesMeasuringToolEntity exist = mesMeasuringToolService.getOne(new LambdaQueryWrapper<MesMeasuringToolEntity>() |
||||||
|
.eq(MesMeasuringToolEntity::getToolType, "1") |
||||||
|
.eq(MesMeasuringToolEntity::getToolName, excel.getToolName())); |
||||||
|
if (exist != null) { |
||||||
|
return R.fail("量具" + excel.getToolName() + "已存在"); |
||||||
|
} |
||||||
|
MesMeasuringToolEntity mesMeasuringToolEntity = new MesMeasuringToolEntity(); |
||||||
|
BeanUtils.copyProperties(excel, mesMeasuringToolEntity); |
||||||
|
mesMeasuringToolEntity.setToolType("1"); |
||||||
|
list.add(mesMeasuringToolEntity); |
||||||
|
} |
||||||
|
return R.status(mesMeasuringToolService.saveBatch(list)); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/check-import-excel") |
||||||
|
@Operation(summary = "导入Excel", description = "MultipartFile") |
||||||
|
public R checkImportExcel(@RequestParam("file") MultipartFile file) { |
||||||
|
R checkR = ExcelExtUtil.importExcelCheck(file); |
||||||
|
if (checkR != null) { |
||||||
|
return checkR; |
||||||
|
} |
||||||
|
List<MesMeasuringToolImportExcel> importList = ExcelUtil.read( |
||||||
|
file, 0, 1, MesMeasuringToolImportExcel.class |
||||||
|
); |
||||||
|
Set<String> existSet = new HashSet<>(); |
||||||
|
List<MesMeasuringToolEntity> list = new ArrayList<>(); |
||||||
|
for (MesMeasuringToolImportExcel excel : importList) { |
||||||
|
if(StringUtils.isEmpty(excel.getToolCode())){ |
||||||
|
return R.fail("量具名称为空"); |
||||||
|
} |
||||||
|
if (existSet.contains(excel.getToolCode())) { |
||||||
|
return R.fail("Excel里量具【" + excel.getToolCode() + "】重复了"); |
||||||
|
} |
||||||
|
existSet.add(excel.getToolCode()); |
||||||
|
MesMeasuringToolEntity exist = mesMeasuringToolService.getOne( |
||||||
|
new LambdaQueryWrapper<MesMeasuringToolEntity>() |
||||||
|
.eq(MesMeasuringToolEntity::getToolType, "2") |
||||||
|
.eq(MesMeasuringToolEntity::getToolCode, excel.getToolCode())); |
||||||
|
if (exist != null) { |
||||||
|
return R.fail("量具" + excel.getToolCode() + "已存在"); |
||||||
|
} |
||||||
|
MesMeasuringToolEntity mesMeasuringToolEntity = new MesMeasuringToolEntity(); |
||||||
|
BeanUtils.copyProperties(excel, mesMeasuringToolEntity); |
||||||
|
mesMeasuringToolEntity.setToolType("2"); |
||||||
|
list.add(mesMeasuringToolEntity); |
||||||
|
} |
||||||
|
return R.status(mesMeasuringToolService.saveBatch(list)); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package org.springblade.desk.device.feign; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import io.swagger.v3.oas.annotations.Hidden; |
||||||
|
import jakarta.annotation.Resource; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
import org.springblade.desk.device.service.IMesMeasuringToolService; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@Hidden |
||||||
|
public class MesMeasuringToolClientImpl implements MesMeasuringToolClient { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private IMesMeasuringToolService mesMeasuringToolService; |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<MesMeasuringToolEntity> selectCheckTool() { |
||||||
|
return mesMeasuringToolService.list(new LambdaQueryWrapper<MesMeasuringToolEntity>().eq(MesMeasuringToolEntity::getToolType, "2")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean saveOrUpdateBatch(List<MesMeasuringToolEntity> list) { |
||||||
|
return mesMeasuringToolService.saveOrUpdateBatch(list); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
package org.springblade.desk.device.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
import org.springblade.desk.device.pojo.vo.MesMeasuringToolVO; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public interface MesMeasuringToolMapper extends BaseMapper<MesMeasuringToolEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义分页 |
||||||
|
* |
||||||
|
* @param page |
||||||
|
* @param query |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<MesMeasuringToolVO> selectMesMeasuringToolPage(IPage page, MesMeasuringToolEntity query); |
||||||
|
|
||||||
|
/** |
||||||
|
* 自定义查询 |
||||||
|
* |
||||||
|
* @param query |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<MesMeasuringToolVO> selectMesMeasuringTool(@Param("query") MesMeasuringToolEntity query); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
<?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.device.mapper.MesMeasuringToolMapper"> |
||||||
|
|
||||||
|
<!-- 通用查询映射结果 --> |
||||||
|
<resultMap id="mesMeasuringToolResultMap" type="org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity"> |
||||||
|
<result column="ID" property="id"/> |
||||||
|
<result column="TOOL_CODE" property="toolCode"/> |
||||||
|
<result column="TOOL_NAME" property="toolName"/> |
||||||
|
<result column="TOOL_SIZE" property="toolSize"/> |
||||||
|
<result column="TOOL_TYPE" property="toolType"/> |
||||||
|
<result column="DUE_DATE" property="dueDate"/> |
||||||
|
<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"/> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
<resultMap id="mesMeasuringToolVOResultMap" type="org.springblade.desk.device.pojo.vo.MesMeasuringToolVO" extends="mesMeasuringToolResultMap"> |
||||||
|
<result column="UPDATE_USER_NAME" property="updateUserName"/> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
<sql id="selectMesMeasuringToolSql"> |
||||||
|
select a.*, bu.REAL_NAME as UPDATE_USER_NAME |
||||||
|
from MES_MEASURING_TOOL a |
||||||
|
LEFT JOIN BLADE_USER bu on a.UPDATE_USER = bu.id |
||||||
|
where a.is_deleted = 0 |
||||||
|
<if test="query.toolCode != null and query.toolCode != ''"> |
||||||
|
AND a.TOOL_CODE LIKE CONCAT('%', CONCAT(#{query.toolCode}, '%')) |
||||||
|
</if> |
||||||
|
<if test="query.toolName != null and query.toolName != ''"> |
||||||
|
AND a.TOOL_NAME LIKE CONCAT('%', CONCAT(#{query.toolName}, '%')) |
||||||
|
</if> |
||||||
|
<if test="query.toolSize != null and query.toolSize != ''"> |
||||||
|
AND a.TOOL_SIZE = #{query.toolSize} |
||||||
|
</if> |
||||||
|
<if test="query.toolType != null and query.toolType != ''"> |
||||||
|
AND a.TOOL_TYPE = #{query.toolType} |
||||||
|
</if> |
||||||
|
<if test="query.status != null and query.status != ''"> |
||||||
|
AND a.STATUS = #{query.status} |
||||||
|
</if> |
||||||
|
ORDER BY a.CREATE_TIME ASC |
||||||
|
</sql> |
||||||
|
|
||||||
|
<select id="selectMesMeasuringToolPage" resultMap="mesMeasuringToolVOResultMap"> |
||||||
|
<include refid="selectMesMeasuringToolSql"/> |
||||||
|
</select> |
||||||
|
|
||||||
|
<select id="selectMesMeasuringTool" resultMap="mesMeasuringToolVOResultMap"> |
||||||
|
<include refid="selectMesMeasuringToolSql"/> |
||||||
|
</select> |
||||||
|
|
||||||
|
</mapper> |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package org.springblade.desk.device.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.core.mp.base.BaseService; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
import org.springblade.desk.device.pojo.vo.MesMeasuringToolVO; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备量具服务类 |
||||||
|
*/ |
||||||
|
public interface IMesMeasuringToolService extends BaseService<MesMeasuringToolEntity> { |
||||||
|
|
||||||
|
IPage<MesMeasuringToolVO> selectMeaToolPage(IPage<MesMeasuringToolVO> page, MesMeasuringToolEntity query); |
||||||
|
|
||||||
|
List<MesMeasuringToolVO> selectMeaTool(MesMeasuringToolEntity query); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
package org.springblade.desk.device.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
import org.springblade.core.mp.base.BaseServiceImpl; |
||||||
|
import org.springblade.desk.device.mapper.MesMeasuringToolMapper; |
||||||
|
import org.springblade.desk.device.pojo.entity.MesMeasuringToolEntity; |
||||||
|
import org.springblade.desk.device.pojo.vo.MesMeasuringToolVO; |
||||||
|
import org.springblade.desk.device.service.IMesMeasuringToolService; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设备量具服务实现类 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class MesMeasuringToolServiceImpl extends BaseServiceImpl<MesMeasuringToolMapper, MesMeasuringToolEntity> implements IMesMeasuringToolService { |
||||||
|
|
||||||
|
@Override |
||||||
|
public IPage<MesMeasuringToolVO> selectMeaToolPage(IPage<MesMeasuringToolVO> page, MesMeasuringToolEntity query) { |
||||||
|
return page.setRecords(baseMapper.selectMesMeasuringToolPage(page, query)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<MesMeasuringToolVO> selectMeaTool(MesMeasuringToolEntity query) { |
||||||
|
return baseMapper.selectMesMeasuringTool(query); |
||||||
|
} |
||||||
|
} |
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue