新火炬后端单体项目初始化代码
cuijian
2025-07-04 16807e7a9b856a78abbfd80d7ec69e784d5127c7
检验方案
已修改7个文件
224 ■■■■■ 文件已修改
src/main/java/org/jeecg/modules/qms/controller/InspectionItemController.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/qms/controller/InspectionPlanController.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/qms/entity/InspectionPlan.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/qms/mapper/InspectionItemMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/qms/mapper/xml/InspectionItemMapper.xml 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/qms/service/IInspectionItemService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/qms/service/impl/InspectionItemServiceImpl.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/qms/controller/InspectionItemController.java
@@ -237,4 +237,42 @@
         return Result.OK(pageList);
     }
     /**
      * 根据检验方案id查询
      *
      * @param inspectionPlanId
      * @param pageNo
      * @param pageSize
      * @return
      */
     @ApiOperation(value="检验项目-分页列表查询", notes="检验项目-分页列表查询")
     @GetMapping(value = "/queryListByPlanId")
     public Result<?> queryListByPlanId(String inspectionPlanId,
                                @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
         IPage<Map<String, Object>> pageList = inspectionItemService.queryListByPlanId(pageNo,pageSize, inspectionPlanId);
         for(Map<String, Object> r : pageList.getRecords()){
             String inspectionTools = (String) r.get("inspectionTools");
             if(StringUtils.isNotBlank(inspectionTools)){
                 List<String> inspectionToolsList = Arrays.asList(inspectionTools.split(","));
                 List<String> inspectionToolsNameList = new ArrayList<>();
                 String inspectionToolsNames = "";
                 for(String inspectionTool : inspectionToolsList){
                     InspectionTools inspectionTools1 = inspectionToolsService.getById(inspectionTool);
                     if(inspectionTools1 != null){
                         inspectionToolsNameList.add(inspectionTools1.getToolName());
                     }
                 }
                 inspectionToolsNames = inspectionToolsNameList.stream()
                         .collect(Collectors.joining(","));
                 r.put("inspectionToolsNames",inspectionToolsNames);
             }
         }
         return Result.OK(pageList);
     }
}
src/main/java/org/jeecg/modules/qms/controller/InspectionPlanController.java
@@ -1,20 +1,28 @@
package org.jeecg.modules.qms.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.qms.entity.Defect;
import org.jeecg.modules.qms.entity.InspectionItem;
import org.jeecg.modules.qms.entity.InspectionPlan;
import org.jeecg.modules.qms.entity.InspectionPlanItem;
import org.jeecg.modules.qms.service.IInspectionPlanItemService;
import org.jeecg.modules.qms.service.IInspectionPlanService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -51,6 +59,9 @@
public class InspectionPlanController extends JeecgController<InspectionPlan, IInspectionPlanService> {
    @Autowired
    private IInspectionPlanService inspectionPlanService;
     @Autowired
     private IInspectionPlanItemService inspectionPlanItemService;
    
