部门管理增加省市区等
This commit is contained in:
parent
1c45d971b5
commit
09bd0e2cda
|
@ -11,8 +11,12 @@ import java.net.URLDecoder;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nu.modules.nuBizAdvisoryInfo.entity.NuBizAdvisoryInfo;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
|
@ -31,6 +35,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
|
|||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.commons.util.IdUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
@ -41,128 +46,148 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @Description: 护理单元
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-04-11
|
||||
* @Date: 2025-04-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="护理单元")
|
||||
@Api(tags = "护理单元")
|
||||
@RestController
|
||||
@RequestMapping("/nuBaseInfo/nuBaseInfo")
|
||||
@Slf4j
|
||||
public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInfoService> {
|
||||
@Autowired
|
||||
private INuBaseInfoService nuBaseInfoService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param nuBaseInfo
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "护理单元-分页列表查询")
|
||||
@ApiOperation(value="护理单元-分页列表查询", notes="护理单元-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<NuBaseInfo>> queryPageList(NuBaseInfo nuBaseInfo,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
customeRuleMap.put("area_flag", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("status", QueryRuleEnum.LIKE_WITH_OR);
|
||||
QueryWrapper<NuBaseInfo> queryWrapper = QueryGenerator.initQueryWrapper(nuBaseInfo, req.getParameterMap(),customeRuleMap);
|
||||
Page<NuBaseInfo> page = new Page<NuBaseInfo>(pageNo, pageSize);
|
||||
IPage<NuBaseInfo> pageList = nuBaseInfoService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param nuBaseInfo
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-添加")
|
||||
@ApiOperation(value="护理单元-添加", notes="护理单元-添加")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody NuBaseInfo nuBaseInfo) {
|
||||
nuBaseInfoService.save(nuBaseInfo);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param nuBaseInfo
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-编辑")
|
||||
@ApiOperation(value="护理单元-编辑", notes="护理单元-编辑")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody NuBaseInfo nuBaseInfo) {
|
||||
nuBaseInfoService.updateById(nuBaseInfo);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-通过id删除")
|
||||
@ApiOperation(value="护理单元-通过id删除", notes="护理单元-通过id删除")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
nuBaseInfoService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-批量删除")
|
||||
@ApiOperation(value="护理单元-批量删除", notes="护理单元-批量删除")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.nuBaseInfoService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "护理单元-通过id查询")
|
||||
@ApiOperation(value="护理单元-通过id查询", notes="护理单元-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<NuBaseInfo> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
NuBaseInfo nuBaseInfo = nuBaseInfoService.getById(id);
|
||||
if(nuBaseInfo==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(nuBaseInfo);
|
||||
}
|
||||
@Autowired
|
||||
private INuBaseInfoService nuBaseInfoService;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param nuBaseInfo
|
||||
*/
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param nuBaseInfo
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "护理单元-分页列表查询")
|
||||
@ApiOperation(value = "护理单元-分页列表查询", notes = "护理单元-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<NuBaseInfo>> queryPageList(NuBaseInfo nuBaseInfo,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
customeRuleMap.put("area_flag", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("status", QueryRuleEnum.LIKE_WITH_OR);
|
||||
QueryWrapper<NuBaseInfo> queryWrapper = QueryGenerator.initQueryWrapper(nuBaseInfo, req.getParameterMap(), customeRuleMap);
|
||||
Page<NuBaseInfo> page = new Page<NuBaseInfo>(pageNo, pageSize);
|
||||
IPage<NuBaseInfo> pageList = nuBaseInfoService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param nuBaseInfo
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-添加")
|
||||
@ApiOperation(value = "护理单元-添加", notes = "护理单元-添加")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody NuBaseInfo nuBaseInfo) {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String orgCode = deptInfo.getString("code");
|
||||
if (StringUtils.isBlank(orgCode)) {
|
||||
throw new RuntimeException("请先在部门管理中设置机构编码!");
|
||||
}
|
||||
try {
|
||||
Integer code = nuBaseInfoService.getCode();
|
||||
if (code == null) {
|
||||
nuBaseInfo.setCode(orgCode + "-001");
|
||||
} else {
|
||||
//保证3位字符串 不足前面用0补全
|
||||
String codeStr = String.format("%03d", code + 1);
|
||||
nuBaseInfo.setCode(orgCode + "-" + codeStr);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
nuBaseInfo.setCode(orgCode + "-" + IdUtil.simpleUUID());
|
||||
}
|
||||
nuBaseInfoService.save(nuBaseInfo);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param nuBaseInfo
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-编辑")
|
||||
@ApiOperation(value = "护理单元-编辑", notes = "护理单元-编辑")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody NuBaseInfo nuBaseInfo) {
|
||||
nuBaseInfoService.updateById(nuBaseInfo);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-通过id删除")
|
||||
@ApiOperation(value = "护理单元-通过id删除", notes = "护理单元-通过id删除")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
nuBaseInfoService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "护理单元-批量删除")
|
||||
@ApiOperation(value = "护理单元-批量删除", notes = "护理单元-批量删除")
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.nuBaseInfoService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "护理单元-通过id查询")
|
||||
@ApiOperation(value = "护理单元-通过id查询", notes = "护理单元-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<NuBaseInfo> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
NuBaseInfo nuBaseInfo = nuBaseInfoService.getById(id);
|
||||
if (nuBaseInfo == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(nuBaseInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param nuBaseInfo
|
||||
*/
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, NuBaseInfo nuBaseInfo) {
|
||||
|
@ -170,12 +195,12 @@ public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInf
|
|||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("nuBaseInfo:nu_base_info:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
|
|
|
@ -42,6 +42,10 @@ public class NuBaseInfo implements Serializable {
|
|||
@Excel(name = "护理单元名称", width = 15)
|
||||
@ApiModelProperty(value = "护理单元名称")
|
||||
private java.lang.String nuName;
|
||||
/**护理单元编码*/
|
||||
@Excel(name = "护理单元编码", width = 15)
|
||||
@ApiModelProperty(value = "护理单元编码")
|
||||
private java.lang.String code;
|
||||
/**区域标签ID*/
|
||||
@Excel(name = "区域标签ID", width = 15, dicCode = "nu_type")
|
||||
@Dict(dicCode = "nu_type")
|
||||
|
|
|
@ -14,4 +14,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
*/
|
||||
public interface NuBaseInfoMapper extends BaseMapper<NuBaseInfo> {
|
||||
|
||||
Integer getCode();
|
||||
|
||||
}
|
||||
|
|
|
@ -2,4 +2,9 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.nuBaseInfo.mapper.NuBaseInfoMapper">
|
||||
|
||||
</mapper>
|
||||
<select id="getCode" resultType="java.lang.Integer">
|
||||
SELECT MAX(CAST(SUBSTRING_INDEX(code, '-', -1) AS UNSIGNED)) AS max_number
|
||||
FROM nu_base_info
|
||||
WHERE SUBSTRING_INDEX(code, '-', -1) REGEXP '^[0-9]+$';
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
*/
|
||||
public interface INuBaseInfoService extends IService<NuBaseInfo> {
|
||||
|
||||
Integer getCode();
|
||||
}
|
||||
|
|
|
@ -16,4 +16,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
@Service
|
||||
public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseInfo> implements INuBaseInfoService {
|
||||
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
return baseMapper.getCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ public class AppCameraInfo implements Serializable {
|
|||
private String topTime;
|
||||
/**护理单元*/
|
||||
@ApiModelProperty(value = "护理单元ID")
|
||||
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "id")
|
||||
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "code")
|
||||
private String nuId;
|
||||
/**护理单元*/
|
||||
@ApiModelProperty(value = "护理单元")
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Component
|
||||
|
@ -24,22 +24,26 @@ public class SafetyUtil {
|
|||
* @param secureKey 客户端传入的密钥(MD5 值)
|
||||
* @return true=验证通过,false=验证失败
|
||||
*/
|
||||
|
||||
public static boolean validateSecureKey(String secureKey) {
|
||||
if (secureKey == null || downloadkey == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1. 获取当前日期(yyyyMMdd)
|
||||
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
// 获取当前时间(精确到分钟,格式为 yyyyMMddHHmm)
|
||||
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
|
||||
// 获取前一分钟的时间(用于扩大验证窗口)
|
||||
String previousMinute = LocalDateTime.now().minusMinutes(1).format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
|
||||
|
||||
// 2. 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentDate);
|
||||
|
||||
// 3. 计算 MD5
|
||||
// 验证当前时间的密钥
|
||||
String mixedKey = complexMix(downloadkey, currentTime);
|
||||
String md5Hash = calculateMD5(mixedKey);
|
||||
if (secureKey.equalsIgnoreCase(md5Hash)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4. 比较 secureKey 是否匹配(忽略大小写)
|
||||
// 验证前一分钟的密钥(扩大验证窗口)
|
||||
mixedKey = complexMix(downloadkey, previousMinute);
|
||||
md5Hash = calculateMD5(mixedKey);
|
||||
return secureKey.equalsIgnoreCase(md5Hash);
|
||||
}
|
||||
|
||||
|
@ -54,7 +58,6 @@ public class SafetyUtil {
|
|||
* 进行倒序
|
||||
* 3.每 3个字符插入一个固定干扰符 '#'
|
||||
*/
|
||||
|
||||
private static String complexMix(String key, String date) {
|
||||
StringBuilder mixed = new StringBuilder();
|
||||
|
||||
|
@ -102,19 +105,22 @@ public class SafetyUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前的安全密钥
|
||||
* 现在包含精确到分钟的时间信息(yyyyMMddHHmm)
|
||||
*/
|
||||
public static String getSecureKey() {
|
||||
if (downloadkey == null) {
|
||||
return "aaa";
|
||||
}
|
||||
|
||||
// 1. 获取当前日期(yyyyMMdd)
|
||||
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
// 获取当前时间(精确到分钟,格式为 yyyyMMddHHmm)
|
||||
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
|
||||
|
||||
// 2. 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentDate);
|
||||
// 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentTime);
|
||||
|
||||
// 3. 计算 MD5 并返回
|
||||
// 计算 MD5 并返回
|
||||
return calculateMD5(mixedKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,8 +132,8 @@ public class CameraInfo implements Serializable {
|
|||
@TableField(exist = false)
|
||||
private String topTime;
|
||||
/**护理单元*/
|
||||
@ApiModelProperty(value = "护理单元ID")
|
||||
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "id")
|
||||
@ApiModelProperty(value = "护理单元编码")
|
||||
@Dict(dictTable ="nu_base_info",dicText = "nu_name",dicCode = "code")
|
||||
private String nuId;
|
||||
/**护理单元*/
|
||||
@ApiModelProperty(value = "护理单元")
|
||||
|
|
|
@ -129,12 +129,12 @@
|
|||
|
||||
<select id="findNuPage" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
|
||||
select
|
||||
id as nuId,
|
||||
code as nuId,
|
||||
nu_name as nuName
|
||||
from nu_base_info b
|
||||
<where>
|
||||
<if test="params.nuId != null and params.nuId != ''">
|
||||
AND b.id = #{params.nuId}
|
||||
AND b.code = #{params.nuId}
|
||||
</if>
|
||||
<if test="params.nuName != null and params.nuName != ''">
|
||||
AND b.nu_name LIKE concat('%',#{params.nuName},'%')
|
||||
|
@ -262,4 +262,4 @@
|
|||
where device_index = #{deviceIndex}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-payment-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>nu-payment-local-api</artifactId>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-payment</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>nu-payment-api</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>nu-payment-local-api</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-base-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,35 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-payment</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>nu-payment-biz</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-payment-local-api</artifactId>
|
||||
<version>${nursingunit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>hibernate-re</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 企业微信/钉钉 api -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,186 @@
|
|||
package com.nu.modules.systemorder.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import com.nu.modules.systemorder.entity.SystemOrder;
|
||||
import com.nu.modules.systemorder.service.ISystemOrderService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="系统订单表")
|
||||
@RestController
|
||||
@RequestMapping("/systemorder/systemOrder")
|
||||
@Slf4j
|
||||
public class SystemOrderController extends JeecgController<SystemOrder, ISystemOrderService> {
|
||||
@Autowired
|
||||
private ISystemOrderService systemOrderService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param systemOrder
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "系统订单表-分页列表查询")
|
||||
@ApiOperation(value="系统订单表-分页列表查询", notes="系统订单表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<SystemOrder>> queryPageList(SystemOrder systemOrder,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
// 自定义查询规则
|
||||
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
|
||||
// 自定义多选的查询规则为:LIKE_WITH_OR
|
||||
customeRuleMap.put("nursingUnit", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("orderType", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("orderStatus", QueryRuleEnum.LIKE_WITH_OR);
|
||||
QueryWrapper<SystemOrder> queryWrapper = QueryGenerator.initQueryWrapper(systemOrder, req.getParameterMap(),customeRuleMap);
|
||||
Page<SystemOrder> page = new Page<SystemOrder>(pageNo, pageSize);
|
||||
IPage<SystemOrder> pageList = systemOrderService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param systemOrder
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-添加")
|
||||
@ApiOperation(value="系统订单表-添加", notes="系统订单表-添加")
|
||||
@RequiresPermissions("systemorder:nu_system_order:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody SystemOrder systemOrder) {
|
||||
systemOrderService.save(systemOrder);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param systemOrder
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-编辑")
|
||||
@ApiOperation(value="系统订单表-编辑", notes="系统订单表-编辑")
|
||||
@RequiresPermissions("systemorder:nu_system_order:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody SystemOrder systemOrder) {
|
||||
systemOrderService.updateById(systemOrder);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-通过id删除")
|
||||
@ApiOperation(value="系统订单表-通过id删除", notes="系统订单表-通过id删除")
|
||||
@RequiresPermissions("systemorder:nu_system_order:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
systemOrderService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "系统订单表-批量删除")
|
||||
@ApiOperation(value="系统订单表-批量删除", notes="系统订单表-批量删除")
|
||||
@RequiresPermissions("systemorder:nu_system_order:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.systemOrderService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "系统订单表-通过id查询")
|
||||
@ApiOperation(value="系统订单表-通过id查询", notes="系统订单表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SystemOrder> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SystemOrder systemOrder = systemOrderService.getById(id);
|
||||
if(systemOrder==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(systemOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param systemOrder
|
||||
*/
|
||||
@RequiresPermissions("systemorder:nu_system_order:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SystemOrder systemOrder) {
|
||||
return super.exportXls(request, systemOrder, SystemOrder.class, "系统订单表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("systemorder:nu_system_order:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SystemOrder.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package com.nu.modules.systemorder.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_system_order")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_system_order对象", description="系统订单表")
|
||||
public class SystemOrder implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private java.lang.String id;
|
||||
/**机构编码*/
|
||||
@Excel(name = "机构编码", width = 15)
|
||||
@ApiModelProperty(value = "机构编码")
|
||||
private java.lang.String orgCode;
|
||||
/**护理单元*/
|
||||
@Excel(name = "护理单元", width = 15)
|
||||
@ApiModelProperty(value = "护理单元")
|
||||
private java.lang.String nursingUnit;
|
||||
/**支付人的openId*/
|
||||
@Excel(name = "支付人的openId", width = 15)
|
||||
@ApiModelProperty(value = "支付人的openId")
|
||||
private java.lang.String openId;
|
||||
/**客户id(系统中的)*/
|
||||
@Excel(name = "客户id(系统中的)", width = 15)
|
||||
@ApiModelProperty(value = "客户id(系统中的)")
|
||||
private java.lang.String customerId;
|
||||
/**订单类型(字典order_type)*/
|
||||
@Excel(name = "订单类型(字典order_type)", width = 15, dicCode = "order_type")
|
||||
@Dict(dicCode = "order_type")
|
||||
@ApiModelProperty(value = "订单类型(字典order_type)")
|
||||
private java.lang.String orderType;
|
||||
/**金额*/
|
||||
@Excel(name = "金额", width = 15)
|
||||
@ApiModelProperty(value = "金额")
|
||||
private java.math.BigDecimal amount;
|
||||
/**下单时间*/
|
||||
@Excel(name = "下单时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "下单时间")
|
||||
private java.util.Date orderTime;
|
||||
/**回执时间*/
|
||||
@Excel(name = "回执时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "回执时间")
|
||||
private java.util.Date receiptTime;
|
||||
/**订单状态*/
|
||||
@Excel(name = "订单状态", width = 15)
|
||||
@ApiModelProperty(value = "订单状态")
|
||||
private java.lang.String orderStatus;
|
||||
/**订单名称*/
|
||||
@Excel(name = "订单名称", width = 15)
|
||||
@ApiModelProperty(value = "订单名称")
|
||||
private java.lang.String orderName;
|
||||
/**订单描述(咱们自己说明的跟微信支付回执没关系)*/
|
||||
@Excel(name = "订单描述(咱们自己说明的跟微信支付回执没关系)", width = 15)
|
||||
@ApiModelProperty(value = "订单描述(咱们自己说明的跟微信支付回执没关系)")
|
||||
private java.lang.String orderDescription;
|
||||
/**回执描述*/
|
||||
@Excel(name = "回执描述", width = 15)
|
||||
@ApiModelProperty(value = "回执描述")
|
||||
private java.lang.String receiptDescription;
|
||||
/**回执报文*/
|
||||
@Excel(name = "回执报文", width = 15)
|
||||
@ApiModelProperty(value = "回执报文")
|
||||
private java.lang.String receiptMessage;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.systemorder.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.systemorder.entity.SystemOrder;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SystemOrderMapper extends BaseMapper<SystemOrder> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?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.nu.modules.systemorder.mapper.SystemOrderMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,14 @@
|
|||
package com.nu.modules.systemorder.service;
|
||||
|
||||
import com.nu.modules.systemorder.entity.SystemOrder;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISystemOrderService extends IService<SystemOrder> {
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.nu.modules.systemorder.service.impl;
|
||||
|
||||
import com.nu.modules.systemorder.entity.SystemOrder;
|
||||
import com.nu.modules.systemorder.mapper.SystemOrderMapper;
|
||||
import com.nu.modules.systemorder.service.ISystemOrderService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 系统订单表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-05-30
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SystemOrderServiceImpl extends ServiceImpl<SystemOrderMapper, SystemOrder> implements ISystemOrderService {
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-parent</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</parent>
|
||||
<description>支付功能模块</description>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>nursing-unit-payment</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>nu-payment-api</module>
|
||||
<module>nu-payment-biz</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
|
@ -38,10 +38,10 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
|
@ -51,13 +51,14 @@ public class SysCategoryController {
|
|||
@Autowired
|
||||
private ISysCategoryService sysCategoryService;
|
||||
|
||||
/**
|
||||
* 分类编码0
|
||||
*/
|
||||
private static final String CATEGORY_ROOT_CODE = "0";
|
||||
/**
|
||||
* 分类编码0
|
||||
*/
|
||||
private static final String CATEGORY_ROOT_CODE = "0";
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysCategory
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
|
@ -66,17 +67,14 @@ public class SysCategoryController {
|
|||
*/
|
||||
@GetMapping(value = "/rootList")
|
||||
public Result<IPage<SysCategory>> queryPageList(SysCategory sysCategory,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
sysCategory.setPid("0");
|
||||
}
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SysCategory>> result = new Result<IPage<SysCategory>>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -86,8 +84,8 @@ public class SysCategoryController {
|
|||
String name = sysCategory.getName();
|
||||
String code = sysCategory.getCode();
|
||||
//QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<SysCategory>();
|
||||
if(StringUtils.isBlank(name)&&StringUtils.isBlank(code)){
|
||||
queryWrapper.eq("pid", sysCategory.getPid());
|
||||
if (StringUtils.isBlank(name) && StringUtils.isBlank(code)) {
|
||||
queryWrapper.eq("pid","0");
|
||||
}
|
||||
//--author:liusq---date:20211119 -----for: 分类字典页面查询条件配置--------end
|
||||
//--author:os_chengtgen---date:20190804 -----for:【vue3】 分类字典页面显示错误,issues:377--------end
|
||||
|
@ -100,15 +98,16 @@ public class SysCategoryController {
|
|||
}
|
||||
|
||||
@GetMapping(value = "/childList")
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory,HttpServletRequest req) {
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory, HttpServletRequest req) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Result<List<SysCategory>> result = new Result<List<SysCategory>>();
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
queryWrapper.orderByAsc("code");
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(list);
|
||||
|
@ -117,7 +116,8 @@ public class SysCategoryController {
|
|||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* 添加
|
||||
*
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
|
@ -128,24 +128,25 @@ public class SysCategoryController {
|
|||
sysCategoryService.addSysCategory(sysCategory);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("编码重复!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* 编辑
|
||||
*
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT,RequestMethod.POST })
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<SysCategory> edit(@RequestBody SysCategory sysCategory) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId());
|
||||
if(sysCategoryEntity==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
if (sysCategoryEntity == null) {
|
||||
result.error500("编码重复!");
|
||||
} else {
|
||||
sysCategoryService.updateSysCategory(sysCategory);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
|
@ -153,17 +154,18 @@ public class SysCategoryController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<SysCategory> delete(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<SysCategory> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
if (sysCategory == null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
} else {
|
||||
this.sysCategoryService.deleteSysCategory(id);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
|
@ -172,16 +174,17 @@ public class SysCategoryController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<SysCategory> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
public Result<SysCategory> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
}else {
|
||||
} else {
|
||||
this.sysCategoryService.deleteSysCategory(ids);
|
||||
result.success("删除成功!");
|
||||
}
|
||||
|
@ -189,170 +192,170 @@ public class SysCategoryController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SysCategory> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<SysCategory> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
if (sysCategory == null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
} else {
|
||||
result.setResult(sysCategory);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step.1 组装查询条件查询数据
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap());
|
||||
List<SysCategory> pageList = sysCategoryService.list(queryWrapper);
|
||||
// Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if(oConvertUtils.isEmpty(selections)) {
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
}else {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
}
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
return mv;
|
||||
}
|
||||
// Step.1 组装查询条件查询数据
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap());
|
||||
List<SysCategory> pageList = sysCategoryService.list(queryWrapper);
|
||||
// Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if (oConvertUtils.isEmpty(selections)) {
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
} else {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
}
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:" + user.getRealname(), "导出信息"));
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException{
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
// 错误信息
|
||||
List<String> errorMessage = new ArrayList<>();
|
||||
int successLines = 0, errorLines = 0;
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SysCategory> listSysCategorys = ExcelImportUtil.importExcel(file.getInputStream(), SysCategory.class, params);
|
||||
//按照编码长度排序
|
||||
Collections.sort(listSysCategorys);
|
||||
log.info("排序后的list====>",listSysCategorys);
|
||||
for (int i = 0; i < listSysCategorys.size(); i++) {
|
||||
SysCategory sysCategoryExcel = listSysCategorys.get(i);
|
||||
String code = sysCategoryExcel.getCode();
|
||||
if(code.length()>3){
|
||||
String pCode = sysCategoryExcel.getCode().substring(0,code.length()-3);
|
||||
log.info("pCode====>",pCode);
|
||||
String pId=sysCategoryService.queryIdByCode(pCode);
|
||||
log.info("pId====>",pId);
|
||||
if(StringUtils.isNotBlank(pId)){
|
||||
sysCategoryExcel.setPid(pId);
|
||||
}
|
||||
}else{
|
||||
sysCategoryExcel.setPid("0");
|
||||
}
|
||||
try {
|
||||
sysCategoryService.save(sysCategoryExcel);
|
||||
successLines++;
|
||||
} catch (Exception e) {
|
||||
errorLines++;
|
||||
String message = e.getMessage().toLowerCase();
|
||||
int lineNumber = i + 1;
|
||||
// 通过索引名判断出错信息
|
||||
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CATEGORY_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:分类编码已经存在,忽略导入。");
|
||||
} else {
|
||||
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMessage.add("发生异常:" + e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage);
|
||||
}
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
// 错误信息
|
||||
List<String> errorMessage = new ArrayList<>();
|
||||
int successLines = 0, errorLines = 0;
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = entity.getValue();
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SysCategory> listSysCategorys = ExcelImportUtil.importExcel(file.getInputStream(), SysCategory.class, params);
|
||||
//按照编码长度排序
|
||||
Collections.sort(listSysCategorys);
|
||||
log.info("排序后的list====>", listSysCategorys);
|
||||
for (int i = 0; i < listSysCategorys.size(); i++) {
|
||||
SysCategory sysCategoryExcel = listSysCategorys.get(i);
|
||||
String code = sysCategoryExcel.getCode();
|
||||
if (code.length() > 3) {
|
||||
String pCode = sysCategoryExcel.getCode().substring(0, code.length() - 3);
|
||||
log.info("pCode====>", pCode);
|
||||
String pId = sysCategoryService.queryIdByCode(pCode);
|
||||
log.info("pId====>", pId);
|
||||
if (StringUtils.isNotBlank(pId)) {
|
||||
sysCategoryExcel.setPid(pId);
|
||||
}
|
||||
} else {
|
||||
sysCategoryExcel.setPid("0");
|
||||
}
|
||||
try {
|
||||
sysCategoryService.save(sysCategoryExcel);
|
||||
successLines++;
|
||||
} catch (Exception e) {
|
||||
errorLines++;
|
||||
String message = e.getMessage().toLowerCase();
|
||||
int lineNumber = i + 1;
|
||||
// 通过索引名判断出错信息
|
||||
if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CATEGORY_CODE)) {
|
||||
errorMessage.add("第 " + lineNumber + " 行:分类编码已经存在,忽略导入。");
|
||||
} else {
|
||||
errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorMessage.add("发生异常:" + e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ImportExcelUtil.imporReturnRes(errorLines, successLines, errorMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载单个数据 用于回显
|
||||
*/
|
||||
@RequestMapping(value = "/loadOne", method = RequestMethod.GET)
|
||||
public Result<SysCategory> loadOne(@RequestParam(name="field") String field,@RequestParam(name="val") String val) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
/**
|
||||
* 加载单个数据 用于回显
|
||||
*/
|
||||
@RequestMapping(value = "/loadOne", method = RequestMethod.GET)
|
||||
public Result<SysCategory> loadOne(@RequestParam(name = "field") String field, @RequestParam(name = "val") String val) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
//update-begin-author:taoyan date:2022-5-6 for: issues/3663 sql注入问题
|
||||
boolean isClassField = ReflectHelper.isClassField(field, SysCategory.class);
|
||||
if (!isClassField) {
|
||||
return Result.error("字段无效,请检查!");
|
||||
}
|
||||
//update-end-author:taoyan date:2022-5-6 for: issues/3663 sql注入问题
|
||||
QueryWrapper<SysCategory> query = new QueryWrapper<SysCategory>();
|
||||
query.eq(field, val);
|
||||
List<SysCategory> ls = this.sysCategoryService.list(query);
|
||||
if(ls==null || ls.size()==0) {
|
||||
result.setMessage("查询无果");
|
||||
result.setSuccess(false);
|
||||
}else if(ls.size()>1) {
|
||||
result.setMessage("查询数据异常,["+field+"]存在多个值:"+val);
|
||||
result.setSuccess(false);
|
||||
}else {
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
QueryWrapper<SysCategory> query = new QueryWrapper<SysCategory>();
|
||||
query.eq(field, val);
|
||||
List<SysCategory> ls = this.sysCategoryService.list(query);
|
||||
if (ls == null || ls.size() == 0) {
|
||||
result.setMessage("查询无果");
|
||||
result.setSuccess(false);
|
||||
} else if (ls.size() > 1) {
|
||||
result.setMessage("查询数据异常,[" + field + "]存在多个值:" + val);
|
||||
result.setSuccess(false);
|
||||
} else {
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载节点的子数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name="pid") String pid) {
|
||||
/**
|
||||
* 加载节点的子数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByPid(pid);
|
||||
|
@ -366,173 +369,217 @@ public class SysCategoryController {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载一级节点/如果是同步 则所有数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name="async") Boolean async,@RequestParam(name="pcode") String pcode) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByCode(pcode);
|
||||
if(!async) {
|
||||
loadAllCategoryChildren(ls);
|
||||
}
|
||||
result.setResult(ls);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 加载一级节点/如果是同步 则所有数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByCode(pcode);
|
||||
if (!async) {
|
||||
//框架自带傻逼for循环套sql 慎用 慢到想骂人 实测几百个非叶节点就已经爆炸了
|
||||
// loadAllCategoryChildren(ls);
|
||||
//一次sql查所有,系统代码处理循环生成树结构
|
||||
loadAllCategoryChildrenQO(ls);
|
||||
}
|
||||
result.setResult(ls);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归求子节点 同步加载用到
|
||||
*/
|
||||
private void loadAllCategoryChildren(List<TreeSelectModel> ls) {
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
/**
|
||||
* 递归求子节点 同步加载用到
|
||||
*/
|
||||
private void loadAllCategoryChildren(List<TreeSelectModel> ls) {
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
List<TreeSelectModel> temp = this.sysCategoryService.queryListByPid(tsm.getKey());
|
||||
if(temp!=null && temp.size()>0) {
|
||||
if (temp != null && temp.size() > 0) {
|
||||
tsm.setChildren(temp);
|
||||
loadAllCategoryChildren(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验编码
|
||||
* @param pid
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/checkCode")
|
||||
public Result<?> checkCode(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="code",required = false) String code) {
|
||||
if(oConvertUtils.isEmpty(code)){
|
||||
/**
|
||||
* 只查询一次数据库,代码内容循环处理,避免for-sql
|
||||
*
|
||||
* @param ls
|
||||
*/
|
||||
private void loadAllCategoryChildrenQO(List<TreeSelectModel> ls) {
|
||||
// 1. 首先获取所有可能的pid值
|
||||
Set<String> pids = new HashSet<>();
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
pids.add(tsm.getKey());
|
||||
}
|
||||
|
||||
// 2. 一次性查询所有可能需要的节点
|
||||
List<TreeSelectModel> allNodes = this.sysCategoryService.queryAllCategories();
|
||||
|
||||
// 3. 构建节点映射表
|
||||
Map<String, List<TreeSelectModel>> nodeMap = new HashMap<>();
|
||||
for (TreeSelectModel node : allNodes) {
|
||||
String parentId = node.getParentId();
|
||||
nodeMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(node);
|
||||
}
|
||||
|
||||
// 4. 递归构建树结构
|
||||
buildTree(ls, nodeMap);
|
||||
}
|
||||
|
||||
private void buildTree(List<TreeSelectModel> nodes, Map<String, List<TreeSelectModel>> nodeMap) {
|
||||
for (TreeSelectModel node : nodes) {
|
||||
String nodeKey = node.getKey();
|
||||
List<TreeSelectModel> children = nodeMap.get(nodeKey);
|
||||
if (children != null && !children.isEmpty()) {
|
||||
node.setChildren(children);
|
||||
buildTree(children, nodeMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验编码
|
||||
*
|
||||
* @param pid
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/checkCode")
|
||||
public Result<?> checkCode(@RequestParam(name = "pid", required = false) String pid, @RequestParam(name = "code", required = false) String code) {
|
||||
if (oConvertUtils.isEmpty(code)) {
|
||||
return Result.error("错误,类型编码为空!");
|
||||
}
|
||||
if(oConvertUtils.isEmpty(pid)){
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
return Result.ok();
|
||||
}
|
||||
SysCategory parent = this.sysCategoryService.getById(pid);
|
||||
if(code.startsWith(parent.getCode())){
|
||||
if (code.startsWith(parent.getCode())) {
|
||||
return Result.ok();
|
||||
}else{
|
||||
return Result.error("编码不符合规范,须以\""+parent.getCode()+"\"开头!");
|
||||
} else {
|
||||
return Result.error("编码不符合规范,须以\"" + parent.getCode() + "\"开头!");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分类字典树控件 加载节点
|
||||
* @param pid
|
||||
* @param pcode
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="pcode",required = false) String pcode, @RequestParam(name="condition",required = false) String condition) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
//pid如果传值了 就忽略pcode的作用
|
||||
if(oConvertUtils.isEmpty(pid)){
|
||||
if(oConvertUtils.isEmpty(pcode)){
|
||||
/**
|
||||
* 分类字典树控件 加载节点
|
||||
*
|
||||
* @param pid
|
||||
* @param pcode
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name = "pid", required = false) String pid, @RequestParam(name = "pcode", required = false) String pcode, @RequestParam(name = "condition", required = false) String condition) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
//pid如果传值了 就忽略pcode的作用
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
if (oConvertUtils.isEmpty(pcode)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("加载分类字典树参数有误.[null]!");
|
||||
return result;
|
||||
}else{
|
||||
if(ISysCategoryService.ROOT_PID_VALUE.equals(pcode)){
|
||||
} else {
|
||||
if (ISysCategoryService.ROOT_PID_VALUE.equals(pcode)) {
|
||||
pid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
}else{
|
||||
} else {
|
||||
pid = this.sysCategoryService.queryIdByCode(pcode);
|
||||
}
|
||||
if(oConvertUtils.isEmpty(pid)){
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("加载分类字典树参数有误.[code]!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, String> query = null;
|
||||
if(oConvertUtils.isNotEmpty(condition)) {
|
||||
query = JSON.parseObject(condition, Map.class);
|
||||
}
|
||||
List<TreeSelectModel> ls = sysCategoryService.queryListByPid(pid,query);
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Map<String, String> query = null;
|
||||
if (oConvertUtils.isNotEmpty(condition)) {
|
||||
query = JSON.parseObject(condition, Map.class);
|
||||
}
|
||||
List<TreeSelectModel> ls = sysCategoryService.queryListByPid(pid, query);
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictItem", method = RequestMethod.GET)
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
// 非空判断
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("ids 不能为空");
|
||||
return result;
|
||||
}
|
||||
// 查询数据
|
||||
List<String> textList = sysCategoryService.loadDictItem(ids, delNotExist);
|
||||
result.setSuccess(true);
|
||||
result.setResult(textList);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictItem", method = RequestMethod.GET)
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
// 非空判断
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("ids 不能为空");
|
||||
return result;
|
||||
}
|
||||
// 查询数据
|
||||
List<String> textList = sysCategoryService.loadDictItem(ids, delNotExist);
|
||||
result.setSuccess(true);
|
||||
result.setResult(textList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* [列表页面]加载分类字典数据 用于值的替换
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadAllData(@RequestParam(name="code",required = true) String code) {
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>();
|
||||
if(oConvertUtils.isNotEmpty(code) && !CATEGORY_ROOT_CODE.equals(code)){
|
||||
query.likeRight(SysCategory::getCode,code);
|
||||
}
|
||||
List<SysCategory> list = this.sysCategoryService.list(query);
|
||||
if(list==null || list.size()==0) {
|
||||
result.setMessage("无数据,参数有误.[code]");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
List<DictModel> rdList = new ArrayList<DictModel>();
|
||||
for (SysCategory c : list) {
|
||||
rdList.add(new DictModel(c.getId(),c.getName()));
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(rdList);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* [列表页面]加载分类字典数据 用于值的替换
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadAllData(@RequestParam(name = "code", required = true) String code) {
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>();
|
||||
if (oConvertUtils.isNotEmpty(code) && !CATEGORY_ROOT_CODE.equals(code)) {
|
||||
query.likeRight(SysCategory::getCode, code);
|
||||
}
|
||||
List<SysCategory> list = this.sysCategoryService.list(query);
|
||||
if (list == null || list.size() == 0) {
|
||||
result.setMessage("无数据,参数有误.[code]");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
List<DictModel> rdList = new ArrayList<DictModel>();
|
||||
for (SysCategory c : list) {
|
||||
rdList.add(new DictModel(c.getId(), c.getName()));
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(rdList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级id批量查询子节点
|
||||
* @param parentIds
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getChildListBatch")
|
||||
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
|
||||
try {
|
||||
QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<>();
|
||||
List<String> parentIdList = Arrays.asList(parentIds.split(","));
|
||||
queryWrapper.in("pid", parentIdList);
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
IPage<SysCategory> pageList = new Page<>(1, 10, list.size());
|
||||
pageList.setRecords(list);
|
||||
return Result.OK(pageList);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("批量查询子节点失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据父级id批量查询子节点
|
||||
*
|
||||
* @param parentIds
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getChildListBatch")
|
||||
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
|
||||
try {
|
||||
QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<>();
|
||||
List<String> parentIdList = Arrays.asList(parentIds.split(","));
|
||||
queryWrapper.in("pid", parentIdList);
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
IPage<SysCategory> pageList = new Page<>(1, 10, list.size());
|
||||
pageList.setRecords(list);
|
||||
return Result.OK(pageList);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("批量查询子节点失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -20,109 +20,180 @@ import java.util.Objects;
|
|||
* <p>
|
||||
*
|
||||
* @Author Steve
|
||||
* @Since 2019-01-22
|
||||
* @Since 2019-01-22
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart")
|
||||
public class SysDepart implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**父机构ID*/
|
||||
private String parentId;
|
||||
/**机构/部门名称*/
|
||||
@Excel(name="机构/部门名称",width=15)
|
||||
private String departName;
|
||||
/**英文名*/
|
||||
@Excel(name="英文名",width=15)
|
||||
private String departNameEn;
|
||||
/**缩写*/
|
||||
private String departNameAbbr;
|
||||
/**排序*/
|
||||
@Excel(name="排序",width=15)
|
||||
private Integer departOrder;
|
||||
/**描述*/
|
||||
@Excel(name="描述",width=15)
|
||||
private String description;
|
||||
/**机构类别 1=公司,2=组织机构,3=岗位*/
|
||||
@Excel(name="机构类别",width=15,dicCode="org_category")
|
||||
private String orgCategory;
|
||||
/**机构类型*/
|
||||
private String orgType;
|
||||
/**机构编码*/
|
||||
@Excel(name="机构编码",width=15)
|
||||
private String orgCode;
|
||||
/**协议+域名*/
|
||||
@Excel(name="协议+域名",width=30)
|
||||
private String url;
|
||||
/**手机号*/
|
||||
@Excel(name="手机号",width=15)
|
||||
private String mobile;
|
||||
/**传真*/
|
||||
@Excel(name="传真",width=15)
|
||||
private String fax;
|
||||
/**地址*/
|
||||
@Excel(name="地址",width=15)
|
||||
private String address;
|
||||
/**备注*/
|
||||
@Excel(name="备注",width=15)
|
||||
private String memo;
|
||||
/**状态(1启用,0不启用)*/
|
||||
@Dict(dicCode = "depart_status")
|
||||
private String status;
|
||||
/**删除状态(0,正常,1已删除)*/
|
||||
@Dict(dicCode = "del_flag")
|
||||
private String delFlag;
|
||||
/**对接企业微信的ID*/
|
||||
private String qywxIdentifier;
|
||||
/**对接钉钉的部门ID*/
|
||||
private String dingIdentifier;
|
||||
/**创建人*/
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
/**
|
||||
* 父机构ID
|
||||
*/
|
||||
private String parentId;
|
||||
/**
|
||||
* 机构/部门名称
|
||||
*/
|
||||
@Excel(name = "机构/部门名称", width = 15)
|
||||
private String departName;
|
||||
/**
|
||||
* 英文名
|
||||
*/
|
||||
@Excel(name = "英文名", width = 15)
|
||||
private String departNameEn;
|
||||
/**
|
||||
* 缩写
|
||||
*/
|
||||
private String departNameAbbr;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序", width = 15)
|
||||
private Integer departOrder;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "描述", width = 15)
|
||||
private String description;
|
||||
/**
|
||||
* 机构类别 1=公司,2=组织机构,3=岗位
|
||||
*/
|
||||
@Excel(name = "机构类别", width = 15, dicCode = "org_category")
|
||||
private String orgCategory;
|
||||
/**
|
||||
* 机构类型
|
||||
*/
|
||||
private String orgType;
|
||||
/**
|
||||
* 机构编码
|
||||
*/
|
||||
@Excel(name = "机构编码", width = 15)
|
||||
private String orgCode;
|
||||
/**
|
||||
* 协议+域名
|
||||
*/
|
||||
@Excel(name = "协议+域名", width = 30)
|
||||
private String url;
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
@Excel(name = "省份", width = 30)
|
||||
private String province;
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
@Excel(name = "城市", width = 30)
|
||||
private String city;
|
||||
/**
|
||||
* 区县
|
||||
*/
|
||||
@Excel(name = "区县", width = 30)
|
||||
private String district;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Excel(name = "手机号", width = 15)
|
||||
private String mobile;
|
||||
/**
|
||||
* 传真
|
||||
*/
|
||||
@Excel(name = "传真", width = 15)
|
||||
private String fax;
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
@Excel(name = "地址", width = 15)
|
||||
private String address;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
private String memo;
|
||||
/**
|
||||
* 状态(1启用,0不启用)
|
||||
*/
|
||||
@Dict(dicCode = "depart_status")
|
||||
private String status;
|
||||
/**
|
||||
* 删除状态(0,正常,1已删除)
|
||||
*/
|
||||
@Dict(dicCode = "del_flag")
|
||||
private String delFlag;
|
||||
/**
|
||||
* 对接企业微信的ID
|
||||
*/
|
||||
private String qywxIdentifier;
|
||||
/**
|
||||
* 对接钉钉的部门ID
|
||||
*/
|
||||
private String dingIdentifier;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
/**是否有叶子节点: 1是0否*/
|
||||
private Integer izLeaf;
|
||||
/**
|
||||
* 是否有叶子节点: 1是0否
|
||||
*/
|
||||
private Integer izLeaf;
|
||||
|
||||
/**各机构服务器后台接口地址*/
|
||||
private String serverUrl;
|
||||
/**
|
||||
* 各机构服务器后台接口地址
|
||||
*/
|
||||
private String serverUrl;
|
||||
|
||||
//update-begin---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段负责人ids和旧的负责人ids
|
||||
/**部门负责人的ids*/
|
||||
@TableField(exist = false)
|
||||
private String directorUserIds;
|
||||
/**旧的部门负责人的ids(用于比较删除和新增)*/
|
||||
@TableField(exist = false)
|
||||
/**
|
||||
* 部门负责人的ids
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String directorUserIds;
|
||||
/**
|
||||
* 旧的部门负责人的ids(用于比较删除和新增)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String oldDirectorUserIds;
|
||||
//update-end---author:wangshuai ---date:20200308 for:[JTC-119]新增字段负责人ids和旧的负责人ids
|
||||
|
||||
/**
|
||||
* 重写equals方法
|
||||
*/
|
||||
/**
|
||||
* 重写equals方法
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
SysDepart depart = (SysDepart) o;
|
||||
return Objects.equals(id, depart.id) &&
|
||||
Objects.equals(parentId, depart.parentId) &&
|
||||
|
@ -134,6 +205,10 @@ public class SysDepart implements Serializable {
|
|||
Objects.equals(orgCategory, depart.orgCategory) &&
|
||||
Objects.equals(orgType, depart.orgType) &&
|
||||
Objects.equals(orgCode, depart.orgCode) &&
|
||||
Objects.equals(url, depart.url) &&
|
||||
Objects.equals(province, depart.province) &&
|
||||
Objects.equals(city, depart.city) &&
|
||||
Objects.equals(district, depart.district) &&
|
||||
Objects.equals(mobile, depart.mobile) &&
|
||||
Objects.equals(fax, depart.fax) &&
|
||||
Objects.equals(address, depart.address) &&
|
||||
|
@ -153,8 +228,8 @@ public class SysDepart implements Serializable {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), id, parentId, departName,
|
||||
departNameEn, departNameAbbr, departOrder, description,orgCategory,
|
||||
orgType, orgCode, mobile, fax, address, memo, status,
|
||||
delFlag, createBy, createTime, updateBy, updateTime, tenantId);
|
||||
departNameEn, departNameAbbr, departOrder, description, orgCategory,
|
||||
orgType, orgCode, url, province, city, district, mobile, fax, address, memo, status,
|
||||
delFlag, createBy, createTime, updateBy, updateTime, tenantId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,16 +23,16 @@ public interface SysCategoryMapper extends BaseMapper<SysCategory> {
|
|||
/**
|
||||
* 根据父级ID查询树节点数据
|
||||
* @param pid
|
||||
* @param query
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
public List<TreeSelectModel> queryListByPid(@Param("pid") String pid,@Param("query") Map<String, String> query);
|
||||
|
||||
/**
|
||||
* 通过code查询分类字典表
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 通过code查询分类字典表
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT ID FROM sys_category WHERE CODE = #{code,jdbcType=VARCHAR}")
|
||||
public String queryIdByCode(@Param("code") String code);
|
||||
|
||||
|
@ -48,4 +48,6 @@ public interface SysCategoryMapper extends BaseMapper<SysCategory> {
|
|||
@InterceptorIgnore(tenantLine = "true")
|
||||
@Select("SELECT code FROM sys_category WHERE ID = #{id}")
|
||||
SysCategory selectSysCategoryById(@Param("id") String id);
|
||||
|
||||
List<TreeSelectModel> queryAllCategories();
|
||||
}
|
||||
|
|
|
@ -33,5 +33,12 @@
|
|||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAllCategories" resultType="org.jeecg.modules.system.model.TreeSelectModel">
|
||||
select code,
|
||||
name as "title",
|
||||
id as "key",
|
||||
(case when has_child = '1' then 0 else 1 end) as isLeaf,
|
||||
pid as parentId
|
||||
from sys_category
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -61,6 +61,12 @@ public class SysDepartTreeModel implements Serializable {
|
|||
|
||||
private String url;
|
||||
|
||||
private String province;
|
||||
|
||||
private String city;
|
||||
|
||||
private String district;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private String fax;
|
||||
|
@ -113,6 +119,9 @@ public class SysDepartTreeModel implements Serializable {
|
|||
this.orgType = sysDepart.getOrgType();
|
||||
this.orgCode = sysDepart.getOrgCode();
|
||||
this.url = sysDepart.getUrl();
|
||||
this.province = sysDepart.getProvince();
|
||||
this.city = sysDepart.getCity();
|
||||
this.district = sysDepart.getDistrict();
|
||||
this.mobile = sysDepart.getMobile();
|
||||
this.fax = sysDepart.getFax();
|
||||
this.address = sysDepart.getAddress();
|
||||
|
@ -372,6 +381,30 @@ public class SysDepartTreeModel implements Serializable {
|
|||
this.directorUserIds = directorUserIds;
|
||||
}
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写equals方法
|
||||
*/
|
||||
|
@ -395,6 +428,9 @@ public class SysDepartTreeModel implements Serializable {
|
|||
Objects.equals(orgType, model.orgType) &&
|
||||
Objects.equals(orgCode, model.orgCode) &&
|
||||
Objects.equals(url, model.url) &&
|
||||
Objects.equals(province, model.province) &&
|
||||
Objects.equals(city, model.city) &&
|
||||
Objects.equals(district, model.district) &&
|
||||
Objects.equals(mobile, model.mobile) &&
|
||||
Objects.equals(fax, model.fax) &&
|
||||
Objects.equals(address, model.address) &&
|
||||
|
@ -417,7 +453,7 @@ public class SysDepartTreeModel implements Serializable {
|
|||
public int hashCode() {
|
||||
|
||||
return Objects.hash(id, parentId, departName, departNameEn, departNameAbbr,
|
||||
departOrder, description, orgCategory, orgType, orgCode, url, mobile, fax, address,
|
||||
departOrder, description, orgCategory, orgType, orgCode, url, province, city, district, mobile, fax, address,
|
||||
memo, status, delFlag, qywxIdentifier, createBy, createTime, updateBy, updateTime,
|
||||
children, directorUserIds);
|
||||
}
|
||||
|
|
|
@ -19,38 +19,40 @@ public interface ISysCategoryService extends IService<SysCategory> {
|
|||
/**根节点父ID的值*/
|
||||
public static final String ROOT_PID_VALUE = "0";
|
||||
|
||||
/**
|
||||
* 存在子节点
|
||||
*/
|
||||
public static final String HAS_CHILD = "1";
|
||||
/**
|
||||
* 存在子节点
|
||||
*/
|
||||
public static final String HAS_CHILD = "1";
|
||||
|
||||
/**
|
||||
* 添加分类字典
|
||||
* @param sysCategory
|
||||
*/
|
||||
/**
|
||||
* 添加分类字典
|
||||
* @param sysCategory
|
||||
*/
|
||||
void addSysCategory(SysCategory sysCategory);
|
||||
|
||||
/**
|
||||
* 修改分类字典
|
||||
* @param sysCategory
|
||||
*/
|
||||
/**
|
||||
* 修改分类字典
|
||||
* @param sysCategory
|
||||
*/
|
||||
void updateSysCategory(SysCategory sysCategory);
|
||||
|
||||
/**
|
||||
* 根据父级编码加载分类字典的数据
|
||||
* 根据父级编码加载分类字典的数据
|
||||
* @param pcode
|
||||
* @return
|
||||
* @throws JeecgBootException
|
||||
* @throws JeecgBootException
|
||||
*/
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException;
|
||||
|
||||
/**
|
||||
* 根据pid查询子节点集合
|
||||
* 根据pid查询子节点集合
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public List<TreeSelectModel> queryListByPid(String pid);
|
||||
|
||||
public List<TreeSelectModel> queryAllCategories();
|
||||
|
||||
/**
|
||||
* 根据pid查询子节点集合,支持查询条件
|
||||
* @param pid
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.constant.FillRuleConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
|
@ -23,7 +24,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
|
@ -34,14 +35,14 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
String categoryCode = "";
|
||||
String categoryPid = ISysCategoryService.ROOT_PID_VALUE;
|
||||
String parentCode = null;
|
||||
if(oConvertUtils.isNotEmpty(sysCategory.getPid())){
|
||||
if (oConvertUtils.isNotEmpty(sysCategory.getPid())) {
|
||||
categoryPid = sysCategory.getPid();
|
||||
|
||||
//PID 不是根节点 说明需要设置父节点 hasChild 为1
|
||||
if(!ISysCategoryService.ROOT_PID_VALUE.equals(categoryPid)){
|
||||
if (!ISysCategoryService.ROOT_PID_VALUE.equals(categoryPid)) {
|
||||
SysCategory parent = baseMapper.selectById(categoryPid);
|
||||
parentCode = parent.getCode();
|
||||
if(parent!=null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())){
|
||||
if (parent != null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())) {
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
|
@ -49,22 +50,24 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
}
|
||||
//update-begin--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("pid",categoryPid);
|
||||
categoryCode = (String) FillRuleUtil.executeRule(FillRuleConstant.CATEGORY,formData);
|
||||
formData.put("pid", categoryPid);
|
||||
categoryCode = (String) FillRuleUtil.executeRule(FillRuleConstant.CATEGORY, formData);
|
||||
//update-end--Author:baihailong Date:20191209 for:分类字典编码规则生成器做成公用配置
|
||||
sysCategory.setCode(categoryCode);
|
||||
if (StringUtils.isBlank(sysCategory.getCode())) {
|
||||
sysCategory.setCode(categoryCode);
|
||||
}
|
||||
sysCategory.setPid(categoryPid);
|
||||
baseMapper.insert(sysCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysCategory(SysCategory sysCategory) {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
if (oConvertUtils.isEmpty(sysCategory.getPid())) {
|
||||
sysCategory.setPid(ISysCategoryService.ROOT_PID_VALUE);
|
||||
}else{
|
||||
} else {
|
||||
//如果当前节点父ID不为空 则设置父节点的hasChild 为1
|
||||
SysCategory parent = baseMapper.selectById(sysCategory.getPid());
|
||||
if(parent!=null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())){
|
||||
if (parent != null && !ISysCategoryService.HAS_CHILD.equals(parent.getHasChild())) {
|
||||
parent.setHasChild(ISysCategoryService.HAS_CHILD);
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
|
@ -73,35 +76,40 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException{
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException {
|
||||
String pid = ROOT_PID_VALUE;
|
||||
if(oConvertUtils.isNotEmpty(pcode)) {
|
||||
if (oConvertUtils.isNotEmpty(pcode)) {
|
||||
List<SysCategory> list = baseMapper.selectList(new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, pcode));
|
||||
if(list==null || list.size() ==0) {
|
||||
throw new JeecgBootException("该编码【"+pcode+"】不存在,请核实!");
|
||||
if (list == null || list.size() == 0) {
|
||||
throw new JeecgBootException("该编码【" + pcode + "】不存在,请核实!");
|
||||
}
|
||||
if(list.size()>1) {
|
||||
throw new JeecgBootException("该编码【"+pcode+"】存在多个,请核实!");
|
||||
if (list.size() > 1) {
|
||||
throw new JeecgBootException("该编码【" + pcode + "】存在多个,请核实!");
|
||||
}
|
||||
pid = list.get(0).getId();
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,null);
|
||||
return baseMapper.queryListByPid(pid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid) {
|
||||
if(oConvertUtils.isEmpty(pid)) {
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,null);
|
||||
return baseMapper.queryListByPid(pid, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryAllCategories() {
|
||||
return baseMapper.queryAllCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid, Map<String, String> condition) {
|
||||
if(oConvertUtils.isEmpty(pid)) {
|
||||
if (oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid,condition);
|
||||
return baseMapper.queryListByPid(pid, condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,17 +125,18 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
//1.删除时将节点下所有子节点一并删除
|
||||
this.baseMapper.deleteBatchIds(Arrays.asList(allIds.split(",")));
|
||||
//2.将父节点中已经没有下级的节点,修改为没有子节点
|
||||
if(oConvertUtils.isNotEmpty(pids)){
|
||||
if (oConvertUtils.isNotEmpty(pids)) {
|
||||
LambdaUpdateWrapper<SysCategory> updateWrapper = new UpdateWrapper<SysCategory>()
|
||||
.lambda()
|
||||
.in(SysCategory::getId,Arrays.asList(pids.split(",")))
|
||||
.set(SysCategory::getHasChild,"0");
|
||||
.in(SysCategory::getId, Arrays.asList(pids.split(",")))
|
||||
.set(SysCategory::getHasChild, "0");
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询节点下所有子节点
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
|
@ -136,13 +145,13 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
String[] idArr = ids.split(",");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String pidVal : idArr) {
|
||||
if(pidVal != null){
|
||||
if(!sb.toString().contains(pidVal)){
|
||||
if(sb.toString().length() > 0){
|
||||
if (pidVal != null) {
|
||||
if (!sb.toString().contains(pidVal)) {
|
||||
if (sb.toString().length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(pidVal);
|
||||
this.getTreeChildIds(pidVal,sb);
|
||||
this.getTreeChildIds(pidVal, sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +160,7 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
|
||||
/**
|
||||
* 查询需修改标识的父节点ids
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
|
@ -159,24 +169,24 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
//获取id数组
|
||||
String[] idArr = ids.split(",");
|
||||
for (String id : idArr) {
|
||||
if(id != null){
|
||||
if (id != null) {
|
||||
SysCategory category = this.baseMapper.selectById(id);
|
||||
//根据id查询pid值
|
||||
String metaPid = category.getPid();
|
||||
//查询此节点上一级是否还有其他子节点
|
||||
LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysCategory::getPid,metaPid);
|
||||
queryWrapper.notIn(SysCategory::getId,Arrays.asList(idArr));
|
||||
queryWrapper.eq(SysCategory::getPid, metaPid);
|
||||
queryWrapper.notIn(SysCategory::getId, Arrays.asList(idArr));
|
||||
List<SysCategory> dataList = this.baseMapper.selectList(queryWrapper);
|
||||
boolean flag = (dataList == null || dataList.size()==0) && !Arrays.asList(idArr).contains(metaPid)
|
||||
&& !sb.toString().contains(metaPid);
|
||||
if(flag){
|
||||
boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(metaPid)
|
||||
&& !sb.toString().contains(metaPid);
|
||||
if (flag) {
|
||||
//如果当前节点原本有子节点 现在木有了,更新状态
|
||||
sb.append(metaPid).append(",");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sb.toString().endsWith(SymbolConstant.COMMA)){
|
||||
if (sb.toString().endsWith(SymbolConstant.COMMA)) {
|
||||
sb = sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -184,17 +194,18 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
|||
|
||||
/**
|
||||
* 递归 根据父id获取子节点id
|
||||
*
|
||||
* @param pidVal
|
||||
* @param sb
|
||||
* @return
|
||||
*/
|
||||
private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
|
||||
private StringBuffer getTreeChildIds(String pidVal, StringBuffer sb) {
|
||||
LambdaQueryWrapper<SysCategory> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysCategory::getPid,pidVal);
|
||||
queryWrapper.eq(SysCategory::getPid, pidVal);
|
||||
List<SysCategory> dataList = baseMapper.selectList(queryWrapper);
|
||||
if(dataList != null && dataList.size()>0){
|
||||
for(SysCategory category : dataList) {
|
||||
if(!sb.toString().contains(category.getId())){
|
||||
if (dataList != null && dataList.size() > 0) {
|
||||
for (SysCategory category : dataList) {
|
||||
if (!sb.toString().contains(category.getId())) {
|
||||
sb.append(",").append(category.getId());
|
||||
}
|
||||
this.getTreeChildIds(category.getId(), sb);
|
||||
|
|
|
@ -388,3 +388,18 @@ aliyun:
|
|||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
||||
# 微信支付
|
||||
wxpay:
|
||||
# APIv3密钥
|
||||
api-v3-key: asdfiuzwe3534565478WETDSAFRWEq1E
|
||||
# APPID
|
||||
appid: wx8fc3e4305d2fbf0b
|
||||
# 商户ID
|
||||
mch-id: 1717618860
|
||||
# 商户API证书序列号
|
||||
mch-serial-no: 3E51C9D24F64CE50E9273E544561D29684AB21C7
|
||||
# 接收结果通知地址
|
||||
notify-domain: https://www.focusnu.com/nursing-unit_0010507/weiXinPay/callback
|
||||
# 商户私钥文件路径
|
||||
private-key-path: /opt/nu001/apiclient_key.pem
|
||||
|
|
|
@ -249,8 +249,10 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles001/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/upFiles
|
||||
upload: /opt/upFiles001
|
||||
#webapp文件路径
|
||||
webapp: /opt/webapp
|
||||
shiro:
|
||||
|
|
|
@ -247,6 +247,8 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles001/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/nu001/upFiles
|
||||
#webapp文件路径
|
||||
|
|
Loading…
Reference in New Issue