资源管理系统1.1

This commit is contained in:
xbx 2023-11-19 20:30:38 +08:00
parent 143516d671
commit 5ca13acd25
14 changed files with 633 additions and 343 deletions

View File

@ -1,5 +1,7 @@
package rms.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -7,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import rms.entity.RmsFurniture;
import rms.model.RmsFurnitureModel;
import rms.service.IRmsFurnitureService;
@ -16,15 +19,16 @@ import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Arrays;
/**
/**
* @Description: 家具信息表
* @Author: jeecg-boot
* @Date: 2023-11-18
* @Version: V1.0
*/
@Api(tags="家具信息表")
@Api(tags = "家具信息表")
@RestController
@RequestMapping("/rms/rmsFurniture")
@Slf4j
@ -42,13 +46,25 @@ public class RmsFurnitureController extends JeecgController<RmsFurniture, IRmsFu
* @return
*/
//@AutoLog(value = "家具信息表-分页列表查询")
@ApiOperation(value="家具信息表-分页列表查询", notes="家具信息表-分页列表查询")
// @ApiOperation(value = "家具信息表-分页列表查询", notes = "家具信息表-分页列表查询")
// @GetMapping(value = "/list")
// public Result<ArrayList<RmsFurnitureModel>> queryPageList(RmsFurniture rmsFurniture,
// @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
// HttpServletRequest req) {
// return rmsFurnitureService.queryAllFurniture(rmsFurniture, pageNo, pageSize, req);
// }
@ApiOperation(value = "家具信息表-分页列表查询", notes = "家具信息表-分页列表查询")
@GetMapping(value = "/list")
public Result<Page<RmsFurnitureModel>> queryPageList(RmsFurnitureModel rmsFurnitureModel,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
public Result<IPage<RmsFurniture>> queryPageList(RmsFurniture rmsFurniture,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
return rmsFurnitureService.queryAllFurniture(rmsFurnitureModel, pageNo, pageSize, req);
QueryWrapper<RmsFurniture> queryWrapper = QueryGenerator.initQueryWrapper(rmsFurniture, req.getParameterMap());
Page<RmsFurniture> page = new Page<RmsFurniture>(pageNo, pageSize);
IPage<RmsFurniture> pageList = rmsFurnitureService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
@ -58,7 +74,7 @@ public class RmsFurnitureController extends JeecgController<RmsFurniture, IRmsFu
* @return
*/
@AutoLog(value = "家具信息表-添加")
@ApiOperation(value="家具信息表-添加", notes="家具信息表-添加")
@ApiOperation(value = "家具信息表-添加", notes = "家具信息表-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody RmsFurniture rmsFurniture) {
rmsFurnitureService.save(rmsFurniture);
@ -72,8 +88,8 @@ public class RmsFurnitureController extends JeecgController<RmsFurniture, IRmsFu
* @return
*/
@AutoLog(value = "家具信息表-编辑")
@ApiOperation(value="家具信息表-编辑", notes="家具信息表-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
@ApiOperation(value = "家具信息表-编辑", notes = "家具信息表-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody RmsFurniture rmsFurniture) {
rmsFurnitureService.updateById(rmsFurniture);
return Result.OK("编辑成功!");
@ -86,9 +102,9 @@ public class RmsFurnitureController extends JeecgController<RmsFurniture, IRmsFu
* @return
*/
@AutoLog(value = "家具信息表-通过id删除")
@ApiOperation(value="家具信息表-通过id删除", notes="家具信息表-通过id删除")
@ApiOperation(value = "家具信息表-通过id删除", notes = "家具信息表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
rmsFurnitureService.removeById(id);
return Result.OK("删除成功!");
}
@ -100,9 +116,9 @@ public class RmsFurnitureController extends JeecgController<RmsFurniture, IRmsFu
* @return
*/
@AutoLog(value = "家具信息表-批量删除")
@ApiOperation(value="家具信息表-批量删除", notes="家具信息表-批量删除")
@ApiOperation(value = "家具信息表-批量删除", notes = "家具信息表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.rmsFurnitureService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@ -114,11 +130,11 @@ public class RmsFurnitureController extends JeecgController<RmsFurniture, IRmsFu
* @return
*/
//@AutoLog(value = "家具信息表-通过id查询")
@ApiOperation(value="家具信息表-通过id查询", notes="家具信息表-通过id查询")
@ApiOperation(value = "家具信息表-通过id查询", notes = "家具信息表-通过id查询")
@GetMapping(value = "/queryById")
public Result<RmsFurniture> queryById(@RequestParam(name="id",required=true) String id) {
public Result<RmsFurniture> queryById(@RequestParam(name = "id", required = true) String id) {
RmsFurniture rmsFurniture = rmsFurnitureService.getById(id);
if(rmsFurniture==null) {
if (rmsFurniture == null) {
return Result.error("未找到对应数据");
}
return Result.OK(rmsFurniture);

View File

@ -1,11 +1,14 @@
package rms.controller;
import java.util.ArrayList;
import java.util.Arrays;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import rms.entity.RmsLocation;
import rms.model.TreeModel;
import rms.service.IRmsLocationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -20,7 +23,6 @@ import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 存放地表
@ -28,7 +30,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
* @Date: 2023-11-18
* @Version: V1.0
*/
@Api(tags="存放地表")
@Api(tags = "存放地表")
@RestController
@RequestMapping("/rms/rmsLocation")
@Slf4j
@ -46,18 +48,33 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @return
*/
//@AutoLog(value = "存放地表-分页列表查询")
@ApiOperation(value="存放地表-分页列表查询", notes="存放地表-分页列表查询")
@ApiOperation(value = "存放地表-分页列表查询", notes = "存放地表-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<RmsLocation>> queryPageList(RmsLocation rmsLocation,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<RmsLocation> queryWrapper = QueryGenerator.initQueryWrapper(rmsLocation, req.getParameterMap());
Page<RmsLocation> page = new Page<RmsLocation>(pageNo, pageSize);
IPage<RmsLocation> pageList = rmsLocationService.page(page, queryWrapper);
//return Result.OK(rmsLocationService.getsLocationData(page, queryWrapper));
return Result.OK(pageList);
}
//获取树结构
@ApiOperation(value = "存放地表-分页列表查询", notes = "存放地表-分页列表查询")
@GetMapping(value = "/getTree")
public Result<ArrayList<TreeModel>> getTreeList() {
return Result.OK(rmsLocationService.getTreeList());
}
//获取级联样式
@ApiOperation(value = "存放地表-分页列表查询", notes = "存放地表-分页列表查询")
@GetMapping(value = "/getCascader")
public Result<ArrayList<TreeModel>> getCascaderList(@RequestParam(name = "type", defaultValue = "0") Integer type) {
return Result.OK(rmsLocationService.getCascaderList(type));
}
/**
* 添加
*
@ -65,8 +82,7 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @return
*/
@AutoLog(value = "存放地表-添加")
@ApiOperation(value="存放地表-添加", notes="存放地表-添加")
@RequiresPermissions("rms:rms_location:add")
@ApiOperation(value = "存放地表-添加", notes = "存放地表-添加")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody RmsLocation rmsLocation) {
rmsLocationService.save(rmsLocation);
@ -80,9 +96,8 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @return
*/
@AutoLog(value = "存放地表-编辑")
@ApiOperation(value="存放地表-编辑", notes="存放地表-编辑")
@RequiresPermissions("rms:rms_location:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
@ApiOperation(value = "存放地表-编辑", notes = "存放地表-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody RmsLocation rmsLocation) {
rmsLocationService.updateById(rmsLocation);
return Result.OK("编辑成功!");
@ -95,10 +110,9 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @return
*/
@AutoLog(value = "存放地表-通过id删除")
@ApiOperation(value="存放地表-通过id删除", notes="存放地表-通过id删除")
@RequiresPermissions("rms:rms_location:delete")
@ApiOperation(value = "存放地表-通过id删除", notes = "存放地表-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
rmsLocationService.removeById(id);
return Result.OK("删除成功!");
}
@ -110,10 +124,9 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @return
*/
@AutoLog(value = "存放地表-批量删除")
@ApiOperation(value="存放地表-批量删除", notes="存放地表-批量删除")
@RequiresPermissions("rms:rms_location:deleteBatch")
@ApiOperation(value = "存放地表-批量删除", notes = "存放地表-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.rmsLocationService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@ -125,11 +138,11 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @return
*/
//@AutoLog(value = "存放地表-通过id查询")
@ApiOperation(value="存放地表-通过id查询", notes="存放地表-通过id查询")
@ApiOperation(value = "存放地表-通过id查询", notes = "存放地表-通过id查询")
@GetMapping(value = "/queryById")
public Result<RmsLocation> queryById(@RequestParam(name="id",required=true) String id) {
public Result<RmsLocation> queryById(@RequestParam(name = "id", required = true) String id) {
RmsLocation rmsLocation = rmsLocationService.getById(id);
if(rmsLocation==null) {
if (rmsLocation == null) {
return Result.error("未找到对应数据");
}
return Result.OK(rmsLocation);
@ -141,7 +154,6 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @param request
* @param rmsLocation
*/
@RequiresPermissions("rms:rms_location:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, RmsLocation rmsLocation) {
return super.exportXls(request, rmsLocation, RmsLocation.class, "存放地表");
@ -154,7 +166,6 @@ public class RmsLocationController extends JeecgController<RmsLocation, IRmsLoca
* @param response
* @return
*/
@RequiresPermissions("rms:rms_location:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, RmsLocation.class);

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -28,42 +29,60 @@ import lombok.experimental.Accessors;
@TableName("rms_location")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="rms_location对象", description="存放地表")
@ApiModel(value = "rms_location对象", description = "存放地表")
public class RmsLocation implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private java.lang.String id;
/**创建人*/
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
/**
* 创建日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建日期")
private java.util.Date createTime;
/**更新人*/
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
/**
* 更新日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新日期")
private java.util.Date updateTime;
/**所属部门*/
/**
* 所属部门
*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
/**存放地id*/
@Excel(name = "存放地id", width = 15)
@ApiModelProperty(value = "存放地id")
private java.lang.String locationId;
/**存放地名称*/
/**
* 存放地名称
*/
@Excel(name = "存放地名称", width = 15)
@ApiModelProperty(value = "存放地名称")
private java.lang.String locationName;
/**父节点id*/
/**
* 排序号
*/
@Excel(name = "排序号", width = 15)
@ApiModelProperty(value = "排序号")
private java.lang.Integer sortNumber;
/**
* 父节点id
*/
@Excel(name = "父节点id", width = 15)
@ApiModelProperty(value = "父节点id")
private java.lang.String parentLocationId;

View File

@ -4,6 +4,6 @@
<select id="queryAllFurniture" resultType="rms.model.RmsFurnitureModel">
SELECT *
FROM rms_furniture
JOIN rms_location ON rms_furniture.location_id = rms_location.location_id
JOIN rms_location ON rms_furniture.location_id = rms_location.id
</select>
</mapper>

View File

@ -4,6 +4,6 @@
<select id="queryAllRmsInstrument" resultType="rms.model.RmsInstrumentModel">
SELECT *
FROM rms_instrument
JOIN rms_location ON rms_instrument.location_id = rms_location.location_id
JOIN rms_location ON rms_instrument.location_id = rms_location.id
</select>
</mapper>

View File

@ -2,6 +2,7 @@ package rms.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.common.aspect.annotation.Dict;
/**
* 关联地址模型
@ -10,52 +11,84 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode()
public class RmsFurnitureModel {
/**主键*/
/**
* 主键
*/
private String id;
/**领用单位号*/
/**
* 领用单位号
*/
private String collectingUnitNumber;
/**家具编号*/
/**
* 家具编号
*/
private java.lang.String furnitureNumber;
/**家具名称*/
/**
* 家具名称
*/
private java.lang.String furnitureName;
/**分类号*/
/**
* 分类号
*/
private java.lang.String categoryId;
/**型号*/
/**
* 型号
*/
private java.lang.String model;
/**规格*/
/**
* 规格
*/
private java.lang.String specifications;
/**数量*/
/**
* 数量
*/
private String number;
/**单价*/
/**
* 单价
*/
private String unitPrice;
/**金额*/
/**
* 金额
*/
private String amount;
/**厂家*/
/**
* 厂家
*/
private String manufactuer;
/**购置日期*/
/**
* 购置日期
*/
private java.util.Date purchaseDate;
/**领用人*/
/**
* 领用人
*/
private java.lang.String recipient;
/**单据号*/
/**
* 单据号
*/
private String documentNumber;
/**存放地id*/
private String locationId;
//存放地名
private String locationName;
/**备注*/
/**
* 备注
*/
private String note;
/**审核状态*/
/**
* 审核状态
*/
private java.lang.String approvalStatus;
/**初审状态*/
/**
* 初审状态
*/
private java.lang.String initialAudit;
/**使用年限*/
/**
* 使用年限
*/
private String usageYears;
}

View File

@ -35,12 +35,8 @@ public class RmsInstrumentModel {
private java.lang.String recipient;
/**入库时间*/
private java.util.Date entryDate;
/**单据号*/
private java.lang.String documentNumber;
/**存放地id*/
private String locationId;
//存放地名
private String locationName;
/**备注*/
@ -52,9 +48,4 @@ public class RmsInstrumentModel {
/**ID*/
private java.lang.String instrumentId;
}

View File

@ -0,0 +1,22 @@
package rms.model;
import lombok.Data;
import java.util.ArrayList;
/**
* 树结构模型
* 包含以下属性
* 1. 树key
* 2. 树title
* 3. 树children
*/
@Data
public class TreeModel {
private String key;
private String value;
private String title;
private String label;
private Integer sortNumber;
private ArrayList<TreeModel> children;
}

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import rms.model.RmsFurnitureModel;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
/**
* @Description: 家具信息表
@ -15,6 +16,6 @@ import javax.servlet.http.HttpServletRequest;
* @Version: V1.0
*/
public interface IRmsFurnitureService extends IService<RmsFurniture> {
Result<Page<RmsFurnitureModel>> queryAllFurniture(RmsFurnitureModel rmsFurnitureModel, Integer pageNo, Integer pageSize, HttpServletRequest req) ;
Result<ArrayList<RmsFurnitureModel>> queryAllFurniture(RmsFurniture rmsFurniture, Integer pageNo, Integer pageSize, HttpServletRequest req);
}

View File

@ -1,7 +1,12 @@
package rms.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import rms.entity.RmsLocation;
import com.baomidou.mybatisplus.extension.service.IService;
import rms.model.TreeModel;
import java.util.ArrayList;
/**
* @Description: 存放地表
@ -11,4 +16,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IRmsLocationService extends IService<RmsLocation> {
//获取表格数据
ArrayList<RmsLocation> getsLocationData(Page<RmsLocation> page, QueryWrapper<RmsLocation> queryWrapper);
//获取全部的树结构
ArrayList<TreeModel> getTreeList();
//获取某个节点的子节点ids包括自身
ArrayList<String> getChildrenIds(String id);
//获取级联样式
ArrayList<TreeModel> getCascaderList(Integer type);
}

View File

@ -1,7 +1,11 @@
package rms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.system.query.QueryGenerator;
import rms.entity.RmsFurniture;
import rms.mapper.RmsFurnitureMapper;
import rms.model.RmsFurnitureModel;
@ -11,6 +15,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
@ -22,13 +27,38 @@ import java.util.List;
@Service
public class RmsFurnitureServiceImpl extends ServiceImpl<RmsFurnitureMapper, RmsFurniture> implements IRmsFurnitureService {
@Override
public Result<Page<RmsFurnitureModel>> queryAllFurniture(RmsFurnitureModel rmsFurnitureModel, Integer pageNo, Integer pageSize, HttpServletRequest req) {
Page<RmsFurnitureModel> RmsFurnitureModelPage = new Page<>(pageNo, pageSize);
List<RmsFurnitureModel> RmsFurniturelList = getBaseMapper().queryAllFurniture(RmsFurnitureModelPage);
RmsFurnitureModelPage.setRecords(RmsFurniturelList);
return Result.OK(RmsFurnitureModelPage);
public Result<ArrayList<RmsFurnitureModel>> queryAllFurniture(RmsFurniture rmsFurniture, Integer pageNo, Integer pageSize, HttpServletRequest req) {
QueryWrapper<RmsFurniture> queryWrapper = QueryGenerator.initQueryWrapper(rmsFurniture, req.getParameterMap());
Page<RmsFurniture> page = new Page<RmsFurniture>(pageNo, pageSize);
IPage<RmsFurniture> RmsFurnitureModel = page(page, queryWrapper);
//将RmsFurniture转换为RmsFurnitureModel
ArrayList<RmsFurnitureModel> rmsFurnitureModelList = new ArrayList<>();
List<RmsFurniture> records = RmsFurnitureModel.getRecords();
for (RmsFurniture record : records) {
System.out.println(record);
RmsFurnitureModel rmsFurnitureModel = new RmsFurnitureModel();
rmsFurnitureModel.setId(record.getId());
rmsFurnitureModel.setCollectingUnitNumber(record.getCollectingUnitNumber());
rmsFurnitureModel.setFurnitureNumber(record.getFurnitureNumber());
rmsFurnitureModel.setFurnitureName(record.getFurnitureName());
rmsFurnitureModel.setCategoryId(record.getCategoryId());
rmsFurnitureModel.setModel(record.getModel());
rmsFurnitureModel.setSpecifications(record.getSpecifications());
rmsFurnitureModel.setNumber(record.getNumber());
rmsFurnitureModel.setUnitPrice(record.getUnitPrice());
rmsFurnitureModel.setAmount(record.getAmount());
rmsFurnitureModel.setManufactuer(record.getManufactuer());
rmsFurnitureModel.setPurchaseDate(record.getPurchaseDate());
rmsFurnitureModel.setRecipient(record.getRecipient());
rmsFurnitureModel.setDocumentNumber(record.getDocumentNumber());
rmsFurnitureModel.setLocationName(null);
rmsFurnitureModel.setNote(record.getNote());
rmsFurnitureModel.setApprovalStatus(record.getApprovalStatus());
rmsFurnitureModel.setInitialAudit(record.getInitialAudit());
rmsFurnitureModel.setUsageYears(record.getUsageYears());
System.out.println(rmsFurnitureModel);
rmsFurnitureModelList.add(rmsFurnitureModel);
}
return Result.OK(rmsFurnitureModelList);
}
}

View File

@ -1,12 +1,21 @@
package rms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jetbrains.annotations.NotNull;
import rms.entity.RmsLocation;
import rms.mapper.RmsLocationMapper;
import rms.model.TreeModel;
import rms.service.IRmsLocationService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @Description: 存放地表
* @Author: jeecg-boot
@ -15,5 +24,141 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
*/
@Service
public class RmsLocationServiceImpl extends ServiceImpl<RmsLocationMapper, RmsLocation> implements IRmsLocationService {
//获取分页的树数据排序规则为父级在上子集依据sortNumber排序
@Override
public ArrayList<RmsLocation> getsLocationData(Page<RmsLocation> page, QueryWrapper<RmsLocation> queryWrapper) {
//此处查询器查询出来的已经是只有父节点和一层子节点的数据了
//查询全部数据然后先写入父节点再写入子节点依据sortNumber排序最后再依据原本的分页规则进行分页
//获取全部的树结构
Page<RmsLocation> newPage = new Page<>(1, 100000);
IPage<RmsLocation> pageList = page(newPage, queryWrapper);
//如果list长于2即有多个子节点的情况下进行排序否则直接返回
if (pageList.getRecords().size() > 2) {
ArrayList<RmsLocation> treeModels = (ArrayList<RmsLocation>) pageList.getRecords();
return treeModels;
}
//如果长于2遍历全部父节点出现最多的即为总父节点
HashMap<String, Integer> parentMap = new HashMap<>();
for (RmsLocation location : pageList.getRecords()) {
if (location.getParentLocationId() != null && !location.getParentLocationId().isEmpty()) {
if (parentMap.containsKey(location.getParentLocationId())) {
parentMap.put(location.getParentLocationId(), parentMap.get(location.getParentLocationId()) + 1);
} else {
parentMap.put(location.getParentLocationId(), 1);
}
}
}
//
return null;
}
//获取完整的树结构
public ArrayList<TreeModel> getTreeList() {
//依据排序号对list进行排序
ArrayList<TreeModel> treeModels = getTreeModels();
sortTree(treeModels);
return treeModels;
}
//递归对树结构进行排序
private void sortTree(ArrayList<TreeModel> treeModels) {
treeModels.sort((o1, o2) -> {
if (o1.getSortNumber() == null) {
return -1;
}
if (o2.getSortNumber() == null) {
return 1;
}
return o1.getSortNumber() - o2.getSortNumber();
});
for (TreeModel treeModel : treeModels) {
sortTree(treeModel.getChildren());
}
}
//获取级联样式只搜索前两层
public ArrayList<TreeModel> getCascaderList(Integer type) {
List<RmsLocation> list = getBaseMapper().selectList(null);
ArrayList<TreeModel> treeModels = getTreeModels(list);
ArrayList<TreeModel> cascaderList = new ArrayList<>();
for (TreeModel treeModel : treeModels) {
cascaderList.add(treeModel);
//如果存在子集的话
//如果type=1则不进行该操作
if (type == 0 && treeModel.getChildren().size() > 0) {
for (TreeModel child : treeModel.getChildren()) {
child.setChildren(null);
}
}
}
return cascaderList;
}
//获取某个节点的子节点ids包括自身
public ArrayList<String> getChildrenIds(String id) {
ArrayList<String> childrenIds = new ArrayList<>();
childrenIds.add(id);
ArrayList<TreeModel> treeModels = getTreeModels();
for (TreeModel treeModel : treeModels) {
if (treeModel.getKey().equals(id)) {
getChildrenIds(treeModel, childrenIds);
break;
}
}
return childrenIds;
}
private void getChildrenIds(TreeModel treeModel, ArrayList<String> childrenIds) {
for (TreeModel child : treeModel.getChildren()) {
childrenIds.add(child.getKey());
getChildrenIds(child, childrenIds);
}
}
//查询树结构
@NotNull
private ArrayList<TreeModel> getTreeModels() {
List<RmsLocation> list = getBaseMapper().selectList(null);
return getTreeModels(list);
}
@NotNull
private static ArrayList<TreeModel> getTreeModels(List<RmsLocation> list) {
// 2. RmsLocation 转换为 TreeModel
HashMap<String, TreeModel> treeModelMap = new HashMap<>();
for (RmsLocation location : list) {
TreeModel treeModel = new TreeModel();
treeModel.setKey(location.getId());
treeModel.setValue(location.getId());
treeModel.setTitle(location.getLocationName());
treeModel.setLabel(location.getLocationName());
treeModel.setChildren(new ArrayList<>());
treeModel.setSortNumber(location.getSortNumber());
treeModelMap.put(location.getId(), treeModel);
}
// 3. 构建树结构
ArrayList<TreeModel> tree = new ArrayList<>();
for (RmsLocation location : list) {
TreeModel current = treeModelMap.get(location.getId());
if (location.getParentLocationId() == null || location.getParentLocationId().isEmpty()) {
// 如果没有父节点则是树的根节点
tree.add(current);
} else {
// 如果有父节点找到父节点并将当前节点添加为其子节点
TreeModel parent = treeModelMap.get(location.getParentLocationId());
if (parent != null) {
parent.getChildren().add(current);
}
}
}
return tree;
}
}

View File

@ -52,20 +52,21 @@ public class DictAspect {
/**
* 定义切点Pointcut
*/
@Pointcut("execution(public * org.jeecg.modules..*.*Controller.*(..)) || @annotation(org.jeecg.common.aspect.annotation.AutoDict)")
@Pointcut("execution(public * org.jeecg.modules..*.*Controller.*(..)) ||execution(public * rms.controller.*Controller.*(..)) || @annotation(org.jeecg.common.aspect.annotation.AutoDict)")
public void excudeService() {
}
@Around("excudeService()")
public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
long time1=System.currentTimeMillis();
long time1 = System.currentTimeMillis();
Object result = pjp.proceed();
long time2=System.currentTimeMillis();
log.debug("获取JSON数据 耗时:"+(time2-time1)+"ms");
long start=System.currentTimeMillis();
result=this.parseDictText(result);
long end=System.currentTimeMillis();
log.debug("注入字典到JSON数据 耗时"+(end-start)+"ms");
long time2 = System.currentTimeMillis();
log.debug("获取JSON数据 耗时:" + (time2 - time1) + "ms");
long start = System.currentTimeMillis();
result = this.parseDictText(result);
long end = System.currentTimeMillis();
log.debug("注入字典到JSON数据 耗时" + (end - start) + "ms");
return result;
}
@ -89,6 +90,7 @@ public class DictAspect {
* }
* }
* 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
*
* @param result
*/
private Object parseDictText(Object result) {
@ -101,24 +103,24 @@ public class DictAspect {
// 字典数据列表 key = 字典codevalue=数据列表
Map<String, List<String>> dataListMap = new HashMap<>(5);
//取出结果集
List<Object> records=((IPage) ((Result) result).getResult()).getRecords();
List<Object> records = ((IPage) ((Result) result).getResult()).getRecords();
//update-begin--Author:zyf -- Date:20220606 ----forVUEN-1230 判断是否含有字典注解,没有注解返回-----
Boolean hasDict= checkHasDict(records);
if(!hasDict){
Boolean hasDict = checkHasDict(records);
if (!hasDict) {
return result;
}
log.debug(" __ 进入字典翻译切面 DictAspect —— " );
log.debug(" __ 进入字典翻译切面 DictAspect —— ");
//update-end--Author:zyf -- Date:20220606 ----forVUEN-1230 判断是否含有字典注解,没有注解返回-----
for (Object record : records) {
String json="{}";
String json = "{}";
try {
//update-begin--Author:zyf -- Date:20220531 ----forissues/#3629 DictAspect Jackson序列化报错-----
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = objectMapper.writeValueAsString(record);
//update-end--Author:zyf -- Date:20220531 ----forissues/#3629 DictAspect Jackson序列化报错-----
} catch (JsonProcessingException e) {
log.error("json解析失败"+e.getMessage(),e);
log.error("json解析失败" + e.getMessage(), e);
}
//update-begin--Author:scott -- Date:20211223 ----forissues/3303restcontroller返回json数据后key顺序错乱 -----
JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
@ -178,7 +180,7 @@ public class DictAspect {
String value = record.getString(field.getName());
if (oConvertUtils.isNotEmpty(value)) {
List<DictModel> dictModels = translText.get(fieldDictCode);
if(dictModels==null || dictModels.size()==0){
if (dictModels == null || dictModels.size() == 0) {
continue;
}
@ -217,6 +219,7 @@ public class DictAspect {
* 一次性把所有的字典都翻译了
* 1. 所有的普通数据字典的所有数据只执行一次SQL
* 2. 表字典相同的所有数据只执行一次SQL
*
* @param dataListMap
* @return
*/
@ -353,6 +356,7 @@ public class DictAspect {
/**
* 翻译字典文本
*
* @param code
* @param text
* @param table
@ -361,39 +365,39 @@ public class DictAspect {
*/
@Deprecated
private String translateDictValue(String code, String text, String table, String key) {
if(oConvertUtils.isEmpty(key)) {
if (oConvertUtils.isEmpty(key)) {
return null;
}
StringBuffer textValue=new StringBuffer();
StringBuffer textValue = new StringBuffer();
String[] keys = key.split(",");
for (String k : keys) {
String tmpValue = null;
log.debug(" 字典 key : "+ k);
log.debug(" 字典 key : " + k);
if (k.trim().length() == 0) {
continue; //跳过循环
}
//update-begin--Author:scott -- Date:20210531 ----for !56 优化微服务应用下存在表字段需要字典翻译时加载缓慢问题-----
if (!StringUtils.isEmpty(table)){
log.debug("--DictAspect------dicTable="+ table+" ,dicText= "+text+" ,dicCode="+code);
String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]",table,text,code,k.trim());
if (redisTemplate.hasKey(keyString)){
if (!StringUtils.isEmpty(table)) {
log.debug("--DictAspect------dicTable=" + table + " ,dicText= " + text + " ,dicCode=" + code);
String keyString = String.format("sys:cache:dictTable::SimpleKey [%s,%s,%s,%s]", table, text, code, k.trim());
if (redisTemplate.hasKey(keyString)) {
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
tmpValue= commonApi.translateDictFromTable(table,text,code,k.trim());
} else {
tmpValue = commonApi.translateDictFromTable(table, text, code, k.trim());
}
}else {
String keyString = String.format("sys:cache:dict::%s:%s",code,k.trim());
if (redisTemplate.hasKey(keyString)){
} else {
String keyString = String.format("sys:cache:dict::%s:%s", code, k.trim());
if (redisTemplate.hasKey(keyString)) {
try {
tmpValue = oConvertUtils.getString(redisTemplate.opsForValue().get(keyString));
} catch (Exception e) {
log.warn(e.getMessage());
}
}else {
} else {
tmpValue = commonApi.translateDict(code, k.trim());
}
}
@ -412,11 +416,12 @@ public class DictAspect {
/**
* 检测返回结果集中是否包含Dict注解
*
* @param records
* @return
*/
private Boolean checkHasDict(List<Object> records){
if(oConvertUtils.isNotEmpty(records) && records.size()>0){
private Boolean checkHasDict(List<Object> records) {
if (oConvertUtils.isNotEmpty(records) && records.size() > 0) {
for (Field field : oConvertUtils.getAllFields(records.get(0))) {
if (oConvertUtils.isNotEmpty(field.getAnnotation(Dict.class))) {
return true;

View File

@ -149,7 +149,7 @@ spring:
password: aB3cDeF9
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml, classpath*:rms/**/xml/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false