    /**
     * 分页列表查询
@@ -77,31 +88,57 @@
    /**
     *   添加
     *
     * @param inspectionPlan
     * @param jSONObject
     * @return
     */
    @AutoLog(value = "检验方案-添加")
    @ApiOperation(value="检验方案-添加", notes="检验方案-添加")
    //@RequiresPermissions("org.jeecg.modules:qms_inspection_plan:add")
    @PostMapping(value = "/add")
    public Result<String> add(@RequestBody InspectionPlan inspectionPlan) {
    public Result<?> add(@RequestBody JSONObject jSONObject) {
        InspectionPlan inspectionPlan = jSONObject.toJavaObject(InspectionPlan.class);
        inspectionPlan.setPlanStatus(CommonConstant.STATUS_1);
        inspectionPlan.setPublishStatus(CommonConstant.STATUS_0);
        inspectionPlan.setIsNewVersion("1");
        inspectionPlan.setVersion("V1");
        inspectionPlanService.save(inspectionPlan);
        //保存检验方案检验项目关联关系
        JSONArray jsonArray = jSONObject.getJSONArray("detailData");
        List<InspectionPlanItem> inspectionPlanItemList = jsonArray.toJavaList(InspectionPlanItem.class);
        for(int i = 0;i<inspectionPlanItemList.size();i++){
            InspectionPlanItem inspectionPlanItem = inspectionPlanItemList.get(i);
            inspectionPlanItem.setItemId(inspectionPlanItem.getId());
            inspectionPlanItem.setId(null);
            inspectionPlanItem.setPlanId(inspectionPlan.getId());
        }
        inspectionPlanItemService.saveBatch(inspectionPlanItemList);
        return Result.OK("添加成功!");
    }
    
    /**
     *  编辑
     *
     * @param inspectionPlan
     * @param jSONObject
     * @return
     */
    @AutoLog(value = "检验方案-编辑")
    @ApiOperation(value="检验方案-编辑", notes="检验方案-编辑")
    //@RequiresPermissions("org.jeecg.modules:qms_inspection_plan:edit")
    @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> edit(@RequestBody InspectionPlan inspectionPlan) {
    public Result<?> edit(@RequestBody JSONObject jSONObject) {
        InspectionPlan inspectionPlan = jSONObject.toJavaObject(InspectionPlan.class);
        inspectionPlan.setPlanStatus(CommonConstant.STATUS_1);
        inspectionPlanService.updateById(inspectionPlan);
        //删除原关联关系
        inspectionPlanItemService.removeBatchByIds(inspectionPlanItemService.lambdaQuery().eq(InspectionPlanItem::getPlanId,inspectionPlan.getId()).list());
        //保存检验方案检验项目关联关系
        JSONArray jsonArray = jSONObject.getJSONArray("detailData");
        List<InspectionPlanItem> inspectionPlanItemList = jsonArray.toJavaList(InspectionPlanItem.class);
        for(int i = 0;i<inspectionPlanItemList.size();i++){
            InspectionPlanItem inspectionPlanItem = inspectionPlanItemList.get(i);
            inspectionPlanItem.setPlanId(inspectionPlan.getId());
            inspectionPlanItem.setItemId(inspectionPlanItem.getId());
            inspectionPlanItem.setId(null);
        }
        inspectionPlanItemService.saveBatch(inspectionPlanItemList);
        return Result.OK("编辑成功!");
    }
    
@@ -117,6 +154,8 @@
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name="id",required=true) String id) {
        inspectionPlanService.removeById(id);
        //删除关联关系
        inspectionPlanItemService.removeBatchByIds(inspectionPlanItemService.lambdaQuery().eq(InspectionPlanItem::getPlanId,id).list());
        return Result.OK("删除成功!");
    }
    
@@ -191,4 +230,54 @@
         return Result.ok("操作成功!");
     }
     @AutoLog(value = "检验方案-发布")
     @ApiOperation(value = "检验方案-发布", notes = "检验方案-发布")
     @PutMapping(value = "/publish")
     public Result<?> publish(@RequestParam(name = "id", required = true) String id) {
         InspectionPlan inspectionPlan = inspectionPlanService.getById(id);
         if (CommonConstant.STATUS_1.equals(inspectionPlan.getPublishStatus())) {
             inspectionPlan.setPublishStatus(CommonConstant.STATUS_0);
         } else {
             inspectionPlan.setPublishStatus(CommonConstant.STATUS_1);
         }
         inspectionPlanService.updateById(inspectionPlan);
         return Result.ok("操作成功!");
     }
     @AutoLog(value = "检验方案-升版")
     @ApiOperation(value = "检验方案-升版", notes = "检验方案-升版")
     @PutMapping(value = "/version")
     public Result<?> version(@RequestParam(name = "id", required = true) String id) {
         InspectionPlan inspectionPlan = inspectionPlanService.getById(id);
         //复制当前检验方案
         InspectionPlan newInspectionPlan = new InspectionPlan();
         BeanUtil.copyProperties(inspectionPlan,newInspectionPlan);
         newInspectionPlan.setId(null);
         newInspectionPlan.setPlanStatus(CommonConstant.STATUS_1);
         newInspectionPlan.setPublishStatus(CommonConstant.STATUS_0);
         newInspectionPlan.setCreateTime(new Date());
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         newInspectionPlan.setCreateBy(user.getUsername());
         //计算版本,版本+1
         String number = inspectionPlan.getVersion().substring(1);
         BigDecimal newNumber = new BigDecimal(number).add(BigDecimal.ONE);
         newInspectionPlan.setVersion("V"+newNumber);
         newInspectionPlan.setIsNewVersion("1");
         inspectionPlanService.save(newInspectionPlan);
         //复制检验方案检验项目
         List<InspectionPlanItem> inspectionPlanItemList = inspectionPlanItemService.lambdaQuery().eq(InspectionPlanItem::getPlanId,inspectionPlan.getId()).list();
         List<InspectionPlanItem> newInspectionPlanItemList = new ArrayList<>();
         newInspectionPlanItemList.addAll(inspectionPlanItemList);
         for(InspectionPlanItem inspectionPlanItem : inspectionPlanItemList){
             inspectionPlanItem.setId(null);
             inspectionPlanItem.setPlanId(newInspectionPlan.getId());
         }
         inspectionPlanItemService.saveBatch(newInspectionPlanItemList);
         //更新原检验方案为禁用
         inspectionPlan.setPlanStatus(CommonConstant.STATUS_0);
         inspectionPlan.setIsNewVersion("0");
         inspectionPlanService.updateById(inspectionPlan);
         return Result.ok("升版成功!");
     }
}
src/main/java/org/jeecg/modules/qms/entity/InspectionPlan.java
@@ -77,7 +77,23 @@
    /**方案状态*/
    @Excel(name = "方案状态", width = 15)
    @ApiModelProperty(value = "方案状态")
    @Dict(dicCode = "plan_status")
    private String planStatus;
    /**方案发布状态*/
    @Excel(name = "方案发布状态", width = 15)
    @ApiModelProperty(value = "方案发布状态")
    private String publishStatus;
    /**方案版本*/
    @Excel(name = "方案版本", width = 15)
    @ApiModelProperty(value = "方案版本")
    private String version;
    /**是否为最新版本*/
    @Excel(name = "是否为最新版本", width = 15)
    @ApiModelProperty(value = "是否为最新版本")
    private String isNewVersion;
    /**方案分类;首检、巡检、完工检*/
    @Excel(name = "方案分类;首检、巡检、完工检", width = 15)
    @ApiModelProperty(value = "方案分类;首检、巡检、完工检")
