提交 ffd8b1b1 authored 作者: zjm's avatar zjm

Merge branch 'unit-dev' of git.yfzx.zjtys.com.cn:matrix/device-back into dev

......@@ -939,7 +939,11 @@ public class AllotBillController {
}
@GetMapping("/getFileList")
@ApiOperation("通过任务id查询账单中文件")
public ResponseEntity getFileList(Integer taskId){
return ResponseEntity.ok(allotBillService.getFileList(taskId));
}
......@@ -1065,11 +1069,6 @@ public class AllotBillController {
}
}
@GetMapping("getFileList")
@ApiOperation("通过任务id查询账单中文件")
public ResponseEntity getFileList(Integer taskId){
return ResponseEntity.ok(allotBillService.getFileList(taskId));
}
}
......@@ -3,9 +3,11 @@ package com.tykj.dev.device.confirmcheck.entity.cache;
import com.tykj.dev.config.cache.ConfigCache;
import com.tykj.dev.config.repository.SystemConfigDao;
import com.tykj.dev.device.user.cache.AreaCache;
import com.tykj.dev.device.user.cache.AreaExhibitionCache;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.cache.UserCache;
import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.AreaExhibitionDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -33,6 +35,9 @@ public class CacheBeanConfig {
@Autowired
private SystemConfigDao systemConfigDao;
@Autowired
AreaExhibitionDao areaExhibitionDao;
@Bean
public AreaCache initAreaCache() {
return new AreaCache(areaRepo.findAll());
......@@ -43,6 +48,10 @@ public class CacheBeanConfig {
return new UserCache(userDao.findAll());
}
@Bean
public AreaExhibitionCache initAreaExhibitionCache() {
return new AreaExhibitionCache(areaExhibitionDao.findAll());
}
@Bean
public UnitsCache initUnitCache() {
return new UnitsCache(unitsDao.findAll());
......
......@@ -1154,6 +1154,20 @@ public class DeviceLibraryController {
return setOrderNumber(sortNum, allListAndParent);
}
@ApiOperation(value = "为工作交接查询装备", notes = "为工作交接查询装备")
@GetMapping("/selectDeviceForWorkUse")
@Transactional(rollbackFor = Exception.class)
public List<WorkUseVo> selectDeviceForWorkUse(){
return deviceLibraryService.getDevicesForWorkUse();
}
@ApiOperation(value = "修改单位名称", notes = "修改单位名称")
@PostMapping("/updateDeviceLocationAndOwnUnit")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity<String> updateDeviceLocationAndOwnUnit(@RequestBody UpdateUnitVo updateUnitVo){
deviceLibraryService.updateDeviceLocationAndOwnUnit(updateUnitVo);
return ResponseEntity.ok("修改成功");
}
public List<DeviceLibrary> getAllListAndParent(){
DeviceLibrarySelectVo deviceLibrarySelectVo = new DeviceLibrarySelectVo();
......
......@@ -228,5 +228,18 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Query("update DeviceLibrary o set o.storageLocation = :storageLocation where o.id in :deviceIds")
int updateStorageLocation( @Param("storageLocation") String storageLocation,
@Param("deviceIds") List<Integer> deviceIds);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.locationUnit = :updateUnitName where o.locationUnit = :originUnitName")
int updateLocationUnit(@Param("originUnitName") String originUnitName,
@Param("updateUnitName") String updateUnitName);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.ownUnit = :updateUnitName where o.ownUnit = :originUnitName")
int updateOwnUnit( @Param("originUnitName") String originUnitName,
@Param("updateUnitName") String updateUnitName);
}
......@@ -499,4 +499,18 @@ public interface DeviceLibraryService {
void updateStorageLocation(UpdateStorageLocationVo updateStorageLocationVo);
/**
* 查询装备给工作交接使用
* @return WorkUseVos
*/
List<WorkUseVo> getDevicesForWorkUse();
/**
* 修改单位名称则装备的所属所在也需要进行修改
* @param updateUnitVo 修改单位名称的vo
*/
void updateDeviceLocationAndOwnUnit(UpdateUnitVo updateUnitVo);
}
......@@ -1164,6 +1164,56 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
});
}
@Override
public List<WorkUseVo> getDevicesForWorkUse() {
//获取当前登录的单位名称
String currentUserUnitName = userUtils.getCurrentUserUnitName();
PredicateBuilder<DeviceLibrary> builder = Specifications.and();
builder.eq("ownUnit",currentUserUnitName);
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAll(builder.build());
List<Integer> status= new ArrayList<>(Arrays.asList(5,11,12));
deviceLibraries = deviceLibraries.stream().filter(deviceLibrary -> !status.contains(deviceLibrary.getLifeStatus()))
.collect(Collectors.toList());
//进行过滤赋值、
deviceLibraries.forEach(deviceLibrary -> {
if (!deviceLibrary.getOwnUnit().equals(deviceLibrary.getLocationUnit())){
//不在库
deviceLibrary.setIsInLibrary(1);
}else {
//在库
deviceLibrary.setIsInLibrary(0);
}
});
//按照型号,名称,是否在库进行分组 "Ǵ"
Map<String, List<DeviceLibrary>> map = deviceLibraries.stream().collect(groupingBy(deviceLibrary ->
deviceLibrary.getModel() + "Ǵ" +
deviceLibrary.getName() + "Ǵ" +
deviceLibrary.getIsInLibrary()));
List<WorkUseVo> workUseVos = new ArrayList<>();
map.keySet().forEach(s -> {
WorkUseVo workUseVo = new WorkUseVo();
String[] split = s.split("Ǵ");
workUseVo.setModel(split[0]);
workUseVo.setName(split[1]);
workUseVo.setIsInLibrary(Integer.valueOf(split[2]));
List<DeviceLibrary> deviceLibraries1 = map.get(s);
List<String> seqList = deviceLibraries1.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
workUseVo.setSeqNumber(String.join("-",seqList));
workUseVo.setDeviceCount(deviceLibraries1.size());
workUseVos.add(workUseVo);
});
return workUseVos;
}
@Override
@UpdateCache
public void updateDeviceLocationAndOwnUnit(UpdateUnitVo updateUnitVo) {
//先修改所在
deviceLibraryDao.updateLocationUnit(updateUnitVo.getOriginUnitName(),updateUnitVo.getUpdateUnitName());
//修改所属
deviceLibraryDao.updateOwnUnit(updateUnitVo.getOriginUnitName(),updateUnitVo.getUpdateUnitName());
}
// @Override
// @UpdateCache
// public int updatePartParentId(List<Integer> deviceIds) {
......
......@@ -4,6 +4,7 @@ import com.tykj.dev.config.cache.ConfigCache;
import com.tykj.dev.device.library.subject.vo.DeviceExcel;
import com.tykj.dev.device.library.subject.vo.DeviceExcelVo;
import com.tykj.dev.device.library.subject.vo.DeviceVo;
import com.tykj.dev.device.library.subject.vo.WorkUseVo;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.SpringUtils;
import io.swagger.annotations.ApiModel;
......@@ -277,6 +278,10 @@ public class DeviceLibrary implements Serializable {
@Transient
private Integer orderNumber;
@ApiModelProperty(value = "是否在库",notes = "0 在库 1不在库")
@Transient
private Integer isInLibrary;
public void addChildNode(DeviceLibrary deviceLibraryEntity) {
childs.add(deviceLibraryEntity);
}
......@@ -292,6 +297,13 @@ public class DeviceLibrary implements Serializable {
return mapper.map(this, DeviceVo.class);
}
// public WorkUseVo toWorkUse(){
// setConfigName();
// //modelMap复制
// ModelMapper mapper = BeanHelper.getUserMapper();
// return mapper.map(this, WorkUseVo.class);
// }
public DeviceExcelVo toDeviceExcelVo(){
setConfigName();
//modelMap复制
......
package com.tykj.dev.device.library.subject.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author zsp
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("修改单位名称的vo")
public class UpdateUnitVo {
@ApiModelProperty(value = "原单位名称")
private String originUnitName;
@ApiModelProperty(value = "修改后单位名称")
private String updateUnitName;
}
package com.tykj.dev.device.library.subject.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("返回给工作交接的vo")
@Repository
public class WorkUseVo {
@ApiModelProperty(value = "型号")
private String model;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "序列号")
private String seqNumber;
@ApiModelProperty(value = "装备数量")
private Integer deviceCount;
@ApiModelProperty(value = "是否在库",notes = "0 在库 1不在库")
private Integer isInLibrary;
}
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("返回给工作交接的vos")
@Repository
public class WorkUseVos {
@ApiModelProperty(value = "非在库装备列表")
private List<WorkUseVo> exceptionList;
@ApiModelProperty(value = "在库装备列表")
private List<WorkUseVo> normalList;
// @ApiModelProperty(value = "是否在库",notes = "0 在库 1不在库")
// private Integer isInLibrary;
}
spring.application.name=device-dev
spring.datasource.url=jdbc:mysql://192.168.100.249:3306/device?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.url=jdbc:mysql://192.168.100.249:3306/device_master?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
......
package com.tykj.dev.device.user.base.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author zjm
* @version 1.0.0
* @ClassName UnitStoreLocationVo.java
* @Description TODO
* @createTime 2021年11月08日 13:47:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "根据单位名称查询用户的接口", description = "根据单位名称查询用户的接口")
public class UnitStoreLocationVo {
@ApiModelProperty(value = "单位ID", name = "unitId", example = "12321L")
private Integer unitId;
@ApiModelProperty(value = "类型名称", name = "typeName", example = "12321L")
private String typeName="";
}
package com.tykj.dev.device.user.base.req;
import com.tykj.dev.device.user.base.ret.AreaVo;
import com.tykj.dev.device.user.base.ret.LeftNavigation;
import com.tykj.dev.device.user.base.ret.UnitsTrainVo;
import com.tykj.dev.device.user.base.ret.UnitsVo;
import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.misc.base.BeanHelper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.modelmapper.ModelMapper;
import javax.persistence.*;
import java.util.UUID;
/**
* @author zjm
* @version 1.0.0
* @ClassName Units.java
* @Description 单位对象
* @createTime 2020年07月28日 09:23:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel(value = "单位添加对象", description = "单位添加对象")
public class UnitsAddVo {
/**
* 单位名称
*/
@ApiModelProperty(value = "单位名称", name = "unitName", example = "12321L")
private String name;
/**
* 单位描述
*/
@ApiModelProperty(value = "单位描述", name = "unitDesc", example = "12321L")
private String unitDesc;
/**
* 等级
*/
@ApiModelProperty(value = "等级", name = "level", example = "12321L")
private Integer level;
/**
* 排序
*/
@ApiModelProperty(value = "排序", name = "showOrder", example = "12321L")
private Integer showOrder;
@ApiModelProperty(value = "装备配用范围的指定")
private Integer packingMatchingRange;
@ApiModelProperty(value = "是否代管")
private Integer escrow;
@ApiModelProperty(value = "展示区域id")
private Integer exhibitionId;
@ApiModelProperty(value = "上级单位ID")
private Integer parentUnitId;
public Units toUnits(){
ModelMapper mapper = BeanHelper.getUserMapper();
return mapper.map(this, Units.class);
}
}
package com.tykj.dev.device.user.cache;
import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.AreaExhibition;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
......@@ -21,6 +23,7 @@ public class AreaCache {
private Map<Integer, Area> idMap;
public AreaCache(List<Area> areaList) {
nameMap = areaList.stream().collect(Collectors.toMap(Area::getName, Function.identity()));
idMap = areaList.stream().collect(Collectors.toMap(Area::getId, Function.identity()));
......@@ -30,6 +33,10 @@ public class AreaCache {
Area area = nameMap.get(name);
return idMap.get(area.getFatherId());
}
public List<Area> findAllByFatherId(Integer fatherId) {
return new ArrayList<>(idMap.values()).stream().filter(area -> area.getFatherId().equals(fatherId)).collect(Collectors.toList());
}
public Area findByName(String name) {
return nameMap.get(name) == null ? new Area(0, "省直属", 9999, "9999", 0, "") : nameMap.get(name);
......@@ -38,6 +45,11 @@ public class AreaCache {
public Area findById(Integer id) {
return idMap.get(id) == null ? new Area(0, "省直属", 9999, "9999", 0, "") : idMap.get(id);
}
public List<Area> findAll(){
return new ArrayList<>(idMap.values());
}
public AreaCache refresh(List<Area> areaList) {
nameMap = areaList.stream().collect(Collectors.toMap(Area::getName, Function.identity()));
......
package com.tykj.dev.device.user.cache;
import com.tykj.dev.device.user.subject.entity.AreaExhibition;
import com.tykj.dev.device.user.subject.entity.Units;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaExhibitionCache.java
* @Description TODO
* @createTime 2021年11月09日 14:36:00
*/
@Data
public class AreaExhibitionCache {
private Map<Integer, AreaExhibition> idMap;
private List<AreaExhibition> areaExhibitions;
public AreaExhibitionCache(List<AreaExhibition> areaExhibitionList){
this.idMap = areaExhibitionList.stream().collect(Collectors.toMap(AreaExhibition::getId, Function.identity()));
this.areaExhibitions=areaExhibitionList;
}
public Map<Integer, AreaExhibition> getIdMap() {
return idMap;
}
public AreaExhibition findById(Integer id) {
return idMap.get(id);
}
public List<AreaExhibition> findAll(){
return new ArrayList<>(idMap.values());
}
/**
* 查询大于等新序号,小于原序号
* @return
*/
public List<AreaExhibition> findListGeNewAndLtOriginal(Integer newOrder,Integer OriginalOrder){
return new ArrayList<>(idMap.values()).stream().filter(areaExhibition -> (areaExhibition.getOrders()>=newOrder) &&(areaExhibition.getOrders() < OriginalOrder)).collect(Collectors.toList());
}
/**
* 查询大于原序号,小于等于新序号
*/
public List<AreaExhibition> findListLgOriginalAndLeNew(Integer newOrder,Integer OriginalOrder){
return new ArrayList<>(idMap.values()).stream().filter(areaExhibition -> (areaExhibition.getOrders()<=newOrder) &&(areaExhibition.getOrders() > OriginalOrder)).collect(Collectors.toList());
}
/**
* 根据区域id查询下级以及
*/
public List<AreaExhibition> findByFatherId(Integer fatherId){
return new ArrayList<>(idMap.values()).stream().filter(areaExhibition -> fatherId.equals(areaExhibition.getFatherId())).collect(Collectors.toList());
}
public AreaExhibitionCache refresh(List<AreaExhibition> areaExhibitionList){
this.idMap = areaExhibitionList.stream().collect(Collectors.toMap(AreaExhibition::getId, Function.identity()));
this.areaExhibitions=areaExhibitionList;
return this;
}
}
......@@ -14,14 +14,22 @@ public class UnitsCache {
private Map<Integer, Units> idMap;
private Map<Integer,Units> areaIdMpa;
public UnitsCache(List<Units> unitsList){
this.idMap = unitsList.stream().collect(Collectors.toMap(Units::getUnitId, Function.identity()));
this.areaIdMpa=unitsList.stream().collect(Collectors.toMap(Units::getAreaId,Function.identity()));
}
public Map<Integer, Units> getIdMap() {
return idMap;
}
public Units findByAreaId(Integer areaId){
return areaIdMpa.get(areaId);
}
public Units findById(Integer id) {
return idMap.get(id);
}
......@@ -30,8 +38,43 @@ public class UnitsCache {
return new ArrayList<>(idMap.values());
}
public List<Units> findAllByAreaExhibitionId(Integer areaExhibitionId){
return new ArrayList<>(idMap.values()).stream().filter(units -> units.getExhibitionId().equals(areaExhibitionId)).collect(Collectors.toList());
}
/**
* 根据当前单位id查询下级以及本级
*/
public List<Units> findByIdSubordinateAndOneself(Integer unitId){
Units units=idMap.get(unitId);
return new ArrayList<>(idMap.values()).stream().filter(units1 -> units1.getExhibitionId().equals(units.getExhibitionId())).collect(Collectors.toList());
}
/**
* 查询大于等新序号,小于原序号
* @return
*/
public List<Units> findListGeNewAndLtOriginal(Integer newOrder,Integer OriginalOrder){
return new ArrayList<>(idMap.values()).stream().filter(units -> (units.getShowOrder()>=newOrder) &&(units.getShowOrder() < OriginalOrder)).collect(Collectors.toList());
}
/**
* 查询大于原序号,小于等于新序号
*/
public List<Units> findListLgOriginalAndLeNew(Integer newOrder,Integer OriginalOrder){
return new ArrayList<>(idMap.values()).stream().filter(units -> (units.getShowOrder()<=newOrder) &&(units.getShowOrder() > OriginalOrder)).collect(Collectors.toList());
}
public UnitsCache refresh(List<Units> unitsList){
this.idMap = unitsList.stream().collect(Collectors.toMap(Units::getUnitId, Function.identity()));
this.areaIdMpa=unitsList.stream().collect(Collectors.toMap(Units::getAreaId,Function.identity()));
return this;
}
/**
* 根据区域id的集合查询所有的单位
*/
public List<Units> findByAllAreaIds(List<Integer> areaIds){
return new ArrayList<>(idMap.values()).stream().filter(units -> areaIds.contains(units.getAreaId())).collect(Collectors.toList());
}
}
......@@ -81,4 +81,12 @@ public class AreaController {
return ResponseEntity.ok(areaService.findIdQuerySubordinateIds(size));
}
@GetMapping("/findAll")
@ApiOperation(value = "查询所有区域列表", notes = "查询所有区域列表")
public ResponseEntity selectFindAll(){
return ResponseEntity.ok(areaService.findAllArea());
}
}
package com.tykj.dev.device.user.subject.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.subject.entity.AreaExhibition;
import com.tykj.dev.device.user.subject.service.AreaExhibitionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaExhibitionController.java
* @Description TODO
* @createTime 2021年11月09日 11:29:00
*/
@RestController
@AutoDocument
@Api(tags = "区域展示模块", description = "提供区域展示模块接口")
@RequestMapping("/areaExhibition")
public class AreaExhibitionController {
@Autowired
AreaExhibitionService areaExhibitionService;
@GetMapping("/finaAll")
@ApiOperation(value = "查询所有区域列表", notes = "查询所有区域列表")
public ResponseEntity selectFindAll() {
return ResponseEntity.ok(areaExhibitionService.finaAllAreaExhibition());
}
@PostMapping("/save")
@ApiOperation(value = "保存区域展示对象", notes = "保存区域展示对象")
public ResponseEntity saveExhibition(@RequestBody AreaExhibition areaExhibition) {
return ResponseEntity.ok(areaExhibitionService.save(areaExhibition));
}
}
\ No newline at end of file
package com.tykj.dev.device.user.subject.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.base.req.UnitStoreLocationVo;
import com.tykj.dev.device.user.subject.entity.UnitStoreLocation;
import com.tykj.dev.device.user.subject.service.UnitStoreLocationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* @author zjm
* @version 1.0.0
* @ClassName UnitStoreLocationController.java
* @Description TODO
* @createTime 2021年11月08日 13:23:00
*/
@RestController
@AutoDocument
@Api(tags = "各单位存放位置", description = "提供用户相关的接口")
@RequestMapping("/unitStoreLocation")
@Slf4j
public class UnitStoreLocationController {
@Autowired
UnitStoreLocationService unitStoreLocationService;
@PostMapping(value = "/unitIdAndTypeName")
@ApiOperation(value = "根据单位ID以及字段名称查询单位存储列表", notes = "返回单位对象")
public ResponseEntity unitIdAndTypeName(@RequestBody UnitStoreLocationVo unitStoreLocationVo) {
return ResponseEntity.ok(unitStoreLocationService.findAllByUnitIdAndTypeName(unitStoreLocationVo));
}
@PostMapping(value = "/save")
@ApiOperation(value = "添加库房位置对象", notes = "添加库房位置对象")
public ResponseEntity unitIdAndTypeName(@RequestBody UnitStoreLocation unitStoreLocation) {
return ResponseEntity.ok(unitStoreLocationService.save(unitStoreLocation));
}
}
......@@ -2,6 +2,7 @@ package com.tykj.dev.device.user.subject.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.base.req.UnitNameVo;
import com.tykj.dev.device.user.base.req.UnitsAddVo;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService;
......@@ -25,7 +26,7 @@ import springfox.documentation.annotations.ApiIgnore;
*/
@RestController
@AutoDocument
@Api(tags = "用户模块", description = "提供用户相关的接口")
@Api(tags = "单位模块", description = "提供用户相关的接口")
@RequestMapping("/units")
@Slf4j
public class UnitsController {
......@@ -62,13 +63,13 @@ public class UnitsController {
@GetMapping(value = "/areaDevice")
@ApiOperation(value = "查询装备库区域单位列表", notes = "查询装备库区域单位列表")
public ResponseEntity selectOrganizationUnits1(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
return ResponseEntity.ok(unitsService.findLeftNavigation1(securityUser));
return ResponseEntity.ok(unitsService.findLeftNavigation(securityUser));
}
@GetMapping(value = "/areaDirectlyUnder")
@ApiOperation(value = "查询直属代管单位列表", notes = "查询直属代管单位列表")
public ResponseEntity selectOrganizationUnits2(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
return ResponseEntity.ok(unitsService.findLeftNavigation2(securityUser));
return ResponseEntity.ok(unitsService.findLeftNavigation(securityUser));
}
@GetMapping(value = "/findAll/GreaterThanEqual/{level}")
......@@ -134,8 +135,6 @@ public class UnitsController {
return ResponseEntity.ok(unitsService.findbyName(unitNameVo.getUnitName()));
}
@GetMapping("/countries/units")
@ApiOperation(value = "省入库发件单位下拉接口", notes = "省入库发件单位下拉接口")
public ResponseEntity findSuperiorUnitsList(){
......@@ -154,5 +153,49 @@ public class UnitsController {
return ResponseEntity.ok(DeviceModelSort.mapUnitSort);
}
/**
* 单位管理查询单位查询接口
*/
@GetMapping("/findAll/unitManagement")
@ApiOperation(value = "[单位管理]单位管理查询单位查询接口", notes = "单位管理查询单位查询接口")
public ResponseEntity unitManagement(){
return ResponseEntity.ok(unitsService.unitManagement());
}
/**
* 单位管理查询单位查询接口
*/
@PostMapping("/saveUnits")
@ApiOperation(value = "[单位管理]单位管理添加单位接口", notes = "单位管理添加单位接口")
public ResponseEntity unitManagement(@RequestBody UnitsAddVo unitsAddVo){
return ResponseEntity.ok(unitsService.saveUnits(unitsAddVo));
}
/**
* 查询添加单位中所有单位的下拉列表
*/
@GetMapping("/belongsUnits/{unitId}")
@ApiOperation(value = "[单位管理]查询添加单位中所属单位的下拉列表去除自己", notes = "查询添加单位中所属单位的下拉列表")
public ResponseEntity belongsUnits(@PathVariable Integer unitId){
return ResponseEntity.ok(unitsService.belongsUnits(unitId));
}
/**
* 查询添加单位中所有单位的下拉列表
*/
@GetMapping("/belongsUnits")
@ApiOperation(value = "[单位管理]查询添加单位中所属单位的下拉列表", notes = "查询添加单位中所属单位的下拉列表")
public ResponseEntity belongsUnits2(){
return ResponseEntity.ok(unitsService.belongsUnits1());
}
/**
* 单位管理修改单位接口
*/
@PostMapping("/updateUnits")
@ApiOperation(value = "[单位管理]单位管理修改单位接口", notes = "单位管理修改单位接口")
public ResponseEntity updateUnit(@RequestBody Units units){
return ResponseEntity.ok(unitsService.updateUnit(units));
}
}
package com.tykj.dev.device.user.subject.dao;
import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.AreaExhibition;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaExhibitionDao.java
* @Description TODO
* @createTime 2021年11月09日 09:33:00
*/
public interface AreaExhibitionDao extends JpaRepository<AreaExhibition, Integer>, JpaSpecificationExecutor<AreaExhibition> {
}
package com.tykj.dev.device.user.subject.dao;
import com.tykj.dev.device.user.subject.entity.UnitStoreLocation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
public interface UnitStoreLocationDao extends JpaRepository<UnitStoreLocation, Integer>, JpaSpecificationExecutor<UnitStoreLocation> {
List<UnitStoreLocation> findAllByUnitIdAndTypeName(Integer unitId,String typeName);
}
......@@ -39,7 +39,7 @@ public class Area {
private String name;
/**
* 等级 等级 0国家级 1省级 2市级 3县级 4.直属单位
* 等级 等级 0.国家级 1.省级 2.市级 3.县级 4.直属
*/
private Integer type;
......
package com.tykj.dev.device.user.subject.entity;
import com.tykj.dev.device.user.base.ret.LeftNavigation;
import com.tykj.dev.misc.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Transient;
import java.util.UUID;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaExhibition.java
* @Description TODO
* @createTime 2021年11月09日 09:12:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@ApiModel(value = "地区提供展示对象", description = "地区提供展示信息")
public class AreaExhibition extends BaseEntity {
/**
* 区域名称
*/
private String areaName;
/**
* 区域描述
*/
@Column(name = "des",columnDefinition = "TEXT")
private String des;
/**
* 排序
*/
private Integer orders;
/**
* 父类id
*/
private Integer fatherId;
/**
* 父类名称
*/
@Transient
private String fatherName;
public LeftNavigation toLeftNavigation(){
return new LeftNavigation(this.getId(),areaName,null, UUID.randomUUID().toString(),1,Double.valueOf(orders).intValue(),null);
}
}
package com.tykj.dev.device.user.subject.entity;
import com.tykj.dev.misc.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import javax.persistence.Column;
import javax.persistence.Entity;
/**
* @author zjm
* @version 1.0.0
* @ClassName UnitStoreLocation.java
* @Description 存放位置信息
* @createTime 2021年11月08日 12:46:00
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@ApiModel(value = "单位对象", description = "单位详细信息")
public class UnitStoreLocation extends BaseEntity {
private Integer unitId;
private String storeName;
private String typeName;
@Column(name = "des",columnDefinition = "TEXT")
private String des;
private Integer showOrder;
}
......@@ -12,6 +12,7 @@ import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import javax.persistence.*;
import java.util.UUID;
......@@ -88,7 +89,7 @@ public class Units {
@ApiModelProperty(value = "排序", name = "showOrder", example = "12321L")
private Integer showOrder;
@ApiModelProperty(value = "区域名称", name = "areaName", example = "12321L")
@ApiModelProperty(value = "区域展示名称", name = "areaName", example = "12321L")
@Transient
private String areaName;
......@@ -98,12 +99,20 @@ public class Units {
@ApiModelProperty(value = "是否代管")
private Integer escrow;
@ApiModelProperty(value = "展示区域id")
private Integer exhibitionId;
@Transient
@ApiModelProperty(value = "上级单位ID")
private Integer parentUnitId;
/**
* 区域对象
*/
@Transient
private Area area;
public static Units toDb() {
return new Units(
null,
......@@ -117,6 +126,8 @@ public class Units {
null,
null,
null,
null,
null,
null
);
}
......
package com.tykj.dev.device.user.subject.service;
import com.tykj.dev.device.user.subject.entity.AreaExhibition;
import java.util.List;
public interface AreaExhibitionService extends PublicService<AreaExhibition>{
/**
* 区域使用
* @return 区域对象集合
*/
List<AreaExhibition> finaAllAreaExhibition();
/**
* 根据id查询区域展示对象
*/
AreaExhibition findById(Integer areaExhibitionId);
}
......@@ -34,7 +34,13 @@ public interface AreaService extends PublicService<Area> {
List<Integer> findIdQuerySubordinateIds(Integer areaId);
Area findByIdTosuperiorArea(Integer areaId);
/**
* 区域管理使用
*/
List<Area> findAllArea();
}
package com.tykj.dev.device.user.subject.service;
import com.tykj.dev.device.user.base.req.UnitStoreLocationVo;
import com.tykj.dev.device.user.subject.entity.UnitStoreLocation;
import java.util.List;
import java.util.Map;
/**
* @author zjm
* @version 1.0.0
* @ClassName UnitStoreLocationService.java
* @Description TODO
* @createTime 2021年11月08日 12:57:00
*/
public interface UnitStoreLocationService extends PublicService<UnitStoreLocation>{
List<UnitStoreLocation> findAllByUnitIdAndTypeName(UnitStoreLocationVo unitStoreLocationVo);
Map<Integer,String> findByUnitIdToDeviceMap(Integer unitId);
}
package com.tykj.dev.device.user.subject.service;
import com.tykj.dev.device.user.base.req.UnitNameVo;
import com.tykj.dev.device.user.base.req.UnitsAddVo;
import com.tykj.dev.device.user.base.ret.*;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.Units;
......@@ -143,8 +144,8 @@ public interface UnitsService extends PublicService<Units> {
*/
List<Units> findAllByIdIn(List<Integer> ids);
List<Units> finAllDirectlUnderUnits();
List<Units> finAllDirectlUnderUnits();
/**
* 左边侧面导航栏接口
......@@ -187,4 +188,32 @@ public interface UnitsService extends PublicService<Units> {
* @return 所有的单位id
*/
List<Integer> findByAreaId2(Integer areaId);
/**
* 单位管理使用 查询单位的接口
*/
List<Units> unitManagement();
/**
* 新增单位接口
*/
List<Units> saveUnits(UnitsAddVo unitsAddVo);
/**
* 添加单位所有单位列表去掉自己
*/
List<Units> belongsUnits(Integer unitId);
/**
* 添加单位所有单位列表
*/
List<Units> belongsUnits1();
/**
* 更新单位对象
*/
Units updateUnit(Units units);
}
......@@ -55,4 +55,15 @@ public interface UserPublicService {
*/
List<Integer> findAllUnitIdByAreaId(Integer areaId);
/*新的区域查询接口*/
List<Units> accordingExhibitionIdAllUnits(Integer exhibitionId);
/**
* 根据单位id查询当前单位下的全部子对象,以及对象下的子对象
* @return 单位集合
*/
List<Units> findByUnitIdSubordinateAll(Integer unitId);
}
package com.tykj.dev.device.user.subject.service.impl;
import com.tykj.dev.device.user.cache.AreaExhibitionCache;
import com.tykj.dev.device.user.subject.dao.AreaExhibitionDao;
import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.AreaExhibition;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.AreaExhibitionService;
import com.tykj.dev.misc.exception.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author zjm
* @version 1.0.0
* @ClassName AreaExhibitionServiceImpl.java
* @Description TODO
* @createTime 2021年11月09日 11:13:00
*/
@Service
public class AreaExhibitionServiceImpl implements AreaExhibitionService {
@Autowired
AreaExhibitionDao areaExhibitionDao;
@Autowired
AreaExhibitionCache areaExhibitionCache;
@Override
public List<AreaExhibition> finaAllAreaExhibition() {
List<AreaExhibition> areaExhibitions=areaExhibitionDao.findAll().stream().sorted(Comparator.comparing(AreaExhibition::getOrders)).collect(Collectors.toList());
areaExhibitions.forEach(
areaExhibition -> {
if (areaExhibition.getFatherId()!=null) {
AreaExhibition areaExhibition1= areaExhibitionCache.findById(areaExhibition.getFatherId());
areaExhibition.setFatherName(areaExhibition1.getAreaName());
}
}
);
return areaExhibitions;
}
@Override
public AreaExhibition findById(Integer areaExhibitionId){
Optional<AreaExhibition> optionalAreaExhibition = areaExhibitionDao.findById(areaExhibitionId);
if (optionalAreaExhibition.isPresent()){
return optionalAreaExhibition.get();
}else {
throw new ApiException("[区域展示] 根据id查询对象没找到:"+areaExhibitionId);
}
}
@Override
public AreaExhibition save(AreaExhibition areaExhibition) {
if (areaExhibition.getId()==null){
areaExhibition.setOrders(areaExhibitionCache.findAll().size()+1);
}else {
AreaExhibition oldAreaExhibition = areaExhibitionCache.findById(areaExhibition.getId());
int count=areaExhibitionCache.findAll().size();
if (!oldAreaExhibition.getOrders().equals(areaExhibition.getOrders())){
if (count<areaExhibition.getOrders()){
areaExhibition.setOrders(count+1);
}else {
sortingAreaExhibition(areaExhibition.getOrders(),oldAreaExhibition.getOrders());
}
}
}
AreaExhibition areaExhibition1= areaExhibitionDao.save(areaExhibition);
areaExhibitionCache.refresh(areaExhibitionDao.findAll());
return areaExhibition1;
}
private void sortingAreaExhibition(Integer originalOrder,Integer newOrder){
List<AreaExhibition> areaExhibitions;
if (originalOrder>newOrder){
areaExhibitions=areaExhibitionCache.findListGeNewAndLtOriginal(newOrder,originalOrder);
areaExhibitions.forEach(
areaExhibition -> areaExhibition.setOrders(areaExhibition.getOrders()+1)
);
}else {
areaExhibitions=areaExhibitionCache.findListLgOriginalAndLeNew(newOrder,originalOrder);
areaExhibitions.forEach(
areaExhibition -> areaExhibition.setOrders(areaExhibition.getOrders()-1)
);
}
areaExhibitionCache.refresh(areaExhibitionDao.saveAll(areaExhibitions));
}
@Override
public boolean delete(Integer id) {
return false;
}
@Override
public List<AreaExhibition> findAll() {
return areaExhibitionDao.findAll();
}
@Override
public AreaExhibition update(AreaExhibition areaExhibition) {
AreaExhibition areaExhibition1= areaExhibitionDao.save(areaExhibition);
areaExhibitionCache.refresh(areaExhibitionDao.findAll());
return areaExhibition1;
}
}
......@@ -21,8 +21,10 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author zjm
......@@ -136,9 +138,23 @@ public class AreaServiceImpl implements AreaService {
return area;
}
@Override
public List<Area> findAllArea() {
//过滤掉直属的以及区域的
List<Area> areaList=areaDao.findAll().stream().filter(area -> area.getType() < 3).collect(Collectors.toList());
areaList.forEach(area ->{
if (area.getFatherId()!=null) {
area.setFatherName(areaCache.findById(area.getFatherId()).getName());
}
}
);
areaList= areaList.stream().sorted(Comparator.comparing(Area::getOrders)).collect(Collectors.toList());
return areaList;
}
private List<Integer> areaId(List<Integer> ids,Integer areaId){
List<Area> areas= areaDao.findAllByFatherId(areaId);
List<Area> areas= areaCache.findAllByFatherId(areaId);
ids.add(areaId);
if (areas!=null&&areas.size()!=0){
areas.forEach(
......@@ -166,29 +182,6 @@ public class AreaServiceImpl implements AreaService {
return units;
}
// private List<AreaInstitutions> subordinateArea(List<AreaInstitutions> areaInstitutions ,Area area){
// List<Area> list= areaDao.findAllByFatherId(area.getId());
// if (list==null || list.size()==0){
// areaInstitutions.add(new AreaInstitutions(area.getId(), area.getName(), areaInstitutions, unitsDao.findAllByAreaId(area.getId()).stream().map(Units::toVo).collect(Collectors.toList())));
// return areaInstitutions;
// }
// if (area.getType() < 2) {
// areaInstitutions.add(new AreaInstitutions(area.getId(), area.getName(), areaInstitutions, unitsDao.findAllByAreaId(area.getId()).stream().map(Units::toVo).collect(Collectors.toList())));
// }
//
// list.forEach(
// area1 -> {
// List<AreaInstitutions> areaInstitutions1=new ArrayList<>();
// subordinateArea(areaInstitutions1,area1);
// if (area.getType()==2) {
// areaInstitutions1.add(new AreaInstitutions(area.getId(), area.getName(), areaInstitutions, unitsDao.findAllByAreaId(area.getId()).stream().map(Units::toVo).collect(Collectors.toList())));
// }
// areaInstitutions.add(new AreaInstitutions(area1.getId(),area1.getName(),areaInstitutions1,unitsDao.findAllByAreaId(area1.getId()).stream().map(Units::toVo).collect(Collectors.toList())));
// }
// );
// return areaInstitutions;
// }
@Override
public Area save(Area area) {
Optional<Area> optionalArea = areaDao.findById(area.getFatherId());
......
package com.tykj.dev.device.user.subject.service.impl;
import com.tykj.dev.device.user.base.req.UnitStoreLocationVo;
import com.tykj.dev.device.user.subject.dao.UnitStoreLocationDao;
import com.tykj.dev.device.user.subject.entity.UnitStoreLocation;
import com.tykj.dev.device.user.subject.service.UnitStoreLocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author zjm
* @version 1.0.0
* @ClassName UnitStoreLocationServiceImpl.java
* @Description TODO
* @createTime 2021年11月08日 13:02:00
*/
@Service
public class UnitStoreLocationServiceImpl implements UnitStoreLocationService {
@Autowired
UnitStoreLocationDao unitStoreLocationDao;
@Override
public List<UnitStoreLocation> findAllByUnitIdAndTypeName(UnitStoreLocationVo unitStoreLocationVo) {
return unitStoreLocationDao.findAllByUnitIdAndTypeName(unitStoreLocationVo.getUnitId(),unitStoreLocationVo.getTypeName());
}
@Override
public Map<Integer, String> findByUnitIdToDeviceMap(Integer unitId) {
return unitStoreLocationDao.findAllByUnitIdAndTypeName(unitId,"存放位置")
.stream()
.sorted(Comparator.comparing(UnitStoreLocation::getShowOrder))
.collect(Collectors.toMap(UnitStoreLocation::getId,UnitStoreLocation::getStoreName));
}
@Override
public UnitStoreLocation save(UnitStoreLocation unitStoreLocation) {
return unitStoreLocationDao.save(unitStoreLocation);
}
@Override
public boolean delete(Integer id) {
return false;
}
@Override
public List<UnitStoreLocation> findAll() {
return unitStoreLocationDao.findAll().stream().sorted(Comparator.comparing(UnitStoreLocation::getShowOrder))
.collect(Collectors.toList());
}
@Override
public UnitStoreLocation update(UnitStoreLocation unitStoreLocation) {
return unitStoreLocationDao.save(unitStoreLocation);
}
}
......@@ -46,6 +46,9 @@ public class UserPublicServiceImpl implements UserPublicService {
@Autowired
UnitsCache unitsCache;
// @Autowired
// AreaExhibitionServiceImpl
@Autowired
UnitsService unitsService;
......@@ -130,6 +133,22 @@ public class UserPublicServiceImpl implements UserPublicService {
}
@Override
public List<Units> accordingExhibitionIdAllUnits(Integer exhibitionId) {
return null;
}
@Override
public List<Units> findByUnitIdSubordinateAll(Integer unitId) {
Units units= unitsCache.findById(unitId);
List<Integer> areaIds= areaService.findIdQuerySubordinateIds(units.getAreaId());
return unitsCache.findByAllAreaIds(areaIds);
}
@Override
public String findUnitsNameByUserId(Integer userId) {
User resultEntity = userCache.findById(userId);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论