fix:检查报告接口提交

pg_adapter
wangxy 8 months ago
parent ed2654c934
commit 03eea11b46

@ -0,0 +1,85 @@
package com.ruoyi.web.controller.manager;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.CharSequenceUtil;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.check.TdCheckReport;
import com.ruoyi.system.domain.check.TdCheckType;
import com.ruoyi.system.domain.check.dto.TdCheckReportDTO;
import com.ruoyi.system.domain.check.dto.TdCheckTypeDTO;
import com.ruoyi.system.domain.place.TdPlace;
import com.ruoyi.system.service.check.TdCheckReportService;
import com.ruoyi.system.service.check.TdCheckTypeService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* packageName com.ruoyi.web.controller.manager
*
* @author wangxy
* @version JDK 8
* @className CheckReportManager
* @date 2024/8/15
* @description
*/
@Component
public class CheckReportManager {
@Resource
private TdCheckReportService checkReportService;
@Resource
private TdCheckTypeService checkTypeService;
public List<TdCheckReport> selectTdCheckReportList(TdCheckReport tdCheckReport) {
return checkReportService.selectTdCheckReportList(tdCheckReport);
}
@Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdate(TdCheckReportDTO checkReportDTO) {
TdCheckReport tdCheckReport = Convert.convert(TdCheckReport.class, checkReportDTO);
if (CharSequenceUtil.isNotBlank(checkReportDTO.getCheckId())) {
checkTypeService.lambdaUpdate()
.eq(TdCheckType::getCheckId, checkReportDTO.getCheckId())
.remove();
} else {
tdCheckReport.setDepart(ShiroUtils.getSysUser().getDept().getDeptName());
tdCheckReport.setAdduser(ShiroUtils.getSysUser().getLoginName());
tdCheckReport.setCreateTime(new Date());
}
checkReportService.saveOrUpdate(tdCheckReport);
List<TdCheckType> list = Convert.toList(TdCheckType.class, checkReportDTO.getCheckTypeDTOS());
list.forEach(checkReport -> checkReport.setCheckId(tdCheckReport.getCheckId()));
return checkTypeService.saveBatch(list);
}
public TdCheckReportDTO getTdCheckReportDTO(String id) {
TdCheckReport tdCheckReport = checkReportService.getById(id);
TdCheckReportDTO tdCheckReportDto = Convert.convert(TdCheckReportDTO.class, tdCheckReport);
List<TdCheckType> list = checkTypeService.lambdaQuery().eq(TdCheckType::getCheckId, id).list();
if(CollUtil.isNotEmpty(list)){
List<TdCheckTypeDTO> tdCheckTypeDtoS = Convert.toList(TdCheckTypeDTO.class, list);
tdCheckReportDto.setCheckTypeDTOS(tdCheckTypeDtoS);
}
return tdCheckReportDto;
}
@Transactional(rollbackFor = Exception.class)
public boolean deletedTdCheckReportIds(String ids) {
List<String> list = Arrays.asList(Convert.toStrArray(ids));
checkTypeService.lambdaUpdate().in(TdCheckType::getCheckId,list).remove();
return checkReportService.removeByIds(list);
}
}

