9 changed files with 318 additions and 11 deletions
-
2src/main/java/com/xujie/sys/modules/pms/controller/QcController.java
-
10src/main/java/com/xujie/sys/modules/pms/service/Impl/EamServiceImpl.java
-
65src/main/java/com/xujie/sys/modules/sys/controller/SysDepartmentController.java
-
84src/main/java/com/xujie/sys/modules/sys/entity/SysDepartmentEntity.java
-
22src/main/java/com/xujie/sys/modules/sys/mapper/SysDepartmentMapper.java
-
12src/main/java/com/xujie/sys/modules/sys/service/SysDepartmentService.java
-
64src/main/java/com/xujie/sys/modules/sys/service/impl/SysDepartmentServiceImpl.java
-
12src/main/resources/mapper/pms/EamMapper.xml
-
58src/main/resources/mapper/sys/SysDepartmentMapper.xml
@ -0,0 +1,65 @@ |
|||||
|
package com.xujie.sys.modules.sys.controller; |
||||
|
import com.xujie.sys.common.utils.PageUtils; |
||||
|
import com.xujie.sys.common.utils.R; |
||||
|
import com.xujie.sys.modules.pms.data.QcSamplingInspectionPlanData; |
||||
|
import com.xujie.sys.modules.sys.entity.SysDepartmentEntity; |
||||
|
import com.xujie.sys.modules.sys.entity.SysUserEntity; |
||||
|
import com.xujie.sys.modules.sys.service.SysDepartmentService; |
||||
|
import com.xujie.sys.modules.sys.service.SysUserRoleService; |
||||
|
import com.xujie.sys.modules.sys.service.SysUserService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* @description: 部门管理 |
||||
|
* @author: fengyuan_yang |
||||
|
* @date: 2023/6/30 13:34 |
||||
|
* @param: |
||||
|
* @return: |
||||
|
**/ |
||||
|
@RestController |
||||
|
@RequestMapping("/sys/department") |
||||
|
public class SysDepartmentController{ |
||||
|
@Autowired |
||||
|
private SysDepartmentService sysDepartmentService; |
||||
|
|
||||
|
/** |
||||
|
* @description: 查询部门 |
||||
|
* @author: fengyuan_yang |
||||
|
* @date: 2023/6/30 13:42 |
||||
|
* @param: [data] |
||||
|
* @return: com.xujie.sys.common.utils.R |
||||
|
**/ |
||||
|
@PostMapping("departmentSearch") |
||||
|
public R departmentSearch(@RequestBody SysDepartmentEntity data){ |
||||
|
PageUtils page = sysDepartmentService.departmentSearch(data); |
||||
|
return R.ok().put("page", page); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 新增部门 |
||||
|
* @author: fengyuan_yang |
||||
|
* @date: 2023/6/30 13:49 |
||||
|
* @param: [data] |
||||
|
* @return: com.xujie.sys.common.utils.R |
||||
|
**/ |
||||
|
@PostMapping(value="/departmentSave") |
||||
|
public R departmentSave(@RequestBody SysDepartmentEntity data){ |
||||
|
sysDepartmentService.departmentSave(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 删除部门 |
||||
|
* @author: fengyuan_yang |
||||
|
* @date: 2023/6/30 13:50 |
||||
|
* @param: [data] |
||||
|
* @return: com.xujie.sys.common.utils.R |
||||
|
**/ |
||||
|
@PostMapping(value="/departmentDelete") |
||||
|
public R departmentDelete(@RequestBody SysDepartmentEntity data){ |
||||
|
sysDepartmentService.departmentDelete(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,84 @@ |
|||||
|
package com.xujie.sys.modules.sys.entity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.xujie.sys.common.utils.QueryPage; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
public class SysDepartmentEntity extends QueryPage { |
||||
|
// 工厂 |
||||
|
private String site; |
||||
|
// 部门编码 |
||||
|
private String departmentId; |
||||
|
// 部门名称 |
||||
|
private String departmentName; |
||||
|
// 创建时间 |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
||||
|
private Date createDate; |
||||
|
// 创建人 |
||||
|
private String createBy; |
||||
|
// 更新时间 |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
||||
|
private Date updateDate; |
||||
|
// 更新人 |
||||
|
private String updateBy; |
||||
|
|
||||
|
public String getSite() { |
||||
|
return site; |
||||
|
} |
||||
|
|
||||
|
public void setSite(String site) { |
||||
|
this.site = site; |
||||
|
} |
||||
|
|
||||
|
public String getDepartmentId() { |
||||
|
return departmentId; |
||||
|
} |
||||
|
|
||||
|
public void setDepartmentId(String departmentId) { |
||||
|
this.departmentId = departmentId; |
||||
|
} |
||||
|
|
||||
|
public String getDepartmentName() { |
||||
|
return departmentName; |
||||
|
} |
||||
|
|
||||
|
public void setDepartmentName(String departmentName) { |
||||
|
this.departmentName = departmentName; |
||||
|
} |
||||
|
|
||||
|
public Date getCreateDate() { |
||||
|
return createDate; |
||||
|
} |
||||
|
|
||||
|
public void setCreateDate(Date createDate) { |
||||
|
this.createDate = createDate; |
||||
|
} |
||||
|
|
||||
|
public String getCreateBy() { |
||||
|
return createBy; |
||||
|
} |
||||
|
|
||||
|
public void setCreateBy(String createBy) { |
||||
|
this.createBy = createBy; |
||||
|
} |
||||
|
|
||||
|
public Date getUpdateDate() { |
||||
|
return updateDate; |
||||
|
} |
||||
|
|
||||
|
public void setUpdateDate(Date updateDate) { |
||||
|
this.updateDate = updateDate; |
||||
|
} |
||||
|
|
||||
|
public String getUpdateBy() { |
||||
|
return updateBy; |
||||
|
} |
||||
|
|
||||
|
public void setUpdateBy(String updateBy) { |
||||
|
this.updateBy = updateBy; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
package com.xujie.sys.modules.sys.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.xujie.sys.modules.sys.entity.SysDepartmentEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface SysDepartmentMapper { |
||||
|
IPage<SysDepartmentEntity> departmentSearch(Page<SysDepartmentEntity> sysDepartmentEntityPage, @Param("query") SysDepartmentEntity data); |
||||
|
|
||||
|
void departmentSave(SysDepartmentEntity data); |
||||
|
|
||||
|
void departmentDelete(SysDepartmentEntity data); |
||||
|
|
||||
|
List<SysDepartmentEntity> selectDepartmentInObject(SysDepartmentEntity data); |
||||
|
|
||||
|
List<SysDepartmentEntity> selectDepartmentInAdmin(SysDepartmentEntity data); |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package com.xujie.sys.modules.sys.service; |
||||
|
|
||||
|
import com.xujie.sys.common.utils.PageUtils; |
||||
|
import com.xujie.sys.modules.sys.entity.SysDepartmentEntity; |
||||
|
|
||||
|
public interface SysDepartmentService { |
||||
|
PageUtils departmentSearch(SysDepartmentEntity data); |
||||
|
|
||||
|
void departmentSave(SysDepartmentEntity data); |
||||
|
|
||||
|
void departmentDelete(SysDepartmentEntity data); |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
package com.xujie.sys.modules.sys.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.xujie.sys.common.utils.PageUtils; |
||||
|
import com.xujie.sys.modules.pms.data.EamObjectData; |
||||
|
import com.xujie.sys.modules.pms.data.QcTemplateData; |
||||
|
import com.xujie.sys.modules.sys.entity.SysDepartmentEntity; |
||||
|
import com.xujie.sys.modules.sys.mapper.SysDepartmentMapper; |
||||
|
import com.xujie.sys.modules.sys.service.SysDepartmentService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class SysDepartmentServiceImpl implements SysDepartmentService { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysDepartmentMapper sysDepartmentMapper; |
||||
|
|
||||
|
/** |
||||
|
* @description: 查询部门 |
||||
|
* @author: fengyuan_yang |
||||
|
* @date: 2023/6/30 13:53 |
||||
|
* @param: [data] |
||||
|
* @return: com.xujie.sys.common.utils.PageUtils |
||||
|
**/ |
||||
|
@Override |
||||
|
public PageUtils departmentSearch(SysDepartmentEntity data) { |
||||
|
IPage<SysDepartmentEntity> resultList = this.sysDepartmentMapper.departmentSearch(new Page<SysDepartmentEntity>(data.getPage(), data.getLimit()), data); |
||||
|
return new PageUtils(resultList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 新增部门 |
||||
|
* @author: fengyuan_yang |
||||
|
* @date: 2023/6/30 13:53 |
||||
|
* @param: [data] |
||||
|
* @return: void |
||||
|
**/ |
||||
|
@Override |
||||
|
public void departmentSave(SysDepartmentEntity data) { |
||||
|
sysDepartmentMapper.departmentSave(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @description: 删除部门 |
||||
|
* @author: fengyuan_yang |
||||
|
* @date: 2023/6/30 13:54 |
||||
|
* @param: [data] |
||||
|
* @return: void |
||||
|
**/ |
||||
|
@Override |
||||
|
public void departmentDelete(SysDepartmentEntity data) { |
||||
|
// 判断该部门是否被设备和人员引用 |
||||
|
List<SysDepartmentEntity> objectList = sysDepartmentMapper.selectDepartmentInObject(data); |
||||
|
List<SysDepartmentEntity> adminList = sysDepartmentMapper.selectDepartmentInAdmin(data); |
||||
|
if (objectList.size() > 0 || adminList.size() > 0){ |
||||
|
throw new RuntimeException("该部门已被引用,不能删除!"); |
||||
|
} |
||||
|
sysDepartmentMapper.departmentDelete(data); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
<?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.xujie.sys.modules.sys.mapper.SysDepartmentMapper"> |
||||
|
|
||||
|
<!-- 查询部门 --> |
||||
|
<select id="departmentSearch" parameterType="SysDepartmentEntity" resultType="SysDepartmentEntity"> |
||||
|
SELECT |
||||
|
site, |
||||
|
department_id, |
||||
|
department_name, |
||||
|
create_date, |
||||
|
create_by, |
||||
|
update_date, |
||||
|
update_by |
||||
|
FROM sys_department |
||||
|
<where> |
||||
|
<if test="query.departmentId != null and query.departmentId != ''"> |
||||
|
AND department_id like '%' + #{query.departmentId} + '%' |
||||
|
</if> |
||||
|
<if test="query.departmentName != null and query.departmentName != ''"> |
||||
|
AND department_name like '%' + #{query.departmentName} + '%' |
||||
|
</if> |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
<!-- 新增部门 --> |
||||
|
<insert id="departmentSave" parameterType="SysDepartmentEntity"> |
||||
|
insert into sys_department (site, department_id, department_name, create_date, create_by, update_date, update_by) |
||||
|
values (#{site}, #{departmentId}, #{departmentName}, getDate(), #{createBy}, getDate(), #{updateBy}) |
||||
|
</insert> |
||||
|
|
||||
|
<!-- 删除部门 --> |
||||
|
<delete id="departmentDelete" parameterType="SysDepartmentEntity"> |
||||
|
delete from sys_department |
||||
|
where site = #{site} |
||||
|
and department_id = #{departmentId} |
||||
|
</delete> |
||||
|
|
||||
|
<!-- 获取最大方矩阵编码 --> |
||||
|
<select id="selectDepartmentInObject" resultType="SysDepartmentEntity" parameterType="SysDepartmentEntity"> |
||||
|
SELECT |
||||
|
dept_id as departmentId |
||||
|
FROM eam_object |
||||
|
WHERE site = #{site} |
||||
|
AND dept_id = #{departmentId} |
||||
|
</select> |
||||
|
|
||||
|
<!-- 获取最大方矩阵编码 --> |
||||
|
<select id="selectDepartmentInAdmin" resultType="SysDepartmentEntity" parameterType="SysDepartmentEntity"> |
||||
|
SELECT |
||||
|
dept_id as departmentId |
||||
|
FROM eam_admin_dept |
||||
|
WHERE site = #{site} |
||||
|
AND dept_id = #{departmentId} |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue