Compare commits
2 Commits
4085364894
...
9db8a043a9
| Author | SHA1 | Date |
|---|---|---|
|
|
9db8a043a9 | |
|
|
205b9b5801 |
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.material.equipment.controller;
|
||||
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
import com.bonus.material.equipment.service.IDeptEquipmentConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/equipmentConfig")
|
||||
|
||||
public class DeptEquipmentConfigController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IDeptEquipmentConfigService service;
|
||||
|
||||
@GetMapping("/{deptId}")
|
||||
public AjaxResult getConfigByDept(@PathVariable Long deptId) {
|
||||
return AjaxResult.success(service.selectByDeptId(deptId));
|
||||
}
|
||||
|
||||
@PostMapping("/saveEquitConfig")
|
||||
public AjaxResult save(@RequestBody DeptEquipmentConfig configList) {
|
||||
int i = service.saveBatch(configList);
|
||||
if (i > 0){
|
||||
return AjaxResult.success("操作成功");
|
||||
}else {
|
||||
return AjaxResult.error("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
package com.bonus.material.equipment.controller;
|
||||
|
||||
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.InnerAuth;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
||||
import com.bonus.material.equipment.domain.DeptConfigRateSummary;
|
||||
import com.bonus.material.equipment.domain.DeptConfigTypeSummary;
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
import com.bonus.material.equipment.domain.EquipmentDetail;
|
||||
import com.bonus.material.equipment.service.ISysDeptService;
|
||||
import com.bonus.system.api.domain.SysDept;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
public class SysDeptController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysDeptService service;
|
||||
|
||||
/**
|
||||
* 获取部门树列表
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list"))
|
||||
@GetMapping("/deptTree")
|
||||
public AjaxResult deptTree(SysDept dept) {
|
||||
try {
|
||||
return success(service.selectDeptTreeList(dept));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表")
|
||||
public TableDataInfo list(DeptEquipmentConfig user) {
|
||||
try {
|
||||
startPage();
|
||||
List<SysUser> list = service.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
@GetMapping("/listRate")
|
||||
@SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表")
|
||||
public TableDataInfo listRate(DeptConfigRateSummary user) {
|
||||
try {
|
||||
List<DeptConfigRateSummary> list = service.selectDeptConfigRatePivot(user);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/selectConfigList")
|
||||
public AjaxResult selectConfigList(@RequestBody DeptEquipmentConfig user) {
|
||||
return service.selectConfigList(user);
|
||||
}
|
||||
//装备名称下拉框获取
|
||||
@PostMapping("/getTree")
|
||||
public AjaxResult getTree() {
|
||||
return service.getTree();
|
||||
}
|
||||
|
||||
@GetMapping("/listConfigType")
|
||||
@SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表")
|
||||
public TableDataInfo listConfigType(DeptConfigTypeSummary user) {
|
||||
try {
|
||||
startPage();
|
||||
List<DeptConfigTypeSummary> list = service.selectDeptConfigTypeSummary(user);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
@PostMapping("/detailsInfo")
|
||||
@SysLog(title = "公司装备详情页面", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "公司装备详情页面")
|
||||
public TableDataInfo detailsInfo(@RequestBody EquipmentDetail equipmentDetail) {
|
||||
try {
|
||||
List<EquipmentDetail> list = service.detailsInfo(equipmentDetail);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ConfigEntity {
|
||||
|
||||
private String basicConfig;
|
||||
|
||||
private String configurationType;
|
||||
|
||||
private String configurationRate;
|
||||
|
||||
private String configurationDescription;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class DeptConfigRateSummary extends BaseEntity {
|
||||
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
|
||||
private String deptName;
|
||||
//公司
|
||||
private String companyName;
|
||||
|
||||
/** 配置类型A的装备配置率累计值 */
|
||||
private BigDecimal valueA;
|
||||
|
||||
/** 配置类型B的装备配置率累计值 */
|
||||
private BigDecimal valueB;
|
||||
|
||||
/** 配置类型C的装备配置率累计值 */
|
||||
private BigDecimal valueC;
|
||||
|
||||
/** 配置类型D的装备配置率累计值 新型装备 */
|
||||
private BigDecimal valueD;
|
||||
private BigDecimal configType;
|
||||
private Long companyId;
|
||||
private BigDecimal configValue;
|
||||
//装备配置率赋值
|
||||
private BigDecimal configRate;
|
||||
private BigDecimal orderCount;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class DeptConfigTypeSummary {
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
|
||||
/** 子类型名称(mt1.type_name) */
|
||||
private String typeName;
|
||||
|
||||
/** 父类型名称(mt2.type_name) */
|
||||
private String parentTypeName;
|
||||
|
||||
/** 配置率(已转数值) */
|
||||
private BigDecimal configRate;
|
||||
|
||||
/** 配置说明 */
|
||||
private String configDescription;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DeptEquipmentConfig extends BaseEntity {
|
||||
private Long id;
|
||||
private Long deptId;
|
||||
private String typeId;
|
||||
private String equipmentName;
|
||||
private String equipmenttype;
|
||||
private String basicConfig; //基础配置信息
|
||||
private String equipmentId;
|
||||
private List<ConfigEntity> configs;
|
||||
private String configStatus;
|
||||
|
||||
@Excel(name = "配置值")
|
||||
private String configValue;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import com.bonus.system.api.domain.SysDept;
|
||||
import com.bonus.system.api.domain.SysMenu;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Treeselect树结构实体类
|
||||
*
|
||||
* @author bonus
|
||||
*/
|
||||
@Data
|
||||
public class DeptTreeSelect implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
/** 父部门ID */
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String label;
|
||||
|
||||
private String status;
|
||||
|
||||
private Integer level;
|
||||
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<DeptTreeSelect> children;
|
||||
|
||||
public DeptTreeSelect() {
|
||||
|
||||
}
|
||||
|
||||
public DeptTreeSelect(SysDept dept) {
|
||||
this.id = dept.getDeptId();
|
||||
this.parentId = dept.getParentId();
|
||||
this.status = dept.getStatus();
|
||||
this.label = dept.getDeptName();
|
||||
this.level = dept.getLevel();
|
||||
this.children = dept.getChildren().stream().map(DeptTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public DeptTreeSelect(SysMenu menu) {
|
||||
this.id = menu.getMenuId();
|
||||
this.label = menu.getMenuName();
|
||||
this.status = menu.getStatus();
|
||||
this.children = menu.getChildren().stream().map(DeptTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public List<DeptTreeSelect> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<DeptTreeSelect> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 装备配置详情实体类
|
||||
*/
|
||||
@Data
|
||||
public class EquipmentDetail {
|
||||
|
||||
/** 序号 */
|
||||
private Integer index;
|
||||
|
||||
/** 工序 */
|
||||
private String process;
|
||||
|
||||
/** 装备名称 */
|
||||
private String name;
|
||||
|
||||
/** 基本配置标准(台/套) */
|
||||
private String standard;
|
||||
|
||||
/** 装备种类 */
|
||||
private String type;
|
||||
|
||||
/** 配置说明 */
|
||||
private String desc;
|
||||
|
||||
/** 装备配置率赋值 */
|
||||
private String value;
|
||||
|
||||
/** 自有装备数量 */
|
||||
private Integer own;
|
||||
|
||||
/** 租赁装备数量 */
|
||||
private Integer rent;
|
||||
|
||||
/** 装备实际配置率 */
|
||||
private String actual;
|
||||
|
||||
/** 特殊装备配置率 */
|
||||
private String special;
|
||||
|
||||
/** 特殊装备原因 */
|
||||
private String reason;
|
||||
//公司
|
||||
private String companyId;
|
||||
private String configType;
|
||||
/*是否存在新型装备的标识
|
||||
* 是 → status = 1,否 → status = 0
|
||||
*
|
||||
* */
|
||||
private String ifExist;
|
||||
private String orderCount;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NewOwnerdomin {
|
||||
private int companyId; // 公司ID
|
||||
private String maName; // 装备类型ID或名称
|
||||
private String companyName; // 公司名称
|
||||
private Integer maNum; // 数量
|
||||
|
||||
public NewOwnerdomin() {
|
||||
// 必须有无参构造函数
|
||||
}
|
||||
// 构造函数(用于复制)
|
||||
public NewOwnerdomin(NewOwnerdomin o) {
|
||||
this.companyId = o.companyId;
|
||||
this.maName = o.maName;
|
||||
this.maNum = o.maNum;
|
||||
this.companyName = o.companyName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NewmydevInfo {
|
||||
private String companyId;
|
||||
private String typeId;
|
||||
private String typeName;
|
||||
private Integer ownCount;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysDept extends BaseEntity {
|
||||
private Long deptId;
|
||||
private Long parentId;
|
||||
private String ancestors;
|
||||
private String deptName;
|
||||
private Integer orderNum;
|
||||
private String leader;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String status;
|
||||
private Integer isShow;
|
||||
private String delFlag;
|
||||
private String createBy;
|
||||
private String updateBy;
|
||||
private Long menuTemplateId;
|
||||
private Long adminUserId;
|
||||
private String initPassword;
|
||||
private String province;
|
||||
private String city;
|
||||
private String district;
|
||||
private String address;
|
||||
private String deptAbbreviation;
|
||||
private String remark;
|
||||
private String logo;
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.bonus.material.equipment.mapper;
|
||||
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DeptEquipmentConfigMapper {
|
||||
DeptEquipmentConfig selectConfig(Long deptId, Long typeId);
|
||||
List<DeptEquipmentConfig> selectConfigByDept(Long deptId);
|
||||
int insertOrUpdateBatch( DeptEquipmentConfig deptEquipmentConfig);
|
||||
|
||||
int deleteByDeptIdAndTypeId(DeptEquipmentConfig team);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.material.equipment.mapper;
|
||||
|
||||
import com.bonus.material.equipment.domain.ConfigEntity;
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
import com.bonus.material.equipment.domain.DeptTreeSelect;
|
||||
import com.bonus.material.equipment.domain.SysDept;
|
||||
import com.bonus.material.equipment.domain.*;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysDeptMapper {
|
||||
List<SysDept> selectDeptTree();
|
||||
|
||||
List<com.bonus.system.api.domain.SysDept> selectDeptList(com.bonus.system.api.domain.SysDept dept);
|
||||
|
||||
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
||||
|
||||
|
||||
List<ConfigEntity> selectConfigList(DeptEquipmentConfig user);
|
||||
|
||||
List<DeptConfigRateSummary> selectDeptConfigRatePivot(DeptConfigRateSummary entity);
|
||||
|
||||
List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity);
|
||||
|
||||
List<DeptTreeSelect> getTree();
|
||||
|
||||
List<EquipmentDetail> detailsInfo(EquipmentDetail equipmentDetail);
|
||||
|
||||
List<NewmydevInfo> listFromDevInfo(String companyId);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.bonus.material.equipment.service;
|
||||
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDeptEquipmentConfigService {
|
||||
List<DeptEquipmentConfig> selectByDeptId(Long deptId);
|
||||
int saveBatch( DeptEquipmentConfig configList);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.bonus.material.equipment.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.equipment.domain.*;
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
import com.bonus.material.equipment.domain.DeptTreeSelect;
|
||||
import com.bonus.system.api.domain.SysDept;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysDeptService {
|
||||
|
||||
public List<DeptTreeSelect> selectDeptTreeList(SysDept dept);
|
||||
|
||||
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
||||
|
||||
|
||||
AjaxResult selectConfigList(DeptEquipmentConfig user);
|
||||
|
||||
AjaxResult getTree();
|
||||
|
||||
List<DeptConfigRateSummary> selectDeptConfigRatePivot(DeptConfigRateSummary entity);
|
||||
|
||||
List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity);
|
||||
|
||||
List<EquipmentDetail> detailsInfo(EquipmentDetail equipmentDetail);
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.bonus.material.equipment.service.impl;
|
||||
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
import com.bonus.material.equipment.mapper.DeptEquipmentConfigMapper;
|
||||
import com.bonus.material.equipment.service.IDeptEquipmentConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DeptEquipmentConfigServiceImpl implements IDeptEquipmentConfigService {
|
||||
|
||||
@Autowired
|
||||
private DeptEquipmentConfigMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<DeptEquipmentConfig> selectByDeptId(Long deptId) {
|
||||
return mapper.selectConfigByDept(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBatch(DeptEquipmentConfig configList) {
|
||||
configList.setTypeId(configList.getEquipmentId());
|
||||
configList.setConfigValue(configList.getBasicConfig());
|
||||
//直接先删除对应的设备信息 通过公司id 和设备id进行删除
|
||||
DeptEquipmentConfig team = new DeptEquipmentConfig();
|
||||
team.setDeptId(configList.getDeptId());
|
||||
team.setTypeId(configList.getTypeId());
|
||||
mapper.deleteByDeptIdAndTypeId(team);
|
||||
|
||||
return mapper.insertOrUpdateBatch(configList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,388 @@
|
|||
package com.bonus.material.equipment.service.impl;
|
||||
|
||||
|
||||
import com.bonus.common.core.utils.SpringUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.bonus.common.datascope.annotation.DataScope;
|
||||
import com.bonus.common.datascope.utils.CommonDataPermissionInfo;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.equipment.domain.*;
|
||||
import com.bonus.material.equipment.mapper.SysDeptMapper;
|
||||
import com.bonus.material.equipment.service.ISysDeptService;
|
||||
import com.bonus.material.owner.domain.Ownerdomin;
|
||||
import com.bonus.material.owner.mapper.OwnerMapper;
|
||||
import com.bonus.system.api.domain.SysDept;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class SysDeptServiceImpl implements ISysDeptService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(SysDeptServiceImpl.class);
|
||||
@Autowired
|
||||
private SysDeptMapper mapper;
|
||||
|
||||
@Resource
|
||||
private OwnerMapper ownerMapper;
|
||||
|
||||
@Override
|
||||
public List<DeptTreeSelect> selectDeptTreeList(SysDept dept) {
|
||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> selectUserList(DeptEquipmentConfig user) {
|
||||
List<SysUser> sysUsers = mapper.selectUserList(user);
|
||||
return sysUsers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult selectConfigList(DeptEquipmentConfig user) {
|
||||
try {
|
||||
List<ConfigEntity> configEntities = mapper.selectConfigList(user);
|
||||
return ObjectUtils.isNotEmpty(configEntities) ? AjaxResult.success(configEntities) : AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getTree() {
|
||||
try {
|
||||
List<DeptTreeSelect> sysDepts = mapper.getTree();
|
||||
return ObjectUtils.isNotEmpty(sysDepts) ? AjaxResult.success(sysDepts) : AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptConfigRateSummary> selectDeptConfigRatePivot(DeptConfigRateSummary entity) {
|
||||
// 1. 查询配置率项(每条代表一个公司+设备+评分项)
|
||||
List<DeptConfigRateSummary> configList = mapper.selectDeptConfigRatePivot(entity);
|
||||
|
||||
// 2. 查询 ma_own_manage 表中原始设备数据
|
||||
List<Ownerdomin> ownListFromManage = ownerMapper.list(null);
|
||||
|
||||
// 3. 查询 ma_dev_info 表中聚合后的设备数据(包含公司名)
|
||||
List<NewOwnerdomin> ownListFromDevInfo = ownerMapper.listGrouped();
|
||||
|
||||
// 4. 构建设备索引 Map<公司ID_设备名, List<Ownerdomin>>
|
||||
Map<String, List<Ownerdomin>> ownIndex = new HashMap<>();
|
||||
|
||||
for (Ownerdomin device : ownListFromManage) {
|
||||
String key = device.getCompanyId() + "_" + device.getMaName();
|
||||
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(device);
|
||||
}
|
||||
|
||||
for (NewOwnerdomin dev : ownListFromDevInfo) {
|
||||
String key = dev.getCompanyId() + "_" + dev.getMaName();
|
||||
List<Ownerdomin> existList = ownIndex.get(key);
|
||||
|
||||
if (existList != null && !existList.isEmpty()) {
|
||||
for (Ownerdomin device : existList) {
|
||||
device.setMaNum(device.getMaNum() + dev.getMaNum());
|
||||
}
|
||||
} else {
|
||||
Ownerdomin newDevice = new Ownerdomin();
|
||||
newDevice.setCompanyId((long) dev.getCompanyId());
|
||||
newDevice.setMaName(dev.getMaName());
|
||||
newDevice.setMaNum(dev.getMaNum());
|
||||
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(newDevice);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 构建公司 → 汇总对象 Map<String, DeptConfigRateSummary>
|
||||
Map<String, DeptConfigRateSummary> companyMap = new LinkedHashMap<>();
|
||||
|
||||
for (DeptConfigRateSummary config : configList) {
|
||||
String company = config.getCompanyName();
|
||||
String type = config.getConfigType().toPlainString(); // 0:线路 1:电缆 2:变电
|
||||
String maName = config.getDeptName();
|
||||
BigDecimal orderCount = config.getOrderCount();
|
||||
Long configCompanyId = config.getCompanyId();
|
||||
|
||||
String key = configCompanyId + "_" + maName;
|
||||
List<Ownerdomin> sameCompanyDevices = ownIndex.getOrDefault(key, Collections.emptyList());
|
||||
BigDecimal score = computeScoreByMaName(orderCount, sameCompanyDevices, config);
|
||||
|
||||
DeptConfigRateSummary dto = companyMap.computeIfAbsent(company, k -> {
|
||||
DeptConfigRateSummary d = new DeptConfigRateSummary();
|
||||
d.setDeptName(company);
|
||||
d.setCompanyId(configCompanyId);
|
||||
d.setCompanyName(company);
|
||||
d.setValueA(BigDecimal.ZERO);
|
||||
d.setValueB(BigDecimal.ZERO);
|
||||
d.setValueC(BigDecimal.ZERO);
|
||||
return d;
|
||||
});
|
||||
|
||||
switch (type) {
|
||||
case "0":
|
||||
dto.setValueA(dto.getValueA().add(score));
|
||||
break;
|
||||
case "1":
|
||||
dto.setValueB(dto.getValueB().add(score));
|
||||
break;
|
||||
case "2":
|
||||
dto.setValueC(dto.getValueC().add(score));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 5.x:补充未出现在 configList 的公司/设备项
|
||||
Set<String> configKeys = configList.stream()
|
||||
.map(c -> c.getCompanyId() + "_" + c.getDeptName())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (Map.Entry<String, List<Ownerdomin>> entry : ownIndex.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (configKeys.contains(key)) continue;
|
||||
|
||||
List<Ownerdomin> devices = entry.getValue();
|
||||
if (devices == null || devices.isEmpty()) continue;
|
||||
|
||||
Ownerdomin first = devices.get(0);
|
||||
Long companyId = first.getCompanyId();
|
||||
String maName = first.getMaName();
|
||||
|
||||
// 从 devInfo 中找公司名称
|
||||
Optional<NewOwnerdomin> matchDev = ownListFromDevInfo.stream()
|
||||
.filter(d -> d.getCompanyId()==(new Long(companyId).intValue()) && d.getMaName().equals(maName))
|
||||
.findFirst();
|
||||
|
||||
String companyName = matchDev.map(NewOwnerdomin::getCompanyName).orElse("未知公司");
|
||||
|
||||
DeptConfigRateSummary dto = companyMap.computeIfAbsent(companyName, k -> {
|
||||
DeptConfigRateSummary d = new DeptConfigRateSummary();
|
||||
d.setDeptName(companyName);
|
||||
d.setCompanyId(companyId);
|
||||
d.setCompanyName(companyName);
|
||||
d.setValueA(BigDecimal.ZERO);
|
||||
d.setValueB(BigDecimal.ZERO);
|
||||
d.setValueC(BigDecimal.ZERO);
|
||||
return d;
|
||||
});
|
||||
|
||||
// 默认作为线路设备记入 valueA,或根据 maName 判断类型再分类(可拓展)
|
||||
BigDecimal score = computeScoreByMaName(BigDecimal.ZERO, devices, null);
|
||||
dto.setValueA(dto.getValueA().add(score));
|
||||
}
|
||||
|
||||
// 6. 返回汇总结果
|
||||
return new ArrayList<>(companyMap.values());
|
||||
|
||||
}
|
||||
|
||||
// ✅ 可选:添加没有配置项但有设备的公司
|
||||
private void addCompaniesWithoutConfig(List<DeptConfigRateSummary> configList,
|
||||
Map<String, DeptConfigRateSummary> companyMap,
|
||||
Map<String, List<Ownerdomin>> ownIndex) {
|
||||
// 获取所有配置表中出现的公司ID
|
||||
Set<Long> configCompanyIds = configList.stream()
|
||||
.map(DeptConfigRateSummary::getCompanyId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 获取所有设备公司ID
|
||||
Set<Long> deviceCompanyIds = ownIndex.keySet().stream()
|
||||
.map(key -> Long.parseLong(key.split("_")[0]))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 找出有设备但没配置的公司ID
|
||||
Set<Long> missingCompanyIds = new HashSet<>(deviceCompanyIds);
|
||||
missingCompanyIds.removeAll(configCompanyIds);
|
||||
|
||||
// 为这些公司创建空汇总对象
|
||||
for (Long companyId : missingCompanyIds) {
|
||||
// 获取公司名称(需要查询或从设备中提取)
|
||||
String companyName = "未知公司"; // 实际应从设备数据中获取
|
||||
|
||||
companyMap.computeIfAbsent(companyName, k -> {
|
||||
DeptConfigRateSummary d = new DeptConfigRateSummary();
|
||||
d.setDeptName(companyName);
|
||||
d.setCompanyId(companyId);
|
||||
d.setCompanyName(companyName);
|
||||
d.setValueA(BigDecimal.ZERO);
|
||||
d.setValueB(BigDecimal.ZERO);
|
||||
d.setValueC(BigDecimal.ZERO);
|
||||
return d;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> owns, DeptConfigRateSummary config) {
|
||||
if (config == null || owns == null || owns.isEmpty()) return BigDecimal.ZERO;
|
||||
|
||||
BigDecimal ownedTotal = BigDecimal.ZERO;
|
||||
BigDecimal leasedTotal = BigDecimal.ZERO;
|
||||
|
||||
for (Ownerdomin own : owns) {
|
||||
BigDecimal num = new BigDecimal(own.getMaNum());
|
||||
if ("2".equals(own.getType())) {
|
||||
ownedTotal = ownedTotal.add(num); // 自有
|
||||
} else {
|
||||
leasedTotal = leasedTotal.add(num); // 租赁
|
||||
}
|
||||
}
|
||||
|
||||
BigDecimal base = config.getConfigValue(); // 基本配置数量
|
||||
BigDecimal score = config.getConfigRate(); // 满分值
|
||||
|
||||
if (base == null || base.compareTo(BigDecimal.ZERO) == 0) return BigDecimal.ZERO;
|
||||
|
||||
|
||||
// 计算比例 = (自有 + 租赁×0.6 + 订单×0.9) / 基本配置数
|
||||
BigDecimal rate = ownedTotal
|
||||
.add(leasedTotal.multiply(new BigDecimal("0.6")))
|
||||
.add(ordercount.multiply(new BigDecimal("0.9")))
|
||||
.divide(base, 4, RoundingMode.HALF_UP);
|
||||
|
||||
|
||||
// 判断是否超过满分
|
||||
if (rate.compareTo(BigDecimal.ONE) > 0) {
|
||||
return score.setScale(2, RoundingMode.HALF_UP);
|
||||
} else {
|
||||
return rate.multiply(score).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity) {
|
||||
return mapper.selectDeptConfigTypeSummary(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EquipmentDetail> detailsInfo(EquipmentDetail equipmentDetail) {
|
||||
// 1. 原查询,返回 EquipmentDetail 列表
|
||||
List<EquipmentDetail> equipmentDetails = mapper.detailsInfo(equipmentDetail);
|
||||
|
||||
// 2. 新增查询,返回 NewmydevInfo 列表(ma_dev_info 自有设备数据)
|
||||
List<NewmydevInfo> devInfoList = mapper.listFromDevInfo(equipmentDetail.getCompanyId());
|
||||
|
||||
// 3. 建立原有设备索引,key = companyId + "_" + name
|
||||
Map<String, EquipmentDetail> indexMap = new LinkedHashMap<>();
|
||||
for (EquipmentDetail item : equipmentDetails) {
|
||||
String key = item.getCompanyId() + "_" + item.getName();
|
||||
indexMap.put(key, item);
|
||||
}
|
||||
|
||||
// 4. 遍历 devInfoList,合并到 equipmentDetails
|
||||
for (NewmydevInfo devItem : devInfoList) {
|
||||
String key = devItem.getCompanyId() + "_" + devItem.getTypeName();
|
||||
EquipmentDetail existing = indexMap.get(key);
|
||||
|
||||
if (existing != null) {
|
||||
// 已存在,累加自有数量 own
|
||||
if (existing.getOwn() == null) {
|
||||
existing.setOwn(devItem.getOwnCount());
|
||||
} else {
|
||||
existing.setOwn(
|
||||
existing.getOwn() + (devItem.getOwnCount() == null ? 0 : devItem.getOwnCount())
|
||||
);
|
||||
|
||||
}
|
||||
} else {
|
||||
// 不存在,新增一条 EquipmentDetail,赋值必要字段
|
||||
EquipmentDetail newItem = new EquipmentDetail();
|
||||
newItem.setCompanyId(devItem.getCompanyId());
|
||||
newItem.setName(devItem.getTypeName());
|
||||
newItem.setOwn(devItem.getOwnCount());
|
||||
// 其他字段可根据业务决定是否赋默认值
|
||||
newItem.setDesc("来自装备配置管理");
|
||||
equipmentDetails.add(newItem);
|
||||
indexMap.put(key, newItem);
|
||||
}
|
||||
}
|
||||
|
||||
return equipmentDetails;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询部门管理数据
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @return 部门信息集合
|
||||
*/
|
||||
@DataScope(deptAlias = "d")
|
||||
public List<SysDept> selectDeptList(SysDept dept) {
|
||||
try {
|
||||
BaseEntity entity = CommonDataPermissionInfo.backMissionInfo(dept.getParams().get("dataScope").toString());
|
||||
BeanUtils.copyProperties(entity, dept);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (dept.getDeptName() != null) {
|
||||
String str = dept.getDeptName().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_");
|
||||
dept.setDeptName(str);
|
||||
}
|
||||
dept.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
return mapper.selectDeptList(dept);
|
||||
}
|
||||
|
||||
public List<DeptTreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
|
||||
List<SysDept> deptTrees = buildDeptTree(depts);
|
||||
return deptTrees.stream().map(DeptTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysDept> buildDeptTree(List<SysDept> depts) {
|
||||
List<SysDept> returnList = new ArrayList<SysDept>();
|
||||
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
||||
for (SysDept dept : depts) {
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.contains(dept.getParentId())) {
|
||||
recursionFn(depts, dept);
|
||||
returnList.add(dept);
|
||||
}
|
||||
}
|
||||
if (returnList.isEmpty()) {
|
||||
returnList = depts;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
private void recursionFn(List<SysDept> list, SysDept t) {
|
||||
// 得到子节点列表
|
||||
List<SysDept> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (SysDept tChild : childList) {
|
||||
if (hasChild(list, tChild)) {
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
|
||||
List<SysDept> tlist = new ArrayList<SysDept>();
|
||||
Iterator<SysDept> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
SysDept n = (SysDept) it.next();
|
||||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
|
||||
tlist.add(n);
|
||||
}
|
||||
}
|
||||
return tlist;
|
||||
}
|
||||
|
||||
private boolean hasChild(List<SysDept> list, SysDept t) {
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package com.bonus.material.owner.controller;
|
||||
|
||||
|
||||
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.security.utils.SecurityUtils;
|
||||
import com.bonus.material.contract.domain.BmContract;
|
||||
import com.bonus.material.device.domain.dto.DevInfoImpDto;
|
||||
import com.bonus.material.owner.domain.Ownerdomin;
|
||||
import com.bonus.material.owner.service.OwnerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:lizhenhua
|
||||
* @Date:2025/6/26- 9:14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/owner")
|
||||
@Api(value = "自有装备管理", tags = "自有装备管理")
|
||||
public class OwnerController extends BaseController {
|
||||
@Resource
|
||||
private OwnerService ownerService;
|
||||
|
||||
@ApiOperation(value = "自有装备管理列表")
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(Ownerdomin ownerdomin) {
|
||||
startPage();
|
||||
List<Ownerdomin> list = ownerService.list(ownerdomin);
|
||||
return AjaxResult.success(getDataTable(list));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "自有装备管理新增")
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody Ownerdomin ownerdomin) throws UnsupportedEncodingException {
|
||||
if(ownerdomin.getMaNameId() != null){
|
||||
ownerdomin.setMaName(ownerdomin.getMaNameId());
|
||||
}
|
||||
Integer i = ownerService.add(ownerdomin);
|
||||
if (i > 0){
|
||||
return AjaxResult.success("新增成功");
|
||||
}else {
|
||||
return AjaxResult.error("新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "自有装备管理修改")
|
||||
@PostMapping("/edit")
|
||||
public AjaxResult edit(@RequestBody Ownerdomin ownerdomin) throws UnsupportedEncodingException {
|
||||
Integer i = ownerService.edit(ownerdomin);
|
||||
if (i > 0){
|
||||
return AjaxResult.success("修改成功");
|
||||
}else {
|
||||
return AjaxResult.error("修改失败");
|
||||
}
|
||||
}
|
||||
@ApiOperation(value = "自有装备管理删除")
|
||||
@PostMapping("/del")
|
||||
public AjaxResult del(@RequestBody Ownerdomin ownerdomin) {
|
||||
Integer i = ownerService.del(ownerdomin);
|
||||
if (i > 0){
|
||||
return AjaxResult.success("删除成功");
|
||||
}else {
|
||||
return AjaxResult.error("删除失败");
|
||||
}
|
||||
}
|
||||
@ApiOperation(value = "装备批量录入")
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(@RequestParam("file") MultipartFile file,
|
||||
String type) throws Exception {
|
||||
// 1. 空文件判断
|
||||
if (file == null || file.isEmpty()) {
|
||||
return AjaxResult.error("上传的文件不能为空!");
|
||||
}
|
||||
|
||||
// 2. 文件名及格式校验
|
||||
String fileName = file.getOriginalFilename();
|
||||
if (fileName != null) {
|
||||
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
long fileSize = file.getSize();
|
||||
if (!fileExtension.equalsIgnoreCase("xls") && !fileExtension.equalsIgnoreCase("xlsx")) {
|
||||
return AjaxResult.error("文件后缀名必须为 xls 或 xlsx");
|
||||
} else if (fileSize > 10 * 1024 * 1024) {
|
||||
return AjaxResult.error("文件大小不能超过 10MB");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 读取文件内容并处理
|
||||
ExcelUtil<Ownerdomin> util = new ExcelUtil<>(Ownerdomin.class);
|
||||
List<Ownerdomin> maPropInfoList = util.importExcel(file.getInputStream());
|
||||
|
||||
if (maPropInfoList == null || maPropInfoList.isEmpty()) {
|
||||
return AjaxResult.error("导入的数据不能为空!");
|
||||
}
|
||||
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
String message = ownerService.importMaProp(maPropInfoList, type, userId);
|
||||
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.bonus.material.owner.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:liang.chao
|
||||
* @Date:2024/12/13 - 9:17
|
||||
*/
|
||||
@Data
|
||||
public class Ownerdomin {
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "装备分类")
|
||||
private String maType;
|
||||
|
||||
@ApiModelProperty(value = "装备名称")
|
||||
@Excel(name = "装备名称")
|
||||
private String maName;
|
||||
|
||||
@ApiModelProperty(value = "装备规格")
|
||||
@Excel(name = "装备规格")
|
||||
private String maModel;
|
||||
|
||||
@ApiModelProperty(value = "规格id")
|
||||
private Integer modelId;
|
||||
|
||||
@ApiModelProperty(value = "类型(1租赁 2自有)")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "所属公司")
|
||||
private Long companyId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "装备数量")
|
||||
@Excel(name = "装备数量")
|
||||
private Integer maNum;
|
||||
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String creator;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
@Excel(name = "备注")
|
||||
private String remark;
|
||||
@ApiModelProperty(value = "装备名称id")
|
||||
private String maNameId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.bonus.material.owner.mapper;
|
||||
|
||||
|
||||
import com.bonus.material.equipment.domain.NewOwnerdomin;
|
||||
import com.bonus.material.owner.domain.Ownerdomin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OwnerMapper {
|
||||
|
||||
|
||||
List<Ownerdomin> list(Ownerdomin ownerdomin);
|
||||
|
||||
Integer add(Ownerdomin ownerdomin);
|
||||
|
||||
Integer edit(Ownerdomin ownerdomin);
|
||||
|
||||
Integer del(Ownerdomin ownerdomin);
|
||||
|
||||
List<NewOwnerdomin> listGrouped();
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.bonus.material.owner.service;
|
||||
|
||||
import com.bonus.material.owner.domain.Ownerdomin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface OwnerService {
|
||||
|
||||
List<Ownerdomin> list(Ownerdomin ownerdomin);
|
||||
|
||||
Integer add(Ownerdomin ownerdomin);
|
||||
|
||||
Integer edit(Ownerdomin ownerdomin);
|
||||
|
||||
Integer del(Ownerdomin ownerdomin);
|
||||
|
||||
String importMaProp(List<Ownerdomin> maPropInfoList, String type, Long userId);
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.bonus.material.owner.service.impl;
|
||||
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.utils.bean.BeanUtils;
|
||||
import com.bonus.common.core.utils.bean.BeanValidators;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.material.device.domain.DevInfo;
|
||||
import com.bonus.material.device.domain.dto.DevInfoImpDto;
|
||||
import com.bonus.material.owner.domain.Ownerdomin;
|
||||
import com.bonus.material.owner.mapper.OwnerMapper;
|
||||
import com.bonus.material.owner.service.OwnerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Validator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OwnerServiceImpl implements OwnerService {
|
||||
|
||||
@Resource
|
||||
private OwnerMapper ownerMapper;
|
||||
|
||||
@Resource
|
||||
protected Validator validator;
|
||||
|
||||
@Override
|
||||
public List<Ownerdomin> list(Ownerdomin ownerdomin) {
|
||||
ownerdomin.setCreator(SecurityUtils.getLoginUser().getSysUser().getUserId()+"");
|
||||
ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
List<Ownerdomin> list = ownerMapper.list(ownerdomin);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer add(Ownerdomin ownerdomin) {
|
||||
ownerdomin.setCreator(SecurityUtils.getLoginUser().getSysUser().getUserId()+"");
|
||||
ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
return ownerMapper.add(ownerdomin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer edit(Ownerdomin ownerdomin) {
|
||||
return ownerMapper.edit(ownerdomin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer del(Ownerdomin ownerdomin) {
|
||||
return ownerMapper.del(ownerdomin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importMaProp(List<Ownerdomin> maPropInfoList, String type, Long userId) {
|
||||
if (StringUtils.isNull(maPropInfoList) || maPropInfoList.isEmpty()) {
|
||||
throw new ServiceException("导入的数据不能为空!");
|
||||
}
|
||||
|
||||
// 过滤掉空对象或空行
|
||||
maPropInfoList = maPropInfoList.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> StringUtils.isNotEmpty(item.getMaName())) // 替换为你必须字段
|
||||
.collect(Collectors.toList());
|
||||
|
||||
int failureNum = 0;
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
|
||||
for (Ownerdomin devInfo : maPropInfoList) {
|
||||
try {
|
||||
BeanValidators.validateWithException(validator, devInfo);
|
||||
devInfo.setCreator(userId + "");
|
||||
Ownerdomin ownerdomin = new Ownerdomin();
|
||||
BeanUtils.copyProperties(devInfo, ownerdomin);
|
||||
ownerdomin.setType(type);
|
||||
ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
ownerMapper.add(ownerdomin);
|
||||
successMsg.append(" 导入成功");
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = " 导入失败:";
|
||||
failureMsg.append(msg).append(e.getMessage());
|
||||
log.error(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
return successMsg.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.material.equipment.mapper.DeptEquipmentConfigMapper">
|
||||
<delete id="deleteByDeptIdAndTypeId">
|
||||
DELETE FROM ma_dept_config WHERE dept_id = #{deptId} AND type_id = #{typeId}
|
||||
</delete>
|
||||
|
||||
<select id="selectConfig" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||
|
||||
</select>
|
||||
<select id="selectConfigByDept" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||
SELECT * FROM dept_equipment_config WHERE dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<insert id="insertOrUpdateBatch" parameterType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||
INSERT INTO ma_dept_config (
|
||||
dept_id,
|
||||
type_id,
|
||||
config_type,
|
||||
config_value,
|
||||
config_rate,
|
||||
config_description,
|
||||
remark
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="configs" item="item" separator=",">
|
||||
(
|
||||
#{deptId},
|
||||
#{equipmentId},
|
||||
#{item.configurationType},
|
||||
#{item.basicConfig},
|
||||
#{item.configurationRate},
|
||||
#{item.configurationDescription},
|
||||
#{remark}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
config_value = VALUES(config_value),
|
||||
config_rate = VALUES(config_rate),
|
||||
config_description = VALUES(config_description),
|
||||
remark = VALUES(remark),
|
||||
update_time = CURRENT_TIMESTAMP
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
<?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.bonus.material.equipment.mapper.SysDeptMapper">
|
||||
<sql id="selectDeptVo">
|
||||
select d.dept_id,
|
||||
d.parent_id,
|
||||
d.ancestors,
|
||||
d.dept_name,
|
||||
d.order_num,
|
||||
d.leader,
|
||||
d.phone,
|
||||
d.email,
|
||||
d.status,
|
||||
d.del_flag,
|
||||
d.create_by,
|
||||
d.create_time
|
||||
from sys_dept d
|
||||
</sql>
|
||||
<resultMap type="com.bonus.system.api.domain.SysDept" id="SysDeptResult">
|
||||
<id property="deptId" column="dept_id" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="leader" column="leader" />
|
||||
<result property="phone" column="phone" />
|
||||
<result property="email" column="email" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="parentName" column="parent_name" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="menuTemplateId" column="menu_template_id" />
|
||||
<result property="province" column="province" />
|
||||
<result property="city" column="city" />
|
||||
<result property="district" column="district" />
|
||||
<result property="address" column="address" />
|
||||
<result property="deptAbbreviation" column="dept_abbreviation" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="logo" column="logo" />
|
||||
<result property="adminUserId" column="admin_user_id" />
|
||||
<result property="initPassword" column="init_password" />
|
||||
</resultMap>
|
||||
<select id="selectDeptTree">
|
||||
SELECT * FROM sys_dept WHERE del_flag = '0' ORDER BY parent_id, order_num
|
||||
</select>
|
||||
<select id="selectDeptList" parameterType="com.bonus.system.api.domain.SysDept" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where d.del_flag = '0'
|
||||
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND dept_name like concat('%', #{deptName}, '%')
|
||||
</if>
|
||||
|
||||
</select>
|
||||
<select id="selectUserList" resultType="com.bonus.material.equipment.domain.DeptEquipmentConfig">
|
||||
SELECT
|
||||
mt.type_id AS equipmentId,
|
||||
mt2.type_name AS equipmentName,
|
||||
mt.type_name AS equipmenttype,
|
||||
CASE
|
||||
WHEN MAX(mdc.config_value) IS NOT NULL AND MAX(mdc.config_value) != '' THEN '已配置'
|
||||
ELSE '未配置'
|
||||
END AS configStatus
|
||||
FROM ma_type mt
|
||||
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||
LEFT JOIN ma_dept_config mdc
|
||||
ON mdc.type_id = mt.type_id
|
||||
AND mdc.dept_id = #{deptId}
|
||||
WHERE mt.level = 3
|
||||
<if test="equipmentName != null and equipmentName != ''">
|
||||
AND mt.type_name LIKE CONCAT('%', #{equipmentName}, '%')
|
||||
</if>
|
||||
<if test="equipmenttype != null and equipmenttype != ''">
|
||||
AND mt2.type_name LIKE CONCAT('%', #{equipmenttype}, '%')
|
||||
</if>
|
||||
GROUP BY mt.type_id, mt2.type_name, mt.type_name
|
||||
</select>
|
||||
<select id="selectConfigList" resultType="com.bonus.material.equipment.domain.ConfigEntity">
|
||||
SELECT
|
||||
config_value AS basicConfig,
|
||||
config_type AS configurationType,
|
||||
config_rate AS configurationRate,
|
||||
config_description AS configurationDescription
|
||||
FROM ma_dept_config
|
||||
WHERE dept_id = #{deptId}
|
||||
AND type_id = #{typeId}
|
||||
</select>
|
||||
<select id="getTree" resultType="com.bonus.material.equipment.domain.DeptTreeSelect">
|
||||
SELECT
|
||||
mt.type_id AS id,
|
||||
|
||||
mt.type_name AS name
|
||||
FROM ma_type mt
|
||||
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||
LEFT JOIN ma_dept_config mdc
|
||||
ON mdc.type_id = mt.type_id
|
||||
|
||||
WHERE mt.level = 3
|
||||
GROUP BY mt.type_id, mt2.type_name, mt.type_name
|
||||
</select>
|
||||
<select id="selectDeptConfigRatePivot"
|
||||
resultType="com.bonus.material.equipment.domain.DeptConfigRateSummary">
|
||||
SELECT
|
||||
my.type_name AS deptName,
|
||||
sd.dept_name AS companyName,
|
||||
mdc.dept_id AS companyId,
|
||||
mdc.config_type AS configType,
|
||||
mdc.config_value AS configValue,
|
||||
mdc.config_rate AS configRate,
|
||||
IFNULL(order_stat.order_count, 0) AS orderCount
|
||||
FROM
|
||||
ma_dept_config mdc
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = mdc.dept_id
|
||||
LEFT JOIN ma_type my ON my.type_id = mdc.type_id
|
||||
|
||||
-- 设备订单数量子查询
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
sd.dept_id AS dept_id,
|
||||
mt2.type_id AS parent_type_id,
|
||||
COUNT(md.ma_id) AS order_count
|
||||
FROM
|
||||
ma_order_details md
|
||||
LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id
|
||||
LEFT JOIN ma_dev_info mdi ON md.ma_id = mdi.ma_id
|
||||
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||
LEFT JOIN sys_dept sd ON moi.buyer_company = sd.dept_id
|
||||
GROUP BY sd.dept_id, mt2.type_id
|
||||
) order_stat
|
||||
ON order_stat.dept_id = mdc.dept_id
|
||||
AND order_stat.parent_type_id = mdc.type_id
|
||||
|
||||
WHERE 1 = 1
|
||||
|
||||
|
||||
</select>
|
||||
<select id="selectDeptConfigTypeSummary"
|
||||
resultType="com.bonus.material.equipment.domain.DeptConfigTypeSummary">
|
||||
SELECT mt1.type_name AS typeName,
|
||||
mt2.type_name AS parentTypeName,
|
||||
CAST(mdc.config_rate AS DECIMAL(10, 2)) AS configRate,
|
||||
mdc.config_description AS configDescription
|
||||
FROM ma_dept_config mdc
|
||||
LEFT JOIN ma_type mt1 ON mt1.type_id = mdc.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
|
||||
WHERE mdc.dept_id = #{deptId}
|
||||
</select>
|
||||
<select id="detailsInfo" resultType="com.bonus.material.equipment.domain.EquipmentDetail">
|
||||
SELECT
|
||||
d.dept_id AS companyId,
|
||||
mt.type_name AS NAME,
|
||||
d.config_description as `desc`,
|
||||
SUM(CAST(d.config_rate AS DECIMAL(10, 2))) AS `value`,
|
||||
(
|
||||
SELECT
|
||||
CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END
|
||||
FROM ma_dept_config d2
|
||||
WHERE d2.dept_id = d.dept_id AND d2.config_type = '3'
|
||||
) AS ifExist,
|
||||
|
||||
(
|
||||
SELECT COUNT(md.ma_id)
|
||||
FROM ma_order_details md
|
||||
LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id
|
||||
LEFT JOIN ma_dev_info mdi ON md.ma_id = mdi.ma_id
|
||||
LEFT JOIN ma_type mt1 ON mdi.type_id = mt1.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
WHERE
|
||||
moi.buyer_company = d.dept_id AND
|
||||
mt2.type_id = d.type_id
|
||||
) AS orderCount,
|
||||
|
||||
SUM(CAST(d.config_value AS DECIMAL(10, 2))) AS standard,
|
||||
MAX(own_count) AS own,
|
||||
MAX(rent_count) AS rent
|
||||
|
||||
FROM
|
||||
ma_dept_config d
|
||||
LEFT JOIN (
|
||||
SELECT ma_name, SUM(ma_num) AS own_count
|
||||
FROM ma_own_manage
|
||||
WHERE type = '2' AND is_active = '0' and company_id=#{companyId}
|
||||
GROUP BY ma_name
|
||||
) own ON CAST(d.type_id AS CHAR) = own.ma_name
|
||||
|
||||
LEFT JOIN (
|
||||
SELECT ma_name, SUM(ma_num) AS rent_count
|
||||
FROM ma_own_manage
|
||||
WHERE type = '1' AND is_active = '0' and company_id=#{companyId}
|
||||
GROUP BY ma_name
|
||||
) rent ON CAST(d.type_id AS CHAR) = rent.ma_name
|
||||
|
||||
LEFT JOIN ma_type mt ON mt.type_id = d.type_id
|
||||
WHERE
|
||||
1=1
|
||||
<if test="companyId != null">
|
||||
AND d.dept_id = #{companyId}
|
||||
</if>
|
||||
<if test="configType != null">
|
||||
AND d.config_type = #{configType}
|
||||
</if>
|
||||
|
||||
GROUP BY
|
||||
d.dept_id,
|
||||
d.config_type,
|
||||
d.type_id;
|
||||
</select>
|
||||
<select id="listFromDevInfo" resultType="com.bonus.material.equipment.domain.NewmydevInfo">
|
||||
SELECT
|
||||
md.own_co AS companyId,
|
||||
mt2.type_id AS typeId,
|
||||
mt2.type_name as typeName,
|
||||
SUM( 1 ) AS ownCount
|
||||
FROM
|
||||
ma_dev_info md
|
||||
LEFT JOIN ma_type mt ON mt.type_id = md.type_id
|
||||
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
||||
WHERE
|
||||
md.is_active = '1'
|
||||
AND md.own_co = 221
|
||||
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
<?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.bonus.material.owner.mapper.OwnerMapper">
|
||||
<insert id="add">
|
||||
insert into ma_own_manage(
|
||||
ma_type, ma_name, model_id, ma_model, ma_num,
|
||||
creator, remark,company_id,type)
|
||||
values(#{maType}, #{maName}, #{modelId}, #{maModel}, #{maNum}, #{creator}, #{remark}, #{companyId},#{type})
|
||||
</insert>
|
||||
<update id="edit">
|
||||
update ma_own_manage set
|
||||
ma_type = #{maType},
|
||||
ma_name = #{maNameId},
|
||||
model_id = #{modelId},
|
||||
ma_model = #{maModel},
|
||||
ma_num = #{maNum},
|
||||
creator = #{creator},
|
||||
remark = #{remark}
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="del">
|
||||
update ma_own_manage set
|
||||
is_active =1
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="list" resultType="com.bonus.material.owner.domain.Ownerdomin">
|
||||
SELECT
|
||||
m.id,
|
||||
m.type,
|
||||
t.type_id as maNameId,
|
||||
m.company_id as companyId,
|
||||
m.ma_type AS maType,
|
||||
t.type_name AS maName,
|
||||
m.model_id AS modelId,
|
||||
m.ma_model AS maModel,
|
||||
m.ma_num AS maNum,
|
||||
m.create_time AS createTime,
|
||||
m.creator,
|
||||
m.remark
|
||||
FROM
|
||||
ma_own_manage m
|
||||
LEFT JOIN
|
||||
ma_type t ON m.ma_name = t.type_id
|
||||
<where>
|
||||
is_active = 0
|
||||
<if test="type!= null and type != ''">
|
||||
and type like concat('%', #{type}, '%')
|
||||
</if>
|
||||
<if test="maModel!= null and maModel != ''">
|
||||
and ma_model like concat('%', #{maModel}, '%')
|
||||
</if>
|
||||
<if test="maName != null and maName != ''">
|
||||
and ma_name like concat('%', #{maName}, '%')
|
||||
</if>
|
||||
<if test="companyId!= null and companyId != ''">
|
||||
and m.company_id = #{companyId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="listGrouped" resultType="com.bonus.material.equipment.domain.NewOwnerdomin">
|
||||
SELECT
|
||||
md.own_co AS companyId,
|
||||
sd.dept_name as companyName,
|
||||
mt2.type_name AS maName,
|
||||
COUNT(*) AS maNum
|
||||
FROM
|
||||
ma_dev_info md
|
||||
LEFT JOIN ma_type mt ON mt.type_id = md.type_id
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = md.own_co
|
||||
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
|
||||
WHERE
|
||||
md.is_active = '1'
|
||||
GROUP BY
|
||||
md.own_co,
|
||||
mt.type_name
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue