|
|
@ -1,8 +1,11 @@ |
|
|
|
package com.hnac.hzims.spare.service.impl; |
|
|
|
package com.hnac.hzims.spare.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.hnac.hzims.spare.chche.AssetsNumCache; |
|
|
|
import com.hnac.hzims.spare.chche.AssetsNumCache; |
|
|
|
import com.hnac.hzims.spare.entity.*; |
|
|
|
import com.hnac.hzims.spare.entity.*; |
|
|
|
import com.hnac.hzims.spare.enume.BusinessType; |
|
|
|
import com.hnac.hzims.spare.enume.BusinessType; |
|
|
@ -10,6 +13,8 @@ import com.hnac.hzims.spare.mapper.SpAllocationMapper; |
|
|
|
import com.hnac.hzims.spare.mapper.SpRecordMapper; |
|
|
|
import com.hnac.hzims.spare.mapper.SpRecordMapper; |
|
|
|
import com.hnac.hzims.spare.mapper.WtSpWarehouseMapper; |
|
|
|
import com.hnac.hzims.spare.mapper.WtSpWarehouseMapper; |
|
|
|
import com.hnac.hzims.spare.service.*; |
|
|
|
import com.hnac.hzims.spare.service.*; |
|
|
|
|
|
|
|
import com.hnac.hzims.spare.utils.ExcelUtil; |
|
|
|
|
|
|
|
import com.hnac.hzims.spare.vo.SpAllocationExportVO; |
|
|
|
import com.hnac.hzims.spare.vo.SpAllocationVO; |
|
|
|
import com.hnac.hzims.spare.vo.SpAllocationVO; |
|
|
|
import com.hnac.hzims.spare.vo.WtSpBasicVO; |
|
|
|
import com.hnac.hzims.spare.vo.WtSpBasicVO; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
@ -21,23 +26,25 @@ import org.springblade.core.mp.support.Condition; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.feign.IDictBizClient; |
|
|
|
import org.springblade.system.feign.IDictBizClient; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
import org.springblade.system.feign.ISysClient; |
|
|
|
|
|
|
|
import org.springblade.system.user.cache.UserCache; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.entity.User; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 服务实现类 |
|
|
|
* 服务实现类 |
|
|
@ -202,55 +209,47 @@ public class SpAllocationServiceImpl extends ServiceImpl<SpAllocationMapper, SpA |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<SpAllocationVO> selectPageList(IPage<SpAllocationVO> page, SpAllocationVO allocationVO) { |
|
|
|
public IPage<SpAllocationVO> selectPageList(IPage<SpAllocationVO> page, SpAllocationVO allocationVO) { |
|
|
|
|
|
|
|
return page.setRecords(this.selectList(page,allocationVO)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<SpAllocationVO> selectList(IPage<SpAllocationVO> page, SpAllocationVO allocationVO) { |
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
if(null !=allocationVO.getCode()){ |
|
|
|
|
|
|
|
params.put("code",allocationVO.getCode()); |
|
|
|
params.put("code",allocationVO.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if(null !=allocationVO.getStatus()){ |
|
|
|
|
|
|
|
params.put("status",allocationVO.getStatus()); |
|
|
|
params.put("status",allocationVO.getStatus()); |
|
|
|
} |
|
|
|
|
|
|
|
if(null !=allocationVO.getStartDate()){ |
|
|
|
|
|
|
|
params.put("startDate",allocationVO.getStartDate()); |
|
|
|
params.put("startDate",allocationVO.getStartDate()); |
|
|
|
} |
|
|
|
|
|
|
|
if(null !=allocationVO.getEndDate()){ |
|
|
|
|
|
|
|
params.put("endDate",allocationVO.getEndDate()); |
|
|
|
params.put("endDate",allocationVO.getEndDate()); |
|
|
|
|
|
|
|
if(Func.isNotEmpty(allocationVO.getDeptId())){ |
|
|
|
|
|
|
|
List<Long> deptIdList = new ArrayList<>(); |
|
|
|
|
|
|
|
deptIdList.add(allocationVO.getDeptId()); |
|
|
|
|
|
|
|
R<List<Dept>> deptListR = sysClient.getDeptChild(allocationVO.getDeptId()); |
|
|
|
|
|
|
|
if(deptListR.isSuccess() && CollectionUtil.isNotEmpty(deptListR.getData())) { |
|
|
|
|
|
|
|
deptIdList.addAll(deptListR.getData().stream().map(Dept::getId).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
List<Long> longList = new ArrayList<>(); |
|
|
|
params.put("deptList", deptIdList); |
|
|
|
if(null!=allocationVO.getDeptId()){ |
|
|
|
|
|
|
|
R<List<Dept>> deptList = sysClient.getDeptChild(allocationVO.getDeptId()); |
|
|
|
|
|
|
|
for (int i = 0; i < deptList.getData().size(); i++) { |
|
|
|
|
|
|
|
longList.add(deptList.getData().get(i).getId()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
longList.add(allocationVO.getDeptId()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
// longList = personClient.getShuiChangId(AuthUtil.getDeptId());
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(longList.size()>0){ |
|
|
|
|
|
|
|
params.put("deptList",longList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(null!=allocationVO.getOutWarehouseId()){ |
|
|
|
|
|
|
|
params.put("outWarehouseId",allocationVO.getOutWarehouseId()); |
|
|
|
params.put("outWarehouseId",allocationVO.getOutWarehouseId()); |
|
|
|
} |
|
|
|
|
|
|
|
params.put("tenantId", AuthUtil.getTenantId()); |
|
|
|
params.put("tenantId", AuthUtil.getTenantId()); |
|
|
|
List<SpAllocationVO> list = baseMapper.selectPageList(page,params); |
|
|
|
List<SpAllocationVO> list = baseMapper.selectPageList(page,params); |
|
|
|
List<SpAllocationVO> result = new ArrayList<>(); |
|
|
|
return list.stream().peek(this::fillWarehouseName).collect(Collectors.toList()); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
|
|
|
SpAllocationVO entity = list.get(i); |
|
|
|
|
|
|
|
if(null!=entity.getCreateUser()){ |
|
|
|
|
|
|
|
R<User> user = userClient.userInfoById(entity.getCreateUser()); |
|
|
|
|
|
|
|
if(null!=user.getData()){ |
|
|
|
|
|
|
|
entity.setUserName(user.getData().getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void fillWarehouseName(SpAllocationVO entity) { |
|
|
|
|
|
|
|
String userName = Optional.ofNullable(entity).map(SpAllocationVO::getCreateUser) |
|
|
|
|
|
|
|
.map(UserCache::getUser).map(User::getName).orElse(null); |
|
|
|
|
|
|
|
entity.setUserName(userName); |
|
|
|
WtSpWarehouseEntity inWarehouseEntity = warehouseMapper.selectById(entity.getInWarehouseId()); |
|
|
|
WtSpWarehouseEntity inWarehouseEntity = warehouseMapper.selectById(entity.getInWarehouseId()); |
|
|
|
if(ObjectUtil.isNotEmpty(inWarehouseEntity)&&StringUtil.isNotBlank(inWarehouseEntity.getName())){ |
|
|
|
if(ObjectUtil.isNotEmpty(inWarehouseEntity)&&StringUtil.isNotBlank(inWarehouseEntity.getName())){ |
|
|
|
entity.setInWarehouseName(inWarehouseEntity.getName()); |
|
|
|
entity.setInWarehouseName(inWarehouseEntity.getName()); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
entity.setInWarehouseName(""); |
|
|
|
entity.setInWarehouseName(""); |
|
|
|
} |
|
|
|
} |
|
|
|
result.add(entity); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return page.setRecords(result); |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void export(SpAllocationVO allocationVO, HttpServletResponse response) { |
|
|
|
|
|
|
|
List<SpAllocationVO> allocationList = this.selectList(null, allocationVO); |
|
|
|
|
|
|
|
List<SpAllocationExportVO> data = JSONArray.parseArray(JSON.toJSONString(allocationList), SpAllocationExportVO.class); |
|
|
|
|
|
|
|
ExcelUtil.export(response, SpAllocationExportVO.class, data, "调拨单报表", "调拨单"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized boolean updateStatus(SpAllocationEntity allocationEntity) { |
|
|
|
public synchronized boolean updateStatus(SpAllocationEntity allocationEntity) { |
|
|
|