소스 검색

2024年9月27日15:43:08 中电禅道

纪新园 10 달 전
부모
커밋
1b49566569

+ 103 - 42
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java

@@ -1,9 +1,13 @@
 package com.ruoyi.web.controller.common;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.common.utils.file.FileUtils;
 import com.ruoyi.common.utils.file.MimeTypeUtils;
+import com.ruoyi.framework.config.ServerConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -12,13 +16,16 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
-import com.ruoyi.common.config.RuoYiConfig;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.file.FileUploadUtils;
-import com.ruoyi.common.utils.file.FileUtils;
-import com.ruoyi.framework.config.ServerConfig;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 import static com.ruoyi.common.utils.file.FileUploadUtils.getExtension;
 import static com.ruoyi.common.utils.file.FileUploadUtils.isPicture;
@@ -30,8 +37,7 @@ import static com.ruoyi.common.utils.file.ImageUtils.imageMethod;
  * @author ruoyi
  */
 @RestController
-public class CommonController
-{
+public class CommonController {
     private static final Logger log = LoggerFactory.getLogger(CommonController.class);
 
     @Autowired
@@ -41,13 +47,11 @@ public class CommonController
      * 通用下载请求
      *
      * @param fileName 文件名称
-     * @param delete 是否删除
+     * @param delete   是否删除
      */
     @GetMapping("common/download")
-    public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
-    {
-        try
-        {
+    public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
+        try {
             /*if (!FileUtils.checkAllowDownload(fileName))
             {
                 throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
@@ -59,13 +63,10 @@ public class CommonController
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             FileUtils.setAttachmentResponseHeader(response, realFileName);
             FileUtils.writeBytes(filePath, response.getOutputStream());
-            if (delete)
-            {
+            if (delete) {
                 FileUtils.deleteFile(filePath);
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("下载文件失败", e);
         }
     }
@@ -74,10 +75,8 @@ public class CommonController
      * 通用上传请求
      */
     @PostMapping("/common/upload")
-    public AjaxResult uploadFile(MultipartFile file) throws Exception
-    {
-        try
-        {
+    public AjaxResult uploadFile(MultipartFile file) throws Exception {
+        try {
             AjaxResult ajax = AjaxResult.success();
             // 上传文件路径
             String filePath = RuoYiConfig.getUploadPath();
@@ -91,18 +90,18 @@ public class CommonController
             }
             // 上传并返回新文件名称
             String fileName = FileUploadUtils.upload(filePath, file);
-            if (serverConfig.getUrl().contains("qd.dmu.com.cn")){
-                String url = serverConfig.getUrl()+":8443" + fileName;
-                if (url.indexOf("http")!= -1){
+            if (serverConfig.getUrl().contains("qd.dmu.com.cn")) {
+                String url = serverConfig.getUrl() + ":8443" + fileName;
+                if (url.indexOf("http") != -1) {
                     String replace = url.replace("http", "https");
                     url = replace;
                 }
                 ajax.put("fileName", file.getOriginalFilename());
                 ajax.put("url", url);
                 return ajax;
-            }else{
+            } else {
                 String url = serverConfig.getUrl() + fileName;
-                if (url.indexOf("http")!= -1){
+                if (url.indexOf("http") != -1) {
                     String replace = url.replace("http", "https");
                     url = replace;
                 }
@@ -110,9 +109,76 @@ public class CommonController
                 ajax.put("url", url);
                 return ajax;
             }
+        } catch (Exception e) {
+            return AjaxResult.error(e.getMessage());
         }
-        catch (Exception e)
-        {
+    }
+
+    /**
+     * 通用上传请求
+     */
+    @PostMapping("/common/upload/watermark")
+    public AjaxResult uploadFileWatermark(MultipartFile file) throws Exception {
+        if (file.isEmpty()) {
+            return AjaxResult.error("上传失败请重试1");
+        }
+        Date date = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String formattedDate = sdf.format(date);
+        InputStream inputStream = file.getInputStream();
+        BufferedImage originalImage = ImageIO.read(inputStream);
+        int widthSize = (int) (originalImage.getWidth() * 0.5);
+        int heightSize = (int) (originalImage.getHeight() * 0.5);
+        Image compressedImage = originalImage.getScaledInstance(widthSize, heightSize, Image.SCALE_SMOOTH);
+        BufferedImage outputImage = new BufferedImage(widthSize, heightSize, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g2d = (Graphics2D) outputImage.getGraphics();
+        g2d.drawImage(compressedImage, 0, 0, null);
+        OutputStream outputStream = new FileOutputStream(new File(file.getName()+getExtension(file)));
+        AlphaComposite alphaChannel = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
+        g2d.setComposite(alphaChannel);
+        g2d.setColor(Color.BLUE);
+        g2d.setFont(new Font("Arial", Font.BOLD, 30));
+        // 获取图像的宽度和高度
+        int width = outputImage.getWidth();
+        int height = outputImage.getHeight();
+        // 计算水印位置为右下角
+        Rectangle2D rect = g2d.getFont().getStringBounds(formattedDate, g2d.getFontRenderContext());
+        float textWidth = (float) rect.getWidth();
+        float textHeight = (float) rect.getHeight();
+        float x = width - textWidth;
+        float y = height - textHeight;
+        g2d.drawString(formattedDate, x, y);
+        g2d.dispose();
+        g2d.dispose();
+        ImageIO.write(outputImage, file.getName(), outputStream);
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        ImageIO.write(outputImage, "png", byteArrayOutputStream); // 这里可以根据需要指定格式
+        byte[] byteArray = byteArrayOutputStream.toByteArray();
+
+        MultipartFile multipart =  new CustomMultipartFile(byteArray, file.getName(), file.getName(), "image/png");
+        try {
+            AjaxResult ajax = AjaxResult.success();
+            // 上传文件路径
+            String filePath = RuoYiConfig.getUploadPath();
+            String extension = getExtension(multipart);
+            MultipartFile multipartFile = null;
+            if (isPicture(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
+                multipartFile = imageMethod(multipart);
+                String thumbnail = FileUploadUtils.upload(filePath, multipartFile);
+                String url = serverConfig.getUrl() + thumbnail;
+                ajax.put("thumbnailUrl", url);
+            }
+            // 上传并返回新文件名称
+            String fileName = FileUploadUtils.upload(filePath, multipart);
+            String url = serverConfig.getUrl() + fileName;
+            if (url.indexOf("http") != -1) {
+                String replace = url.replace("http", "https");
+                url = replace;
+            }
+            ajax.put("fileName", multipart.getOriginalFilename());
+            ajax.put("url", url);
+            return ajax;
+        } catch (Exception e) {
             return AjaxResult.error(e.getMessage());
         }
     }
@@ -122,12 +188,9 @@ public class CommonController
      */
     @GetMapping("/common/download/resource")
     public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
-            throws Exception
-    {
-        try
-        {
-            if (!FileUtils.checkAllowDownload(resource))
-            {
+            throws Exception {
+        try {
+            if (!FileUtils.checkAllowDownload(resource)) {
                 throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
             }
             // 本地资源路径
@@ -139,9 +202,7 @@ public class CommonController
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
             FileUtils.setAttachmentResponseHeader(response, downloadName);
             FileUtils.writeBytes(downloadPath, response.getOutputStream());
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("下载文件失败", e);
         }
     }

+ 67 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CustomMultipartFile.java

@@ -0,0 +1,67 @@
+package com.ruoyi.web.controller.common;
+
+import org.springframework.core.io.Resource;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.*;
+import java.nio.file.Path;
+
+/**
+ * @author :jixinyuan
+ * @date : 2024/9/27
+ */
+public class CustomMultipartFile implements MultipartFile {
+    private final byte[] content;
+    private final String name;
+    private final String originalFileName;
+    private final String contentType;
+
+    public CustomMultipartFile(byte[] content, String name, String originalFileName, String contentType) {
+        this.content = content;
+        this.name = name;
+        this.originalFileName = originalFileName;
+        this.contentType = contentType;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getOriginalFilename() {
+        return originalFileName;
+    }
+
+    @Override
+    public String getContentType() {
+        return contentType;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return content == null || content.length == 0;
+    }
+
+    @Override
+    public long getSize() {
+        return content.length;
+    }
+
+    @Override
+    public byte[] getBytes() throws IOException {
+        return content;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return new ByteArrayInputStream(content);
+    }
+
+    @Override
+    public void transferTo(File dest) throws IOException, IllegalStateException {
+        try (FileOutputStream fos = new FileOutputStream(dest)) {
+            fos.write(content);
+        }
+    }
+}

+ 8 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/check/TWarehouseCheckController.java

@@ -185,4 +185,12 @@ public class TWarehouseCheckController extends BaseController {
     public AjaxResult saveCheckItemsDetails(@RequestBody TWarehouseCheck tWarehouseCheck) {
         return toAjax(tWarehouseCheckService.saveCheckItemsDetails(tWarehouseCheck));
     }
+
+    /**
+     * 生成巡检明细
+     */
+    @PostMapping("/generateItems")
+    public AjaxResult generateItems(@RequestBody TWarehouseCheck tWarehouseCheck) {
+        return tWarehouseCheckService.generateItems(tWarehouseCheck);
+    }
 }

+ 30 - 25
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/check/TWarehouseCheckItemsController.java

@@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -29,8 +28,7 @@ import java.util.List;
  */
 @RestController
 @RequestMapping("/warehouse/checkitems")
-public class TWarehouseCheckItemsController extends BaseController
-{
+public class TWarehouseCheckItemsController extends BaseController {
     @Autowired
     private ITWarehouseCheckItemsService tWarehouseCheckItemsService;
 
@@ -42,8 +40,7 @@ public class TWarehouseCheckItemsController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('warehouse:checkitems:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TWarehouseCheckItems tWarehouseCheckItems)
-    {
+    public TableDataInfo list(TWarehouseCheckItems tWarehouseCheckItems) {
         startPage();
         List<TWarehouseCheckItems> list = tWarehouseCheckItemsService.selectTWarehouseCheckItemsList(tWarehouseCheckItems);
         return getDataTable(list);
@@ -54,9 +51,8 @@ public class TWarehouseCheckItemsController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('warehouse:checkitems:list')")
     @GetMapping("/listByUser")
-    public TableDataInfo listByUser(TWarehouseCheckItems tWarehouseCheckItems)
-    {
-        if (!"admin".equals(SecurityUtils.getUsername())){
+    public TableDataInfo listByUser(TWarehouseCheckItems tWarehouseCheckItems) {
+        if (!"admin".equals(SecurityUtils.getUsername())) {
             tWarehouseCheckItems.setfInspectorId(SecurityUtils.getLoginUser().getUser().getUserId());
         }
         startPage();
@@ -71,8 +67,7 @@ public class TWarehouseCheckItemsController extends BaseController
     @PreAuthorize("@ss.hasPermi('warehouse:checkitems:export')")
     @Log(title = "巡检check-item", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(TWarehouseCheckItems tWarehouseCheckItems)
-    {
+    public AjaxResult export(TWarehouseCheckItems tWarehouseCheckItems) {
         List<TWarehouseCheckItems> list = tWarehouseCheckItemsService.selectTWarehouseCheckItemsList(tWarehouseCheckItems);
         ExcelUtil<TWarehouseCheckItems> util = new ExcelUtil<TWarehouseCheckItems>(TWarehouseCheckItems.class);
         return util.exportExcel(list, "checkitems");
@@ -83,8 +78,7 @@ public class TWarehouseCheckItemsController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('warehouse:checkitems:query')")
     @GetMapping(value = "/{fId}")
-    public AjaxResult getInfo(@PathVariable("fId") Long fId)
-    {
+    public AjaxResult getInfo(@PathVariable("fId") Long fId) {
         return AjaxResult.success(tWarehouseCheckItemsService.selectTWarehouseCheckItemsById(fId));
     }
 
@@ -94,8 +88,7 @@ public class TWarehouseCheckItemsController extends BaseController
     @PreAuthorize("@ss.hasPermi('warehouse:checkitems:add')")
     @Log(title = "巡检check-item", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TWarehouseCheckItems tWarehouseCheckItems)
-    {
+    public AjaxResult add(@RequestBody TWarehouseCheckItems tWarehouseCheckItems) {
         return toAjax(tWarehouseCheckItemsService.insertTWarehouseCheckItems(tWarehouseCheckItems));
     }
 
@@ -105,8 +98,7 @@ public class TWarehouseCheckItemsController extends BaseController
     @PreAuthorize("@ss.hasPermi('warehouse:checkitems:edit')")
     @Log(title = "巡检check-item", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TWarehouseCheckItems tWarehouseCheckItems)
-    {
+    public AjaxResult edit(@RequestBody TWarehouseCheckItems tWarehouseCheckItems) {
         return toAjax(tWarehouseCheckItemsService.updateTWarehouseCheckItems(tWarehouseCheckItems));
     }
 
@@ -115,28 +107,32 @@ public class TWarehouseCheckItemsController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('warehouse:checkitems:remove')")
     @Log(title = "巡检check-item", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{fIds}")
-    public AjaxResult remove(@PathVariable Long[] fIds)
-    {
-        for (Long itemId : fIds) {
+    @DeleteMapping("/{fIds}")
+    public AjaxResult remove(@PathVariable String fIds) {
+        String[] ids = fIds.split(",");
+        for (String itemId : ids) {
             TWarehouseCheckItemsDetails tWarehouseCheckItemsDetailsQuery = new TWarehouseCheckItemsDetails();
-            tWarehouseCheckItemsDetailsQuery.setfItemFid(itemId);
+            tWarehouseCheckItemsDetailsQuery.setfItemFid(Long.parseLong(itemId));
             List<TWarehouseCheckItemsDetails> tWarehouseCheckItemsDetailsList = tWarehouseCheckItemsDetailsService.selectTWarehouseCheckItemsDetailsList(tWarehouseCheckItemsDetailsQuery);
-            if (tWarehouseCheckItemsDetailsList.size() > 0) {
+            if (!tWarehouseCheckItemsDetailsList.isEmpty()) {
                 String photoUrl = tWarehouseCheckItemsDetailsList.get(0).getfPhotoUrl();
                 if (StringUtils.isNotEmpty(photoUrl) && !"[]".equals(photoUrl)) {
                     return AjaxResult.error("单据存在图片详情,不允许删除");
                 }
             }
         }
-        return toAjax(tWarehouseCheckItemsService.deleteTWarehouseCheckItemsByIds(fIds));
+        Long[] idArr = new Long[ids.length];
+        for (int i = 0; i < ids.length; i++) {
+            idArr[i] = Long.parseLong(ids[i]);
+        }
+        return toAjax(tWarehouseCheckItemsService.deleteTWarehouseCheckItemsByIds(idArr));
     }
+
     /**
      * 查询巡检check-item列表
      */
     @GetMapping("/appListByUser")
-    public TableDataInfo appListByUser(TWarehouseCheckItems tWarehouseCheckItems)
-    {
+    public TableDataInfo appListByUser(TWarehouseCheckItems tWarehouseCheckItems) {
         SysUser user = SecurityUtils.getLoginUser().getUser();
         if ("外部用户".equals(user.getDept().getDeptName())) {
             tWarehouseCheckItems.setfInspectorId(user.getUserId());
@@ -149,4 +145,13 @@ public class TWarehouseCheckItemsController extends BaseController
         List<TWarehouseCheckItems> list = tWarehouseCheckItemsService.appListByUser(tWarehouseCheckItems);
         return getDataTable(list);
     }
+
+    /**
+     * 查询巡检check-item列表不分页
+     */
+    @GetMapping("/listAll")
+    public AjaxResult listAll(TWarehouseCheckItems tWarehouseCheckItems) {
+        List<TWarehouseCheckItems> list = tWarehouseCheckItemsService.selectTWarehouseCheckItemsList(tWarehouseCheckItems);
+        return AjaxResult.success(list);
+    }
 }

+ 23 - 11
ruoyi-warehouse/src/main/java/com/ruoyi/warehouse/check/domain/TWarehouseCheck.java

@@ -78,6 +78,29 @@ public class TWarehouseCheck extends BaseEntity
     /** 图片地址 */
     private String fPhotoUrl;
 
+    /**
+     * 巡检名称
+     */
+    private String cname;
+
+    /** 最新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "最新时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date fUpdateTime;
+
+    /** 删除状态(0正常 1停用) */
+    @Excel(name = "删除状态", readConverterExp = "0=正常,1=停用")
+    private Integer fDelFlag;
+    private List<TWarehouseCheckItems> tWarehouseCheckItemsList;
+
+    public String getCname() {
+        return cname;
+    }
+
+    public void setCname(String cname) {
+        this.cname = cname;
+    }
+
     public String getfPhotoUrl() {
         return fPhotoUrl;
     }
@@ -86,8 +109,6 @@ public class TWarehouseCheck extends BaseEntity
         this.fPhotoUrl = fPhotoUrl;
     }
 
-    private List<TWarehouseCheckItems> tWarehouseCheckItemsList;
-
     public List<TWarehouseCheckItems> gettWarehouseCheckItemsList() {
         return tWarehouseCheckItemsList;
     }
@@ -128,15 +149,6 @@ public class TWarehouseCheck extends BaseEntity
         this.fUpdateByName = fUpdateByName;
     }
 
-    /** 最新时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "最新时间", width = 30, dateFormat = "yyyy-MM-dd")
-    private Date fUpdateTime;
-
-    /** 删除状态(0正常 1停用) */
-    @Excel(name = "删除状态", readConverterExp = "0=正常,1=停用")
-    private Integer fDelFlag;
-
     public void setfId(Long fId)
     {
         this.fId = fId;

+ 80 - 57
ruoyi-warehouse/src/main/java/com/ruoyi/warehouse/check/domain/TWarehouseCheckItems.java

@@ -35,6 +35,86 @@ public class TWarehouseCheckItems extends BaseEntity
     /** 巡检人ID */
     private Long fInspectorId;
 
+    /** 巡检人姓名 */
+    private String fInspectorName;
+
+    /** 制单人姓名 */
+    private String fCreateByName;
+
+    /** 更新人姓名 */
+    private String fUpdateByName;
+
+    /** 巡检日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "巡检日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date fInspectionDatetime;
+
+    /** 最新巡检人id */
+    @Excel(name = "最新巡检人id")
+    private Long fInspectorIdLast;
+
+    /** 最新巡检人姓名 */
+    private String fInspectorNameLast;
+
+    /** 最新巡检日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "最新巡检日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date fInspectionDatetimeLast;
+
+    /** 最新巡检日期区间查询 */
+    private String inspectionBeginDate;
+
+    /** 最新巡检日期区间查询 */
+    private String inspectionEndDate;
+
+    /** 巡检备注 */
+    @Excel(name = "巡检备注")
+    private String fRemark;
+
+    /** 制单人 */
+    @Excel(name = "制单人")
+    private Long fCreateBy;
+
+    /** 制单日期 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "制单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date fCreateTime;
+
+    /** 更新人 */
+    @Excel(name = "更新人")
+    private Long fUpdateBy;
+
+    /** 最新时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "最新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date fUpdateTime;
+
+    /** 删除状态(0正常 1停用) */
+    @Excel(name = "删除状态", readConverterExp = "0=正常,1=停用")
+    private Integer fDelFlag;
+
+    /** 是否有效(0否 1是) */
+    private Integer whetherEffective;
+
+    /** 星期 */
+    private String week;
+
+    public Integer getWhetherEffective() {
+        return whetherEffective;
+    }
+
+    public void setWhetherEffective(Integer whetherEffective) {
+        this.whetherEffective = whetherEffective;
+    }
+
+    public String getWeek() {
+        return week;
+    }
+
+    public void setWeek(String week) {
+        this.week = week;
+    }
+
     public Long getfInspectorId() {
         return fInspectorId;
     }
@@ -43,8 +123,6 @@ public class TWarehouseCheckItems extends BaseEntity
         this.fInspectorId = fInspectorId;
     }
 
-    /** 巡检人姓名 */
-    private String fInspectorName;
 
     public String getfWarehouseName() {
         return fWarehouseName;
@@ -78,24 +156,6 @@ public class TWarehouseCheckItems extends BaseEntity
         this.fUpdateByName = fUpdateByName;
     }
 
-    /** 制单人姓名 */
-    private String fCreateByName;
-
-    /** 更新人姓名 */
-    private String fUpdateByName;
-
-    /** 巡检日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "巡检日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    private Date fInspectionDatetime;
-
-    /** 最新巡检人id */
-    @Excel(name = "最新巡检人id")
-    private Long fInspectorIdLast;
-
-    /** 最新巡检人姓名 */
-    private String fInspectorNameLast;
-
     public String getfInspectorNameLast() {
         return fInspectorNameLast;
     }
@@ -104,17 +164,6 @@ public class TWarehouseCheckItems extends BaseEntity
         this.fInspectorNameLast = fInspectorNameLast;
     }
 
-    /** 最新巡检日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "最新巡检日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    private Date fInspectionDatetimeLast;
-
-    /** 最新巡检日期区间查询 */
-    private String inspectionBeginDate;
-
-    /** 最新巡检日期区间查询 */
-    private String inspectionEndDate;
-
     public String getInspectionBeginDate() {
         return inspectionBeginDate;
     }
@@ -131,32 +180,6 @@ public class TWarehouseCheckItems extends BaseEntity
         this.inspectionEndDate = inspectionEndDate;
     }
 
-    /** 巡检备注 */
-    @Excel(name = "巡检备注")
-    private String fRemark;
-
-    /** 制单人 */
-    @Excel(name = "制单人")
-    private Long fCreateBy;
-
-    /** 制单日期 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "制单日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    private Date fCreateTime;
-
-    /** 更新人 */
-    @Excel(name = "更新人")
-    private Long fUpdateBy;
-
-    /** 最新时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "最新时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
-    private Date fUpdateTime;
-
-    /** 删除状态(0正常 1停用) */
-    @Excel(name = "删除状态", readConverterExp = "0=正常,1=停用")
-    private Integer fDelFlag;
-
     public void setfId(Long fId)
     {
         this.fId = fId;

+ 3 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouse/check/service/ITWarehouseCheckService.java

@@ -2,6 +2,7 @@ package com.ruoyi.warehouse.check.service;
 
 import java.util.List;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.TWarehouse;
 import com.ruoyi.warehouse.check.domain.TWarehouseCheck;
 
@@ -71,4 +72,6 @@ public interface ITWarehouseCheckService
      * @return 结果
      */
     public int saveCheckItemsDetails(TWarehouseCheck tWarehouseCheck);
+
+    AjaxResult generateItems(TWarehouseCheck tWarehouseCheck);
 }

+ 62 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouse/check/service/impl/TWarehouseCheckServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ruoyi.warehouse.check.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.TWarehouse;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
@@ -14,6 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -164,4 +171,59 @@ public class TWarehouseCheckServiceImpl implements ITWarehouseCheckService {
         tWarehouseCheckItemsDetails.setfCreateTime(new Date());
         return tWarehouseCheckItemsDetailsMapper.insertTWarehouseCheckItemsDetails(tWarehouseCheckItemsDetails);
     }
+
+    @Override
+    public AjaxResult generateItems(TWarehouseCheck tWarehouseCheck) {
+        if (ObjectUtils.isNull(tWarehouseCheck.getfInspectorBeginDatetime()) ||
+                ObjectUtils.isNull(tWarehouseCheck.getfInspectorEndDatetime())) {
+            throw new RuntimeException("请维护巡检日期起止");
+        }
+        LocalDate localDateStart = tWarehouseCheck.getfInspectorBeginDatetime().toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+        LocalDate localDateEnd = tWarehouseCheck.getfInspectorEndDatetime().toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDate();
+        long daysBetween = ChronoUnit.DAYS.between(localDateStart, localDateEnd);
+        List<TWarehouseCheckItems> tWarehouseCheckItemsList = new ArrayList<>();
+        for (int i = 1; i <= daysBetween; i++) {
+            TWarehouseCheckItems items = new TWarehouseCheckItems();
+            items.setfCheckFid(tWarehouseCheck.getfId());
+            items.setfWarehouseFid(tWarehouseCheck.getfWarehouseFid());
+            items.setfWarehouseName(tWarehouseCheck.getfWarehouseName());
+            items.setfInspectorId(tWarehouseCheck.getfInspectorId());
+            items.setfInspectorName(tWarehouseCheck.getfInspectorName());
+            items.setfCreateByName(SecurityUtils.getUsername());
+            items.setfCreateBy(SecurityUtils.getLoginUser().getUser().getUserId());
+            items.setfCreateTime(new Date());
+            items.setWhetherEffective(0);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(tWarehouseCheck.getfInspectorBeginDatetime());
+            calendar.add(Calendar.DAY_OF_MONTH, i);
+            items.setfInspectionDatetime(calendar.getTime());
+            // 获取星期数(星期日为1,星期六为7)
+            int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
+            String week = "星期";
+            if (1 == weekDay) {
+                week = week + "日";
+            } else if (2 == weekDay) {
+                week = week + "一";
+            } else if (weekDay == 3) {
+                week = week + "二";
+            } else if (4 == weekDay) {
+                week = week + "三";
+            } else if (5 == weekDay) {
+                week = week + "四";
+            } else if (6 == weekDay) {
+                week = week + "五";
+            } else {
+                week = week + "六";
+            }
+            items.setWeek(week);
+            tWarehouseCheckItemsMapper.insertTWarehouseCheckItems(items);
+            tWarehouseCheckItemsList.add(items);
+        }
+        tWarehouseCheck.settWarehouseCheckItemsList(tWarehouseCheckItemsList);
+        return AjaxResult.success(tWarehouseCheck);
+    }
 }

+ 13 - 1
ruoyi-warehouse/src/main/resources/mapper/warehouse/TWarehouseCheckItemsMapper.xml

@@ -23,12 +23,16 @@
         <result property="fCreateByName" column="f_create_by_name"/>
         <result property="fUpdateByName" column="f_update_by_name"/>
         <result property="fWarehouseName" column="f_warehouse_name"/>
+        <result property="whetherEffective" column="whether_effective"/>
+        <result property="week" column="week"/>
     </resultMap>
 
     <sql id="selectTWarehouseCheckItemsVo">
         select a.f_id,
                a.f_check_fid,
                a.f_warehouse_fid,
+               a.whether_effective,
+               a.week,
                w.f_name                 as f_warehouse_name,
                inspection.nick_name     as f_Inspector_name,
                a.f_inspection_datetime,
@@ -69,10 +73,12 @@
             <if test="fUpdateBy != null ">and a.f_update_by = #{fUpdateBy}</if>
             <if test="fUpdateTime != null ">and a.f_update_time = #{fUpdateTime}</if>
             <if test="fDelFlag != null ">and a.f_del_flag = #{fDelFlag}</if>
+            <if test="whetherEffective != null ">and a.whether_effective = #{whetherEffective}</if>
+            <if test="week != null ">and find_in_set(a.week,#{week})</if>
             <if test="inspectionBeginDate != null and inspectionBeginDate != ''">and f_inspection_datetime &gt;= #{inspectionBeginDate}</if>
             <if test="inspectionEndDate != null and inspectionEndDate != ''">and f_inspection_datetime &lt;= #{inspectionEndDate}</if>
         </where>
-            order by f_id desc
+            order by f_inspection_datetime asc
     </select>
 
     <select id="selectTWarehouseCheckItemsById" parameterType="Long" resultMap="TWarehouseCheckItemsResult">
@@ -96,6 +102,8 @@
             <if test="fUpdateBy != null">f_update_by,</if>
             <if test="fUpdateTime != null">f_update_time,</if>
             <if test="fDelFlag != null">f_del_flag,</if>
+            <if test="whetherEffective != null">whether_effective,</if>
+            <if test="week != null">week,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="fCheckFid != null">#{fCheckFid},</if>
@@ -110,6 +118,8 @@
             <if test="fUpdateBy != null">#{fUpdateBy},</if>
             <if test="fUpdateTime != null">#{fUpdateTime},</if>
             <if test="fDelFlag != null">#{fDelFlag},</if>
+            <if test="whetherEffective != null">#{whetherEffective},</if>
+            <if test="week != null">#{week},</if>
         </trim>
     </insert>
 
@@ -128,6 +138,8 @@
             <if test="fUpdateBy != null">f_update_by = #{fUpdateBy},</if>
             <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>
             <if test="fDelFlag != null">f_del_flag = #{fDelFlag},</if>
+            <if test="whetherEffective != null">whether_effective = #{whetherEffective},</if>
+            <if test="week != null">week = #{week},</if>
         </trim>
         where f_id = #{fId}
     </update>

+ 7 - 0
ruoyi-warehouse/src/main/resources/mapper/warehouse/TWarehouseCheckMapper.xml

@@ -21,6 +21,7 @@
         <result property="fUpdateByName" column="f_update_by_name"/>
         <result property="fUpdateTime" column="f_update_time"/>
         <result property="fDelFlag" column="f_del_flag"/>
+        <result property="cname" column="cname"/>
     </resultMap>
 
     <sql id="selectTWarehouseCheckVo">
@@ -29,6 +30,7 @@
                f_inspector_id,
                f_system_no,
                a.f_inspector_begin_datetime,
+               a.cname,
                a.f_inspector_end_datetime,
                a.f_remark,
                a.f_create_by,
@@ -67,6 +69,7 @@
                update_time,
                remark,
                f_location,
+               cname,
                f_warehouse_information
         from t_warehouse
         where f_id in (select f_warehouse_fid from t_warehouse_check)
@@ -110,6 +113,7 @@
             <if test="fUpdateBy != null ">and f_update_by = #{fUpdateBy}</if>
             <if test="fUpdateTime != null ">and f_update_time = #{fUpdateTime}</if>
             <if test="fDelFlag != null ">and f_del_flag = #{fDelFlag}</if>
+            <if test="cname != null ">and cname like concat('%', #{cname}, '%')</if>
         </where>
         order by a.f_create_time desc
     </select>
@@ -138,6 +142,7 @@
             <if test="fUpdateBy != null">f_update_by,</if>
             <if test="fUpdateTime != null">f_update_time,</if>
             <if test="fDelFlag != null">f_del_flag,</if>
+            <if test="cname != null">cname,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="fWarehouseFid != null">#{fWarehouseFid},</if>
@@ -151,6 +156,7 @@
             <if test="fUpdateBy != null">#{fUpdateBy},</if>
             <if test="fUpdateTime != null">#{fUpdateTime},</if>
             <if test="fDelFlag != null">#{fDelFlag},</if>
+            <if test="cname != null">#{cname},</if>
         </trim>
     </insert>
 
@@ -168,6 +174,7 @@
             <if test="fUpdateBy != null">f_update_by = #{fUpdateBy},</if>
             <if test="fUpdateTime != null">f_update_time = #{fUpdateTime},</if>
             <if test="fDelFlag != null">f_del_flag = #{fDelFlag},</if>
+            <if test="cname != null">cname = #{cname},</if>
         </trim>
         where f_id = #{fId}
     </update>