设备管理

This commit is contained in:
mashuai 2024-10-17 16:05:21 +08:00
parent 61bf060826
commit d7046c075e
9 changed files with 253 additions and 80 deletions

View File

@ -1,9 +1,20 @@
package com.bonus.material.basic.controller;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.system.api.RemoteDictDataService;
import com.bonus.system.api.domain.SysDictData;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -38,6 +49,9 @@ public class BmUnitController extends BaseController
@Autowired
private IBmUnitService bmUnitService;
@Resource
private RemoteDictDataService remoteDictDataService;
/**
* 查询往来单位管理列表
*/
@ -48,6 +62,7 @@ public class BmUnitController extends BaseController
{
startPage();
List<BmUnit> list = bmUnitService.selectBmUnitList(bmUnit);
extracted(list);
return getDataTable(list);
}
@ -62,10 +77,37 @@ public class BmUnitController extends BaseController
public void export(HttpServletResponse response, BmUnit bmUnit)
{
List<BmUnit> list = bmUnitService.selectBmUnitList(bmUnit);
extracted(list);
ExcelUtil<BmUnit> util = new ExcelUtil<BmUnit>(BmUnit.class);
util.exportExcel(response, list, "往来单位管理数据");
}
/**
* 将字典数据转换为 BmUnit 对象
* @param list
*/
private void extracted(List<BmUnit> list) {
AjaxResult ajaxResult = remoteDictDataService.dictType("bm_unit_type", SecurityConstants.INNER);
// 假设 ajaxResult.get("data") 返回的是 List<LinkedHashMap>
List<LinkedHashMap> rawData = (List<LinkedHashMap>) ajaxResult.get("data");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// rawData 转换为 SysDictData 列表
List<SysDictData> dataList = rawData.stream()
.map(rawDatum -> objectMapper.convertValue(rawDatum, SysDictData.class))
.collect(Collectors.toList());
// 使用 Map 存储字典数据以提高查找速度
Map<String, String> dictMap = dataList.stream()
.collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
// 更新 BmUnit 列表
list.forEach(unit -> {
String typeName = dictMap.get(unit.getTypeId());
if (typeName != null) {
unit.setTypeName(typeName);
}
});
}
/**
* 获取往来单位管理详细信息
*/

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.ma.vo.MachineVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,7 +48,7 @@ public class MachineController extends BaseController {
public TableDataInfo list(Machine machine)
{
startPage();
List<Machine> list = machineService.selectMachineList(machine);
List<MachineVo> list = machineService.selectMachineList(machine);
return getDataTable(list);
}
@ -61,8 +62,8 @@ public class MachineController extends BaseController {
@PostMapping("/export")
public void export(HttpServletResponse response, Machine machine)
{
List<Machine> list = machineService.selectMachineList(machine);
ExcelUtil<Machine> util = new ExcelUtil<Machine>(Machine.class);
List<MachineVo> list = machineService.selectMachineList(machine);
ExcelUtil<MachineVo> util = new ExcelUtil<MachineVo>(MachineVo.class);
util.exportExcel(response, list, "机具设备管理数据");
}
@ -74,7 +75,7 @@ public class MachineController extends BaseController {
@GetMapping(value = "/{maId}")
public AjaxResult getInfo(@PathVariable("maId") Long maId)
{
return success(machineService.selectMachineByMaId(maId));
return AjaxResult.success(machineService.selectMachineByMaId(maId));
}
/**
@ -100,7 +101,7 @@ public class MachineController extends BaseController {
@PutMapping
public AjaxResult edit(@RequestBody Machine machine)
{
return toAjax(machineService.updateMachine(machine));
return machineService.updateMachine(machine);
}
/**
@ -110,9 +111,9 @@ public class MachineController extends BaseController {
@PreventRepeatSubmit
@RequiresPermissions("ma:machine:remove")
@SysLog(title = "机具设备管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除机具设备管理")
@DeleteMapping("/{maIds}")
public AjaxResult remove(@PathVariable Long[] maIds)
@DeleteMapping("/{maId}")
public AjaxResult remove(@PathVariable Long maId)
{
return toAjax(machineService.deleteMachineByMaIds(maIds));
return machineService.deleteMachineByMaId(maId);
}
}

View File

@ -148,5 +148,10 @@ public class Machine extends BaseEntity
@ApiModelProperty(value = "联系电话")
private String phone;
@ApiModelProperty(value = "关键字")
private String keyWord;
@ApiModelProperty(value = "是否是固定资产 0 是1 否")
private Integer isAssets;
}

View File

@ -2,6 +2,7 @@ package com.bonus.material.ma.mapper;
import java.util.List;
import com.bonus.material.ma.domain.Machine;
import com.bonus.material.ma.vo.MachineVo;
/**
* 机具设备管理Mapper接口
@ -17,7 +18,7 @@ public interface MachineMapper
* @param maId 机具设备管理主键
* @return 机具设备管理
*/
public Machine selectMachineByMaId(Long maId);
public MachineVo selectMachineByMaId(Long maId);
/**
* 查询机具设备管理列表
@ -25,7 +26,7 @@ public interface MachineMapper
* @param machine 机具设备管理
* @return 机具设备管理集合
*/
public List<Machine> selectMachineList(Machine machine);
public List<MachineVo> selectMachineList(Machine machine);
/**
* 新增机具设备管理

View File

@ -1,7 +1,10 @@
package com.bonus.material.ma.service;
import java.util.List;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.ma.domain.Machine;
import com.bonus.material.ma.vo.MachineVo;
/**
* 机具设备管理Service接口
@ -17,7 +20,7 @@ public interface IMachineService
* @param maId 机具设备管理主键
* @return 机具设备管理
*/
public Machine selectMachineByMaId(Long maId);
public MachineVo selectMachineByMaId(Long maId);
/**
* 查询机具设备管理列表
@ -25,7 +28,7 @@ public interface IMachineService
* @param machine 机具设备管理
* @return 机具设备管理集合
*/
public List<Machine> selectMachineList(Machine machine);
public List<MachineVo> selectMachineList(Machine machine);
/**
* 新增机具设备管理
@ -41,7 +44,7 @@ public interface IMachineService
* @param machine 机具设备管理
* @return 结果
*/
public int updateMachine(Machine machine);
public AjaxResult updateMachine(Machine machine);
/**
* 批量删除机具设备管理
@ -57,5 +60,5 @@ public interface IMachineService
* @param maId 机具设备管理主键
* @return 结果
*/
public int deleteMachineByMaId(Long maId);
public AjaxResult deleteMachineByMaId(Long maId);
}

View File

@ -1,13 +1,18 @@
package com.bonus.material.ma.service.impl;
import java.util.List;
import com.bonus.common.biz.enums.HttpCodeEnum;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.ma.vo.MachineVo;
import org.springframework.stereotype.Service;
import com.bonus.material.ma.mapper.MachineMapper;
import com.bonus.material.ma.domain.Machine;
import com.bonus.material.ma.service.IMachineService;
import javax.annotation.Resource;
/**
* 机具设备管理Service业务层处理
*
@ -17,7 +22,7 @@ import com.bonus.material.ma.service.IMachineService;
@Service
public class MachineServiceImpl implements IMachineService
{
@Autowired
@Resource
private MachineMapper machineMapper;
/**
@ -27,7 +32,7 @@ public class MachineServiceImpl implements IMachineService
* @return 机具设备管理
*/
@Override
public Machine selectMachineByMaId(Long maId)
public MachineVo selectMachineByMaId(Long maId)
{
return machineMapper.selectMachineByMaId(maId);
}
@ -39,7 +44,7 @@ public class MachineServiceImpl implements IMachineService
* @return 机具设备管理
*/
@Override
public List<Machine> selectMachineList(Machine machine)
public List<MachineVo> selectMachineList(Machine machine)
{
return machineMapper.selectMachineList(machine);
}
@ -64,10 +69,14 @@ public class MachineServiceImpl implements IMachineService
* @return 结果
*/
@Override
public int updateMachine(Machine machine)
public AjaxResult updateMachine(Machine machine)
{
machine.setUpdateTime(DateUtils.getNowDate());
return machineMapper.updateMachine(machine);
int result = machineMapper.updateMachine(machine);
if (result > 0) {
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
/**
@ -89,8 +98,12 @@ public class MachineServiceImpl implements IMachineService
* @return 结果
*/
@Override
public int deleteMachineByMaId(Long maId)
public AjaxResult deleteMachineByMaId(Long maId)
{
return machineMapper.deleteMachineByMaId(maId);
int result = machineMapper.deleteMachineByMaId(maId);
if (result > 0) {
return AjaxResult.success(HttpCodeEnum.SUCCESS.getMsg(), result);
}
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
}
}

View File

@ -0,0 +1,27 @@
package com.bonus.material.ma.vo;
import com.bonus.material.ma.domain.Machine;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 设备返回vo
* @Author ma_sh
* @create 2024/10/17 13:25
*/
@Data
public class MachineVo extends Machine {
@ApiModelProperty("物品类型-一级")
private String itemType;
@ApiModelProperty("物品种类-二级")
private String materialType;
@ApiModelProperty("设备类型-三级")
private String materialName;
@ApiModelProperty("规格型号-四级")
private String materialModel;
}

View File

@ -47,35 +47,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectBmUnitList" resultType="com.bonus.material.basic.domain.BmUnit">
select bu.unit_id as unitId, bu.unit_name as unitName, bu.status as status, bu.type_id as typeId, but.type_name
as typeName, bu.link_man as
linkMan, bu.telphone as telphone,
bu.dept_id as deptId, bu.del_flag as delFlag, bu.create_by as createBy, bu.create_time as createTime,
bu.update_by as updateBy, bu.update_time as updateTime, bu.remark as remark from bm_unit bu
left join bm_unit_type but on but.type_id = bu.type_id and but.del_flag = 0
select unit_id as unitId, unit_name as unitName, status as status, type_id as typeId, link_man as
linkMan, telphone as telphone,
dept_id as deptId, del_flag as delFlag, create_by as createBy, create_time as createTime,
update_by as updateBy, update_time as updateTime, remark as remark from bm_unit
where
bu.del_flag = 0
del_flag = 0
<if test="unitName != null and unitName != ''">and unit_name like concat('%', #{unitName}, '%')</if>
</select>
<select id="selectBmUnitByUnitId" resultType="com.bonus.material.basic.domain.BmUnit">
select bu.unit_id as unitId,
bu.unit_name as unitName,
bu.status as status,
bu.type_id as typeId,
but.type_name as typeName,
bu.link_man as linkMan,
bu.telphone as telphone,
bu.dept_id as deptId,
bu.del_flag as delFlag,
bu.create_by as createBy,
bu.create_time as createTime,
bu.update_by as updateBy,
bu.update_time as updateTime,
bu.remark as remark
from bm_unit bu
left join bm_unit_type but on but.type_id = bu.type_id and but.del_flag = 0
where bu.del_flag = 0 and bu.unit_id = #{unitId}
select unit_id as unitId,
unit_name as unitName,
status as status,
type_id as typeId,
link_man as linkMan,
telphone as telphone,
dept_id as deptId,
del_flag as delFlag,
create_by as createBy,
create_time as createTime,
update_by as updateBy,
update_time as updateTime,
remark as remark
from bm_unit
where del_flag = 0 and unit_id = #{unitId}
</select>
<insert id="insertBmUnit" parameterType="com.bonus.material.basic.domain.BmUnit" useGeneratedKeys="true" keyProperty="unitId">

View File

@ -37,41 +37,127 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select ma_id, type_id, ma_code, pre_code, ma_status, qr_code, buy_price, ma_vender, out_fac_time, out_fac_code, assets_code, check_man, this_check_time, next_check_time, gps_code, rfid_code, erp_code, transfer_code, in_out_num, buy_task, own_house, company_id, create_time, update_time, inspect_man, inspect_status, phone from ma_machine
</sql>
<select id="selectMachineList" parameterType="com.bonus.material.ma.domain.Machine" resultMap="MachineResult">
<include refid="selectMachineVo"/>
<where>
<if test="typeId != null "> and type_id = #{typeId}</if>
<if test="maCode != null and maCode != ''"> and ma_code = #{maCode}</if>
<if test="preCode != null and preCode != ''"> and pre_code = #{preCode}</if>
<if test="maStatus != null and maStatus != ''"> and ma_status = #{maStatus}</if>
<if test="qrCode != null and qrCode != ''"> and qr_code = #{qrCode}</if>
<if test="buyPrice != null "> and buy_price = #{buyPrice}</if>
<if test="maVender != null and maVender != ''"> and ma_vender = #{maVender}</if>
<if test="outFacTime != null "> and out_fac_time = #{outFacTime}</if>
<if test="outFacCode != null and outFacCode != ''"> and out_fac_code = #{outFacCode}</if>
<if test="assetsCode != null and assetsCode != ''"> and assets_code = #{assetsCode}</if>
<if test="checkMan != null and checkMan != ''"> and check_man = #{checkMan}</if>
<if test="thisCheckTime != null "> and this_check_time = #{thisCheckTime}</if>
<if test="nextCheckTime != null "> and next_check_time = #{nextCheckTime}</if>
<if test="gpsCode != null and gpsCode != ''"> and gps_code = #{gpsCode}</if>
<if test="rfidCode != null and rfidCode != ''"> and rfid_code = #{rfidCode}</if>
<if test="erpCode != null and erpCode != ''"> and erp_code = #{erpCode}</if>
<if test="transferCode != null and transferCode != ''"> and transfer_code = #{transferCode}</if>
<if test="inOutNum != null "> and in_out_num = #{inOutNum}</if>
<if test="buyTask != null and buyTask != ''"> and buy_task = #{buyTask}</if>
<if test="ownHouse != null and ownHouse != ''"> and own_house = #{ownHouse}</if>
<if test="companyId != null and companyId != ''"> and company_id = #{companyId}</if>
<if test="inspectMan != null and inspectMan != ''"> and inspect_man = #{inspectMan}</if>
<if test="inspectStatus != null and inspectStatus != ''"> and inspect_status = #{inspectStatus}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
</where>
<select id="selectMachineList" resultType="com.bonus.material.ma.vo.MachineVo">
SELECT
ma.ma_id as maId,
ma.type_id as typeId,
mt4.type_name as itemType,
mt3.type_name as materialType,
mt2.type_name as materialName,
mt.type_name as materialModel,
ma.ma_code as maCode,
ma.pre_code as preCode,
ma.ma_status as maStatus,
ma.qr_code as qrCode,
ma.buy_price as buyPrice,
ma.ma_vender as maVender,
ma.out_fac_time as outFacTime,
ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,
ma.check_man as checkMan,
ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,
ma.gps_code as gpsCode,
ma.rfid_code as rfidCode,
ma.erp_code as erpCode,
ma.transfer_code as transferCode,
ma.in_out_num as inOutNum,
ma.buy_task as buyTask,
ma.own_house as ownHouse,
ma.company_id as companyId,
ma.create_time as createTime,
ma.update_time as updateTime,
ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus,
ma.phone as phone
FROM
ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
where
1 = 1
<if test="keyWord != null and keyWord != ''">
and (
ma.ma_code like concat('%', #{keyWord}, '%')
or ma.assets_code like concat('%', #{keyWord}, '%')
or ma.pre_code like concat('%', #{keyWord}, '%')
or ma.buy_task like concat('%', #{keyWord}, '%')
or ma.own_house like concat('%', #{keyWord}, '%')
)
</if>
<if test="materialType != null and materialType != ''">
and mt3.type_name like concat('%', #{materialType}, '%')
</if>
<if test="materialName != null and materialName != ''">
and mt2.type_name like concat('%', #{materialName}, '%')
</if>
<if test="materialModel != null and materialModel != ''">
and mt.type_name like concat('%', #{materialModel}, '%')
</if>
<if test="isAssets != null">
<if test="isAssets == 0">
AND ma.assets_code IS NOT NULL
AND ma.assets_code != ''
</if>
<if test="isAssets == 1">
AND (ma.assets_code IS NULL OR ma.assets_code = '')
</if>
</if>
order by ma.create_time desc
</select>
<select id="selectMachineByMaId" parameterType="Long" resultMap="MachineResult">
<include refid="selectMachineVo"/>
where ma_id = #{maId}
<select id="selectMachineByMaId" resultType="com.bonus.material.ma.vo.MachineVo">
SELECT
ma.ma_id as maId,
ma.type_id as typeId,
mt4.type_name as itemType,
mt3.type_name as materialType,
mt2.type_name as materialName,
mt.type_name as materialModel,
ma.ma_code as maCode,
ma.pre_code as preCode,
ma.ma_status as maStatus,
ma.qr_code as qrCode,
ma.buy_price as buyPrice,
ma.ma_vender as maVender,
ma.out_fac_time as outFacTime,
ma.out_fac_code as outFacCode,
ma.assets_code as assetsCode,
ma.check_man as checkMan,
ma.this_check_time as thisCheckTime,
ma.next_check_time as nextCheckTime,
ma.gps_code as gpsCode,
ma.rfid_code as rfidCode,
ma.erp_code as erpCode,
ma.transfer_code as transferCode,
ma.in_out_num as inOutNum,
ma.buy_task as buyTask,
ma.own_house as ownHouse,
ma.company_id as companyId,
ma.create_time as createTime,
ma.update_time as updateTime,
ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus,
ma.phone as phone
FROM
ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
and mt3.`level` = '2' and mt3.del_flag = '0'
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
and mt4.`level` = '1' and mt4.del_flag = '0'
where ma.ma_id = #{maId}
</select>
<insert id="insertMachine" parameterType="com.bonus.material.ma.domain.Machine" useGeneratedKeys="true" keyProperty="maId">
insert into ma_machine
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -156,7 +242,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="buyTask != null">buy_task = #{buyTask},</if>
<if test="ownHouse != null">own_house = #{ownHouse},</if>
<if test="companyId != null">company_id = #{companyId},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="inspectMan != null">inspect_man = #{inspectMan},</if>
<if test="inspectStatus != null">inspect_status = #{inspectStatus},</if>