Commit 192a86d3 authored by zhengjiawei's avatar zhengjiawei

重点设备配套设施调整

parent 028f276b
package com.yeejoin.amos.fas.dao.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* @description: 公共实体
* @author: duanwei
**/
@Data
@Accessors(chain = true)
public class BaseEntity implements Serializable {
private static final long serialVersionUID = -5464322936854328207L;
@TableId(type = IdType.ID_WORKER)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@TableField(value = "create_date", fill = FieldFill.INSERT) // 新增和更新执行
private Date createDate;
}
package com.yeejoin.amos.fas.dao.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.List;
/**
* 装备分类
*
* @author wujiang
* @date 2020-07-07
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("wl_equipment_category")
@ApiModel(value="EquipmentCategory装备分类实体", description="装备分类")
public class EquipmentCategory extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long parentId;
@ApiModelProperty(value = "装备分类编码")
private String code;
@ApiModelProperty(value = "装备分类名称")
private String name;
@ApiModelProperty(value = "消耗性装备标志")
private Boolean isConsumptive;
@ApiModelProperty(value = "用途或性能")
private String description;
@ApiModelProperty(value = "备注")
private String remark;
@TableField(exist=false)
@ApiModelProperty(value = "级别")
private String level;
@TableField(exist=false)
@ApiModelProperty(value = "个数")
private Double count;
@TableField(exist=false)
private boolean hasLowerClassification; //是否存在下级
@TableField(exist=false)
private List<EquipmentCategory> children = new ArrayList<>(); //子集
}
package com.yeejoin.amos.fas.business.controller;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificService;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.core.util.CommonResponse;
import com.yeejoin.amos.fas.core.util.CommonResponseUtil;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author zjw
* @date 2020-11-04
*/
@RestController
@RequestMapping(value = "/api/equipment")
@Api(tags = "重点设备配套设施调整Api")
public class EquipmentSpecificController extends BaseController{
@Autowired
private EquipmentSpecificService equipmentSpecificService;
@Autowired
private IEquipmentCategoryService iEquipmentCategoryService;
@GetMapping(value = "/getEquipmentBySpe")
@ApiOperation(httpMethod = "GET", value = "获取装备台账信息", notes = "获取装备台账信息")
public CommonResponse getEquipmentBySpe(
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "code",required = false) String code,
@RequestParam(value = "pageNumber",required = false) int pageNumber,
@RequestParam(value = "pageSize",required = false) int pageSize,
@RequestParam(value = "equipmentId",required = false) String equipmentId ) {
return CommonResponseUtil.success(equipmentSpecificService.getEquipmentBySpe(name, code, pageNumber, pageSize,equipmentId));
}
@GetMapping(value = "/list-tree", produces = "application/json;charset=UTF-8")
@ApiOperation(httpMethod = "GET", value = "全量数据树形结构返回", notes = "全量数据树形结构返回")
public CommonResponse getTreelist() {
List<EquipmentCategory> equipmentCategorys = iEquipmentCategoryService.list();
List<EquipmentCategory> list = new ArrayList<>();
Map<String, List<EquipmentCategory>> tmpMap = new HashMap<String, List<EquipmentCategory>>();
equipmentCategorys.forEach(action -> {
if (action.getParentId() == null) {
list.add(action);
} else {
if (tmpMap.get(action.getParentId().toString()) == null) {
ArrayList<EquipmentCategory> tmplist = new ArrayList<EquipmentCategory>();
tmplist.add(action);
tmpMap.put(action.getParentId().toString(), tmplist);
} else {
if (!tmpMap.get(action.getParentId().toString()).contains(action)) {
tmpMap.get(action.getParentId().toString()).add(action);
}
}
}
});
getChildren(list, tmpMap);
return CommonResponseUtil.success(list);
}
private void getChildren(List<EquipmentCategory> list, Map<String, List<EquipmentCategory>> tmpMap) {
for (EquipmentCategory equipmentCategory : list) {
if (tmpMap.get(equipmentCategory.getId().toString()) != null
&& tmpMap.get(equipmentCategory.getId().toString()).size() > 0) {
List<EquipmentCategory> equipcliss = tmpMap.get(equipmentCategory.getId().toString());
equipmentCategory.setHasLowerClassification(true);
equipmentCategory.setChildren(equipcliss);
getChildren(equipcliss, tmpMap);
}
}
}
}
package com.yeejoin.amos.fas.business.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import java.util.List;
/**
* 装备分类 Mapper 接口
*
* @author wujiang
* @date 2020-07-07
*/
public interface EquipmentCategoryMapper extends BaseMapper {
/**
* 获取全量数据
* @return
*/
List<EquipmentCategory> list( );
}
package com.yeejoin.amos.fas.business.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 设备配置 Mapper 接口
*
* @author zjw
* @date 2020-11-04
*/
public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecificVo> {
/**
* 获取配置数据
* @param pageNumber
* @param pageSize
* @param name
* @param code
* @param equipmentId
* @return
*/
List<EquipmentSpecificVo> getEquipmentBySpe(@Param("pageNumber") int pageNumber, @Param("pageSize") int pageSize, @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId);
int getEquipmentBySpeCount( @Param("name")String name, @Param("code")String code,@Param("equipmentId") String equipmentId);
}
package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.fas.business.service.intfc.IEquipmentCategoryService;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 装备分类 服务实现类
*
* @author zjw
* @date 2020-11-04
*/
@Service
public class EquipmentCategoryServiceImpl implements IEquipmentCategoryService {
@Autowired
private EquipmentCategoryMapper equipmentCategoryMapper;
@Override
public List<EquipmentCategory> list( ) {
return equipmentCategoryMapper.list();
}
}
package com.yeejoin.amos.fas.business.service.impl;
import com.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificMapper;
import com.yeejoin.amos.fas.business.service.intfc.EquipmentSpecificService;
import com.yeejoin.amos.fas.business.vo.EquipmentSpecificVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 装备配置 服务实现类
*
* @author zjw
* @date 2020-11-04
*/
@Service("equipmentSpecificService")
public class EquipmentSpecificServiceImpl implements EquipmentSpecificService {
@Autowired
EquipmentSpecificMapper equipmentSpecificMapper;
@Override
public Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize ,String equipmentId) {
Map<String, Object> map = new HashMap<>();
pageNumber = pageNumber*pageSize;
code = checkid(code);
List<EquipmentSpecificVo> equipmentBySpe = equipmentSpecificMapper.getEquipmentBySpe(pageNumber, pageSize, name, code,equipmentId);
int equipmentBySpeCount = equipmentSpecificMapper.getEquipmentBySpeCount(name, code,equipmentId);
map.put("content",equipmentBySpe);
map.put("totalElements",equipmentBySpeCount);
return map;
}
/**
* 截取装备分类code 码
* @param id
* @return
*/
private String checkid(String id){
if ("".equals(id) || "null".equals(id ) ){
return id;
}
String substring = id.substring(1, 2);
String substring1 = id.substring(2, 4);
String substring2 = id.substring(4, 6);
String substring3 = id.substring(6);
if (!substring.equals("0")){
substring = id.substring(0, 2);
if (!substring1.equals("00")){
substring += substring1;
if(!substring2.equals("00")){
substring += substring2;
if(!substring3.equals("00")){
substring += substring3;
}
}
}
}else {
substring = id.substring(0, 1);
}
return substring;
}
}
package com.yeejoin.amos.fas.business.service.intfc;
import java.util.Map;
/**
* @author zjw
* @date 2020-11-04
* 配置设备
*/
public interface EquipmentSpecificService {
/**
* 获取配置装备
* @param name
* @param code
* @param pageNumber
* @param pageSize
* @return
*/
Map<String ,Object> getEquipmentBySpe(String name, String code, int pageNumber, int pageSize, String equipmentId);
}
package com.yeejoin.amos.fas.business.service.intfc;
import com.yeejoin.amos.fas.dao.entity.EquipmentCategory;
import java.util.List;
/**
* 装备分类 服务类
*
* @author wujiang
* @date 2020-07-07
*/
public interface IEquipmentCategoryService {
/**
* 获取全量装备信息
* @return
*/
List<EquipmentCategory> list( );
}
package com.yeejoin.amos.fas.business.vo;
import lombok.Data;
@Data
public class EquipmentSpecificVo {
private String id;
//装备码
private String code;
//装备名称
private String name;
//装备分类
private String type;
//是否绑定
private String isbind;
//地址
private String address;
//库存
private Integer amount;
//是否单件管理(1是多件)
private Integer single;
}
<?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.yeejoin.amos.fas.business.dao.mapper.EquipmentCategoryMapper">
<select id="list" resultType="com.yeejoin.amos.fas.dao.entity.EquipmentCategory">
select * from wl_equipment_category
</select>
</mapper>
\ No newline at end of file
<?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.yeejoin.amos.fas.business.dao.mapper.EquipmentSpecificMapper">
<select id="getEquipmentBySpe" resultType="com.yeejoin.amos.fas.business.vo.EquipmentSpecificVo">
select
sto.id as id ,
equ.code as code,
det.name as name,
cate.name as type,
if(fire.fire_equipment_id is null ,'NO','YES') as isbind,
ware.full_name as address,
spe.single as single,
sto.amount as amount
from
wl_stock_detail as sto
left join wl_equipment_specific as spe on sto.qr_code = spe.qr_code
left join wl_warehouse_structure as ware on sto.warehouse_structure_id = ware .id
left join wl_equipment_detail as det on sto.equipment_detail_id = det.id
left join wl_equipment as equ on det.equipment_id = equ.id
left join wl_equipment_category as cate on equ.category_id = cate.id
left join f_equipment_fire_equipment as fire on sto.id = fire.fire_equipment_id
where sto.amount <![CDATA[>]]> 0
<if test="name != null and name!='null' ">
and det.name like CONCAT('%',#{name},'%' )
</if>
<if test="code != null and code!='null' ">
and cate.code like CONCAT('%',#{code},'%' )
</if>
<if test="equipmentId != null and equipmentId!='null' ">
and fire.equipment_id = #{equipmentId}
</if>
limit #{pageNumber},#{pageSize}
</select>
<select id="getEquipmentBySpeCount" resultType="int">
select
count(1)
from
wl_stock_detail as sto
left join wl_equipment_detail as det on sto.equipment_detail_id = det.id
left join wl_equipment as equ on det.equipment_id = equ.id
left join wl_equipment_category as cate on equ.category_id = cate.id
where sto.amount <![CDATA[>]]> 0
<if test="name != null and name!='null' ">
and det.name like CONCAT('%',#{name},'%' )
</if>
<if test="code != null and code!='null' ">
and cate.code like CONCAT('%',#{code},'%' )
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment