Browse Source

巡检与考核开发8.26

admin 3 weeks ago
parent
commit
ab225df5f4

+ 0 - 129
client-app/src/main/java/com/sapit/client/app/manage/controller/inspect/AssessResultManageController.java

@@ -5,7 +5,6 @@ import com.sapit.common.constant.ReturnCode;
 import com.sapit.common.framwork.AuthToken;
 import com.sapit.common.framwork.PageControlData;
 import com.sapit.common.framwork.ResultBean;
-import com.sapit.common.entity.inspect.BuAssessResult;
 import com.sapit.common.search.inspect.BuAssessResultSearchBean;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
@@ -46,43 +45,6 @@ public class AssessResultManageController {
         return getPageResult(page, list);
     }
 
-    /**
-     * 考核排名分页查询
-     * @param pageSize  每页数量
-     * @param currentPage  当前页
-     * @param searchBean  查询条件
-     * @return 考核排名分页数据
-     */
-    @PostMapping("/getAssessRankPage")
-    @AuthToken(type = "admin")
-    public ResultBean assessRankPage(int pageSize, int currentPage, BuAssessResultSearchBean searchBean) {
-        PageControlData page = buildPage(pageSize, currentPage);
-        List<?> list = assessResultService.getAssessPage(page, searchBean);
-        return getPageResult(page, list);
-    }
-
-    /**
-     * 考核结果详情(支持按ID或按门店+周期查询)
-     * @param id 考核结果ID
-     * @param storeId 门店ID
-     * @param periodType 周期类型(1周度 2月度)
-     * @param periodCode 周期编码
-     * @return 考核结果详情
-     */
-    @PostMapping("/getAssessDetail")
-    @AuthToken(type = "admin")
-    public ResultBean assessDetail(Long id, Long storeId, Integer periodType, String periodCode) {
-        BuAssessResult result;
-        if (id != null) {
-            result = assessResultService.getAssessDetail(id);
-        } else if (storeId != null && periodType != null && periodCode != null) {
-            result = assessResultService.getAssessDetailByPeriod(storeId, periodType, periodCode);
-        } else {
-            return paramError();
-        }
-        return objectResult(result);
-    }
-
     /**
      * 门店考核趋势查询
      * @param storeIds 门店ID集合
@@ -99,44 +61,6 @@ public class AssessResultManageController {
         return listResult(trend);
     }
 
-    /**
-     * 更新考核结果
-     * @param assessResult 考核结果信息
-     * @return 更新结果
-     */
-    @PostMapping("/updateAssess")
-    @AuthToken(type = "admin")
-    public ResultBean updateAssessResult(BuAssessResult assessResult) {
-        ResultBean bean = new ResultBean();
-        if (assessResult == null || assessResult.getAssessResultId() == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(assessResultService.updateAssessResult(assessResult) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("更新完成");
-        return bean;
-    }
-
-    /**
-     * 删除考核结果
-     * @param id 考核结果ID
-     * @return 删除结果
-     */
-    @PostMapping("/deleteAssess")
-    @AuthToken(type = "admin")
-    public ResultBean deleteAssessResult(Long id) {
-        ResultBean bean = new ResultBean();
-        if (id == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(assessResultService.deleteAssessResult(id) > 0 ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("删除完成");
-        return bean;
-    }
-
     /**
      * 考核汇总(手动汇总:按周期内任务生成考核记录并立即计算得分/等级/排名)
      * @param periodType 周期类型(1周度 2月度)
@@ -166,28 +90,6 @@ public class AssessResultManageController {
         return bean;
     }
 
-    /**
-     * 考核数据汇总(按门店+周期计算巡检分/自动分/综合分/等级)
-     * @param storeId 门店ID
-     * @param periodType 周期类型(1周度 2月度)
-     * @param periodCode 周期编码
-     * @param startDate 开始日期(yyyy-MM-dd)
-     * @param endDate 结束日期(yyyy-MM-dd)
-     * @return 汇总结果
-     */
-    @PostMapping("/summarizeAssess")
-    @AuthToken(type = "admin")
-    public ResultBean summarizeAssessResult(Long storeId, Integer periodType, String periodCode,
-                                             @DateTimeFormat(pattern = "yyyy-MM-dd") Date startDate,
-                                             @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate) {
-        if (storeId == null || periodType == null || periodCode == null
-                || startDate == null || endDate == null) {
-            return paramError();
-        }
-        return statusResult(assessResultService.summarizeAssessResult(storeId, periodType, periodCode,
-                startDate, endDate), "考核汇总完成");
-    }
-
     /**
      * 考核排名更新(按综合分重新计算排名)
      * @param periodType 周期类型(1周度 2月度)
@@ -203,25 +105,6 @@ public class AssessResultManageController {
         return statusResult(assessResultService.updateAssessRank(periodType, periodCode), "排名更新完成");
     }
 
-    /**
-     * 考核报告数据导出(返回JSON数据,供页面预览)
-     * @param periodType 周期类型(1周度 2月度)
-     * @param periodCode 周期编码
-     * @return 考核报告数据
-     */
-    @PostMapping("/exportAssessReport")
-    @AuthToken(type = "admin")
-    public ResultBean exportAssessReport(Integer periodType, String periodCode) {
-        if (periodType == null || periodCode == null) {
-            return paramError();
-        }
-        Map<String, Object> report = assessResultService.exportAssessReport(periodType, periodCode);
-        if (report == null || report.isEmpty()) {
-            return objectResult(null);
-        }
-        return objectResult(report);
-    }
-
     /**
      * 考核等级分布查询
      * @param periodType 周期类型(1周度 2月度)
@@ -293,18 +176,6 @@ public class AssessResultManageController {
         return bean;
     }
 
-    private ResultBean objectResult(Object object) {
-        ResultBean bean = new ResultBean();
-        if (object == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.FAILED);
-            bean.getRtnBean().setRtnMsg("数据不存在");
-            return bean;
-        }
-        bean.setObj(object);
-        bean.getRtnBean().setRtnCode(ReturnCode.SUCCESS);
-        return bean;
-    }
-
     private ResultBean listResult(List<?> list) {
         ResultBean bean = new ResultBean();
         bean.setList(list == null ? new ArrayList<>() : list);

+ 2 - 22
client-app/src/main/java/com/sapit/client/app/manage/controller/inspect/InspectIndicatorManageController.java

@@ -2,6 +2,7 @@ package com.sapit.client.app.manage.controller.inspect;
 
 import com.sapit.client.app.manage.inspect.service.InspectIndicatorService;
 import com.sapit.common.constant.ReturnCode;
+import com.sapit.common.entity.inspect.BuInspectIndicator;
 import com.sapit.common.framwork.AuthToken;
 import com.sapit.common.framwork.PageControlData;
 import com.sapit.common.framwork.ResultBean;
@@ -10,8 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -41,25 +40,6 @@ public class InspectIndicatorManageController {
         List<?> list = inspectIndicatorService.getIndicatorList(page, searchBean);
         return getPageResult(page, list);
     }
-    /**
-     * 查询指标详情
-     * @param id 指标ID
-     * @return 指标详情
-     */
-    @PostMapping("/getIndicatorDetail")
-    @AuthToken(type = "admin")
-    public ResultBean indicatorDetail(Long id) {
-        Object object = id == null ? null : inspectIndicatorService.getIndicatorById(id);
-        ResultBean bean = new ResultBean();
-        if (object == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.FAILED);
-            bean.getRtnBean().setRtnMsg("数据不存在");
-        } else {
-            bean.setObj(object);
-            bean.getRtnBean().setRtnCode(ReturnCode.SUCCESS);
-        }
-        return bean;
-    }
     /**
      * 新增指标
      * @param indicator 指标信息
@@ -67,7 +47,7 @@ public class InspectIndicatorManageController {
      */
     @PostMapping("/save")
     @AuthToken(type = "admin")
-    public ResultBean saveIndicator(com.sapit.common.entity.inspect.BuInspectIndicator indicator) {
+    public ResultBean saveIndicator(BuInspectIndicator indicator) {
         ResultBean bean = new ResultBean();
         if (indicator == null) {
             bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);

+ 21 - 81
client-app/src/main/java/com/sapit/client/app/manage/controller/inspect/InspectPlanManageController.java

@@ -8,7 +8,6 @@ import com.sapit.common.framwork.ResultBean;
 import com.sapit.common.entity.inspect.BuInspectPlanIndicator;
 import com.sapit.common.entity.inspect.BuInspectPlanStore;
 import com.sapit.common.search.inspect.BuInspectPlanSearchBean;
-import com.sapit.common.search.inspect.BuInspectPlanIndicatorSearchBean;
 import com.sapit.common.search.inspect.BuInspectPlanStoreSearchBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -31,9 +30,9 @@ public class InspectPlanManageController {
 
     /**
      * 巡检计划分页查询
-     * @param pageSize
-     * @param currentPage
-     * @param searchBean
+     * @param pageSize 每页数量
+     * @param currentPage 当前页
+     * @param searchBean 查询条件
      * @return
      */
     @PostMapping("/getPlanPage")
@@ -45,17 +44,17 @@ public class InspectPlanManageController {
     }
     /**
      * 巡检计划详情
-     * @param id
+     * @param id 巡检计划ID
      * @return
      */
     @PostMapping("/getPlanDetail")
     @AuthToken(type = "admin")
     public ResultBean planDetail(Long id) {
-        return objectResult(id == null ? null : inspectPlanService.getPlanDetail(id));
+        return objectResult(id == null ? null : inspectPlanService.getPlanById(id));
     }
     /**
      * 巡检计划关联指标详情
-     * @param planId
+     * @param planId 巡检计划ID
      * @return
      */
     @PostMapping("/getPlanIndicators")
@@ -68,7 +67,7 @@ public class InspectPlanManageController {
     }
     /**
      * 巡检计划关联门店详情
-     * @param planId
+     * @param planId 巡检计划ID
      * @return
      */
     @PostMapping("/getPlanStores")
@@ -81,7 +80,7 @@ public class InspectPlanManageController {
     }
     /**
      * 巡检计划新增/更新
-     * @param plan
+     * @param plan 巡检计划实体
      * @return
      */
     @PostMapping("/save")
@@ -100,7 +99,7 @@ public class InspectPlanManageController {
     }
     /**
      * 巡检计划更新
-     * @param plan
+     * @param plan 巡检计划实体
      * @return
      */
     @PostMapping("/update")
@@ -119,7 +118,7 @@ public class InspectPlanManageController {
     }
     /**
      * 巡检计划删除
-     * @param id
+     * @param id 巡检计划ID
      * @return
      */
     @PostMapping("/delete")
@@ -131,8 +130,9 @@ public class InspectPlanManageController {
             bean.getRtnBean().setRtnMsg("参数错误");
             return bean;
         }
-        bean.getRtnBean().setRtnCode(inspectPlanService.delete(id) > 0 ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("删除完成");
+        Map<String, Object> result = inspectPlanService.delete(id);
+        bean.getRtnBean().setRtnCode(Boolean.TRUE.equals(result.get("success")) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
+        bean.getRtnBean().setRtnMsg(String.valueOf(result.get("reason")));
         return bean;
     }
     /**
@@ -161,7 +161,7 @@ public class InspectPlanManageController {
     }
     /**
      * 巡检计划暂停
-     * @param id
+     * @param id 巡检计划ID
      * @return
      */
     @PostMapping("/pause")
@@ -170,11 +170,15 @@ public class InspectPlanManageController {
         if (id == null) {
             return paramError();
         }
-        return statusResult(inspectPlanService.changeStatus(id, 2), "暂停完成");
+        Map<String, Object> result = inspectPlanService.pause(id);
+        ResultBean bean = new ResultBean();
+        bean.getRtnBean().setRtnCode(Boolean.TRUE.equals(result.get("success")) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
+        bean.getRtnBean().setRtnMsg(String.valueOf(result.get("reason")));
+        return bean;
     }
     /**
      * 巡检计划结束
-     * @param id
+     * @param id 巡检计划ID
      * @return
      */
     @PostMapping("/finish")
@@ -185,23 +189,9 @@ public class InspectPlanManageController {
         }
         return statusResult(inspectPlanService.finish(id), "结束完成");
     }
-    /**
-     * 巡检指标分页查询
-     * @param pageSize  每页数量
-     * @param currentPage  当前页
-     * @param searchBean  查询条件
-     * @return
-     */
-    @PostMapping("/getPlanIndicatorPage")
-    @AuthToken(type = "admin")
-    public ResultBean planIndicatorPage(int pageSize, int currentPage, BuInspectPlanIndicatorSearchBean searchBean) {
-        PageControlData page = buildPage(pageSize, currentPage);
-        List<?> list = inspectPlanService.getPlanIndicatorPage(page, searchBean);
-        return getPageResult(page, list);
-    }
     /**
      * 巡检指标新增/更新
-     * @param planIndicator
+     * @param planIndicator 巡检指标实体
      * @return
      */
     @PostMapping("/savePlanIndicator")
@@ -217,24 +207,6 @@ public class InspectPlanManageController {
         bean.getRtnBean().setRtnMsg(planIndicator.getPlanIndicatorId() == null ? "新增完成" : "保存完成");
         return bean;
     }
-    /**
-     * 巡检指标更新
-     * @param planIndicator
-     * @return
-     */
-    @PostMapping("/updatePlanIndicator")
-    @AuthToken(type = "admin")
-    public ResultBean updatePlanIndicator(BuInspectPlanIndicator planIndicator) {
-        ResultBean bean = new ResultBean();
-        if (planIndicator == null || planIndicator.getPlanIndicatorId() == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(inspectPlanService.updatePlanIndicator(planIndicator) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("更新完成");
-        return bean;
-    }
     /**
      * 巡检指标删除
      * @param id
@@ -253,20 +225,6 @@ public class InspectPlanManageController {
         bean.getRtnBean().setRtnMsg("删除完成");
         return bean;
     }
-    /**
-     * 巡检计划关联门店分页查询
-     * @param pageSize  每页数量
-     * @param currentPage  当前页
-     * @param searchBean  查询条件
-     * @return 关联门店分页结果
-     */
-    @PostMapping("/getPlanStorePage")
-    @AuthToken(type = "admin")
-    public ResultBean planStorePage(int pageSize, int currentPage, BuInspectPlanStoreSearchBean searchBean) {
-        PageControlData page = buildPage(pageSize, currentPage);
-        List<?> list = inspectPlanService.getPlanStorePage(page, searchBean);
-        return getPageResult(page, list);
-    }
     /**
      * 巡检计划关联门店新增/更新
      * @param planStore 关联门店信息
@@ -285,24 +243,6 @@ public class InspectPlanManageController {
         bean.getRtnBean().setRtnMsg(planStore.getPlanStoreId() == null ? "新增完成" : "保存完成");
         return bean;
     }
-    /**
-     * 巡检计划关联门店更新
-     * @param planStore 关联门店信息
-     * @return 更新结果
-     */
-    @PostMapping("/updatePlanStore")
-    @AuthToken(type = "admin")
-    public ResultBean updatePlanStore(BuInspectPlanStore planStore) {
-        ResultBean bean = new ResultBean();
-        if (planStore == null || planStore.getPlanStoreId() == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(inspectPlanService.updatePlanStore(planStore) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("更新完成");
-        return bean;
-    }
     /**
      * 巡检计划关联门店删除
      * @param id 关联门店ID

+ 21 - 89
client-app/src/main/java/com/sapit/client/app/manage/controller/inspect/InspectTaskManageController.java

@@ -6,10 +6,8 @@ import com.sapit.common.constant.ReturnCode;
 import com.sapit.common.framwork.AuthToken;
 import com.sapit.common.framwork.PageControlData;
 import com.sapit.common.framwork.ResultBean;
-import com.sapit.common.entity.inspect.BuInspectTask;
 import com.sapit.common.entity.inspect.BuInspectTaskItem;
 import com.sapit.common.search.inspect.BuInspectTaskSearchBean;
-import com.sapit.common.search.inspect.BuInspectTaskItemSearchBean;
 import com.sapit.common.util.DateUtil;
 import com.sapit.common.util.FileFtpUploadUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +18,9 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -96,20 +97,6 @@ public class InspectTaskManageController {
         }
         return listResult(inspectTaskService.getTaskItems(taskId));
     }
-    /**
-     * 巡检员待执行任务列表(我的任务)
-     * @param inspectorId 巡检员ID
-     * @return 待执行任务列表
-     */
-    @PostMapping("/getMyTaskList")
-    @AuthToken(type = "admin")
-    public ResultBean myTaskList(Long inspectorId) {
-        if (inspectorId == null) {
-            return paramError();
-        }
-        return listResult(inspectTaskService.getMyTaskList(inspectorId));
-    }
-
     /**
      * 巡检任务开始执行
      * @param id
@@ -134,24 +121,6 @@ public class InspectTaskManageController {
     public ResultBean taskStatistics(Long planId) {
         return listResult(inspectTaskService.getTaskStatistics(planId));
     }
-    /**
-     * 巡检任务更新
-     * @param task
-     * @return
-     */
-    @PostMapping("/updateTask")
-    @AuthToken(type = "admin")
-    public ResultBean updateTask(BuInspectTask task) {
-        ResultBean bean = new ResultBean();
-        if (task == null || task.getTaskId() == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(inspectTaskService.updateTask(task) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("更新完成");
-        return bean;
-    }
     /**
      * 巡检任务取消
      * @param id
@@ -208,39 +177,6 @@ public class InspectTaskManageController {
         bean.getRtnBean().setRtnMsg("提交完成");
         return bean;
     }
-    /**
-     * 巡检任务指标项分页查询
-     * @param pageSize 每页数量
-     * @param currentPage 当前页
-     * @param searchBean 查询条件
-     * @return 指标项分页结果
-     */
-    @PostMapping("/getTaskItemPage")
-    @AuthToken(type = "admin")
-    public ResultBean taskItemPage(int pageSize, int currentPage, BuInspectTaskItemSearchBean searchBean) {
-        PageControlData page = buildPage(pageSize, currentPage);
-        List<?> list = inspectTaskService.getTaskItemPage(page, searchBean);
-        return getPageResult(page, list);
-    }
-    /**
-     * 巡检任务指标项保存
-     * @param taskItem 指标项信息
-     * @return 保存结果
-     */
-    @PostMapping("/saveTaskItem")
-    @AuthToken(type = "admin")
-    public ResultBean saveTaskItem(BuInspectTaskItem taskItem) {
-        ResultBean bean = new ResultBean();
-        if (taskItem == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(inspectTaskService.saveTaskItem(taskItem) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg(taskItem.getTaskItemId() == null ? "新增完成" : "保存完成");
-        return bean;
-    }
-
     /**
      * 巡检任务指标项更新
      * @param taskItem 指标项信息
@@ -259,24 +195,6 @@ public class InspectTaskManageController {
         bean.getRtnBean().setRtnMsg("更新完成");
         return bean;
     }
-    /**
-     * 巡检任务指标项删除
-     * @param id 指标项ID
-     * @return 删除结果
-     */
-    @PostMapping("/deleteTaskItem")
-    @AuthToken(type = "admin")
-    public ResultBean deleteTaskItem(Long id) {
-        ResultBean bean = new ResultBean();
-        if (id == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(inspectTaskService.deleteTaskItem(id) > 0 ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("删除完成");
-        return bean;
-    }
     /**
      * 巡检图片上传(FTP,单张不超过200K)
      * @param file 图片文件
@@ -286,21 +204,35 @@ public class InspectTaskManageController {
     @PostMapping("/uploadPicture")
     @AuthToken(type = "admin")
     public ResultBean uploadPicture(@RequestParam(value = "file", required = false) MultipartFile file,
-                                    String dir) {
+                                    String dir, HttpServletRequest request) {
         ResultBean bean = new ResultBean();
         if (file == null || file.getOriginalFilename() == null || file.getOriginalFilename().isEmpty()) {
             return paramError();
         }
-        if (file.getSize() > 204800) {
+        byte[] bytes;
+        try {
+            bytes = file.getBytes();
+        } catch (IOException e) {
+            bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
+            bean.getRtnBean().setRtnMsg("文件上传失败");
+            return bean;
+        }
+        if (bytes.length > 204800) {
             bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
             bean.getRtnBean().setRtnMsg("图片大小超过200K");
             return bean;
         }
+        // 仅允许上传图片类型
+        if (!FileFtpUploadUtil.isImage(new ByteArrayInputStream(bytes))) {
+            bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
+            bean.getRtnBean().setRtnMsg("仅支持上传JPEG/PNG/GIF/BMP/WEBP图片");
+            return bean;
+        }
         String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.') + 1);
         String fileName = DateUtil.getStrToday("yyyyMMddHHmmssSSS") + "." + suffix;
         String path = dir == null || dir.trim().isEmpty() ? "/inspect" : dir;
         try {
-            if (!FileFtpUploadUtil.uploadFile(path, fileName, file.getInputStream())) {
+            if (!FileFtpUploadUtil.uploadFile(path, fileName, new ByteArrayInputStream(bytes))) {
                 bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
                 bean.getRtnBean().setRtnMsg("文件上传失败");
                 return bean;
@@ -311,7 +243,7 @@ public class InspectTaskManageController {
             return bean;
         }
         bean.getRtnBean().setRtnCode(ReturnCode.SUCCESS);
-        bean.setObj(FileFtpUploadUtil.rootURL + path + "/" + fileName);
+        bean.setObj(FileFtpUploadUtil.buildRemoteUrl(request, path, fileName));
         return bean;
     }
 

+ 0 - 123
client-app/src/main/java/com/sapit/client/app/manage/controller/inspect/RectificationManageController.java

@@ -5,7 +5,6 @@ import com.sapit.common.constant.ReturnCode;
 import com.sapit.common.framwork.AuthToken;
 import com.sapit.common.framwork.PageControlData;
 import com.sapit.common.framwork.ResultBean;
-import com.sapit.common.entity.inspect.BuRectification;
 import com.sapit.common.search.inspect.BuRectificationSearchBean;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -15,7 +14,6 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -40,74 +38,6 @@ public class RectificationManageController {
         return getPageResult(page, list);
     }
 
-    /**
-     * 整改记录详情
-     * @param id 整改记录ID
-     * @return 整改记录详情
-     */
-    @PostMapping("/getRectDetail")
-    @AuthToken(type = "admin")
-    public ResultBean rectificationDetail(Long id) {
-        return objectResult(id == null ? null : rectificationService.getRectDetail(id));
-    }
-
-    /**
-     * 新增整改记录
-     * @param rectification 整改记录信息
-     * @return 新增结果
-     */
-    @PostMapping("/saveRect")
-    @AuthToken(type = "admin")
-    public ResultBean saveRectification(BuRectification rectification) {
-        ResultBean bean = new ResultBean();
-        if (rectification == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(rectificationService.saveRectification(rectification) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg(rectification.getRectId() == null ? "新增完成" : "保存完成");
-        return bean;
-    }
-
-    /**
-     * 更新整改记录
-     * @param rectification 整改记录信息
-     * @return 更新结果
-     */
-    @PostMapping("/updateRect")
-    @AuthToken(type = "admin")
-    public ResultBean updateRectification(BuRectification rectification) {
-        ResultBean bean = new ResultBean();
-        if (rectification == null || rectification.getRectId() == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(rectificationService.updateRectification(rectification) ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("更新完成");
-        return bean;
-    }
-
-    /**
-     * 删除整改记录
-     * @param id 整改记录ID
-     * @return 删除结果
-     */
-    @PostMapping("/deleteRect")
-    @AuthToken(type = "admin")
-    public ResultBean deleteRectification(Long id) {
-        ResultBean bean = new ResultBean();
-        if (id == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(rectificationService.deleteRectification(id) > 0 ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("删除完成");
-        return bean;
-    }
-
     /**
      * 批量更新整改截止日期
      * @param rectIds 整改记录ID集合
@@ -124,17 +54,6 @@ public class RectificationManageController {
         return statusResult(rectificationService.batchUpdateDeadline(rectIds, deadlineDate), "截止日期更新完成");
     }
 
-    /**
-     * 整改状态统计
-     * @param storeId 门店ID
-     * @return 整改统计列表
-     */
-    @PostMapping("/getRectStatistics")
-    @AuthToken(type = "admin")
-    public ResultBean rectificationStatistics(Long storeId) {
-        return listResult(rectificationService.getRectStatistics(storeId));
-    }
-
     /**
      * 整改催办
      * @param id 整改记录ID
@@ -149,29 +68,6 @@ public class RectificationManageController {
         return statusResult(rectificationService.urge(id), "催办完成");
     }
 
-    /**
-     * 门店提交整改反馈(待整改/整改中 -> 待复检)
-     * @param id 整改记录ID
-     * @param feedbackContent 反馈内容
-     * @param feedbackPictures 反馈图片(逗号分隔)
-     * @return 提交结果
-     */
-    @PostMapping("/submitRect")
-    @AuthToken(type = "admin")
-    public ResultBean submitRectification(Long id, String feedbackContent, String feedbackPictures) {
-        ResultBean bean = new ResultBean();
-        if (id == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.PARAM_WRONG);
-            bean.getRtnBean().setRtnMsg("参数错误");
-            return bean;
-        }
-        bean.getRtnBean().setRtnCode(
-                rectificationService.submitRectification(id, feedbackContent, feedbackPictures) > 0
-                        ? ReturnCode.SUCCESS : ReturnCode.FAILED);
-        bean.getRtnBean().setRtnMsg("提交完成");
-        return bean;
-    }
-
     /**
      * 整改复检
      * @param id 整改记录ID
@@ -216,25 +112,6 @@ public class RectificationManageController {
         return bean;
     }
 
-    private ResultBean objectResult(Object object) {
-        ResultBean bean = new ResultBean();
-        if (object == null) {
-            bean.getRtnBean().setRtnCode(ReturnCode.FAILED);
-            bean.getRtnBean().setRtnMsg("数据不存在");
-            return bean;
-        }
-        bean.setObj(object);
-        bean.getRtnBean().setRtnCode(ReturnCode.SUCCESS);
-        return bean;
-    }
-
-    private ResultBean listResult(List<?> list) {
-        ResultBean bean = new ResultBean();
-        bean.setList(list == null ? new ArrayList<>() : list);
-        bean.getRtnBean().setRtnCode(ReturnCode.SUCCESS);
-        return bean;
-    }
-
     private PageControlData buildPage(int pageSize, int currentPage) {
         PageControlData page = new PageControlData();
         page.setPageSize(pageSize);

+ 1 - 35
client-app/src/main/java/com/sapit/client/app/manage/inspect/service/AssessResultService.java

@@ -22,28 +22,13 @@ public class AssessResultService {
     private BuInspectPlanDao inspectPlanDao;
 
     public List<BuAssessResult> getAssessPage(PageControlData page, BuAssessResultSearchBean searchBean) {
-        return assessResultDao.getList(page, searchBean, " order by summaryDate desc, assessResultId desc");
+        return assessResultDao.getList(page, searchBean, " order by rankNo asc, assessResultId asc");
     }
 
     public BuAssessResult getAssessDetail(Long id) {
         return (BuAssessResult) assessResultDao.findById(BuAssessResult.class, id);
     }
 
-    public BuAssessResult getAssessDetailByPeriod(Long storeId, Integer periodType, String periodCode) {
-        if (storeId == null || periodType == null || periodCode == null) {
-            return null;
-        }
-        String escapedCode = InspectCommonUtils.escapeSql(periodCode);
-        List<?> rows = assessResultDao.searchBySql(
-                "select * from bu_assess_result where STORE_ID = " + storeId
-                        + " and PERIOD_TYPE = " + periodType
-                        + " and PERIOD_CODE = '" + escapedCode + "'");
-        if (rows == null || rows.isEmpty()) {
-            return null;
-        }
-        return (BuAssessResult) rows.get(0);
-    }
-
     public List<Map<String, Object>> getAssessDetailTasks(Long storeId, Integer periodType, String periodCode) {
         List<Map<String, Object>> tasks = new ArrayList<>();
         if (storeId == null || periodType == null || periodCode == null) {
@@ -116,25 +101,6 @@ public class AssessResultService {
         return assessResultDao.save(assessResult);
     }
 
-    public boolean updateAssessResult(BuAssessResult assessResult) {
-        if (assessResult == null || assessResult.getAssessResultId() == null) {
-            return false;
-        }
-        BuAssessResult old = (BuAssessResult) assessResultDao.findById(
-                BuAssessResult.class, assessResult.getAssessResultId());
-        if (old == null) {
-            return false;
-        }
-        assessResult.setCreateDate(old.getCreateDate());
-        assessResult.setUpdateDate(old.getUpdateDate());
-        return assessResultDao.update(assessResult);
-    }
-
-    public int deleteAssessResult(Long id) {
-        return assessResultDao.executeSql("delete from bu_assess_result where ASSESS_RESULT_ID = :id",
-                InspectCommonUtils.params("id", id));
-    }
-
     public List<Map<String, Object>> getLevelDistribution(Integer periodType, String periodCode) {
         List<Map<String, Object>> distribution = new ArrayList<>();
         if (periodType == null || periodCode == null) {

+ 6 - 7
client-app/src/main/java/com/sapit/client/app/manage/inspect/service/InspectIndicatorService.java

@@ -32,18 +32,17 @@ public class InspectIndicatorService {
         return inspectIndicatorDao.getList(page, searchBean, " order by sort asc, indicatorId desc");
     }
 
-
-    public List<BuInspectIndicator> getIndicatorPage(PageControlData page, BuInspectIndicatorSearchBean searchBean) {
-        return getIndicatorList(page, searchBean);
-    }
-
     public BuInspectIndicator getIndicatorById(Long id) {
         return (BuInspectIndicator) inspectIndicatorDao.findById(BuInspectIndicator.class, id);
     }
 
+    /**
+     * 新增指标
+     * @param indicator 指标信息
+     * @return 新增结果
+     */
     public boolean save(BuInspectIndicator indicator) {
-        if (indicator == null || indicator.getIndicatorCode() == null
-                || indicator.getIndicatorCode().trim().isEmpty()) {
+        if (indicator == null || indicator.getIndicatorCode() == null || indicator.getIndicatorCode().trim().isEmpty()) {
             return false;
         }
         if (indicator.getCreateDate() == null) {

+ 86 - 71
client-app/src/main/java/com/sapit/client/app/manage/inspect/service/InspectPlanService.java

@@ -36,18 +36,30 @@ public class InspectPlanService {
     @Autowired
     private BuInspectPlanStoreDao inspectPlanStoreDao;
 
+    /**
+     * 获取巡检计划分页列表
+     * @param page 分页数据
+     * @param searchBean 查询条件
+     * @return 巡检计划分页列表
+     */
     public List<BuInspectPlan> getPlanPage(PageControlData page, BuInspectPlanSearchBean searchBean) {
         return inspectPlanDao.getList(page, searchBean, " order by planId desc");
     }
 
-    public BuInspectPlan getPlanDetail(Long id) {
-        return (BuInspectPlan) inspectPlanDao.findById(BuInspectPlan.class, id);
-    }
-
+    /**
+     * 根据ID获取巡检计划
+     * @param id 巡检计划ID
+     * @return 巡检计划
+     */
     public BuInspectPlan getPlanById(Long id) {
-        return getPlanDetail(id);
+        return (BuInspectPlan) inspectPlanDao.findById(BuInspectPlan.class, id);
     }
 
+    /**
+     * 根据ID获取巡检计划关联指标
+     * @param planId 巡检计划ID
+     * @return 巡检计划关联指标
+     */
     public List<BuInspectPlanIndicator> getPlanIndicators(Long planId) {
         BuInspectPlanIndicatorSearchBean searchBean = new BuInspectPlanIndicatorSearchBean();
         searchBean.setPlanId(planId);
@@ -55,6 +67,11 @@ public class InspectPlanService {
         return inspectPlanIndicatorDao.getList(searchBean, " order by sort asc, planIndicatorId asc");
     }
 
+    /**
+     * 根据ID获取巡检计划关联门店
+     * @param planId 巡检计划ID
+     * @return 巡检计划关联门店
+     */
     public List<BuInspectPlanStore> getPlanStores(Long planId) {
         BuInspectPlanStoreSearchBean searchBean = new BuInspectPlanStoreSearchBean();
         searchBean.setPlanId(planId);
@@ -62,6 +79,11 @@ public class InspectPlanService {
         return inspectPlanStoreDao.getList(searchBean, " order by planStoreId asc");
     }
 
+    /**
+     * 保存巡检计划
+     * @param plan 巡检计划
+     * @return
+     */
     public boolean save(BuInspectPlan plan) {
         if (!InspectCommonUtils.validPlan(plan)) {
             return false;
@@ -69,10 +91,11 @@ public class InspectPlanService {
         return inspectPlanDao.save(plan);
     }
 
-    public boolean savePlan(BuInspectPlan plan) {
-        return save(plan);
-    }
-
+    /**
+     * 更新巡检计划
+     * @param plan 巡检计划
+     * @return
+     */
     public boolean update(BuInspectPlan plan) {
         if (!InspectCommonUtils.validPlan(plan) || plan.getPlanId() == null) {
             return false;
@@ -89,10 +112,6 @@ public class InspectPlanService {
         return inspectPlanDao.update(plan);
     }
 
-    public boolean updatePlan(BuInspectPlan plan) {
-        return update(plan);
-    }
-
     /**
      * 发布巡检计划。
      * 返回 {success, reason}:success=false 时 reason 为失败原因。
@@ -144,41 +163,73 @@ public class InspectPlanService {
         return result;
     }
 
-    public Map<String, Object> publishPlan(Long id) {
-        return publish(id);
-    }
-
-    public int changeStatus(Long id, Integer status) {
-        return inspectPlanDao.executeSql(
-                "update bu_inspect_plan set STATUS = :status where PLAN_ID = :id",
-                InspectCommonUtils.with(InspectCommonUtils.params("id", id), "status", status));
-    }
-
-    public int pausePlan(Long id) {
-        return inspectPlanDao.executeSql(
-                "update bu_inspect_plan set STATUS = 2 where PLAN_ID = :id and STATUS = 1",
-                InspectCommonUtils.params("id", id));
-    }
-
+    /**
+     * 完成巡检计划
+     * @param id 巡检计划ID
+     * @return
+     */
     public int finish(Long id) {
         return inspectPlanDao.executeSql(
                 "update bu_inspect_plan set STATUS = 3, FINISH_DATE = NOW() where PLAN_ID = :id and STATUS in (1, 2)",
                 InspectCommonUtils.params("id", id));
     }
 
-    public int finishPlan(Long id) {
-        return finish(id);
+    /**
+     * 删除巡检计划。仅草稿状态(0)可删除,返回 {success, reason}。
+     */
+    public Map<String, Object> delete(Long id) {
+        Map<String, Object> result = new HashMap<>();
+        result.put("success", false);
+        BuInspectPlan plan = getPlanById(id);
+        if (plan == null) {
+            result.put("reason", "计划不存在");
+            return result;
+        }
+        int status = plan.getStatus() == null ? 0 : plan.getStatus();
+        if (status != 0) {
+            result.put("reason", "仅草稿状态的计划可删除,当前计划为" + statusName(status) + ",无法删除");
+            return result;
+        }
+        int rows = inspectPlanDao.executeSql("delete from bu_inspect_plan where PLAN_ID = :id and STATUS = 0",
+                InspectCommonUtils.params("id", id));
+        result.put("success", rows > 0);
+        result.put("reason", rows > 0 ? "删除完成" : "计划不存在或状态已变更,无法删除");
+        return result;
     }
 
-    public int delete(Long id) {
-        return inspectPlanDao.executeSql("delete from bu_inspect_plan where PLAN_ID = :id",
+    /**
+     * 暂停巡检计划。仅已发布状态(1)可暂停,返回 {success, reason}。
+     */
+    public Map<String, Object> pause(Long id) {
+        Map<String, Object> result = new HashMap<>();
+        result.put("success", false);
+        BuInspectPlan plan = getPlanById(id);
+        if (plan == null) {
+            result.put("reason", "计划不存在");
+            return result;
+        }
+        int status = plan.getStatus() == null ? 0 : plan.getStatus();
+        if (status != 1) {
+            result.put("reason", "仅已发布的计划可暂停,当前计划为" + statusName(status) + ",无法暂停");
+            return result;
+        }
+        int rows = inspectPlanDao.executeSql("update bu_inspect_plan set STATUS = 2 where PLAN_ID = :id and STATUS = 1",
                 InspectCommonUtils.params("id", id));
+        result.put("success", rows > 0);
+        result.put("reason", rows > 0 ? "暂停完成" : "计划状态已变更,无法暂停");
+        return result;
     }
 
-    public int deletePlan(Long id) {
-        return delete(id);
+    private String statusName(Integer status) {
+        switch (status == null ? 0 : status) {
+            case 1: return "已发布";
+            case 2: return "已暂停";
+            case 3: return "已结束";
+            default: return "草稿";
+        }
     }
 
+
     public BigDecimal getPlanIndicatorWeightSum(Long planId) {
         List<?> rows = inspectPlanIndicatorDao.searchBySql(
                 "select ifnull(sum(WEIGHT), 0) from bu_inspect_plan_indicator "
@@ -186,59 +237,23 @@ public class InspectPlanService {
         return InspectCommonUtils.firstDecimal(rows);
     }
 
-    public boolean validPlanIndicatorWeight(Long planId) {
-        return getPlanIndicatorWeightSum(planId).compareTo(new BigDecimal("100")) == 0;
-    }
 
-    public List<BuInspectPlanIndicator> getPlanIndicatorPage(PageControlData page, BuInspectPlanIndicatorSearchBean searchBean) {
-        return inspectPlanIndicatorDao.getList(page, searchBean, " order by sort asc, planIndicatorId desc");
-    }
 
     public boolean savePlanIndicator(BuInspectPlanIndicator planIndicator) {
         return inspectPlanIndicatorDao.save(planIndicator);
     }
 
-    public boolean updatePlanIndicator(BuInspectPlanIndicator planIndicator) {
-        if (planIndicator == null || planIndicator.getPlanIndicatorId() == null) {
-            return false;
-        }
-        BuInspectPlanIndicator old = (BuInspectPlanIndicator) inspectPlanIndicatorDao.findById(
-                BuInspectPlanIndicator.class, planIndicator.getPlanIndicatorId());
-        if (old == null) {
-            return false;
-        }
-        planIndicator.setCreateDate(old.getCreateDate());
-        planIndicator.setUpdateDate(old.getUpdateDate());
-        return inspectPlanIndicatorDao.update(planIndicator);
-    }
-
     public int deletePlanIndicator(Long id) {
         return inspectPlanIndicatorDao.executeSql(
                 "delete from bu_inspect_plan_indicator where PLAN_INDICATOR_ID = :id",
                 InspectCommonUtils.params("id", id));
     }
 
-    public List<BuInspectPlanStore> getPlanStorePage(PageControlData page, BuInspectPlanStoreSearchBean searchBean) {
-        return inspectPlanStoreDao.getList(page, searchBean, " order by planStoreId desc");
-    }
 
     public boolean savePlanStore(BuInspectPlanStore planStore) {
         return inspectPlanStoreDao.save(planStore);
     }
 
-    public boolean updatePlanStore(BuInspectPlanStore planStore) {
-        if (planStore == null || planStore.getPlanStoreId() == null) {
-            return false;
-        }
-        BuInspectPlanStore old = (BuInspectPlanStore) inspectPlanStoreDao.findById(
-                BuInspectPlanStore.class, planStore.getPlanStoreId());
-        if (old == null) {
-            return false;
-        }
-        planStore.setCreateDate(old.getCreateDate());
-        return inspectPlanStoreDao.update(planStore);
-    }
-
     public int deletePlanStore(Long id) {
         return inspectPlanStoreDao.executeSql(
                 "delete from bu_inspect_plan_store where PLAN_STORE_ID = :id",

+ 0 - 40
client-app/src/main/java/com/sapit/client/app/manage/inspect/service/InspectTaskService.java

@@ -41,19 +41,6 @@ public class InspectTaskService {
         return getTaskDetail(id);
     }
 
-    public boolean updateTask(BuInspectTask task) {
-        if (task == null || task.getTaskId() == null) {
-            return false;
-        }
-        BuInspectTask old = getTaskById(task.getTaskId());
-        if (old == null) {
-            return false;
-        }
-        task.setCreateDate(old.getCreateDate());
-        task.setUpdateDate(old.getUpdateDate());
-        return inspectTaskDao.update(task);
-    }
-
     public int cancelTask(Long id) {
         return inspectTaskDao.executeSql(
                 "update bu_inspect_task set STATUS = 4, CANCEL_DATE = NOW() where TASK_ID = :id and STATUS in (1, 2)",
@@ -149,16 +136,6 @@ public class InspectTaskService {
         return submitTask(taskId);
     }
 
-    public List<BuInspectTask> getMyTaskList(Long inspectorId) {
-        if (inspectorId == null) {
-            return new ArrayList<>();
-        }
-        BuInspectTaskSearchBean searchBean = new BuInspectTaskSearchBean();
-        searchBean.setInspectorId(inspectorId);
-        searchBean.setStatus(1);
-        return inspectTaskDao.getList(searchBean, " order by taskDate desc, taskId desc");
-    }
-
     public List<?> getTaskStatistics(Long planId) {
         String sql = "select PLAN_ID, count(1) as task_count, sum(case when STATUS = 3 then 1 else 0 end) as finish_count, "
                 + "sum(case when PASS_FLAG = 1 then 1 else 0 end) as pass_count, "
@@ -171,17 +148,6 @@ public class InspectTaskService {
         return inspectTaskDao.searchBySql(sql);
     }
 
-    public List<BuInspectTaskItem> getTaskItemPage(PageControlData page, BuInspectTaskItemSearchBean searchBean) {
-        return inspectTaskItemDao.getList(page, searchBean, " order by sort asc, taskItemId desc");
-    }
-
-    public boolean saveTaskItem(BuInspectTaskItem taskItem) {
-        if (taskItem != null && !InspectCommonUtils.validPictureUrls(taskItem.getPictureUrls())) {
-            return false;
-        }
-        return inspectTaskItemDao.save(taskItem);
-    }
-
     public boolean updateTaskItem(BuInspectTaskItem taskItem) {
         if (taskItem != null && !InspectCommonUtils.validPictureUrls(taskItem.getPictureUrls())) {
             return false;
@@ -199,12 +165,6 @@ public class InspectTaskService {
         return inspectTaskItemDao.update(taskItem);
     }
 
-    public int deleteTaskItem(Long id) {
-        return inspectTaskItemDao.executeSql(
-                "delete from bu_inspect_task_item where TASK_ITEM_ID = :id",
-                InspectCommonUtils.params("id", id));
-    }
-
     public int createRectificationsForTask(Long taskId) {
         String sql = "insert into bu_rectification "
                 + "(TASK_ID, TASK_ITEM_ID, PLAN_ID, STORE_ID, STORE_NAME, INDICATOR_ID, INDICATOR_NAME, "

+ 0 - 38
client-app/src/main/java/com/sapit/client/app/manage/inspect/service/RectificationService.java

@@ -25,10 +25,6 @@ public class RectificationService {
         return rectificationDao.getList(page, searchBean, " order by deadlineDate asc, rectId desc");
     }
 
-    public List<BuRectification> getRectificationPage(PageControlData page, BuRectificationSearchBean searchBean) {
-        return getRectPage(page, searchBean);
-    }
-
     public BuRectification getRectDetail(Long id) {
         return (BuRectification) rectificationDao.findById(BuRectification.class, id);
     }
@@ -50,28 +46,6 @@ public class RectificationService {
                 InspectCommonUtils.with(InspectCommonUtils.params("id", id), "storeId", storeId));
     }
 
-    public boolean saveRectification(BuRectification rectification) {
-        return rectificationDao.save(rectification);
-    }
-
-    public boolean updateRectification(BuRectification rectification) {
-        if (rectification == null || rectification.getRectId() == null) {
-            return false;
-        }
-        BuRectification old = getRectificationById(rectification.getRectId());
-        if (old == null) {
-            return false;
-        }
-        rectification.setCreateDate(old.getCreateDate());
-        rectification.setUpdateDate(old.getUpdateDate());
-        return rectificationDao.update(rectification);
-    }
-
-    public int deleteRectification(Long id) {
-        return rectificationDao.executeSql("delete from bu_rectification where RECT_ID = :id",
-                InspectCommonUtils.params("id", id));
-    }
-
     public int batchUpdateDeadline(List<Long> rectIds, Date deadlineDate) {
         if (rectIds == null || rectIds.isEmpty() || deadlineDate == null) {
             return 0;
@@ -161,18 +135,6 @@ public class RectificationService {
         return urge(id);
     }
 
-    public List<?> getRectStatistics(Long storeId) {
-        String sql = "select STORE_ID, count(1) as rect_count, "
-                + "sum(case when STATUS = 6 then 1 else 0 end) as overtime_count, "
-                + "ifnull(avg(timestampdiff(day, CREATE_DATE, ifnull(RECHECK_DATE, NOW()))), 0) as avg_days "
-                + "from bu_rectification where 1 = 1 ";
-        if (storeId != null) {
-            sql += " and STORE_ID = " + storeId;
-        }
-        sql += " group by STORE_ID";
-        return rectificationDao.searchBySql(sql);
-    }
-
     public int createNextRectification(BuRectification previous) {
         String sql = "insert into bu_rectification "
                 + "(TASK_ID, TASK_ITEM_ID, PLAN_ID, STORE_ID, STORE_NAME, INDICATOR_ID, INDICATOR_NAME, "

+ 22 - 4
client-app/src/main/java/com/sapit/client/app/store/controller/inspect/RectificationApiController.java

@@ -14,6 +14,9 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -77,20 +80,35 @@ public class RectificationApiController {
 
     @PostMapping("/uploadPicture")
     @AuthToken(type = "sales")
-    public ResultBean uploadPicture(@RequestParam(value = "file", required = false) MultipartFile file) {
+    public ResultBean uploadPicture(@RequestParam(value = "file", required = false) MultipartFile file,
+                                    HttpServletRequest request) {
         ResultBean bean = new ResultBean();
         if (file == null || file.getOriginalFilename() == null || file.getOriginalFilename().isEmpty()) {
             return paramError();
         }
-        if (file.getSize() > 204800) {
+        byte[] bytes;
+        try {
+            bytes = file.getBytes();
+        } catch (IOException e) {
+            bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
+            bean.getRtnBean().setRtnMsg("文件上传失败");
+            return bean;
+        }
+        if (bytes.length > 204800) {
             bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
             bean.getRtnBean().setRtnMsg("图片大小超过200K");
             return bean;
         }
+        // 仅允许上传图片类型
+        if (!FileFtpUploadUtil.isImage(new ByteArrayInputStream(bytes))) {
+            bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
+            bean.getRtnBean().setRtnMsg("仅支持上传JPEG/PNG/GIF/BMP/WEBP图片");
+            return bean;
+        }
         String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf('.') + 1);
         String fileName = DateUtil.getStrToday("yyyyMMddHHmmssSSS") + "." + suffix;
         try {
-            if (!FileFtpUploadUtil.uploadFile("/rectification", fileName, file.getInputStream())) {
+            if (!FileFtpUploadUtil.uploadFile("/rectification", fileName, new ByteArrayInputStream(bytes))) {
                 bean.getRtnBean().setRtnCode(ReturnCode.SYSTEMERR);
                 bean.getRtnBean().setRtnMsg("文件上传失败");
                 return bean;
@@ -101,7 +119,7 @@ public class RectificationApiController {
             return bean;
         }
         bean.getRtnBean().setRtnCode(ReturnCode.SUCCESS);
-        bean.setObj(FileFtpUploadUtil.rootURL + "/rectification/" + fileName);
+        bean.setObj(FileFtpUploadUtil.buildRemoteUrl(request, "/rectification", fileName));
         return bean;
     }
 

+ 8 - 0
common/src/main/java/com/sapit/common/framwork/BaseDao.java

@@ -343,6 +343,14 @@ public class BaseDao<T> {
 	}
 
 	// 查询表数据(带分页)
+
+    /**
+     * 查询表数据(带分页)
+     * @param page 分页参数
+     * @param searchBean 查询参数类
+     * @param orderBy 排序参数
+     * @return
+     */
 	public List<T> getList(PageControlData page, BaseSearchBean searchBean,String orderBy) {
 		String hql = " from " + getEntity() + " where 1=1 " + searchBean.getSerchCondition() + orderBy;
 		return this.searchByHql(page, hql);

+ 93 - 1
common/src/main/java/com/sapit/common/util/FileFtpUploadUtil.java

@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -92,6 +93,30 @@ public class FileFtpUploadUtil {
         return ftp;
     }
 
+    /**
+	 * 逐级进入并确保目录存在(不存在则创建),全部成功返回 true。
+	 */
+	private static boolean ensureDir(FTPClient ftp, String dir) throws IOException {
+		if (dir == null || dir.trim().isEmpty()) {
+			return true;
+		}
+		String[] parts = dir.split("/");
+		StringBuilder cur = new StringBuilder();
+		for (String p : parts) {
+			if (p == null || p.trim().isEmpty()) {
+				continue;
+			}
+			cur.append("/").append(p);
+			if (!ftp.changeWorkingDirectory(cur.toString())) {
+				ftp.makeDirectory(cur.toString());
+				if (!ftp.changeWorkingDirectory(cur.toString())) {
+					return false;
+				}
+			}
+		}
+		return true;
+	}
+
     /**
 	 * 方法名称:文件上传 
 	 * 功能描述:文件上传
@@ -111,7 +136,12 @@ public class FileFtpUploadUtil {
 			ftpClient.setControlEncoding("UTF-8"); // 中文支持
 			ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
 			ftpClient.enterLocalPassiveMode();
-			ftpClient.changeWorkingDirectory(savePath + path);
+
+			// 进入/创建目标目录,校验成功后再上传,避免目录不存在时文件被写到默认位置导致URL 404
+			if (!ensureDir(ftpClient, savePath + path)) {
+				ftpClient.logout();
+				return false;
+			}
 
 			if (ftpClient.storeFile(fileName, input)) {
 				rtn = true;
@@ -158,6 +188,68 @@ public class FileFtpUploadUtil {
         }
         return flag;
     }
+
+    /**
+     * 通过文件头(魔数)判断是否为常见图片格式,防止上传非图片文件。
+     * @param in 文件输入流(调用方需自行关闭)
+     * @return true=是图片
+     */
+    public static boolean isImage(InputStream in) {
+        if (in == null) {
+            return false;
+        }
+        byte[] b = new byte[12];
+        int n;
+        try {
+            n = in.read(b);
+        } catch (IOException e) {
+            return false;
+        }
+        if (n < 4) {
+            return false;
+        }
+        // JPEG: FF D8 FF
+        if (n >= 3 && (b[0] & 0xFF) == 0xFF && (b[1] & 0xFF) == 0xD8 && (b[2] & 0xFF) == 0xFF) {
+            return true;
+        }
+        // PNG: 89 50 4E 47
+        if (n >= 8 && (b[0] & 0xFF) == 0x89 && b[1] == 'P' && b[2] == 'N' && b[3] == 'G') {
+            return true;
+        }
+        // GIF: 47 49 46
+        if (n >= 4 && b[0] == 'G' && b[1] == 'I' && b[2] == 'F') {
+            return true;
+        }
+        // BMP: 42 4D
+        if (n >= 2 && b[0] == 'B' && b[1] == 'M') {
+            return true;
+        }
+        // WEBP: RIFF....WEBP
+        if (n >= 12 && b[0] == 'R' && b[1] == 'I' && b[2] == 'F' && b[3] == 'F'
+                && b[8] == 'W' && b[9] == 'E' && b[10] == 'B' && b[11] == 'P') {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 组装图片对外访问URL。
+     * rootURL 已配置时使用配置;未配置时返回相对路径(dir + fileName),由前端按自身站点解析,
+     * 避免臆造一个可能无法访问的后端绝对地址导致图片加载失败。
+     * @param request 当前请求(预留,暂不使用)
+     * @param path 相对目录,如 /inspect、/rectification
+     * @param fileName 文件名
+     * @return 完整URL或相对路径
+     */
+    public static String buildRemoteUrl(HttpServletRequest request, String path, String fileName) {
+        String root = rootURL;
+        if (root == null) {
+            root = "";
+        }
+        root = root.trim();
+        String dir = (path == null || path.isEmpty()) ? "" : path;
+        return root + dir + "/" + fileName;
+    }
     
 //	public static void main(String [] args) throws FileNotFoundException {
 //		uploadIp = "123.57.45.174";

File diff suppressed because it is too large
+ 0 - 21
frontend-inspect-portal.vue


Some files were not shown because too many files changed in this diff