项目部管理接口
This commit is contained in:
parent
65936d5b95
commit
98866341a9
|
|
@ -1,8 +1,14 @@
|
|||
package com.bonus.base.basic.controller;
|
||||
|
||||
import com.bonus.base.basic.domain.BmProject;
|
||||
import com.bonus.base.basic.domain.vo.ProDepartVo;
|
||||
import com.bonus.base.basic.domain.vo.UnitVo;
|
||||
import com.bonus.base.basic.service.ProDepartService;
|
||||
import com.bonus.base.common.annotation.PreventRepeatSubmit;
|
||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
|
|
@ -11,6 +17,8 @@ import io.swagger.annotations.ApiOperation;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:ProDepartController
|
||||
|
|
@ -22,23 +30,39 @@ import javax.annotation.Resource;
|
|||
@Api(tags = "项目部")
|
||||
@RestController
|
||||
@RequestMapping("/depart/")
|
||||
public class ProDepartController {
|
||||
public class ProDepartController extends BaseController {
|
||||
|
||||
@Resource(name = "ProDepartService")
|
||||
private ProDepartService service;
|
||||
|
||||
@ApiOperation(value = "查询项目部")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:depart:list")
|
||||
@RequiresPermissions("basic:depart:list")
|
||||
@SysLog(title = "项目部管理", businessType = OperaType.INSERT, logType = 1,module = "项目部管理->查询项目部")
|
||||
@GetMapping("getDeparts")
|
||||
public AjaxResult getDeparts(ProDepartVo vo) {
|
||||
return service.getDeparts(vo);
|
||||
public TableDataInfo getDeparts(ProDepartVo vo) {
|
||||
startPage();
|
||||
List<ProDepartVo> list = service.getDeparts(vo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出项目部")
|
||||
@PreventRepeatSubmit
|
||||
@RequiresPermissions("basic:depart:export")
|
||||
@SysLog(title = "项目部管理", businessType = OperaType.EXPORT, logType = 1,module = "项目部管理->导出项目部")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ProDepartVo vo) {
|
||||
List<ProDepartVo> list = service.getDeparts(vo);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.get(i).setSerialNumber(i + 1);
|
||||
}
|
||||
ExcelUtil<ProDepartVo> util = new ExcelUtil<ProDepartVo>(ProDepartVo.class);
|
||||
util.exportExcel(response, list, "项目部管理数据");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增项目部")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:depart:add")
|
||||
@RequiresPermissions("basic:depart:add")
|
||||
@SysLog(title = "项目部管理", businessType = OperaType.INSERT, logType = 1,module = "项目部管理->新增单位")
|
||||
@PostMapping("addDepart")
|
||||
public AjaxResult addDepart(@RequestBody ProDepartVo vo) {
|
||||
|
|
@ -53,7 +77,7 @@ public class ProDepartController {
|
|||
|
||||
@ApiOperation(value = "修改项目部")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:depart:edit")
|
||||
@RequiresPermissions("basic:depart:edit")
|
||||
@SysLog(title = "项目部管理", businessType = OperaType.UPDATE, logType = 1,module = "项目部管理->修改项目部")
|
||||
@PostMapping("editDepart")
|
||||
public AjaxResult editDepart(@RequestBody ProDepartVo vo) {
|
||||
|
|
@ -62,7 +86,7 @@ public class ProDepartController {
|
|||
|
||||
@ApiOperation(value = "删除项目部")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:depart:del")
|
||||
@RequiresPermissions("basic:depart:del")
|
||||
@SysLog(title = "项目部管理", businessType = OperaType.DELETE, logType = 1,module = "项目部管理->删除项目部")
|
||||
@PostMapping("delDepart")
|
||||
public AjaxResult delDepart(@RequestBody ProDepartVo vo) {
|
||||
|
|
@ -71,7 +95,7 @@ public class ProDepartController {
|
|||
|
||||
@ApiOperation(value = "设置项目部状态")
|
||||
// @PreventRepeatSubmit
|
||||
// @RequiresPermissions("basic:depart:editStatus")
|
||||
@RequiresPermissions("basic:depart:editStatus")
|
||||
@SysLog(title = "项目部管理", businessType = OperaType.UPDATE, logType = 1,module = "项目部管理->设置项目部状态")
|
||||
@PostMapping("editDepartStatus")
|
||||
public AjaxResult editDepartStatus(@RequestBody ProDepartVo vo) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.base.basic.domain.vo;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
|
@ -31,13 +32,16 @@ public class ProDepartVo {
|
|||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String keyWord;
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
@Excel(name = "序号")
|
||||
private int serialNumber;
|
||||
|
||||
@NotNull(message = "id不能为空", groups = {Edit.class, Del.class, Use.class})
|
||||
private Long id;
|
||||
|
||||
private String associationId;
|
||||
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 分公司id
|
||||
*/
|
||||
|
|
@ -47,6 +51,7 @@ public class ProDepartVo {
|
|||
/**
|
||||
* 分公司名称
|
||||
* */
|
||||
@Excel(name = "分公司名称")
|
||||
private String branchCompanyName;
|
||||
|
||||
/**
|
||||
|
|
@ -54,6 +59,7 @@ public class ProDepartVo {
|
|||
*/
|
||||
@NotBlank(message = "项目部名称不能为空", groups = {Add.class, Edit.class})
|
||||
@Length(max = 128, message = "项目部名称字符长度不能超过128", groups = {Add.class, Edit.class})
|
||||
@Excel(name = "项目部名称")
|
||||
private String departName;
|
||||
|
||||
/**
|
||||
|
|
@ -62,10 +68,23 @@ public class ProDepartVo {
|
|||
@Pattern(regexp = "[01]", message = "只允许输入0或1")
|
||||
private String useStatus;
|
||||
|
||||
/**
|
||||
* 状态名称
|
||||
*/
|
||||
@Excel(name = "状态")
|
||||
private String useStatusName;
|
||||
|
||||
/**
|
||||
* 标段工程数量
|
||||
* */
|
||||
@Excel(name = "标段工程数量")
|
||||
private int bidNum;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Length(max = 255, message = "备注字符长度不能超过255", groups = {Add.class, Edit.class})
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
|
|
@ -73,20 +92,17 @@ public class ProDepartVo {
|
|||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private Long updateUserId = Optional.ofNullable(SecurityUtils.getUserId()).orElse(0L);
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人员
|
||||
* */
|
||||
@Excel(name = "更新人员")
|
||||
private String updateUserName;
|
||||
|
||||
/**
|
||||
* 标段工程数量
|
||||
* */
|
||||
private int bidNum;
|
||||
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
private List<ProDepartVo> children;
|
||||
|
||||
/**
|
||||
* 新增条件限制
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.bonus.base.basic.service;
|
|||
import com.bonus.base.basic.domain.vo.ProDepartVo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @className:ProDepartService
|
||||
* @author:cwchen
|
||||
|
|
@ -63,5 +65,5 @@ public interface ProDepartService {
|
|||
* @author cwchen
|
||||
* @date 2025/4/17 15:48
|
||||
*/
|
||||
AjaxResult getDeparts(ProDepartVo vo);
|
||||
List<ProDepartVo> getDeparts(ProDepartVo vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,39 +121,13 @@ public class ProDepartServiceImpl implements ProDepartService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getDeparts(ProDepartVo vo) {
|
||||
return AjaxResult.success(buildTreeWithMap(mapper.getDeparts(vo)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建树形数据
|
||||
* @param nodes
|
||||
* @return List<ProDepartVo>
|
||||
* @author cwchen
|
||||
* @date 2025/4/17 15:51
|
||||
*/
|
||||
public List<ProDepartVo> buildTreeWithMap(List<ProDepartVo> nodes) {
|
||||
List<ProDepartVo> tree = new ArrayList<>();
|
||||
Map<String, ProDepartVo> nodeMap = new HashMap<>();
|
||||
// 第一次遍历:将所有节点存入map
|
||||
for (ProDepartVo node : nodes) {
|
||||
nodeMap.put(node.getAssociationId(), node);
|
||||
public List<ProDepartVo> getDeparts(ProDepartVo vo) {
|
||||
try {
|
||||
List<ProDepartVo> list = Optional.ofNullable(mapper.getDeparts(vo)).orElseGet(ArrayList::new);
|
||||
return list;
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
return new ArrayList<ProDepartVo>();
|
||||
}
|
||||
// 第二次遍历:建立父子关系
|
||||
for (ProDepartVo node : nodes) {
|
||||
String parentId = node.getParentId();
|
||||
if (parentId == null || parentId.isEmpty()) {
|
||||
tree.add(node);
|
||||
} else {
|
||||
ProDepartVo parent = nodeMap.get(parentId);
|
||||
if (parent != null) {
|
||||
if (parent.getChildren() == null) {
|
||||
parent.setChildren(new ArrayList<>());
|
||||
}
|
||||
parent.getChildren().add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,30 +64,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<!--查询项目部-->
|
||||
<select id="getDeparts" resultType="com.bonus.base.basic.domain.vo.ProDepartVo">
|
||||
SELECT CONCAT('company-',tbc.id) AS associationId ,
|
||||
NULL AS parentId,
|
||||
tbc.company_name AS departName,
|
||||
'/' AS useStatus,
|
||||
tbc.remark,
|
||||
'/' AS updateUserName,
|
||||
NULL AS updateTime,
|
||||
IFNULL(A.num,0) AS bidNum
|
||||
FROM tb_branch_company tbc
|
||||
LEFT JOIN (
|
||||
SELECT company_id,COUNT(*) AS num
|
||||
FROM bm_project_lot bpl
|
||||
WHERE del_flag = '0'
|
||||
GROUP BY company_id
|
||||
) A ON A.company_id = tbc.id
|
||||
UNION ALL
|
||||
SELECT tpd.id AS associationId,
|
||||
CONCAT('company-',tpd.branch_company_id) AS parentId,
|
||||
SELECT tpd.id AS id,
|
||||
tpd.branch_company_id AS branchCompanyId,
|
||||
tpd.depart_name AS departName,
|
||||
tpd.use_status AS useStatus,
|
||||
tpd.remark,
|
||||
su.nick_name AS updateUserName,
|
||||
tpd.update_time AS updateTime,
|
||||
IFNULL(A.num,0) AS bidNum
|
||||
IFNULL(A.num,0) AS bidNum,
|
||||
tbc.company_name AS branchCompanyName,
|
||||
IF(tpd.use_status = '1','启用','解散') AS useStatusName
|
||||
FROM tb_pro_depart tpd
|
||||
LEFT JOIN tb_branch_company tbc on tpd.branch_company_id = tbc.id
|
||||
LEFT JOIN sys_user su ON tpd.update_user_id = su.user_id
|
||||
|
|
@ -97,6 +83,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE del_flag = '0'
|
||||
GROUP BY dept_id
|
||||
) A ON A.dept_id = tpd.id
|
||||
WHERE tpd.is_active = '1'
|
||||
<where>
|
||||
<if test="keyWord!=null and keyWord!=''">
|
||||
AND (
|
||||
INSTR(tpd.depart_name,#{keyWord}) > 0 OR
|
||||
INSTR(tbc.company_name,#{keyWord}) > 0
|
||||
)
|
||||
</if>
|
||||
AND tpd.is_active = '1'
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue