优化代码生成

完成风险管理
main
liukewei 12 months ago
parent e1d3a417da
commit 274358c359

@ -1,4 +1,4 @@
package com.ruoyi.web.controller.ehs; package com.ruoyi.ehsMaterial.controller;
import java.util.List; import java.util.List;
import java.util.Arrays; import java.util.Arrays;
@ -28,7 +28,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* Controller * Controller
* *
* @author ruoyi * @author ruoyi
* @date 2023-12-01 * @date 2023-12-04
*/ */
@Api(tags="物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”管理") @Api(tags="物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”管理")
@RestController @RestController
@ -41,7 +41,6 @@ public class EhsMaterialController extends BaseController
/** /**
* *
*/ */
@ApiOperation("查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表")
@PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:list')") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(EhsMaterial ehsMaterial) public TableDataInfo list(EhsMaterial ehsMaterial)
@ -54,7 +53,6 @@ public class EhsMaterialController extends BaseController
/** /**
* *
*/ */
@ApiOperation("导出物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表")
@PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:export')") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:export')")
@Log(title = "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”", businessType = BusinessType.EXPORT) @Log(title = "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
@ -68,12 +66,11 @@ public class EhsMaterialController extends BaseController
/** /**
* *
*/ */
@ApiOperation("获取物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”详细信息")
@PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:query')") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:query')")
@GetMapping(value = "/{materialId}") @GetMapping(value = "/{materialId}")
public AjaxResult getInfo(@PathVariable("materialId") Long materialId) public AjaxResult getInfo(@PathVariable("materialId") Long materialId)
{ {
return success(ehsMaterialService.getById(materialId)); return success(ehsMaterialService.selectEhsMaterialByMaterialId(materialId));
} }
/** /**
@ -106,7 +103,7 @@ public class EhsMaterialController extends BaseController
@ApiOperation("删除物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”") @ApiOperation("删除物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”")
@PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:remove')") @PreAuthorize("@ss.hasPermi('ehsMaterial:ehsMaterial:remove')")
@Log(title = "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”", businessType = BusinessType.DELETE) @Log(title = "物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”", businessType = BusinessType.DELETE)
@DeleteMapping("/{materialIds}") @DeleteMapping("/{materialIds}")
public AjaxResult remove(@PathVariable Long[] materialIds) public AjaxResult remove(@PathVariable Long[] materialIds)
{ {
return toAjax(ehsMaterialService.removeByIds(Arrays.asList(materialIds))); return toAjax(ehsMaterialService.removeByIds(Arrays.asList(materialIds)));

@ -4,6 +4,7 @@ import java.util.List;
import java.util.Arrays; import java.util.Arrays;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ehsRisk.domain.EhsRisk; import com.ruoyi.ehsRisk.domain.EhsRisk;
import com.ruoyi.ehsRisk.service.IEhsRiskService; import com.ruoyi.ehsRisk.service.IEhsRiskService;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -29,7 +30,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
* Controller * Controller
* *
* @author ruoyi * @author ruoyi
* @date 2023-11-30 * @date 2023-12-04
*/ */
@Api(tags="风险信息管理") @Api(tags="风险信息管理")
@RestController @RestController
@ -39,10 +40,10 @@ public class EhsRiskController extends BaseController
@Autowired @Autowired
private IEhsRiskService ehsRiskService; private IEhsRiskService ehsRiskService;
/** /**
* *
*/ */
@ApiOperation("查询风险信息列表")
@PreAuthorize("@ss.hasPermi('system:risk:list')") @PreAuthorize("@ss.hasPermi('system:risk:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(EhsRisk ehsRisk) public TableDataInfo list(EhsRisk ehsRisk)
@ -55,12 +56,12 @@ public class EhsRiskController extends BaseController
/** /**
* *
*/ */
@ApiOperation("导出风险信息列表")
@PreAuthorize("@ss.hasPermi('system:risk:export')") @PreAuthorize("@ss.hasPermi('system:risk:export')")
@Log(title = "风险信息", businessType = BusinessType.EXPORT) @Log(title = "风险信息", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, EhsRisk ehsRisk) public void export(HttpServletResponse response, EhsRisk ehsRisk)
{ {
List<EhsRisk> list = ehsRiskService.selectEhsRiskList(ehsRisk); List<EhsRisk> list = ehsRiskService.selectEhsRiskList(ehsRisk);
ExcelUtil<EhsRisk> util = new ExcelUtil<EhsRisk>(EhsRisk.class); ExcelUtil<EhsRisk> util = new ExcelUtil<EhsRisk>(EhsRisk.class);
util.exportExcel(response, list, "风险信息数据"); util.exportExcel(response, list, "风险信息数据");
@ -69,12 +70,11 @@ public class EhsRiskController extends BaseController
/** /**
* *
*/ */
@ApiOperation("获取风险信息详细信息")
@PreAuthorize("@ss.hasPermi('system:risk:query')") @PreAuthorize("@ss.hasPermi('system:risk:query')")
@GetMapping(value = "/{riskId}") @GetMapping(value = "/{riskId}")
public AjaxResult getInfo(@PathVariable("riskId") Long riskId) public AjaxResult getInfo(@PathVariable("riskId") Long riskId)
{ {
return success(ehsRiskService.getById(riskId)); return success(ehsRiskService.selectEhsRiskByRiskId(riskId));
} }
/** /**
@ -107,7 +107,7 @@ public class EhsRiskController extends BaseController
@ApiOperation("删除风险信息") @ApiOperation("删除风险信息")
@PreAuthorize("@ss.hasPermi('system:risk:remove')") @PreAuthorize("@ss.hasPermi('system:risk:remove')")
@Log(title = "风险信息", businessType = BusinessType.DELETE) @Log(title = "风险信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{riskIds}") @DeleteMapping("/{riskIds}")
public AjaxResult remove(@PathVariable Long[] riskIds) public AjaxResult remove(@PathVariable Long[] riskIds)
{ {
return toAjax(ehsRiskService.removeByIds(Arrays.asList(riskIds))); return toAjax(ehsRiskService.removeByIds(Arrays.asList(riskIds)));

@ -129,4 +129,16 @@ public class SysDeptController extends BaseController
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId)); return toAjax(deptService.deleteDeptById(deptId));
} }
/**
* idname
*
* @param dept
* @return
*/
@GetMapping("/getAllDeptList")
public AjaxResult selectAllDeptList(SysDept dept)
{
List<SysDept> depts = deptService.selectAllDeptList(dept);
return success(depts);
}
} }

@ -45,18 +45,19 @@ public class GenConstants
"bit", "bigint", "float", "double", "decimal" }; "bit", "bigint", "float", "double", "decimal" };
/** 页面不需要编辑字段 */ /** 页面不需要编辑字段 */
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" }; public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag", "create_user_id", "update_user_id" };
/** 页面不需要显示的列表字段 */ /** 页面不需要显示的列表字段 */
public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by", public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
"update_time" }; "update_time" , "create_user_id", "update_user_id"};
/** 页面不需要查询字段 */ /** 页面不需要查询字段 */
public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by", public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
"update_time", "remark" }; "update_time", "remark" , "createUserId", "updateUserId"};
/** Entity基类字段 */ /** Entity基类字段 */
public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" }; public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark",
"deptId", "createUserId", "updateUserId", "deptName" };
/** Tree基类字段 */ /** Tree基类字段 */
public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" }; public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };

@ -9,12 +9,15 @@ import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
/** /**
* Entity * Entity
* *
* @author ruoyi * @author ruoyi
*/ */
@Data
public class BaseEntity implements Serializable public class BaseEntity implements Serializable
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -33,6 +36,9 @@ public class BaseEntity implements Serializable
/** 创建者 */ /** 创建者 */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
private Long deptId; private Long deptId;
/** 上报部门 */
@Excel(name = "上报部门")
private String deptName;
/** 创建时间 */ /** 创建时间 */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ -58,89 +64,7 @@ public class BaseEntity implements Serializable
private Map<String, Object> params; private Map<String, Object> params;
public Long getCreateUserId() {
return createUserId;
}
public void setCreateUserId(Long createUserId) {
this.createUserId = createUserId;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(Long updateUserId) {
this.updateUserId = updateUserId;
}
public String getSearchValue()
{
return searchValue;
}
public void setSearchValue(String searchValue)
{
this.searchValue = searchValue;
}
public String getCreateBy()
{
return createBy;
}
public void setCreateBy(String createBy)
{
this.createBy = createBy;
}
public Date getCreateTime()
{
return createTime;
}
public void setCreateTime(Date createTime)
{
this.createTime = createTime;
}
public String getUpdateBy()
{
return updateBy;
}
public void setUpdateBy(String updateBy)
{
this.updateBy = updateBy;
}
public Date getUpdateTime()
{
return updateTime;
}
public void setUpdateTime(Date updateTime)
{
this.updateTime = updateTime;
}
public String getRemark()
{
return remark;
}
public void setRemark(String remark)
{
this.remark = remark;
}
public Map<String, Object> getParams() public Map<String, Object> getParams()
{ {

@ -59,6 +59,8 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
// 当前已登录 更新人填充(不管为不为空) // 当前已登录 更新人填充(不管为不为空)
if (StringUtils.isNotBlank(username)) { if (StringUtils.isNotBlank(username)) {
baseEntity.setUpdateBy(username); baseEntity.setUpdateBy(username);
Long userId = baseEntity.getCreateUserId()!=null ? baseEntity.getCreateUserId() : SecurityUtils.getUserId();
baseEntity.setUpdateUserId(userId);
} }
} }
} catch (Exception e) { } catch (Exception e) {

@ -333,6 +333,7 @@ public class GenTableColumn extends BaseEntity
return StringUtils.equalsAnyIgnoreCase(javaField, return StringUtils.equalsAnyIgnoreCase(javaField,
// BaseEntity // BaseEntity
"createBy", "createTime", "updateBy", "updateTime", "remark", "createBy", "createTime", "updateBy", "updateTime", "remark",
"updateUserId", "deptId","createUserId",
// TreeEntity // TreeEntity
"parentName", "parentId", "orderNum", "ancestors"); "parentName", "parentId", "orderNum", "ancestors");
} }

@ -0,0 +1,141 @@
package ${packageName}.controller;
import java.util.List;
import java.util.Arrays;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
#if($table.crud || $table.sub)
import com.ruoyi.common.core.page.TableDataInfo;
#elseif($table.tree)
#end
/**
* ${functionName}Controller
*
* @author ${author}
* @date ${datetime}
*/
@Api(tags="${functionName}管理")
@RestController
@RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends BaseController
{
@Autowired
private I${ClassName}Service ${className}Service;
/**
* 查询${functionName}列表
*/
@ApiOperation("查询${functionName}列表")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@GetMapping("/list")
#if($table.crud || $table.sub)
public TableDataInfo list(${ClassName} ${className})
{
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return getDataTable(list);
}
#elseif($table.tree)
public AjaxResult list(${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return success(list);
}
#end
/**
* 导出${functionName}列表
*/
@ApiOperation("导出${functionName}列表")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
util.exportExcel(response, list, "${functionName}数据");
}
/**
* 获取${functionName}详细信息
*/
@ApiOperation("获取${functionName}详细信息")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@GetMapping(value = "/{${pkColumn.javaField}}")
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
{
#if($table.sub)
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
#else
return success(${className}Service.getById(${pkColumn.javaField}));
#end
}
/**
* 新增${functionName}
*/
@ApiOperation("新增${functionName}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ${ClassName} ${className})
{
#if($table.sub)
return toAjax(${className}Service.insert${ClassName}(${className}));
#else
return toAjax(${className}Service.save(${className}));
#end
}
/**
* 修改${functionName}
*/
@ApiOperation("修改${functionName}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ${ClassName} ${className})
{
#if($table.sub)
return toAjax(${className}Service.update${ClassName}(${className}));
#else
return toAjax(${className}Service.updateById(${className}));
#end
}
/**
* 删除${functionName}
*/
@ApiOperation("删除${functionName}")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}")
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
{
#if($table.sub)
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
#else
return toAjax(${className}Service.removeByIds(Arrays.asList(${pkColumn.javaField}s)));
#end
}
}

@ -0,0 +1,72 @@
package ${packageName}.domain;
#foreach ($import in $importList)
import ${import};
#end
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 lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import com.ruoyi.common.annotation.Excel;
#if($table.crud || $table.sub)
import com.ruoyi.common.core.domain.BaseEntity;
#elseif($table.tree)
import com.ruoyi.common.core.domain.TreeEntity;
#end
/**
* ${functionName}对象 ${tableName}
*
* @author ${author}
* @date ${datetime}
*/
#if($table.crud || $table.sub)
#set($Entity="BaseEntity")
#elseif($table.tree)
#set($Entity="TreeEntity")
#end
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("${tableName}")
public class ${ClassName} extends ${Entity}
{
private static final long serialVersionUID = 1L;
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
#if($column.pk)
@TableId(type= IdType.AUTO)
#end
private $column.javaType $column.javaField;
#end
#end
#if($table.sub)
/** $table.subTable.functionName信息 */
@TableField(exist = false)
private List<${subClassName}> ${subclassName}List;
#end
}

@ -0,0 +1,43 @@
package ${packageName}.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import ${packageName}.domain.${ClassName};
#if($table.sub)
import java.util.List;
import org.apache.ibatis.annotations.Param;
import ${packageName}.domain.${subClassName};
#end
/**
* ${functionName}Mapper接口
*
* @author ${author}
* @date ${datetime}
*/
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
#if($table.sub)
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
List<${subClassName}> select${subClassName}By${pkColumn.capJavaField}(@Param("${pkColumn.javaField}")${pkColumn.javaType} ${pkColumn.javaField});
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
int delete${subClassName}By${subTableFkClassName}(@Param("${pkColumn.javaField}")${pkColumn.javaType} ${pkColumn.javaField});
/**
* 批量新增${subTable.functionName}
*
* @param ${subclassName}List ${subTable.functionName}列表
* @return 结果
*/
int batchInsert${subClassName}(List<${subClassName}> ${subclassName}List);
#end
}

@ -0,0 +1,64 @@
package ${packageName}.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import ${packageName}.domain.${ClassName};
/**
* ${functionName}Service接口
*
* @author ${author}
* @date ${datetime}
*/
public interface I${ClassName}Service extends IService<${ClassName}> {
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
#if($table.sub)
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int update${ClassName}(${ClassName} ${className});
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
#end
}

@ -0,0 +1,179 @@
package ${packageName}.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;
#if($table.sub)
import java.util.Arrays;
import org.springframework.transaction.annotation.Transactional;
import ${packageName}.domain.${subClassName};
#end
import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
/**
* ${functionName}Service业务层处理
*
* @author ${author}
* @date ${datetime}
*/
@Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service {
@Autowired
private ${ClassName}Mapper ${className}Mapper;
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}
*/
@Override
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
{
List<${ClassName}> ${className}List = ${className}Mapper.selectList(buildQueryWrapper(${className}));
#if($table.sub)
if (StringUtils.isNotNull(${className}List)) {
for (${ClassName} temp : ${className}List) {
List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(temp.get${pkColumn.capJavaField}());
temp.set${subClassName}List(${subclassName}List);
}
}
#end
return ${className}List;
}
#if($table.sub)
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
@Override
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{
${ClassName} ${className} = ${className}Mapper.selectById(${pkColumn.javaField});
List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
${className}.set${subClassName}List(${subclassName}List);
return ${className};
}
/**
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
@Transactional
@Override
public int insert${ClassName}(${ClassName} ${className})
{
int rows = ${className}Mapper.insert(${className});
insert${subClassName}(${className});
return rows;
}
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
@Transactional
@Override
public int update${ClassName}(${ClassName} ${className})
{
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
insert${subClassName}(${className});
return ${className}Mapper.updateById(${className});
}
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
* @return 结果
*/
@Transactional
@Override
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
{
List<${pkColumn.javaType}> ${pkColumn.javaField}List = Arrays.asList(${pkColumn.javaField}s);
for (${pkColumn.javaType} ${pkColumn.javaField} : ${pkColumn.javaField}List) {
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
}
return ${className}Mapper.deleteBatchIds(${pkColumn.javaField}List);
}
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
@Transactional
@Override
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
return ${className}Mapper.deleteById(${pkColumn.javaField});
}
/**
* 新增${subTable.functionName}信息
*
* @param ${className} ${functionName}对象
*/
private void insert${subClassName}(${ClassName} ${className})
{
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
if (StringUtils.isNotNull(${subclassName}List)) {
for (${subClassName} ${subclassName} : ${subclassName}List) {
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
}
${className}Mapper.batchInsert${subClassName}(${subclassName}List);
}
}
#end
private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName} query) {
Map<String, Object> params = query.getParams();
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
#foreach($column in $columns)
#if($column.query)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($mpMethod=$column.queryType.toLowerCase())
#if($queryType != 'BETWEEN')
#if($javaType == 'String')
#set($condition='StringUtils.isNotBlank(query.get'+$AttrName+'())')
#else
#set($condition='query.get'+$AttrName+'() != null')
#end
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, query.get$AttrName());
#else
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
#end
#end
#if($column.javaField == 'createTime')
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
lqw.orderByDesc(${ClassName}::get$AttrName);
#end
#end
return lqw;
}
}

@ -0,0 +1,61 @@
package ${packageName}.domain;
#foreach ($import in $subImportList)
import ${import};
#end
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* ${subTable.functionName}对象 ${subTableName}
*
* @author ${author}
* @date ${datetime}
*/
@Data
@ToString
@NoArgsConstructor
@Accessors(chain = true)
@TableName("${subTableName}")
@ApiModel(value = "${subClassName}", description = "${subTable.functionName}实体")
public class ${subClassName} extends BaseEntity
{
private static final long serialVersionUID = 1L;
#foreach ($column in $subTable.columns)
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */
#if($column.list)
#set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
#end
#end
#if($column.pk)
@TableId(type= IdType.AUTO)
#end
@ApiModelProperty("$column.columnComment")
private $column.javaType $column.javaField;
#end
#end
}

@ -41,55 +41,48 @@ public class ${ClassName}Controller extends BaseController
@Autowired @Autowired
private I${ClassName}Service ${className}Service; private I${ClassName}Service ${className}Service;
/** /**
* 查询${functionName}列表 * 查询${functionName}列表
*/ */
@ApiOperation("查询${functionName}列表") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") @GetMapping("/list")
@GetMapping("/list") #if($table.crud || $table.sub)
#if($table.crud || $table.sub) public TableDataInfo list(${ClassName} ${className})
public TableDataInfo list(${ClassName} ${className}) {
{ startPage();
startPage(); List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); return getDataTable(list);
return getDataTable(list); }
} #elseif($table.tree)
#elseif($table.tree) public AjaxResult list(${ClassName} ${className})
public AjaxResult list(${ClassName} ${className}) {
{ List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); return success(list);
return success(list); }
} #end
#end
/** /**
* 导出${functionName}列表 * 导出${functionName}列表
*/ */
@ApiOperation("导出${functionName}列表") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@Log(title = "${functionName}", businessType = BusinessType.EXPORT) @PostMapping("/export")
@PostMapping("/export") public void export(HttpServletResponse response, ${ClassName} ${className})
public void export(HttpServletResponse response, ${ClassName} ${className}) {
{ List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); util.exportExcel(response, list, "${functionName}数据");
util.exportExcel(response, list, "${functionName}数据"); }
}
/** /**
* 获取${functionName}详细信息 * 获取${functionName}详细信息
*/ */
@ApiOperation("获取${functionName}详细信息") @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") @GetMapping(value = "/{${pkColumn.javaField}}")
@GetMapping(value = "/{${pkColumn.javaField}}") public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
{ return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
#if($table.sub) }
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
#else
return success(${className}Service.getById(${pkColumn.javaField}));
#end
}
/** /**
* 新增${functionName} * 新增${functionName}

@ -2,6 +2,7 @@ package ${packageName}.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import java.util.List;
#if($table.sub) #if($table.sub)
import java.util.List; import java.util.List;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -15,14 +16,22 @@ import ${packageName}.domain.${subClassName};
* @date ${datetime} * @date ${datetime}
*/ */
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> { public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
/**
* 查询${functionName}列表
*
* @param ${className} ${functionName}
* @return ${functionName}集合
*/
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
#if($table.sub) #if($table.sub)
/**
* 查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
*/
List<${subClassName}> select${subClassName}By${pkColumn.capJavaField}(@Param("${pkColumn.javaField}")${pkColumn.javaType} ${pkColumn.javaField});
/** /**
* 删除${functionName}信息 * 删除${functionName}信息

@ -12,53 +12,55 @@ import ${packageName}.domain.${ClassName};
*/ */
public interface I${ClassName}Service extends IService<${ClassName}> { public interface I${ClassName}Service extends IService<${ClassName}> {
/** /**
* 查询${functionName}列表 * 查询${functionName}
* *
* @param ${className} ${functionName} * @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}集合 * @return ${functionName}
*/ */
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
#if($table.sub) /**
/** * 查询${functionName}列表
* 查询${functionName} *
* * @param ${className} ${functionName}
* @param ${pkColumn.javaField} ${functionName}主键 * @return ${functionName}集合
* @return ${functionName} */
*/ public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
/** #if($table.sub)
* 新增${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
/**
* 修改${functionName}
*
* @param ${className} ${functionName}
* @return 结果
*/
public int update${ClassName}(${ClassName} ${className});
/** /**
* 批量删除${functionName} * 新增${functionName}
* *
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合 * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s); public int insert${ClassName}(${ClassName} ${className});
/** /**
* 删除${functionName}信息 * 修改${functionName}
* *
* @param ${pkColumn.javaField} ${functionName}主键 * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}); public int update${ClassName}(${ClassName} ${className});
#end
/**
* 批量删除${functionName}
*
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
/**
* 删除${functionName}信息
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return 结果
*/
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
#end
} }

@ -8,11 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
#if($table.sub) #if($table.sub)
import java.util.Arrays; import java.util.Arrays;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import ${packageName}.domain.${subClassName}; import ${packageName}.domain.${subClassName};
#end #end
import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName}; import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service; import ${packageName}.service.I${ClassName}Service;
@ -26,154 +26,142 @@ import ${packageName}.service.I${ClassName}Service;
@Service @Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service {
@Autowired @Autowired
private ${ClassName}Mapper ${className}Mapper; private ${ClassName}Mapper ${className}Mapper;
/** /**
* 查询${functionName}列表 * 查询${functionName}
* *
* @param ${className} ${functionName} * @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName} * @return ${functionName}
*/ */
@Override @Override
public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{ {
List<${ClassName}> ${className}List = ${className}Mapper.selectList(buildQueryWrapper(${className})); return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
#if($table.sub) }
if (StringUtils.isNotNull(${className}List)) {
for (${ClassName} temp : ${className}List) {
List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(temp.get${pkColumn.capJavaField}());
temp.set${subClassName}List(${subclassName}List);
}
}
#end
return ${className}List;
}
#if($table.sub) /**
/** * 查询${functionName}列表
* 查询${functionName} *
* * @param ${className} ${functionName}
* @param ${pkColumn.javaField} ${functionName}主键 * @return ${functionName}
* @return ${functionName} */
*/ @Override
@Override public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) {
{ return ${className}Mapper.select${ClassName}List(${className});
${ClassName} ${className} = ${className}Mapper.selectById(${pkColumn.javaField}); }
List<${subClassName}> ${subclassName}List = ${className}Mapper.select${subClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
${className}.set${subClassName}List(${subclassName}List);
return ${className};
}
/** #if($table.sub)
* 新增${functionName} /**
* * 新增${functionName}
* @param ${className} ${functionName} *
* @return 结果 * @param ${className} ${functionName}
*/ * @return 结果
@Transactional */
@Override @Transactional
public int insert${ClassName}(${ClassName} ${className}) @Override
{ public int insert${ClassName}(${ClassName} ${className})
int rows = ${className}Mapper.insert(${className}); {
insert${subClassName}(${className}); int rows = ${className}Mapper.insert(${className});
return rows; insert${subClassName}(${className});
} return rows;
}
/** /**
* 修改${functionName} * 修改${functionName}
* *
* @param ${className} ${functionName} * @param ${className} ${functionName}
* @return 结果 * @return 结果
*/ */
@Transactional @Transactional
@Override @Override
public int update${ClassName}(${ClassName} ${className}) public int update${ClassName}(${ClassName} ${className})
{ {
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}()); ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
insert${subClassName}(${className}); insert${subClassName}(${className});
return ${className}Mapper.updateById(${className}); return ${className}Mapper.updateById(${className});
} }
/** /**
* 批量删除${functionName} * 批量删除${functionName}
* *
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键 * @param ${pkColumn.javaField}s 需要删除的${functionName}主键
* @return 结果 * @return 结果
*/ */
@Transactional @Transactional
@Override @Override
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s) public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
{ {
List<${pkColumn.javaType}> ${pkColumn.javaField}List = Arrays.asList(${pkColumn.javaField}s); List<${pkColumn.javaType}> ${pkColumn.javaField}List = Arrays.asList(${pkColumn.javaField}s);
for (${pkColumn.javaType} ${pkColumn.javaField} : ${pkColumn.javaField}List) { for (${pkColumn.javaType} ${pkColumn.javaField} : ${pkColumn.javaField}List) {
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
} }
return ${className}Mapper.deleteBatchIds(${pkColumn.javaField}List); return ${className}Mapper.deleteBatchIds(${pkColumn.javaField}List);
} }
/** /**
* 删除${functionName}信息 * 删除${functionName}信息
* *
* @param ${pkColumn.javaField} ${functionName}主键 * @param ${pkColumn.javaField} ${functionName}主键
* @return 结果 * @return 结果
*/ */
@Transactional @Transactional
@Override @Override
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{ {
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField}); ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
return ${className}Mapper.deleteById(${pkColumn.javaField}); return ${className}Mapper.deleteById(${pkColumn.javaField});
} }
/** /**
* 新增${subTable.functionName}信息 * 新增${subTable.functionName}信息
* *
* @param ${className} ${functionName}对象 * @param ${className} ${functionName}对象
*/ */
private void insert${subClassName}(${ClassName} ${className}) private void insert${subClassName}(${ClassName} ${className})
{ {
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List(); List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}(); ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
if (StringUtils.isNotNull(${subclassName}List)) { if (StringUtils.isNotNull(${subclassName}List)) {
for (${subClassName} ${subclassName} : ${subclassName}List) { for (${subClassName} ${subclassName} : ${subclassName}List) {
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField}); ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
} }
${className}Mapper.batchInsert${subClassName}(${subclassName}List); ${className}Mapper.batchInsert${subClassName}(${subclassName}List);
} }
} }
#end #end
private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName} query) { private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName} query) {
Map<String, Object> params = query.getParams(); Map<String, Object> params = query.getParams();
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
#foreach($column in $columns) #foreach($column in $columns)
#if($column.query) #if($column.query)
#set($queryType=$column.queryType) #set($queryType=$column.queryType)
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
#set($javaType=$column.javaType) #set($javaType=$column.javaType)
#set($columnName=$column.columnName) #set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($mpMethod=$column.queryType.toLowerCase()) #set($mpMethod=$column.queryType.toLowerCase())
#if($queryType != 'BETWEEN') #if($queryType != 'BETWEEN')
#if($javaType == 'String') #if($javaType == 'String')
#set($condition='StringUtils.isNotBlank(query.get'+$AttrName+'())') #set($condition='StringUtils.isNotBlank(query.get'+$AttrName+'())')
#else #else
#set($condition='query.get'+$AttrName+'() != null') #set($condition='query.get'+$AttrName+'() != null')
#end
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, query.get$AttrName());
#else
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
#end
#end
#if($column.javaField == 'createTime')
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
lqw.orderByDesc(${ClassName}::get$AttrName);
#end #end
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, query.get$AttrName());
#else
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
#end #end
#end return lqw;
#if($column.javaField == 'createTime') }
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
lqw.orderByDesc(${ClassName}::get$AttrName);
#end
#end
return lqw;
}
} }

@ -0,0 +1,36 @@
<?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="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
</resultMap>
#if($table.sub)
<resultMap type="${subClassName}" id="${subClassName}Result">
#foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end
</resultMap>
<select id="select${subClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultType="${packageName}.domain.${subClassName}">
select * from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}}
</select>
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}">
delete from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}}
</delete>
<insert id="batchInsert${subClassName}">
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values
<foreach item="item" index="index" collection="list" separator=",">
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end)
</foreach>
</insert>
#end
</mapper>

@ -1,36 +1,78 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.mapper.${ClassName}Mapper"> <mapper namespace="${packageName}.mapper.${ClassName}Mapper">
<resultMap type="${ClassName}" id="${ClassName}Result"> <resultMap type="${ClassName}" id="${ClassName}Result">
#foreach ($column in $columns) #foreach ($column in $columns)
<result property="${column.javaField}" column="${column.columnName}" /> <result property="${column.javaField}" column="${column.columnName}" />
#end
</resultMap>
#if($table.sub)
<resultMap type="${subClassName}" id="${subClassName}Result">
#foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="${column.columnName}" />
#end #end
</resultMap> </resultMap>
#if($table.sub)
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
<collection property="${subclassName}List" notNullColumn="sub_${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
</resultMap>
<select id="select${subClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultType="${packageName}.domain.${subClassName}"> <resultMap type="${subClassName}" id="${subClassName}Result">
select * from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}} #foreach ($column in $subTable.columns)
<result property="${column.javaField}" column="sub_${column.columnName}" />
#end
</resultMap>
#end
<sql id="select${ClassName}Vo">
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
</sql>
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
<include refid="select${ClassName}Vo"/>
<where>
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
#elseif($queryType == "NE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
#elseif($queryType == "GT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt; #{$javaField}</if>
#elseif($queryType == "GTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &gt;= #{$javaField}</if>
#elseif($queryType == "LT")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt; #{$javaField}</if>
#elseif($queryType == "LTE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName &lt;= #{$javaField}</if>
#elseif($queryType == "LIKE")
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
#elseif($queryType == "BETWEEN")
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
#end
#end
#end
</where>
</select> </select>
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="${pkColumn.javaType}"> <select id="select${ClassName}By${pkColumn.capJavaField}" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
delete from ${subTableName} where ${subTableFkName} = #{${pkColumn.javaField}} #if($table.crud || $table.tree)
</delete> <include refid="select${ClassName}Vo"/>
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
<insert id="batchInsert${subClassName}"> #elseif($table.sub)
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($foreach.count != $subTable.columns.size()),#end#end) values select#foreach($column in $columns) a.$column.columnName#if($foreach.count != $columns.size()),#end#end,
<foreach item="item" index="index" collection="list" separator=","> #foreach($column in $subTable.columns) b.$column.columnName as sub_$column.columnName#if($foreach.count != $subTable.columns.size()),#end#end
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($foreach.count != $subTable.columns.size()),#end#end)
</foreach> from ${tableName} a
</insert> left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
#end where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
#end
</select>
</mapper> </mapper>

@ -15,7 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
* ehs_material * ehs_material
* *
* @author ruoyi * @author ruoyi
* @date 2023-12-01 * @date 2023-12-04
*/ */
@Data @Data
@ToString @ToString
@ -66,13 +66,6 @@ public class EhsMaterial extends BaseEntity
@Excel(name = "联系电话") @Excel(name = "联系电话")
private String tel; private String tel;
/** 创建者部门 */
private Long deptId;
/** 创建者id */
private Long createUserId;
/** 修改着id */
private Long updateUserId;
} }

@ -3,11 +3,28 @@ package com.ruoyi.ehsMaterial.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.ehsMaterial.domain.EhsMaterial; import com.ruoyi.ehsMaterial.domain.EhsMaterial;
import java.util.List;
/** /**
* Mapper * Mapper
* *
* @author ruoyi * @author ruoyi
* @date 2023-12-01 * @date 2023-12-04
*/ */
public interface EhsMaterialMapper extends BaseMapper<EhsMaterial> { public interface EhsMaterialMapper extends BaseMapper<EhsMaterial> {
/**
*
*
* @param materialId
* @return
*/
public EhsMaterial selectEhsMaterialByMaterialId(Long materialId);
/**
*
*
* @param ehsMaterial
* @return
*/
public List<EhsMaterial> selectEhsMaterialList(EhsMaterial ehsMaterial);
} }

@ -8,10 +8,18 @@ import com.ruoyi.ehsMaterial.domain.EhsMaterial;
* Service * Service
* *
* @author ruoyi * @author ruoyi
* @date 2023-12-01 * @date 2023-12-04
*/ */
public interface IEhsMaterialService extends IService<EhsMaterial> { public interface IEhsMaterialService extends IService<EhsMaterial> {
/**
*
*
* @param materialId
* @return
*/
public EhsMaterial selectEhsMaterialByMaterialId(Long materialId);
/** /**
* *
* *

@ -16,7 +16,7 @@ import com.ruoyi.ehsMaterial.service.IEhsMaterialService;
* Service * Service
* *
* @author ruoyi * @author ruoyi
* @date 2023-12-01 * @date 2023-12-04
*/ */
@Service @Service
public class EhsMaterialServiceImpl extends ServiceImpl<EhsMaterialMapper, EhsMaterial> implements IEhsMaterialService { public class EhsMaterialServiceImpl extends ServiceImpl<EhsMaterialMapper, EhsMaterial> implements IEhsMaterialService {
@ -24,6 +24,18 @@ public class EhsMaterialServiceImpl extends ServiceImpl<EhsMaterialMapper, EhsMa
@Autowired @Autowired
private EhsMaterialMapper ehsMaterialMapper; private EhsMaterialMapper ehsMaterialMapper;
/**
*
*
* @param materialId
* @return
*/
@Override
public EhsMaterial selectEhsMaterialByMaterialId(Long materialId)
{
return ehsMaterialMapper.selectEhsMaterialByMaterialId(materialId);
}
/** /**
* *
* *
@ -33,8 +45,7 @@ public class EhsMaterialServiceImpl extends ServiceImpl<EhsMaterialMapper, EhsMa
@Override @Override
public List<EhsMaterial> selectEhsMaterialList(EhsMaterial ehsMaterial) public List<EhsMaterial> selectEhsMaterialList(EhsMaterial ehsMaterial)
{ {
List<EhsMaterial> ehsMaterialList = ehsMaterialMapper.selectList(buildQueryWrapper(ehsMaterial)); return ehsMaterialMapper.selectEhsMaterialList(ehsMaterial);
return ehsMaterialList;
} }

@ -72,5 +72,4 @@ public class EhsRisk extends BaseEntity
/** 联系电话 */ /** 联系电话 */
@Excel(name = "联系电话") @Excel(name = "联系电话")
private String tel2; private String tel2;
} }

@ -3,6 +3,8 @@ package com.ruoyi.ehsRisk.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.ehsRisk.domain.EhsRisk; import com.ruoyi.ehsRisk.domain.EhsRisk;
import java.util.List;
/** /**
* Mapper * Mapper
* *
@ -10,4 +12,19 @@ import com.ruoyi.ehsRisk.domain.EhsRisk;
* @date 2023-11-30 * @date 2023-11-30
*/ */
public interface EhsRiskMapper extends BaseMapper<EhsRisk> { public interface EhsRiskMapper extends BaseMapper<EhsRisk> {
/**
*
*
* @param riskId
* @return
*/
public EhsRisk selectEhsRiskByRiskId(Long riskId);
/**
*
*
* @param ehsRisk
* @return
*/
public List<EhsRisk> selectEhsRiskList(EhsRisk ehsRisk);
} }

@ -12,6 +12,14 @@ import com.ruoyi.ehsRisk.domain.EhsRisk;
*/ */
public interface IEhsRiskService extends IService<EhsRisk> { public interface IEhsRiskService extends IService<EhsRisk> {
/**
*
*
* @param riskId
* @return
*/
public EhsRisk selectEhsRiskByRiskId(Long riskId);
/** /**
* *
* *
@ -19,5 +27,4 @@ public interface IEhsRiskService extends IService<EhsRisk> {
* @return * @return
*/ */
public List<EhsRisk> selectEhsRiskList(EhsRisk ehsRisk); public List<EhsRisk> selectEhsRiskList(EhsRisk ehsRisk);
} }

@ -3,6 +3,7 @@ package com.ruoyi.ehsRisk.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ehsRisk.domain.EhsRisk; import com.ruoyi.ehsRisk.domain.EhsRisk;
import com.ruoyi.ehsRisk.mapper.EhsRiskMapper; import com.ruoyi.ehsRisk.mapper.EhsRiskMapper;
import com.ruoyi.ehsRisk.service.IEhsRiskService; import com.ruoyi.ehsRisk.service.IEhsRiskService;
@ -23,6 +24,17 @@ public class EhsRiskServiceImpl extends ServiceImpl<EhsRiskMapper, EhsRisk> impl
@Autowired @Autowired
private EhsRiskMapper ehsRiskMapper; private EhsRiskMapper ehsRiskMapper;
/**
*
*
* @param riskId
* @return
*/
@Override
public EhsRisk selectEhsRiskByRiskId(Long riskId)
{
return ehsRiskMapper.selectEhsRiskByRiskId(riskId);
}
/** /**
* *
@ -33,8 +45,11 @@ public class EhsRiskServiceImpl extends ServiceImpl<EhsRiskMapper, EhsRisk> impl
@Override @Override
public List<EhsRisk> selectEhsRiskList(EhsRisk ehsRisk) public List<EhsRisk> selectEhsRiskList(EhsRisk ehsRisk)
{ {
List<EhsRisk> ehsRiskList = ehsRiskMapper.selectList(buildQueryWrapper(ehsRisk)); if(SecurityUtils.getLoginUser().getUser().getDept().getParentId()!=null &&
return ehsRiskList; SecurityUtils.getLoginUser().getUser().getDept().getParentId().longValue()!=0){
ehsRisk.setDeptId(SecurityUtils.getLoginUser().getUser().getDept().getParentId().longValue());
}
return ehsRiskMapper.selectEhsRiskList(ehsRisk);
} }
@ -43,15 +58,18 @@ public class EhsRiskServiceImpl extends ServiceImpl<EhsRiskMapper, EhsRisk> impl
LambdaQueryWrapper<EhsRisk> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<EhsRisk> lqw = Wrappers.lambdaQuery();
lqw.eq(query.getRiskGrade() != null, EhsRisk::getRiskGrade, query.getRiskGrade()); lqw.eq(query.getRiskGrade() != null, EhsRisk::getRiskGrade, query.getRiskGrade());
lqw.eq(StringUtils.isNotBlank(query.getReportAddressType()), EhsRisk::getReportAddressType, query.getReportAddressType()); lqw.eq(StringUtils.isNotBlank(query.getReportAddressType()), EhsRisk::getReportAddressType, query.getReportAddressType());
lqw.eq(StringUtils.isNotBlank(query.getRiskLocation()), EhsRisk::getRiskLocation, query.getRiskLocation()); lqw.like(StringUtils.isNotBlank(query.getRiskLocation()), EhsRisk::getRiskLocation, query.getRiskLocation());
lqw.eq(StringUtils.isNotBlank(query.getTel()), EhsRisk::getTel, query.getTel()); lqw.like(StringUtils.isNotBlank(query.getTel()), EhsRisk::getTel, query.getTel());
lqw.eq(StringUtils.isNotBlank(query.getPeopleQuantity()), EhsRisk::getPeopleQuantity, query.getPeopleQuantity()); lqw.between(params.get("beginPeopleQuantity") != null && params.get("endPeopleQuantity") != null,
lqw.eq(StringUtils.isNotBlank(query.getMaterialsQuantity()), EhsRisk::getMaterialsQuantity, query.getMaterialsQuantity()); EhsRisk::getPeopleQuantity ,params.get("beginPeopleQuantity"), params.get("endPeopleQuantity"));
lqw.eq(StringUtils.isNotBlank(query.getRepairTeam()), EhsRisk::getRepairTeam, query.getRepairTeam()); lqw.between(params.get("beginMaterialsQuantity") != null && params.get("endMaterialsQuantity") != null,
lqw.eq(StringUtils.isNotBlank(query.getPersonResponsible()), EhsRisk::getPersonResponsible, query.getPersonResponsible()); EhsRisk::getMaterialsQuantity ,params.get("beginMaterialsQuantity"), params.get("endMaterialsQuantity"));
lqw.eq(StringUtils.isNotBlank(query.getVillagePersonResponsible()), EhsRisk::getVillagePersonResponsible, query.getVillagePersonResponsible()); lqw.between(params.get("beginRepairTeam") != null && params.get("endRepairTeam") != null,
lqw.eq(StringUtils.isNotBlank(query.getVillagePersonResponsible2()), EhsRisk::getVillagePersonResponsible2, query.getVillagePersonResponsible2()); EhsRisk::getRepairTeam ,params.get("beginRepairTeam"), params.get("endRepairTeam"));
lqw.eq(StringUtils.isNotBlank(query.getTel2()), EhsRisk::getTel2, query.getTel2()); lqw.like(StringUtils.isNotBlank(query.getPersonResponsible()), EhsRisk::getPersonResponsible, query.getPersonResponsible());
lqw.like(StringUtils.isNotBlank(query.getVillagePersonResponsible()), EhsRisk::getVillagePersonResponsible, query.getVillagePersonResponsible());
lqw.like(StringUtils.isNotBlank(query.getVillagePersonResponsible2()), EhsRisk::getVillagePersonResponsible2, query.getVillagePersonResponsible2());
lqw.like(StringUtils.isNotBlank(query.getTel2()), EhsRisk::getTel2, query.getTel2());
lqw.orderByDesc(EhsRisk::getCreateTime); lqw.orderByDesc(EhsRisk::getCreateTime);
return lqw; return lqw;
} }

@ -115,4 +115,12 @@ public interface SysDeptMapper
* @return * @return
*/ */
public int deleteDeptById(Long deptId); public int deleteDeptById(Long deptId);
/**
* idname
*
* @param dept
* @return
*/
public List<SysDept> selectAllDeptList(SysDept dept);
} }

