parent
							
								
									1517763a90
								
							
						
					
					
						commit
						c4f81f337e
					
				| @ -0,0 +1,115 @@ | |||||||
|  | package com.glxp.api.admin.controller.thrsys; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.admin.entity.thrsys.ThrInvWarehouseEntity; | ||||||
|  | import com.glxp.api.admin.req.inout.DeleteRequest; | ||||||
|  | import com.glxp.api.admin.req.thrsys.FilterThrInvWarehouseRequest; | ||||||
|  | import com.glxp.api.admin.res.thrsys.ThrInvWarehouseResponse; | ||||||
|  | import com.glxp.api.admin.service.thrsys.ThrInvWarehouseService; | ||||||
|  | import com.glxp.api.common.enums.ResultEnum; | ||||||
|  | import com.glxp.api.common.res.BaseResponse; | ||||||
|  | import com.glxp.api.common.util.ResultVOUtils; | ||||||
|  | import lombok.extern.slf4j.Slf4j; | ||||||
|  | import org.springframework.beans.BeanUtils; | ||||||
|  | import org.springframework.validation.BindingResult; | ||||||
|  | import org.springframework.web.bind.annotation.GetMapping; | ||||||
|  | import org.springframework.web.bind.annotation.PostMapping; | ||||||
|  | import org.springframework.web.bind.annotation.RequestBody; | ||||||
|  | import org.springframework.web.bind.annotation.RestController; | ||||||
|  | 
 | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | import javax.validation.Valid; | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.util.HashMap; | ||||||