@ -0,0 +1,146 @@
package com.ruoyi.web.controller.system.check;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TdCheck;
import com.ruoyi.system.domain.check.TdCheckReport;
import com.ruoyi.system.domain.check.dto.TdCheckReportDTO;
import com.ruoyi.web.controller.manager.CheckReportManager;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* packageName com.ruoyi.web.controller.system.check
*
* @author wangxy
* @version JDK 8
* @className CheckReportController
* @date 2024/8/15
* @description
*/
@Controller
@RequestMapping("/system/checkReport")
public class CheckReportController extends BaseController {
private String prefix = "system/checkReport";
@Resource
private CheckReportManager checkReportManager;
@RequiresPermissions("system:check:view")
@GetMapping()
public String place() {
return prefix + "/checkReport";
}
/**
*
*/
@RequiresPermissions("system:check:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(TdCheckReport tdCheckReport) {
startPage();
List<TdCheckReport> tdCheckReports = checkReportManager.selectTdCheckReportList(tdCheckReport);
return getDataTable(tdCheckReports);
}
/**
*
*/
@GetMapping("/add")
public String add() {
return prefix + "/add";
}
/**
*
*/
@RequiresPermissions("system:check:add")
@Log(title = "检查报告", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(@RequestBody TdCheckReportDTO checkReportDTO) {
return toAjax(checkReportManager.saveOrUpdate(checkReportDTO));
}
/**
*
*/
@RequiresPermissions("system:check:edit")
@GetMapping("/edit/{checkId}")
public String edit(@PathVariable("checkId") String checkId, ModelMap mmap) {
TdCheckReportDTO tdCheckReportDTO = checkReportManager.getTdCheckReportDTO(checkId);
mmap.put("tdCheckReportDTO", tdCheckReportDTO);
return prefix + "/edit";
}
/**
*
*/
@RequiresPermissions("system:check:edit")
@Log(title = "检查报告", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(@RequestBody TdCheckReportDTO checkReportDTO) {
return toAjax(checkReportManager.saveOrUpdate(checkReportDTO));
}
/**
*
*/
@GetMapping("/view/{checkId}")
public AjaxResult view(@PathVariable("checkId") String checkId) {
return AjaxResult.success(checkReportManager.getTdCheckReportDTO(checkId));
}
/**
*
*/
@RequiresPermissions("system:check:remove")
@Log(title = "检查报告", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(checkReportManager.deletedTdCheckReportIds(ids));
}
/**
*
*/
@RequiresPermissions("system:check:selfcheck")
@GetMapping("/selfcheck/{checkId}")
public String selfcheck(@PathVariable("checkId") String checkId, ModelMap mmap) {
TdCheckReportDTO tdCheckReportDTO = checkReportManager.getTdCheckReportDTO(checkId);
mmap.put("tdCheckReportDTO", tdCheckReportDTO);
return prefix + "/selfcheck";
}
/**
*
*/
@RequiresPermissions("system:check:selfcheck")
@Log(title = "检查报告管理", businessType = BusinessType.CHECK)
@PostMapping("/selfcheckSave")
@ResponseBody
public AjaxResult selfcheckSave(@RequestBody TdCheckReportDTO checkReportDTO) {
return toAjax(checkReportManager.saveOrUpdate(checkReportDTO));
}
}

@ -0,0 +1,80 @@
package com.ruoyi.system.domain.check;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
*
* @author 13560
* @TableName td_check_report
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class TdCheckReport implements Serializable {
/**
* id
*/
@TableId
private String checkId;
/**
*
*/
private String adduser;
/**
*
*/
private String depart;
/**
*
*/
private Date checkStartTime;
/**
*
*/
private Date checkEndTime;
/**
* 0. 1.
*/
private String checkType;
/**
*
*/
private String area;
/**
*
*/
private String framework;
/**
* 012
*/
private String checkState;
/**
*
*/
private String checkName;
/**
*
*/
private Date createTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,57 @@
package com.ruoyi.system.domain.check;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
*
* @author 13560
* @TableName td_check_type
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class TdCheckType implements Serializable {
/**
*
*/
@TableId
private String id;
/**
* id
*/
private String checkId;
/**
*
*/
private String checkType;
/**
*
*/
private String typeContent;
/**
* 01
*/
private String starts;
/**
* 01
*/
private String resultStarts;
/**
*
*/
private String remark;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,82 @@
package com.ruoyi.system.domain.check.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*
* @author 13560
* @TableName td_check_report
*/
@Data
public class TdCheckReportDTO implements Serializable {
/**
* id
*/
private String checkId;
/**
*
*/
private String adduser;
/**
*
*/
private String depart;
/**
*
*/
private Date checkStartTime;
/**
*
*/
private Date checkEndTime;
/**
* 0. 1.
*/
private String checkType;
/**
*
*/
private String area;
/**
*
*/
private String framework;
/**
* 012
*/
private String checkState;
/**
*
*/
private String checkName;
/**
*
*/
private Date createTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
/**
*
*/
private List<TdCheckTypeDTO> checkTypeDTOS;
}

@ -0,0 +1,55 @@
package com.ruoyi.system.domain.check.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
*
* @author 13560
* @TableName td_check_type
*/
@Data
public class TdCheckTypeDTO implements Serializable {
/**
*
*/
private String id;
/**
* id
*/
private String checkId;
/**
*
*/
private String checkType;
/**
*
*/
private String typeContent;
/**
* 01
*/
private String starts;
/**
* 01
*/
private String resultStarts;
/**
*
*/
private String remark;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,23 @@
package com.ruoyi.system.mapper.check;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.check.TdCheckReport;
import java.util.List;
/**
* @author 13560
* @description td_check_report()Mapper
* @createDate 2024-08-15 11:15:02
* @Entity generator.domain.TdCheckReport
*/
public interface TdCheckReportMapper extends BaseMapper<TdCheckReport> {
public List<TdCheckReport> selectTdCheckReportList(TdCheckReport tdCheckReport);
}

@ -0,0 +1,18 @@
package com.ruoyi.system.mapper.check;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.system.domain.check.TdCheckType;
/**
* @author 13560
* @description td_check_typeMapper
* @createDate 2024-08-15 11:15:02
* @Entity generator.domain.TdCheckType
*/
public interface TdCheckTypeMapper extends BaseMapper<TdCheckType> {
}

@ -0,0 +1,19 @@
package com.ruoyi.system.service.check;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.domain.check.TdCheckReport;
import com.ruoyi.system.domain.place.TdPlace;
import java.util.List;
/**
* @author 13560
* @description td_check_report()Service
* @createDate 2024-08-15 11:15:02
*/
public interface TdCheckReportService extends IService<TdCheckReport> {
public List<TdCheckReport> selectTdCheckReportList(TdCheckReport tdCheckReport);
}

@ -0,0 +1,13 @@
package com.ruoyi.system.service.check;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.system.domain.check.TdCheckType;
/**
* @author 13560
* @description td_check_typeService
* @createDate 2024-08-15 11:15:02
*/
public interface TdCheckTypeService extends IService<TdCheckType> {
}

@ -0,0 +1,33 @@
package com.ruoyi.system.service.check.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.check.TdCheckReport;
import com.ruoyi.system.mapper.check.TdCheckReportMapper;
import com.ruoyi.system.mapper.place.TdPlaceMapper;
import com.ruoyi.system.service.check.TdCheckReportService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author 13560
* @description td_check_report()Service
* @createDate 2024-08-15 11:15:02
*/
@Service
public class TdCheckReportServiceImpl extends ServiceImpl<TdCheckReportMapper, TdCheckReport>
implements TdCheckReportService {
@Resource
private TdCheckReportMapper checkReportMapper;
@Override
public List<TdCheckReport> selectTdCheckReportList(TdCheckReport tdCheckReport) {
return checkReportMapper.selectTdCheckReportList(tdCheckReport);
}
}

@ -0,0 +1,22 @@
package com.ruoyi.system.service.check.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.check.TdCheckType;
import com.ruoyi.system.mapper.check.TdCheckTypeMapper;
import com.ruoyi.system.service.check.TdCheckTypeService;
import org.springframework.stereotype.Service;
/**
* @author 13560
* @description td_check_typeService
* @createDate 2024-08-15 11:15:02
*/
@Service
public class TdCheckTypeServiceImpl extends ServiceImpl<TdCheckTypeMapper, TdCheckType>
implements TdCheckTypeService {
}

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.check.TdCheckReportMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.check.TdCheckReport">
<id property="checkId" column="check_id" jdbcType="VARCHAR"/>
<result property="adduser" column="adduser" jdbcType="VARCHAR"/>
<result property="depart" column="depart" jdbcType="VARCHAR"/>
<result property="checkStartTime" column="check_start_time" jdbcType="TIMESTAMP"/>
<result property="checkEndTime" column="check_end_time" jdbcType="TIMESTAMP"/>
<result property="checkType" column="check_type" jdbcType="VARCHAR"/>
<result property="area" column="area" jdbcType="VARCHAR"/>
<result property="framework" column="framework" jdbcType="VARCHAR"/>
<result property="checkState" column="check_state" jdbcType="VARCHAR"/>
<result property="checkName" column="check_name" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
check_id,adduser,depart,
check_start_time,check_end_time,check_type,
area,framework,check_state,
check_name,create_time
</sql>
<select id="selectTdCheckReportList" resultType="com.ruoyi.system.domain.check.TdCheckReport">
select <include refid="Base_Column_List"/> from td_check_report
<trim prefix="where" prefixOverrides="and|or">
<if test="area!=null and area!=''">
AND area = #{area}
</if>
<if test="framework!=null and framework!=''">
AND framework = #{framework}
</if>
<if test="checkState!=null and checkState!=''">
AND checkState = #{checkState}
</if>
<if test="depart!=null and depart!=''">
AND depart = #{depart}
</if>
</trim>
ORDER BY create_time DESC
</select>
</mapper>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.check.TdCheckTypeMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.system.domain.check.TdCheckType">
<id property="id" column="id" jdbcType="VARCHAR"/>
<id property="checkId" column="check_id" jdbcType="VARCHAR"/>
<result property="checkType" column="check_type" jdbcType="VARCHAR"/>
<result property="typeContent" column="type_content" jdbcType="VARCHAR"/>
<result property="starts" column="starts" jdbcType="VARCHAR"/>
<result property="resultStarts" column="result_starts" jdbcType="VARCHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,check_id,check_type,
type_content,starts,result_starts,
remark
</sql>
</mapper>
Loading…
Cancel
Save