@ -121,4 +121,11 @@ public interface ISysDeptService
* @return * @return
*/ */
public int deleteDeptById(Long deptId); public int deleteDeptById(Long deptId);
/**
* idname
*
* @param dept
* @return
*/
public List<SysDept> selectAllDeptList(SysDept dept);
} }

@ -335,4 +335,14 @@ public class SysDeptServiceImpl implements ISysDeptService
{ {
return getChildList(list, t).size() > 0; return getChildList(list, t).size() > 0;
} }
/**
* idname
*
* @param dept
* @return
*/
public List<SysDept> selectAllDeptList(SysDept dept){
return deptMapper.selectAllDeptList(dept);
}
} }

@ -1,29 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.ehsMaterial.mapper.EhsMaterialMapper"> <mapper namespace="com.ruoyi.ehsMaterial.mapper.EhsMaterialMapper">
<resultMap type="EhsMaterial" id="EhsMaterialResult"> <resultMap type="EhsMaterial" id="EhsMaterialResult">
<result property="materialId" column="material_id" /> <result property="materialId" column="material_id" />
<result property="materialType" column="material_type" /> <result property="materialType" column="material_type" />
<result property="classFirst" column="class_first" /> <result property="classFirst" column="class_first" />
<result property="classSecond" column="class_second" /> <result property="classSecond" column="class_second" />
<result property="materialName" column="material_name" /> <result property="materialName" column="material_name" />
<result property="materialSpecs" column="material_specs" /> <result property="materialSpecs" column="material_specs" />
<result property="materialQuantity" column="material_quantity" /> <result property="materialQuantity" column="material_quantity" />
<result property="reserveLocation" column="reserve_location" /> <result property="reserveLocation" column="reserve_location" />
<result property="managerPerson" column="Manager_person" /> <result property="managerPerson" column="Manager_person" />
<result property="tel" column="tel" /> <result property="tel" column="tel" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="deptId" column="dept_id" /> <result property="deptId" column="dept_id" />
<result property="createUserId" column="create_user_id" /> <result property="createUserId" column="create_user_id" />
<result property="updateUserId" column="update_user_id" /> <result property="updateUserId" column="update_user_id" />
</resultMap> </resultMap>
<sql id="selectEhsMaterialVo">
select material_id, material_type, class_first, class_second, material_name, material_specs, material_quantity, reserve_location, Manager_person, tel, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_material
</sql>
<select id="selectEhsMaterialList" parameterType="EhsMaterial" resultMap="EhsMaterialResult">
<include refid="selectEhsMaterialVo"/>
<where>
<if test="materialType != null "> and material_type = #{materialType}</if>
<if test="classFirst != null "> and class_first = #{classFirst}</if>
<if test="classSecond != null and classSecond != ''"> and class_second = #{classSecond}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="materialSpecs != null and materialSpecs != ''"> and material_specs = #{materialSpecs}</if>
<if test="materialQuantity != null and materialQuantity != ''"> and material_quantity = #{materialQuantity}</if>
<if test="reserveLocation != null and reserveLocation != ''"> and reserve_location like concat('%', #{reserveLocation}, '%')</if>
<if test="managerPerson != null and managerPerson != ''"> and Manager_person like concat('%', #{managerPerson}, '%')</if>
<if test="tel != null and tel != ''"> and tel like concat('%', #{tel}, '%')</if>
</where>
</select>
<select id="selectEhsMaterialByMaterialId" parameterType="Long" resultMap="EhsMaterialResult">
<include refid="selectEhsMaterialVo"/>
where material_id = #{materialId}
</select>
</mapper> </mapper>

@ -2,7 +2,7 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.EhsRiskMapper"> <mapper namespace="com.ruoyi.ehsRisk.mapper.EhsRiskMapper">
<resultMap type="EhsRisk" id="EhsRiskResult"> <resultMap type="EhsRisk" id="EhsRiskResult">
<result property="riskId" column="risk_id" /> <result property="riskId" column="risk_id" />
@ -22,7 +22,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" />
<result property="createUserId" column="create_user_id" />
<result property="updateUserId" column="update_user_id" />
</resultMap> </resultMap>
<sql id="selectEhsRiskVo">
select r.*, d.dept_name
from ehs_risk r left join sys_dept d on r.dept_id = d.dept_id
</sql>
<select id="selectEhsRiskList" parameterType="EhsRisk" resultMap="EhsRiskResult">
<include refid="selectEhsRiskVo"/>
<where>
<if test="deptId != null "> and r.dept_Id = #{deptId}</if>
<if test="riskGrade != null "> and risk_grade = #{riskGrade}</if>
<if test="reportAddressType != null and reportAddressType != ''"> and report_address_type = #{reportAddressType}</if>
<if test="riskLocation != null and riskLocation != ''"> and risk_location like concat('%', #{riskLocation}, '%')</if>
<if test="tel != null and tel != ''"> and tel like concat('%', #{tel}, '%')</if>
<if test="params.beginPeopleQuantity != null and params.beginPeopleQuantity != '' and params.endPeopleQuantity != null and params.endPeopleQuantity != ''"> and people_quantity between #{params.beginPeopleQuantity} and #{params.endPeopleQuantity}</if>
<if test="params.beginMaterialsQuantity != null and params.beginMaterialsQuantity != '' and params.endMaterialsQuantity != null and params.endMaterialsQuantity != ''"> and materials_quantity between #{params.beginMaterialsQuantity} and #{params.endMaterialsQuantity}</if>
<if test="params.beginRepairTeam != null and params.beginRepairTeam != '' and params.endRepairTeam != null and params.endRepairTeam != ''"> and repair_team between #{params.beginRepairTeam} and #{params.endRepairTeam}</if>
<if test="personResponsible != null and personResponsible != ''"> and person_responsible like concat('%', #{personResponsible}, '%')</if>
<if test="villagePersonResponsible != null and villagePersonResponsible != ''"> and village_person_responsible like concat('%', #{villagePersonResponsible}, '%')</if>
<if test="villagePersonResponsible2 != null and villagePersonResponsible2 != ''"> and village_person_responsible2 like concat('%', #{villagePersonResponsible2}, '%')</if>
<if test="tel2 != null and tel2 != ''"> and tel2 like concat('%', #{tel2}, '%')</if>
</where>
</select>
<select id="selectEhsRiskByRiskId" parameterType="Long" resultMap="EhsRiskResult">
<include refid="selectEhsRiskVo"/>
where risk_id = #{riskId}
</select>
</mapper> </mapper>

@ -57,7 +57,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
<select id="selectAllDeptList" parameterType="SysDept" resultMap="SysDeptResult">
select d.dept_id,d.dept_name
from sys_dept d
order by d.order_num
</select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name (select dept_name from sys_dept where dept_id = d.parent_id) parent_name

@ -50,3 +50,11 @@ export function delDept(deptId) {
method: 'delete' method: 'delete'
}) })
} }
//查询所有部门数据的id和name
export function listAllDept() {
return request({
url: '/system/dept/getAllDeptList',
method: 'get'
})
}

@ -29,6 +29,12 @@ const user = {
}, },
SET_PERMISSIONS: (state, permissions) => { SET_PERMISSIONS: (state, permissions) => {
state.permissions = permissions state.permissions = permissions
},
SET_PARENTID: (state, parentId) => {
state.parentId = parentId
},
SET_DEPTID: (state, deptid) => {
state.deptId = deptid
} }
}, },
@ -65,6 +71,8 @@ const user = {
commit('SET_ID', user.userId) commit('SET_ID', user.userId)
commit('SET_NAME', user.userName) commit('SET_NAME', user.userName)
commit('SET_AVATAR', avatar) commit('SET_AVATAR', avatar)
commit('SET_PARENTID', user.dept.parentId)
commit('SET_DEPTID', user.dept.deptId)
resolve(res) resolve(res)
}).catch(error => { }).catch(error => {
reject(error) reject(error)

@ -1,22 +1,25 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="类别" prop="classFirst"> <!-- <el-form-item label="类别" prop="classFirst">
<el-input <el-input
v-model="queryParams.classFirst" v-model="queryParams.classFirst"
placeholder="请输入类别" placeholder="请输入类别"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item>-->
<el-form-item label="类别" prop="classSecond">
<el-select v-model="queryParams.classSecond" placeholder="请选择类别" clearable>
<el-option
v-for="dict in curDict"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="类别" prop="classSecond">
<el-input
v-model="queryParams.classSecond"
placeholder="请输入类别"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="物资名称" prop="materialName"> <el-form-item label="物资名称" prop="materialName">
<el-input <el-input
v-model="queryParams.materialName" v-model="queryParams.materialName"
@ -124,7 +127,7 @@
<el-table-column label="类别" align="center" prop="classFirst" /> <el-table-column label="类别" align="center" prop="classFirst" />
<el-table-column label="类别" align="center" prop="classSecond"> <el-table-column label="类别" align="center" prop="classSecond">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.material_class_1" :value="scope.row.classSecond"/> <dict-tag :options="curDict" :value="scope.row.classSecond"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="物资名称" align="center" prop="materialName" /> <el-table-column label="物资名称" align="center" prop="materialName" />
@ -164,11 +167,18 @@
<!-- 添加或修改物资信息包含 通用应急救援装备防汛抗旱应急救援装备森林防灭火应急救援装备救灾物资对话框 --> <!-- 添加或修改物资信息包含 通用应急救援装备防汛抗旱应急救援装备森林防灭火应急救援装备救灾物资对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="类别" prop="classFirst"> <!--<el-form-item label="类别" prop="classFirst">
<el-input v-model="form.classFirst" placeholder="请输入类别" /> <el-input v-model="form.classFirst" placeholder="请输入类别" />
</el-form-item> </el-form-item>-->
<el-form-item label="类别" prop="classSecond"> <el-form-item label="类别" prop="classSecond">
<el-input v-model="form.classSecond" placeholder="请输入类别" /> <el-select v-model="form.classSecond" placeholder="请选择类别">
<el-option
v-for="dict in curDict"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="物资名称" prop="materialName"> <el-form-item label="物资名称" prop="materialName">
<el-input v-model="form.materialName" placeholder="请输入物资名称" /> <el-input v-model="form.materialName" placeholder="请输入物资名称" />
@ -191,15 +201,6 @@
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
<el-form-item label="创建者部门" prop="deptId">
<el-input v-model="form.deptId" placeholder="请输入创建者部门" />
</el-form-item>
<el-form-item label="创建者id" prop="createUserId">
<el-input v-model="form.createUserId" placeholder="请输入创建者id" />
</el-form-item>
<el-form-item label="修改着id" prop="updateUserId">
<el-input v-model="form.updateUserId" placeholder="请输入修改着id" />
</el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
@ -210,161 +211,195 @@
</template> </template>
<script> <script>
import { listEhsMaterial, getEhsMaterial, delEhsMaterial, addEhsMaterial, updateEhsMaterial } from "@/api/ehs/ehsMaterial"; import { listEhsMaterial, getEhsMaterial, delEhsMaterial, addEhsMaterial, updateEhsMaterial } from "@/api/ehs/ehsMaterial";
import { getDicts } from "@/api/system/dict/data";
export default {
name: "EhsMaterial",
// dicts: ['material_class_1','material_class_2','material_class_3','material_class_4'],
export default { data() {
name: "EhsMaterial", return {
data() { curDict:[],
return { //
// loading: true,
loading: true, //
// ids: [],
ids: [], //
// single: true,
single: true, //
// multiple: true,
multiple: true, //
// showSearch: true,
showSearch: true, //
// total: 0,
total: 0, //
// ehsMaterialList: [],
ehsMaterialList: [], //
// title: "",
title: "", //
// open: false,
open: false, materialClass:0,
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
materialType: null, materialType: null,
classFirst: null, classFirst: null,
classSecond: null, classSecond: null,
materialName: null, materialName: null,
materialSpecs: null, materialSpecs: null,
materialQuantity: null, materialQuantity: null,
reserveLocation: null, reserveLocation: null,
managerPerson: null, managerPerson: null,
tel: null, tel: null,
}, classFirst:this.$route.query.classFirst
// },
form: {}, //
// form: {
rules: { classFirst:this.$route.query.classFirst
} },
}; //
}, rules: {
created() { }
this.getList();
},
methods: {
/** 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表 */
getList() {
this.loading = true;
listEhsMaterial(this.queryParams).then(response => {
this.ehsMaterialList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
materialId: null,
materialType: null,
classFirst: null,
classSecond: null,
materialName: null,
materialSpecs: null,
materialQuantity: null,
reserveLocation: null,
managerPerson: null,
tel: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
deptId: null,
createUserId: null,
updateUserId: null
}; };
this.resetForm("form");
}, },
/** 搜索按钮操作 */ created() {
handleQuery() {
this.queryParams.pageNum = 1;
this.getList(); this.getList();
this.materialClass = this.$route.query.classFirst;
this.getDictList();
}, },
/** 重置按钮操作 */
resetQuery() { methods: {
this.resetForm("queryForm"); /** 查询物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”列表 */
this.handleQuery(); getList() {
}, this.loading = true;
// listEhsMaterial(this.queryParams).then(response => {
handleSelectionChange(selection) { this.ehsMaterialList = response.rows;
this.ids = selection.map(item => item.materialId) this.total = response.total;
this.single = selection.length!==1 this.loading = false;
this.multiple = !selection.length });
}, },
/** 新增按钮操作 */ getDictList() {
handleAdd() { this.loading = true;
this.reset(); let str = "";
this.open = true; if(this.materialClass ==1)
this.title = "添加物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”"; str = "material_class_1";
}, else if(this.materialClass ==2)
/** 修改按钮操作 */ str = "material_class_2";
handleUpdate(row) { else if(this.materialClass ==3)
this.reset(); str = "material_class_3";
const materialId = row.materialId || this.ids else if(this.materialClass ==4)
getEhsMaterial(materialId).then(response => { str = "material_class_4";
this.form = response.data; else
this.open = true; str = this.materialClass;
this.title = "修改物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”"; getDicts(str).then(response => {
}); if(response.data!=null) {
}, response.data.forEach(item => {
/** 提交按钮 */ console.log(item);
submitForm() { this.curDict.push({"label": item.dictLabel, "value": item.dictValue})
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.materialId != null) {
updateEhsMaterial(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addEhsMaterial(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}); });
} }
} this.loading = false;
}); });
}, },
/** 删除按钮操作 */ //
handleDelete(row) { cancel() {
const materialIds = row.materialId || this.ids; this.open = false;
this.$modal.confirm('是否确认删除物资信息包含 通用应急救援装备”“防汛抗旱应急救援装备”“森林防灭火应急救援装备”“救灾物资”编号为"' + materialIds + '"的数据项?').then(function() { this.reset();
return delEhsMaterial(materialIds); },
}).then(() => { //
reset() {
this.form = {
materialId: null,
materialType: null,
classFirst: null,
classSecond: null,
materialName: null,
materialSpecs: null,
materialQuantity: null,
reserveLocation: null,
managerPerson: null,
tel: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null,
deptId: null,
createUserId: null,
updateUserId: null,
classFirst:this.$route.query.classFirst
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); },
}).catch(() => {}); /** 重置按钮操作 */
}, resetQuery() {
/** 导出按钮操作 */ this.resetForm("queryForm");
handleExport() { this.handleQuery();
this.download('ehsMaterial/ehsMaterial/export', { },
...this.queryParams //
}, `ehsMaterial_${new Date().getTime()}.xlsx`) handleSelectionChange(selection) {
this.ids = selection.map(item => item.materialId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加物资信息包含";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const materialId = row.materialId || this.ids
getEhsMaterial(materialId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改物资信息";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.materialId != null) {
updateEhsMaterial(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addEhsMaterial(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const materialIds = row.materialId || this.ids;
this.$modal.confirm('是否确认删除物资信息' + materialIds + '"的数据项?').then(function() {
return delEhsMaterial(materialIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('ehsMaterial/ehsMaterial/export', {
...this.queryParams
}, `ehsMaterial_${new Date().getTime()}.xlsx`)
}
} }
} };
};
</script> </script>

@ -1,6 +1,16 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="部门" prop="deptId" v-show="deptShow">
<el-select v-model="queryParams.deptId" placeholder="请选择部门" clearable>
<el-option
v-for="dict in allDeptList"
:key="dict.deptId"
:label="dict.deptName"
:value="dict.deptId"
/>
</el-select>
</el-form-item>
<el-form-item label="风险点等级" prop="riskGrade"> <el-form-item label="风险点等级" prop="riskGrade">
<el-select v-model="queryParams.riskGrade" placeholder="请选择风险点等级" clearable> <el-select v-model="queryParams.riskGrade" placeholder="请选择风险点等级" clearable>
<el-option <el-option
@ -158,6 +168,7 @@
<dict-tag :options="dict.type.risk_report_address_type" :value="scope.row.reportAddressType"/> <dict-tag :options="dict.type.risk_report_address_type" :value="scope.row.reportAddressType"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="上报单位" align="center" prop="deptName" />
<el-table-column label="风险点位置" align="center" prop="riskLocation" /> <el-table-column label="风险点位置" align="center" prop="riskLocation" />
<el-table-column label="联系电话" align="center" prop="tel" /> <el-table-column label="联系电话" align="center" prop="tel" />
<el-table-column label="涉及群众数量" align="center" prop="peopleQuantity" /> <el-table-column label="涉及群众数量" align="center" prop="peopleQuantity" />
@ -260,7 +271,7 @@
<script> <script>
import { listRisk, getRisk, delRisk, addRisk, updateRisk } from "@/api/ehs/ehsRisk"; import { listRisk, getRisk, delRisk, addRisk, updateRisk } from "@/api/ehs/ehsRisk";
import {listAllDept } from "@/api/system/dept";
export default { export default {
name: "Risk", name: "Risk",
dicts: ['risk_grade', 'risk_report_address_type'], dicts: ['risk_grade', 'risk_report_address_type'],
@ -280,10 +291,14 @@ export default {
total: 0, total: 0,
// //
riskList: [], riskList: [],
//
allDeptList: [],
// //
title: "", title: "",
// //
open: false, open: false,
//
deptShow: false,
// //
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
@ -309,6 +324,8 @@ export default {
}, },
created() { created() {
this.getList(); this.getList();
this.getListAllDept();
this.deptShow = this.$store.state.user.parentId==0 ?true :false;
}, },
methods: { methods: {
/** 查询风险信息列表 */ /** 查询风险信息列表 */
@ -320,6 +337,15 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
/** 单位信息列表 */
getListAllDept() {
console.log(this.$store.state.user.deptId);
this.loading = true;
listAllDept().then(response => {
this.allDeptList = response.data;
this.loading = false;
});
},
// //
cancel() { cancel() {
this.open = false; this.open = false;

Loading…
Cancel
Save