|  | import java.util.List; | ||||||
|  | import java.util.Map; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 第三方仓库信息接口 | ||||||
|  |  */ | ||||||
|  | @Slf4j | ||||||
|  | @RestController | ||||||
|  | public class ThrInvWarehouseController { | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     ThrInvWarehouseService thrInvWarehouseService; | ||||||
|  | 
 | ||||||
|  |     @GetMapping("spms/thrsys/warehouse/filter") | ||||||
|  |     public BaseResponse filterInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) { | ||||||
|  |         List<ThrInvWarehouseEntity> thrInvWarehouseEntities = thrInvWarehouseService.filterThrInvWarehouse(filterThrInvWarehouseRequest); | ||||||
|  |         List<ThrInvWarehouseResponse> merge = merge(thrInvWarehouseEntities, 0); | ||||||
|  | 
 | ||||||
|  |         Map<String, Object> restMap = new HashMap<>(); | ||||||
|  |         restMap.put("list", merge); | ||||||
|  |         return ResultVOUtils.success(restMap); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public List<ThrInvWarehouseResponse> merge(List<ThrInvWarehouseEntity> thrInvWarehouseEntities, Integer pid) { | ||||||
|  |         List<ThrInvWarehouseResponse> thrInvWarehouseResponses = new ArrayList<>(); | ||||||
|  |         for (ThrInvWarehouseEntity thrInvWarehouseEntity : thrInvWarehouseEntities) { | ||||||
|  |             ThrInvWarehouseResponse thrInvWarehouseResponse = new ThrInvWarehouseResponse(); | ||||||
|  |             BeanUtils.copyProperties(thrInvWarehouseEntity, thrInvWarehouseResponse); | ||||||
|  |             if (pid.equals(thrInvWarehouseEntity.getPid())) { | ||||||
|  |                 thrInvWarehouseResponse.setChildren(merge(thrInvWarehouseEntities, thrInvWarehouseEntity.getId())); | ||||||
|  |                 thrInvWarehouseResponses.add(thrInvWarehouseResponse); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return thrInvWarehouseResponses; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @GetMapping("spms/thrsys/warehouse/filterAll") | ||||||
|  |     public BaseResponse filterAllInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) { | ||||||
|  |         filterThrInvWarehouseRequest.setPid(0); | ||||||
|  |         List<ThrInvWarehouseEntity> thrInvWarehouseEntities = thrInvWarehouseService.filterThrInvWarehouse(filterThrInvWarehouseRequest); | ||||||
|  |         return ResultVOUtils.success(thrInvWarehouseEntities); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PostMapping("/spms/thrsys/warehouse/save") | ||||||
|  |     public BaseResponse save(@RequestBody @Valid ThrInvWarehouseEntity thrInvWarehouseEntity, | ||||||
|  |                              BindingResult bindingResult) { | ||||||
|  | 
 | ||||||
|  |         if (bindingResult.hasErrors()) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         if (thrInvWarehouseEntity.getPid() == null) { | ||||||
|  |             thrInvWarehouseEntity.setPid(0); // 默认设置
 | ||||||
|  |         } | ||||||
|  |         boolean b = thrInvWarehouseService.insertInvWarehouse(thrInvWarehouseEntity); | ||||||
|  |         if (!b) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.NOT_NETWORK); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success("添加成功!"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PostMapping("/spms/thrsys/warehouse/edit") | ||||||
|  |     public BaseResponse edit(@RequestBody @Valid ThrInvWarehouseEntity thrInvWarehouseEntity, | ||||||
|  |                              BindingResult bindingResult) { | ||||||
|  | 
 | ||||||
|  |         if (bindingResult.hasErrors()) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); | ||||||
|  |         } | ||||||
|  |         if (thrInvWarehouseEntity.getId() == null) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); | ||||||
|  |         } | ||||||
|  |         thrInvWarehouseEntity.setPid(null); // 不能修改父级 pid
 | ||||||
|  |         boolean b = thrInvWarehouseService.updateInvWarehouse(thrInvWarehouseEntity); | ||||||
|  |         if (!b) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.NOT_NETWORK); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PostMapping("/spms/thrsys/warehouse/delete") | ||||||
|  |     public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) { | ||||||
|  | 
 | ||||||
|  |         if (deleteRequest.getId() == null) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); | ||||||
|  |         } | ||||||
|  |         boolean b = thrInvWarehouseService.deleteById(deleteRequest.getId()); | ||||||
|  |         if (!b) { | ||||||
|  |             return ResultVOUtils.error(ResultEnum.NOT_NETWORK); | ||||||
|  |         } | ||||||
|  |         return ResultVOUtils.success(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,32 @@ | |||||||
|  | package com.glxp.api.admin.entity.thrsys; | ||||||
|  | 
 | ||||||
|  | import lombok.Data; | ||||||
|  | 
 | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * 第三方仓库信息 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class ThrInvWarehouseEntity { | ||||||
|  | 
 | ||||||
|  |     private Integer id; | ||||||
|  |     private Integer pid; | ||||||
|  |     private String code; | ||||||
|  |     private String name; | ||||||
|  |     private Boolean advanceType; | ||||||
|  |     private Boolean isDefault; | ||||||
|  |     private Integer status; | ||||||
|  |     private Date updateTime; | ||||||
|  |     private String remark; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |     * 仓库等级 | ||||||
|  |     */ | ||||||
|  |     private Integer level; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |     * 父级仓库编码 | ||||||
|  |     */ | ||||||
|  |     private String pcode; | ||||||
|  | } | ||||||
| @ -0,0 +1,19 @@ | |||||||
|  | package com.glxp.api.admin.req.thrsys; | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.admin.req.ListPageRequest; | ||||||
|  | import lombok.Data; | ||||||
|  | 
 | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | @Data | ||||||
|  | public class FilterThrInvWarehouseRequest extends ListPageRequest { | ||||||
|  | 
 | ||||||
|  |     private Integer id; | ||||||
|  |     private Integer pid; | ||||||
|  |     private String code; | ||||||
|  |     private String name; | ||||||
|  |     private Boolean advanceType; | ||||||
|  |     private Boolean isDefault; | ||||||
|  |     private Date updateTime; | ||||||
|  |     private String key; | ||||||
|  | } | ||||||
| @ -0,0 +1,28 @@ | |||||||
|  | package com.glxp.api.admin.service.thrsys; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import com.glxp.api.admin.entity.thrsys.ThrInvWarehouseEntity; | ||||||
|  | import com.glxp.api.admin.req.thrsys.FilterThrInvWarehouseRequest; | ||||||
|  | 
 | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | public interface ThrInvWarehouseService { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     ThrInvWarehouseEntity findDefault(Boolean advaceType, Boolean isDefault); | ||||||
|  | 
 | ||||||
|  |     List<ThrInvWarehouseEntity> filterThrInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest); | ||||||
|  | 
 | ||||||
|  |     List<ThrInvWarehouseEntity> filterGroupInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest); | ||||||
|  | 
 | ||||||
|  |     boolean insertInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity); | ||||||
|  | 
 | ||||||
|  |     boolean updateInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity); | ||||||
|  | 
 | ||||||
|  |     ThrInvWarehouseEntity selectById(String id); | ||||||
|  | 
 | ||||||
|  |     ThrInvWarehouseEntity selectByCode(String code); | ||||||
|  | 
 | ||||||