@@ -86,6 +102,7 @@
    /**抽样规则ID*/
    @Excel(name = "抽样规则ID", width = 15)
    @ApiModelProperty(value = "抽样规则ID")
    @Dict(dictTable = "qms_sampling_rules",dicCode = "id",dicText = "rule_name")
    private String ruleId;
    /**方案描述*/
    @Excel(name = "方案描述", width = 15)
src/main/java/org/jeecg/modules/qms/mapper/InspectionItemMapper.java
@@ -19,4 +19,6 @@
public interface InspectionItemMapper extends BaseMapper<InspectionItem> {
    public IPage<Map<String, Object>> queryList(IPage<Map> pageData, @Param(Constants.WRAPPER) Wrapper<Map> wrapper);
    public IPage<Map<String, Object>> queryListByPlanId(IPage<Map> pageData, @Param(Constants.WRAPPER) Wrapper<Map> wrapper);
}
src/main/java/org/jeecg/modules/qms/mapper/xml/InspectionItemMapper.xml
@@ -15,11 +15,50 @@
            t1.create_time createTime,
            t2.item_text itemCategoryName,
            t3.item_text qualitativeOrQuantitativeName,
            t1.remark
            t1.remark,
            t4.sorter,
            t4.standard_value standardValue,
            t4.max_value 'maxValue',
            t4.min_value 'minValue',
            t4.plan_id planId
        FROM
            qms_inspection_item t1
                left join qms_inspection_plan_item t4 on t4.item_id = t1.id
                LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'item_category' ) t2 ON t2.item_value = t1.item_category
                left join ( SELECT * FROM v_sys_dict WHERE dict_code = 'qualitative_or_quantitative' ) t3 on t3.item_value = t1.qualitative_or_quantitative
            ${ew.customSqlSegment}
    </select>
    <select id="queryListByPlanId" resultType="map" parameterType="String">
        SELECT
            t1.id,
            t1.item_code itemCode,
            t1.item_name itemName,
            t1.item_category itemCategory,
            t1.qualitative_or_quantitative qualitativeOrQuantitative,
            t1.inspection_tools inspectionTools,
            t1.item_status itemStatus,
            t1.create_time createTime,
            t2.sorter,
            t2.standard_value standardValue,
            t2.min_value 'minValue',
            t2.max_value 'maxValue',
            t3.plan_code planCode,
            t3.plan_name planName,
            t3.material_number materialNumber,
            t3.material_name materialName,
            t6.item_text planCategoryName,
            t4.item_text itemCategoryName,
            t5.item_text qualitativeOrQuantitativeName,
            t1.remark
        FROM
            qms_inspection_item t1
                INNER JOIN qms_inspection_plan_item t2 ON t2.item_id = t1.id
                INNER JOIN qms_inspection_plan t3 ON t3.id = t2.plan_id
                LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'item_category' ) t4 ON t4.item_value = t1.item_category
                LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'qualitative_or_quantitative' ) t5 ON t5.item_value = t1.qualitative_or_quantitative
                LEFT JOIN ( SELECT * FROM v_sys_dict WHERE dict_code = 'plan_category' ) t6 ON t6.item_value = t3.plan_category
        ${ew.customSqlSegment}
    </select>
</mapper>
src/main/java/org/jeecg/modules/qms/service/IInspectionItemService.java
@@ -15,4 +15,6 @@
public interface IInspectionItemService extends IService<InspectionItem> {
    IPage<Map<String, Object>> queryList(Integer pageNo, Integer pageSize, Map<String, String> query);
    IPage<Map<String, Object>> queryListByPlanId(Integer pageNo, Integer pageSize, String inspectionPlanId);
}
src/main/java/org/jeecg/modules/qms/service/impl/InspectionItemServiceImpl.java
@@ -51,4 +51,21 @@
        }
        return super.getBaseMapper().queryList(pageData,queryWrapper);
    }
    @Override
    public IPage<Map<String, Object>> queryListByPlanId(Integer pageNo, Integer pageSize, String inspectionPlanId) {
        if (pageNo == null || pageNo < 1 || pageSize == null || pageSize < 1) {
            ExceptionCast.cast("参数错误");
        }
        IPage<Map> pageData = new Page<Map>(pageNo, pageSize);
        QueryWrapper<Map> queryWrapper = Wrappers.query();
        if (null != inspectionPlanId) {
           queryWrapper.eq("t2.plan_id", inspectionPlanId);
            // 排序写法
            List<OrderItem> orderItems = new ArrayList<>();
            orderItems.add(OrderItem.desc("t2.sorter"));
            ((Page<Map>) pageData).setOrders(orderItems);
        }
        return super.getBaseMapper().queryListByPlanId(pageData,queryWrapper);
    }
}