diff --git a/src/main/java/org/springblade/modules/business/contraller/DeviceController.java b/src/main/java/org/springblade/modules/business/contraller/DeviceController.java index 292d600..2e40694 100644 --- a/src/main/java/org/springblade/modules/business/contraller/DeviceController.java +++ b/src/main/java/org/springblade/modules/business/contraller/DeviceController.java @@ -22,6 +22,7 @@ import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.modules.business.excel.DeviceExcel; +import org.springblade.modules.business.excel.DeviceImportExcel; import org.springblade.modules.business.excel.DeviceImporter; import org.springblade.modules.business.pojo.dto.DeviceDTO; import org.springblade.modules.business.pojo.entity.Device; @@ -187,9 +188,9 @@ public class DeviceController extends BladeController { */ @PostMapping("/import-device") @Operation(summary = "导入设备", description = "传入excel") - public R importDevice(MultipartFile file, Integer isCovered) { - DeviceImporter deviceImporter = new DeviceImporter(deviceService, isCovered == 1); - ExcelUtil.save(file, deviceImporter, DeviceExcel.class); + public R importDevice(MultipartFile file) { + DeviceImporter deviceImporter = new DeviceImporter(deviceService); + ExcelUtil.save(file, deviceImporter, DeviceImportExcel.class); return R.success("操作成功"); } @@ -210,20 +211,20 @@ public class DeviceController extends BladeController { @GetMapping("/export-template") @Operation(summary = "导出模板") public void exportDevice(HttpServletResponse response) { - List list = new ArrayList<>(); - DeviceExcel deviceExcel = new DeviceExcel(); - deviceExcel.setCode("WX-20241017-01"); - deviceExcel.setName("测试设备"); - deviceExcel.setModel("MDP-456"); - deviceExcel.setType("设备类型1"); - deviceExcel.setPosition("种子常规检测室1"); - deviceExcel.setSupplier("山东烁今"); - deviceExcel.setProduceTime(new Date()); - deviceExcel.setLimsName("测试实验室"); - deviceExcel.setFloorName("三层"); - deviceExcel.setRoomName("301"); - list.add(deviceExcel); - ExcelUtil.export(response, "设备模板", "设备表", list, DeviceExcel.class); + List list = new ArrayList<>(); +// DeviceExcel deviceExcel = new DeviceExcel(); +// deviceExcel.setCode("WX-20241017-01"); +// deviceExcel.setName("测试设备"); +// deviceExcel.setModel("MDP-456"); +// deviceExcel.setType("设备类型1"); +// deviceExcel.setPosition("种子常规检测室1"); +// deviceExcel.setSupplier("山东烁今"); +// deviceExcel.setProduceTime(new Date()); +// deviceExcel.setLimsName("测试实验室"); +// deviceExcel.setFloorName("三层"); +// deviceExcel.setRoomName("301"); +// list.add(deviceExcel); + ExcelUtil.export(response, "设备模板", "设备表", list, DeviceImportExcel.class); } } diff --git a/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java b/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java index e5acd1f..2dfb34d 100644 --- a/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java +++ b/src/main/java/org/springblade/modules/business/contraller/MaintenanceController.java @@ -189,6 +189,7 @@ public class MaintenanceController extends BladeController { MaintenanceTask taskOld = taskService.getById(task.getId()); taskOld.setSignUrl(task.getSignUrl()); taskOld.setRemark(task.getRemark()); + taskOld.setInspectionConclusion(task.getInspectionConclusion()); taskService.updateById(taskOld); return R.success(); @@ -498,4 +499,10 @@ public class MaintenanceController extends BladeController { public void maintenancePlanReport(@RequestBody MaintenancePlan maintenancePlan, HttpServletResponse response) throws IOException { planDetailService.maintenancePlanReport(maintenancePlan, response); } + + @PostMapping("/repair-output-service") + @Operation(summary = "导出运维服务单", description = "导出运维服务单") + public void repairOutputService(@RequestBody MaintenanceTask task, HttpServletResponse response) throws IOException { + taskDetailService.repairOutputService(task, response); + } } diff --git a/src/main/java/org/springblade/modules/business/contraller/WorkOrderController.java b/src/main/java/org/springblade/modules/business/contraller/WorkOrderController.java index 2f83809..c4d1915 100644 --- a/src/main/java/org/springblade/modules/business/contraller/WorkOrderController.java +++ b/src/main/java/org/springblade/modules/business/contraller/WorkOrderController.java @@ -262,7 +262,8 @@ public class WorkOrderController extends BladeController { messageService.saveMessage(workOrder.getRequirementCode(), "您已接收新的维修单,请尽快处理", workOrder.getRepairPerson(), 2); } // todo 审核通过 - LogUtil.saveLog(workOrderOld.getRequirementCode(), WorkOrderStatusEnum.KF_ORDER_ALLOT.getName()); + User user = userService.getById(workOrder.getRepairPerson()); + LogUtil.saveLog(workOrderOld.getRequirementCode(), WorkOrderStatusEnum.KF_ORDER_ALLOT.getName() + ":" + user.getName()); return R.success(""); } diff --git a/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java b/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java index 96ae460..d4b4fda 100644 --- a/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java +++ b/src/main/java/org/springblade/modules/business/contraller/supplies/ApplyController.java @@ -11,14 +11,18 @@ import org.springblade.common.cache.UserCache; import org.springblade.core.boot.ctrl.BladeController; 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.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.modules.business.pojo.dto.supplies.ApplyDTO; +import org.springblade.modules.business.pojo.entity.maintenance.MaintenancePlan; import org.springblade.modules.business.pojo.entity.supplies.Apply; import org.springblade.modules.business.pojo.entity.supplies.ApplyDetail; import org.springblade.modules.business.pojo.entity.supplies.Goods; +import org.springblade.modules.business.pojo.entity.workorder.WorkOrder; +import org.springblade.modules.business.service.IWorkOrderService; import org.springblade.modules.business.service.supplies.IApplyDetailService; import org.springblade.modules.business.service.supplies.IApplyService; import org.springblade.modules.business.service.supplies.IGoodsService; @@ -43,6 +47,7 @@ public class ApplyController extends BladeController { private final IApplyService applyService; private final IApplyDetailService applyDetailService; private final IGoodsService goodsService; + private final IWorkOrderService workOrderService; /** * 物品申领表 详情 @@ -59,13 +64,23 @@ public class ApplyController extends BladeController { */ @GetMapping("/list") public R> list(ApplyDTO apply, Query query) { + BladeUser user = AuthUtil.getUser(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Apply.class); wrapper.orderByDesc(Apply::getCreateTime); wrapper.eq(apply.getIsReturn() != null, Apply::getIsReturn, apply.getIsReturn()); wrapper.eq(StringUtils.isNotBlank(apply.getApplyUser()), Apply::getApplyUser, apply.getApplyUser()); + if (!user.getRoleName().contains("administrator") && !user.getRoleName().contains("admin") && !user.getRoleName().contains("库管员")) { + wrapper.eq(Apply::getApplyUserId,user.getUserId()); + } IPage pages = applyService.page(Condition.getPage(query), wrapper); List records = pages.getRecords(); if (CollectionUtil.isNotEmpty(records)) { + for(Apply record: records){ + WorkOrder order = workOrderService.getById(record.getWorkId()); + if(order != null){ + record.setRequirementCode(order.getRequirementCode()); + } + } List ids = records.stream().map(Apply::getId).collect(Collectors.toList()); List details = applyDetailService.list(Wrappers.lambdaQuery(ApplyDetail.class).in(ApplyDetail::getApplyId, ids)); for (Apply record : records) { diff --git a/src/main/java/org/springblade/modules/business/excel/CustomMergeStrategy.java b/src/main/java/org/springblade/modules/business/excel/CustomMergeStrategy.java new file mode 100644 index 0000000..91d7100 --- /dev/null +++ b/src/main/java/org/springblade/modules/business/excel/CustomMergeStrategy.java @@ -0,0 +1,41 @@ +package org.springblade.modules.business.excel; + +import com.alibaba.excel.metadata.Head; +import com.alibaba.excel.write.merge.AbstractMergeStrategy; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.RegionUtil; + +import java.util.List; + +public class CustomMergeStrategy extends AbstractMergeStrategy { + @Override + protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) { + if (relativeRowIndex == null || relativeRowIndex == 0) { + return; + } + int rowIndex = cell.getRowIndex(); + int colIndex = cell.getColumnIndex(); + sheet = cell.getSheet(); + Row preRow = sheet.getRow(rowIndex - 1); + Cell preCell = preRow.getCell(colIndex);// 获取上一行的该格 + List list = sheet.getMergedRegions(); + CellStyle cs = cell.getCellStyle(); + cell.setCellStyle(cs); + for (int i = 0; i < list.size(); i++) { + CellRangeAddress cellRangeAddress = list.get(i); + if (cellRangeAddress.containsRow(preCell.getRowIndex()) && cellRangeAddress.containsColumn(preCell.getColumnIndex())) { + int lastColIndex = cellRangeAddress.getLastColumn(); + int firstColIndex = cellRangeAddress.getFirstColumn(); + CellRangeAddress cra = new CellRangeAddress(cell.getRowIndex(), cell.getRowIndex(), firstColIndex, lastColIndex); + sheet.addMergedRegion(cra); + RegionUtil.setBorderBottom(BorderStyle.THIN, cra, sheet); + RegionUtil.setBorderLeft(BorderStyle.THIN, cra, sheet); + RegionUtil.setBorderRight(BorderStyle.THIN, cra, sheet); + RegionUtil.setBorderTop(BorderStyle.THIN, cra, sheet); + return; + } + } + } + +} diff --git a/src/main/java/org/springblade/modules/business/excel/DeviceImportExcel.java b/src/main/java/org/springblade/modules/business/excel/DeviceImportExcel.java new file mode 100644 index 0000000..21a1c24 --- /dev/null +++ b/src/main/java/org/springblade/modules/business/excel/DeviceImportExcel.java @@ -0,0 +1,44 @@ +package org.springblade.modules.business.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; + +/** + * 设备表 Excel实体类 + * @author BladeX + * @since 2024-10-14 + */ +@Data +@ColumnWidth(25) +@HeadRowHeight(20) +@ContentRowHeight(18) +public class DeviceImportExcel implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + + @ExcelProperty("设备编号") + private String code; + + @ExcelProperty("设备名称") + private String name; + + @ExcelProperty("设备类型") + private String type; + + @ExcelProperty({"巡检相关","巡检内容"}) + private String checkContent; + + @ExcelProperty({"巡检相关","工艺要求"}) + private String craft; + + @ExcelProperty("备注") + private String description; + + +} diff --git a/src/main/java/org/springblade/modules/business/excel/DeviceImporter.java b/src/main/java/org/springblade/modules/business/excel/DeviceImporter.java index 37dc12b..846629b 100644 --- a/src/main/java/org/springblade/modules/business/excel/DeviceImporter.java +++ b/src/main/java/org/springblade/modules/business/excel/DeviceImporter.java @@ -37,13 +37,12 @@ import java.util.List; * @author Chill */ @RequiredArgsConstructor -public class DeviceImporter implements ExcelImporter { +public class DeviceImporter implements ExcelImporter { private final IDeviceService service; - private final Boolean isCovered; @Override - public void save(List data) { - service.importGoods(data, isCovered); + public void save(List data) { + service.importDevice(data); } } diff --git a/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.java b/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.java index e59962d..39dc040 100644 --- a/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.java +++ b/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.java @@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Param; import org.springblade.modules.business.pojo.entity.maintenance.MaintenanceTaskDetail; import java.util.List; +import java.util.Map; /** * 维保任务详情 Mapper 接口 @@ -17,4 +18,8 @@ public interface MaintenanceTaskDetailMapper extends BaseMapper findListByDeviceId(@Param("deviceId")Long deviceId); + String findPeriod(); + + Map getDeptContact(@Param("deptId")long deptId); + } diff --git a/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.xml b/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.xml index 2487302..9fe4ef4 100644 --- a/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.xml +++ b/src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.xml @@ -15,4 +15,27 @@ a.is_deleted = 0 AND a.device_id = #{deviceId} + + diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/DeviceMaintenance.java b/src/main/java/org/springblade/modules/business/pojo/entity/DeviceMaintenance.java index 931c404..8331260 100644 --- a/src/main/java/org/springblade/modules/business/pojo/entity/DeviceMaintenance.java +++ b/src/main/java/org/springblade/modules/business/pojo/entity/DeviceMaintenance.java @@ -2,6 +2,8 @@ package org.springblade.modules.business.pojo.entity; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -36,6 +38,7 @@ public class DeviceMaintenance extends BaseEntity { /** * 巡检周期 1:月, 2:季, 3:半年 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Integer period; /** diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTask.java b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTask.java index 646b84a..febae60 100644 --- a/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTask.java +++ b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTask.java @@ -3,6 +3,8 @@ package org.springblade.modules.business.pojo.entity.maintenance; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -114,6 +116,7 @@ public class MaintenanceTask extends BaseEntity { /** * 审批结果(0不通过 1通过) */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Integer approveResult; /** @@ -124,6 +127,7 @@ public class MaintenanceTask extends BaseEntity { /** * 审批人 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Long approvePerson; /** @@ -206,6 +210,7 @@ public class MaintenanceTask extends BaseEntity { /** * 差旅费 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Double travelExpense; /** @@ -216,5 +221,6 @@ public class MaintenanceTask extends BaseEntity { /** * 总价 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Double totalPrice; } diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTaskDetail.java b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTaskDetail.java index b9b7c0d..6580ea1 100644 --- a/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTaskDetail.java +++ b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/MaintenanceTaskDetail.java @@ -3,6 +3,8 @@ package org.springblade.modules.business.pojo.entity.maintenance; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -24,8 +26,21 @@ import java.util.List; @Schema(description = "维保任务详细") public class MaintenanceTaskDetail extends BaseEntity { + /** + * 任务id + */ private Long taskId; + /** + * 计划id + */ + private Long planId; + + /** + * 计划明细id + */ + private Long planDetailId; + /** * 设备id */ @@ -88,16 +103,19 @@ public class MaintenanceTaskDetail extends BaseEntity { /** * 维修价格 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Double price; /** * 客户确认是否维修, 0:不维修, 1维修 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Integer isRepair; /** * 确认是否需要物资 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Integer isNeed; /** diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/RepairGoodsOutputData.java b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/RepairGoodsOutputData.java new file mode 100644 index 0000000..c0c238c --- /dev/null +++ b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/RepairGoodsOutputData.java @@ -0,0 +1,26 @@ +package org.springblade.modules.business.pojo.entity.maintenance; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.converters.bytearray.ByteArrayImageConverter; +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = false) +public class RepairGoodsOutputData { + + private long no; + + //物料名称 + private String goodsName; + + //数量 + private Integer number; + + //价格 + private Double price; + + private Double totalPrice; + +} diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/UnRepairGoodsOutputData.java b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/UnRepairGoodsOutputData.java new file mode 100644 index 0000000..aeeb699 --- /dev/null +++ b/src/main/java/org/springblade/modules/business/pojo/entity/maintenance/UnRepairGoodsOutputData.java @@ -0,0 +1,24 @@ +package org.springblade.modules.business.pojo.entity.maintenance; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = false) +public class UnRepairGoodsOutputData { + + private long no1; + + + //物料名称 + private String goodsName1; + + //数量 + private Integer number1; + + //价格 + private Double price1; + + private Double totalPrice1; + +} diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Apply.java b/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Apply.java index f5213ed..c1ac538 100644 --- a/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Apply.java +++ b/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Apply.java @@ -97,4 +97,7 @@ public class Apply extends BaseEntity { @TableField(exist = false) List details; + + @TableField(exist = false) + private String requirementCode;; } diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Goods.java b/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Goods.java index fc43bdd..fab93d0 100644 --- a/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Goods.java +++ b/src/main/java/org/springblade/modules/business/pojo/entity/supplies/Goods.java @@ -2,6 +2,8 @@ package org.springblade.modules.business.pojo.entity.supplies; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.mp.base.BaseEntity; @@ -134,6 +136,7 @@ public class Goods extends BaseEntity { /** * 续订时间(天) */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Integer renewNum; /** diff --git a/src/main/java/org/springblade/modules/business/pojo/entity/workorder/WorkOrder.java b/src/main/java/org/springblade/modules/business/pojo/entity/workorder/WorkOrder.java index a79022a..33758db 100644 --- a/src/main/java/org/springblade/modules/business/pojo/entity/workorder/WorkOrder.java +++ b/src/main/java/org/springblade/modules/business/pojo/entity/workorder/WorkOrder.java @@ -2,6 +2,8 @@ package org.springblade.modules.business.pojo.entity.workorder; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.NullSerializer; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -52,6 +54,7 @@ public class WorkOrder extends BaseEntity { /** * 设备id */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Long deviceId; /** @@ -143,6 +146,7 @@ public class WorkOrder extends BaseEntity { /** * 是否需要申领物料(0否 1是) */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Integer isNeedMaterial; /** @@ -226,25 +230,30 @@ public class WorkOrder extends BaseEntity { /** * 折扣 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Double discount; /** * 折扣后总价 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Double discountPrice; /** * 维修类型 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Integer repairType; /** * 人工费 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Double laborCost; /** * 差旅费 */ + @JsonSerialize(nullsUsing = NullSerializer.class) private Double travelExpense; } diff --git a/src/main/java/org/springblade/modules/business/service/IDeviceService.java b/src/main/java/org/springblade/modules/business/service/IDeviceService.java index 6a6f876..b2c8906 100644 --- a/src/main/java/org/springblade/modules/business/service/IDeviceService.java +++ b/src/main/java/org/springblade/modules/business/service/IDeviceService.java @@ -3,6 +3,7 @@ package org.springblade.modules.business.service; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.core.mp.base.BaseService; +import org.springblade.modules.business.excel.DeviceImportExcel; import org.springblade.modules.business.pojo.dto.DeviceDTO; import org.springblade.modules.business.pojo.entity.Device; import org.springblade.modules.business.excel.DeviceExcel; @@ -46,7 +47,7 @@ public interface IDeviceService extends BaseService { List selectStatusCount(String startTime, String endTime); - void importGoods(List data, Boolean isCovered); + void importDevice(List data); List limsList(Device device); diff --git a/src/main/java/org/springblade/modules/business/service/IMaintenanceTaskDetailService.java b/src/main/java/org/springblade/modules/business/service/IMaintenanceTaskDetailService.java index 793d551..3611f4f 100644 --- a/src/main/java/org/springblade/modules/business/service/IMaintenanceTaskDetailService.java +++ b/src/main/java/org/springblade/modules/business/service/IMaintenanceTaskDetailService.java @@ -21,4 +21,7 @@ public interface IMaintenanceTaskDetailService extends BaseService task, HttpServletResponse response) throws IOException; + + void repairOutputService(MaintenanceTask task, HttpServletResponse response) throws IOException; + } diff --git a/src/main/java/org/springblade/modules/business/service/impl/DeviceServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/DeviceServiceImpl.java index 1c9c334..a17e6f3 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/DeviceServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/DeviceServiceImpl.java @@ -5,20 +5,22 @@ import com.aliyun.oss.ServiceException; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.zxing.WriterException; import lombok.AllArgsConstructor; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springblade.common.cache.SysCache; import org.springblade.common.constant.CommonConstant; import org.springblade.common.utils.CommonUtil; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.modules.business.excel.DeviceExcel; +import org.springblade.modules.business.excel.DeviceImportExcel; import org.springblade.modules.business.mapper.DeviceMapper; import org.springblade.modules.business.pojo.dto.DeviceDTO; import org.springblade.modules.business.pojo.entity.Device; @@ -36,10 +38,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -152,7 +151,7 @@ public class DeviceServiceImpl extends BaseServiceImpl imp return baseMapper.selectStatusCount(startTime, endTime); } - @Override + /*@Override public void importGoods(List data, Boolean isCovered) { List list = new ArrayList<>(); // 获取负责的实验室数据 @@ -203,6 +202,36 @@ public class DeviceServiceImpl extends BaseServiceImpl imp } else { this.saveBatch(list); } + }*/ + + @Override + public void importDevice(List data) { + data.forEach(deviceExcel -> { + if(StringUtils.isEmpty(deviceExcel.getCode())){ + throw new ServiceException("设备" + deviceExcel.getName() + "未填写设备编码,请修改后再上传!"); + } + Device device = BeanUtil.copyProperties(deviceExcel, Device.class); + DeviceMaintenance deviceMaintenance = BeanUtil.copyProperties(deviceExcel, DeviceMaintenance.class); + if (device != null) { + //根据编码查询设备 + Device oldDevice = this.getOne(Wrappers.lambdaQuery(Device.class).eq(Device::getCode,device.getCode()).eq(BaseEntity::getIsDeleted,0)); + if (oldDevice != null) { + device.setId(oldDevice.getId()); + this.saveOrUpdate(device); + } else { + device.setRunStatus(CommonConstant.DEVICE_RUN_STATUS_WORKING); + this.save(device); + } + if(deviceMaintenance != null){ + if(oldDevice != null){ + maintenanceService.remove(Wrappers.lambdaQuery(DeviceMaintenance.class).eq(DeviceMaintenance::getDeviceId,oldDevice.getId())); + } + deviceMaintenance.setDeviceId(device.getId()); + maintenanceService.save(deviceMaintenance); + } + } + }); + } @Override diff --git a/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java index aeed47d..7015b41 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/MaintenancePlanServiceImpl.java @@ -10,7 +10,9 @@ import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServletResponse; import lombok.AllArgsConstructor; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springblade.common.cache.UserCache; +import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; @@ -294,17 +296,16 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl maintenanceSupervisorList = userService.list(Wrappers.lambdaQuery(User.class).eq(User::getRoleId, roleId)); try { for (User maintenanceSupervisor : maintenanceSupervisorList) { - Optional phone = Optional.ofNullable(maintenanceSupervisor.getPhone()); - if (phone.isEmpty()) { + if (StringUtils.isEmpty(maintenanceSupervisor.getPhone())) { continue; //TODO 当手机号为空时需要处理的逻辑 } Optional realName = Optional.ofNullable(maintenanceSupervisor.getRealName()); //TODO 当真实姓名为空时需要处理的逻辑 if (realName.isEmpty()) { - smsService.sendSms(phone.get(), "未实名"); + smsService.sendSms(maintenanceSupervisor.getPhone(), "未实名"); } else { - smsService.sendSms(phone.get(), realName.get()); + smsService.sendSms(maintenanceSupervisor.getPhone(), realName.get()); } } } catch (Exception e) { @@ -338,11 +339,11 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl taskDetails = new ArrayList<>(); - MaintenanceTaskDetail maintenanceTaskDetail = new MaintenanceTaskDetail(); - List list = taskService.list(Wrappers.lambdaQuery(MaintenanceTask.class).eq(MaintenanceTask::getPlanId, planId)); for (MaintenancePlanDetail newPlanDetail : newDetails) { MaintenanceTaskDetail taskDetail = new MaintenanceTaskDetail(); taskDetail.setTaskId(maintenanceTask.getId()); + taskDetail.setPlanId(newPlanDetail.getPlanId()); + taskDetail.setPlanDetailId(newPlanDetail.getId()); taskDetail.setFloorName(newPlanDetail.getFloorName()); taskDetail.setDeptId(newPlanDetail.getDeptId()); taskDetail.setDeptName(newPlanDetail.getDeptName()); @@ -353,6 +354,13 @@ public class MaintenancePlanServiceImpl extends BaseServiceImpl implements IMaintenanceTaskDetailService { + @Autowired + private IUserService userService; + + @Autowired + private IMaintenanceApplyGoodsService maintenanceApplyGoodsService; @Override public List findListByDeviceId(Long deviceId) { @@ -55,14 +73,35 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl map = new HashMap<>(); - map.put("taskName", task.getDeptName()); - map.put("address", task.getDeptName()); - map.put("taskContent", task.getTaskContent()); - map.put("serviceManName", task.getServicemanName()); + Map map0 = new HashMap<>(); + map0.put("taskName", task.getDeptName()); + String period = baseMapper.findPeriod(); + map0.put("period",period + "度报告"); + map0.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日")); + map0.put("taskCode", task.getTaskCode()); + + Map map1 = new HashMap<>(); + map1.put("taskName", task.getDeptName()); + map1.put("address", task.getDeptName()); + map1.put("taskContent", task.getTaskContent()); + + Map map2 = new HashMap<>(); + map2.put("taskName", task.getDeptName()); + map2.put("address", task.getDeptName()); + map2.put("inspectionConclusion", task.getInspectionConclusion()); + map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); + //获取客户联系人、联系电话 + Map cusMap = baseMapper.getDeptContact(task.getDeptId()); + if(CollectionUtils.isNotEmpty(cusMap)){ + map2.put("contact",cusMap.get("name")); //联系人 + map2.put("phone",cusMap.get("phone")); //联系方式 + } + List maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); List maintenanceOutputDataList = new ArrayList<>(); + List maintenanceOutputDataList1 = new ArrayList<>(); long no = 0; + long no1 = 0; for (MaintenanceTaskDetail maintenanceTaskDetail : maintenanceTaskDetailList) { no++; MaintenanceOutputData maintenanceOutputData = new MaintenanceOutputData(); @@ -101,33 +140,55 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); + map2.put("image", voidWriteCellData); + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + map2.put("image",null); } + //将数据导出到Excel ServletOutputStream outputStream = response.getOutputStream(); try (ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(fileInputStream).build()) { - WriteSheet writeSheet = EasyExcel.writerSheet().build(); - excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet); - excelWriter.fill(map, writeSheet); + WriteSheet writeSheet0 = EasyExcel.writerSheet(0).build(); + excelWriter.fill(map0, writeSheet0); + + WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); + excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet1); + excelWriter.fill(map1, writeSheet1); + + WriteSheet writeSheet2 = EasyExcel.writerSheet(2).build(); + excelWriter.fill(maintenanceOutputDataList1, fillConfig, writeSheet2); + + WriteSheet writeSheet3 = EasyExcel.writerSheet(3).build(); + excelWriter.fill(map2, writeSheet3); + excelWriter.finish(); outputStream.flush(); outputStream.close(); @@ -141,14 +202,36 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl map = new HashMap<>(); - map.put("taskName", task.getDeptName()); - map.put("address", task.getDeptName()); - map.put("taskContent", task.getTaskContent()); - map.put("serviceManName", task.getServicemanName()); + Map map0 = new HashMap<>(); + map0.put("taskName", task.getDeptName()); + String period = baseMapper.findPeriod(); + map0.put("period",period + "度报告"); + map0.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日")); + map0.put("taskCode", task.getTaskCode()); + + Map map1 = new HashMap<>(); + map1.put("taskName", task.getDeptName()); + map1.put("address", task.getDeptName()); + map1.put("taskContent", task.getTaskContent()); + + Map map2 = new HashMap<>(); + map2.put("taskName", task.getDeptName()); + map2.put("address", task.getDeptName()); + map2.put("inspectionConclusion", task.getInspectionConclusion()); + map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); + + //获取客户联系人、联系电话 + Map cusMap = baseMapper.getDeptContact(task.getDeptId()); + if(CollectionUtils.isNotEmpty(cusMap)){ + map2.put("contact",cusMap.get("name")); //联系人 + map2.put("phone",cusMap.get("phone")); //联系方式 + } + List maintenanceTaskDetailList = baseMapper.selectList(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId, task.getId())); List maintenanceOutputDataList = new ArrayList<>(); + List maintenanceOutputDataList1 = new ArrayList<>(); long no = 0; + long no1 = 0; for (MaintenanceTaskDetail maintenanceTaskDetail : maintenanceTaskDetailList) { no++; MaintenanceOutputData maintenanceOutputData = new MaintenanceOutputData(); @@ -187,40 +270,191 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); + map2.put("image", voidWriteCellData); + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + map2.put("image",null); } //将数据导出到Excel ZipOutputStream zos = new ZipOutputStream(response.getOutputStream()); String fileName = task.getTaskCode() + "巡检报告.xlsx"; zos.putNextEntry(new ZipEntry(fileName)); try (ExcelWriter excelWriter = EasyExcel.write(zos).withTemplate(fileInputStream).build()) { - WriteSheet writeSheet = EasyExcel.writerSheet().build(); - excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet); - excelWriter.fill(map, writeSheet); + WriteSheet writeSheet0 = EasyExcel.writerSheet(0).build(); + excelWriter.fill(map0, writeSheet0); + + WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); + excelWriter.fill(maintenanceOutputDataList, fillConfig, writeSheet1); + excelWriter.fill(map1, writeSheet1); + + WriteSheet writeSheet2 = EasyExcel.writerSheet(2).build(); + excelWriter.fill(maintenanceOutputDataList1, fillConfig, writeSheet2); + + WriteSheet writeSheet3 = EasyExcel.writerSheet(3).build(); + excelWriter.fill(map2, writeSheet3); + excelWriter.finish(); zos.flush(); zos.closeEntry(); } } } + + @Override + public void repairOutputService(MaintenanceTask task, HttpServletResponse response) throws IOException { + //数据获取 + String templateFile = "RepairService.xlsx"; + InputStream fileInputStream = this.getClass().getClassLoader().getResourceAsStream("excel" + "/" + templateFile); + FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build(); + Map map0 = new HashMap<>(); + map0.put("taskName", task.getDeptName()); //客户名称 + map0.put("address", task.getDeptName()); //地址 + //获取客户联系人、联系电话 + Map cusMap = baseMapper.getDeptContact(task.getDeptId()); + if(CollectionUtils.isNotEmpty(cusMap)){ + map0.put("contact",cusMap.get("name")); //联系人 + map0.put("phone",cusMap.get("phone")); //联系方式 + } + map0.put("servicemanName", task.getServicemanName()); //维修工程师 + map0.put("inspectionConclusion", task.getInspectionConclusion()); //维修结论 + if(task.getServicemanId() != null){ + User serviceman = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, task.getServicemanId())); + map0.put("servicemanPhone", serviceman.getPhone()); //维修工程师联系方式 + } + map0.put("faultDescribe",task.getFaultDescribe()); //故障现象 + map0.put("faultCause",task.getFaultCause()); //故障原因 + map0.put("travelExpense",task.getTravelExpense()==null?0:task.getTravelExpense()); //维修差旅费 + map0.put("processingResult",task.getProcessingResult()); //处理结果 + map0.put("finishTime",task.getFinishTime() != null ? DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日") : ""); //维修结束时间 + + Map map1 = new HashMap<>(); + map1.put("taskName", task.getDeptName()); + map1.put("address", task.getDeptName()); + if(CollectionUtils.isNotEmpty(cusMap)){ + map1.put("contact",cusMap.get("name")); //联系人 + map1.put("phone",cusMap.get("phone")); //联系方式 + } + map1.put("inspectionConclusion", task.getInspectionConclusion()); + map1.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); //客户签字时间 + + + List repairGoodsList = new ArrayList<>(); + List unRepairGoodsList = new ArrayList<>(); + long no = 0; + long no1 = 0; + double total = 0.0; + double total1 = 0.0; + List taskDetailList = this.list(Wrappers.lambdaQuery(MaintenanceTaskDetail.class).eq(MaintenanceTaskDetail::getTaskId,task.getId()).eq(BaseEntity::getIsDeleted,0)); + if(CollectionUtils.isNotEmpty(taskDetailList)){ + Map> taskDetailMap = taskDetailList.stream().collect(Collectors.groupingBy(MaintenanceTaskDetail::getIsRepair)); + for (Map.Entry> entry : taskDetailMap.entrySet()) { + if(entry.getKey() == 1){ + for(MaintenanceTaskDetail detail : entry.getValue()){ + List list = maintenanceApplyGoodsService.list(Wrappers.lambdaQuery(MaintenanceTaskDetailGoods.class).eq(MaintenanceTaskDetailGoods::getParentId,detail.getId()).eq(BaseEntity::getIsDeleted,0)); + if(CollectionUtils.isNotEmpty(list)){ + for(MaintenanceTaskDetailGoods goods : list){ + no++; + RepairGoodsOutputData repairGoodsOutputData = new RepairGoodsOutputData(); + repairGoodsOutputData.setNo(no); + repairGoodsOutputData.setGoodsName(goods.getGoodsName()); + repairGoodsOutputData.setNumber(goods.getNumber()); + repairGoodsOutputData.setPrice(goods.getPrice()); + repairGoodsOutputData.setTotalPrice(goods.getNumber() * goods.getPrice()); + repairGoodsList.add(repairGoodsOutputData); + total+=goods.getNumber() * goods.getPrice(); + } + } + } + }else{ + for(MaintenanceTaskDetail detail : entry.getValue()){ + List list = maintenanceApplyGoodsService.list(Wrappers.lambdaQuery(MaintenanceTaskDetailGoods.class).eq(MaintenanceTaskDetailGoods::getParentId,detail.getId()).eq(BaseEntity::getIsDeleted,0)); + if(CollectionUtils.isNotEmpty(list)){ + for(MaintenanceTaskDetailGoods goods : list){ + no1++; + RepairGoodsOutputData unRepairGoodsOutputData = new RepairGoodsOutputData(); + unRepairGoodsOutputData.setNo(no1); + unRepairGoodsOutputData.setGoodsName(goods.getGoodsName()); + unRepairGoodsOutputData.setNumber(goods.getNumber()); + unRepairGoodsOutputData.setPrice(goods.getPrice()); + unRepairGoodsOutputData.setTotalPrice(goods.getNumber() * goods.getPrice()); + unRepairGoodsList.add(unRepairGoodsOutputData); + total1+=goods.getNumber() * goods.getPrice(); + } + } + } + } + } + } + map0.put("total",total); //维修材料费用 + map0.put("repairTotal", (task.getTravelExpense() == null ? 0.0 : task.getTravelExpense()) + total); //维修费总计 + map0.put("total1",total1); //未维修项目材料费用 + + //获取签字图片 + if (StringUtils.isNotBlank(task.getSignatureUrl())) { + try { + //获取图片 + URL url = new URL(task.getSignatureUrl()); + HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); + httpURLConnection.setRequestMethod("GET"); + httpURLConnection.setDoInput(true); + InputStream inputStream = httpURLConnection.getInputStream(); + BufferedImage image = ImageIO.read(inputStream); + ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); + ImageIO.write(image, "png", arrayOutputStream); + byte[] bytes = arrayOutputStream.toByteArray(); + Double width = Double.valueOf(image.getWidth()); + Double height = Double.valueOf(image.getHeight()); + WriteCellData voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9); + map0.put("image", voidWriteCellData); + map1.put("image", voidWriteCellData); + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + map0.put("image",null); + map1.put("image",null); + } + + //将数据导出到Excel + ServletOutputStream outputStream = response.getOutputStream(); + try (ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(fileInputStream).build()) { + WriteSheet writeSheet0 = EasyExcel.writerSheet(0).registerWriteHandler(new CustomMergeStrategy()).build(); + excelWriter.fill(map0, writeSheet0); + excelWriter.fill(new FillWrapper("data1", repairGoodsList),fillConfig, writeSheet0); + excelWriter.fill(new FillWrapper("data2", unRepairGoodsList),fillConfig, writeSheet0); + + WriteSheet writeSheet1 = EasyExcel.writerSheet(1).build(); + excelWriter.fill(map1, writeSheet1); + + excelWriter.finish(); + outputStream.flush(); + outputStream.close(); + } + } } diff --git a/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java b/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java index 758408f..f295e41 100644 --- a/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java +++ b/src/main/java/org/springblade/modules/business/service/impl/WorkOrderServiceImpl.java @@ -637,7 +637,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl limsId = Optional.ofNullable(device.get().getLimsId()); if (limsId.isPresent()) { - map.put("in", total + workOrder.getLaborCost()); + map.put("in", total + (workOrder.getLaborCost() == null ? 0 : workOrder.getLaborCost())); map.put("out", "--"); map.put("sel1", "√"); map.put("sel2", null); diff --git a/src/main/java/org/springblade/modules/system/pojo/entity/Dept.java b/src/main/java/org/springblade/modules/system/pojo/entity/Dept.java index a621aa2..1754b7f 100644 --- a/src/main/java/org/springblade/modules/system/pojo/entity/Dept.java +++ b/src/main/java/org/springblade/modules/system/pojo/entity/Dept.java @@ -120,11 +120,13 @@ public class Dept implements Serializable { @Schema(description = "是否已删除") private Integer isDeleted; - /** - * 部门种类 - * 实验室,房间 - */ -// private Integer deptCat; + private String provinceName; + + private String provinceCode; + + private String cityName; + + private String cityCode; } diff --git a/src/main/resources/excel/MaintenanceTaskReport.xlsx b/src/main/resources/excel/MaintenanceTaskReport.xlsx index 50ba63b..2d5becf 100644 Binary files a/src/main/resources/excel/MaintenanceTaskReport.xlsx and b/src/main/resources/excel/MaintenanceTaskReport.xlsx differ diff --git a/src/main/resources/excel/RepairService.xlsx b/src/main/resources/excel/RepairService.xlsx new file mode 100644 index 0000000..91df203 Binary files /dev/null and b/src/main/resources/excel/RepairService.xlsx differ