|  |     boolean deleteById(String id); | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,86 @@ | |||||||
|  | package com.glxp.api.admin.service.thrsys.impl; | ||||||
|  | 
 | ||||||
|  | import com.github.pagehelper.PageHelper; | ||||||
|  | import com.glxp.api.admin.dao.thrsys.ThrInvWarehouseDao; | ||||||
|  | import com.glxp.api.admin.entity.thrsys.ThrInvWarehouseEntity; | ||||||
|  | import com.glxp.api.admin.req.thrsys.FilterThrInvWarehouseRequest; | ||||||
|  | import com.glxp.api.admin.service.thrsys.ThrInvWarehouseService; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | import java.util.Collections; | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  | public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @Resource | ||||||
|  |     ThrInvWarehouseDao thrInvWarehouseDao; | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public ThrInvWarehouseEntity findDefault(Boolean advaceType, Boolean isDefault) { | ||||||
|  | 
 | ||||||
|  |         FilterThrInvWarehouseRequest filterThrInvWarehouseRequest = new FilterThrInvWarehouseRequest(); | ||||||
|  |         filterThrInvWarehouseRequest.setIsDefault(isDefault); | ||||||
|  |         filterThrInvWarehouseRequest.setAdvanceType(advaceType); | ||||||
|  |         List<ThrInvWarehouseEntity> thrInvWarehouseEntities = thrInvWarehouseDao.filterThrInvWarehouse(filterThrInvWarehouseRequest); | ||||||
|  |         if (thrInvWarehouseEntities != null && thrInvWarehouseEntities.size() > 0) | ||||||
|  |             return thrInvWarehouseEntities.get(0); | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public List<ThrInvWarehouseEntity> filterThrInvWarehouse(FilterThrInvWarehouseRequest FilterThrInvWarehouseRequest) { | ||||||
|  |         if (FilterThrInvWarehouseRequest == null) { | ||||||
|  |             return Collections.emptyList(); | ||||||
|  |         } | ||||||
|  |         if (FilterThrInvWarehouseRequest.getPage() != null) { | ||||||
|  |             int offset = (FilterThrInvWarehouseRequest.getPage() - 1) * FilterThrInvWarehouseRequest.getLimit(); | ||||||
|  |             PageHelper.offsetPage(offset, FilterThrInvWarehouseRequest.getLimit()); | ||||||
|  |         } | ||||||
|  |         return thrInvWarehouseDao.filterThrInvWarehouse(FilterThrInvWarehouseRequest); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public List<ThrInvWarehouseEntity> filterGroupInvWarehouse(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) { | ||||||
|  |         if (filterThrInvWarehouseRequest == null) { | ||||||
|  |             return Collections.emptyList(); | ||||||
|  |         } | ||||||
|  |         if (filterThrInvWarehouseRequest.getPage() != null) { | ||||||
|  |             int offset = (filterThrInvWarehouseRequest.getPage() - 1) * filterThrInvWarehouseRequest.getLimit(); | ||||||
|  |             PageHelper.offsetPage(offset, filterThrInvWarehouseRequest.getLimit()); | ||||||
|  |         } | ||||||
|  |         return thrInvWarehouseDao.filterThrGroupInvWarehouse(filterThrInvWarehouseRequest); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public boolean insertInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity) { | ||||||
|  |         return thrInvWarehouseDao.insertThrInvWarehouse(thrInvWarehouseEntity); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public boolean updateInvWarehouse(ThrInvWarehouseEntity thrInvWarehouseEntity) { | ||||||
|  |         return thrInvWarehouseDao.updateThrInvWarehouse(thrInvWarehouseEntity); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public ThrInvWarehouseEntity selectById(String id) { | ||||||
|  |         return thrInvWarehouseDao.selectById(id); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public ThrInvWarehouseEntity selectByCode(String code) { | ||||||
|  |         FilterThrInvWarehouseRequest thrInvWarehouseRequest = new FilterThrInvWarehouseRequest(); | ||||||
|  |         thrInvWarehouseRequest.setCode(code); | ||||||
|  |         List<ThrInvWarehouseEntity> invWarehouseEntities = thrInvWarehouseDao.filterThrInvWarehouse(thrInvWarehouseRequest); | ||||||
|  |         if (invWarehouseEntities != null && invWarehouseEntities.size() > 0) | ||||||
|  |             return invWarehouseEntities.get(0); | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public boolean deleteById(String id) { | ||||||
|  |         return thrInvWarehouseDao.deleteById(id); | ||||||
|  |     } | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in New Issue