|
|
@ -1,5 +1,7 @@ |
|
|
|
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.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
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; |
|
|
@ -11,8 +13,10 @@ import com.hnac.hzims.spare.mapper.SpReceiveMapper; |
|
|
|
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.SpReceiveVO; |
|
|
|
import com.hnac.hzims.spare.vo.SpReceiveVO; |
|
|
|
import com.hnac.hzims.spare.vo.WtSpBasicVO; |
|
|
|
import com.hnac.hzims.spare.vo.WtSpBasicVO; |
|
|
|
|
|
|
|
import com.hnac.hzims.spare.vo.SpReceiveExportVO; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
@ -23,6 +27,7 @@ import org.springblade.core.mp.support.Query; |
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
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.Func; |
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.entity.Dept; |
|
|
|
import org.springblade.system.feign.IDictBizClient; |
|
|
|
import org.springblade.system.feign.IDictBizClient; |
|
|
@ -33,9 +38,11 @@ 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.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 服务实现类 |
|
|
|
* 服务实现类 |
|
|
@ -191,76 +198,57 @@ public class SpReceiveServiceImpl extends ServiceImpl<SpReceiveMapper, SpReceive |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public IPage<SpReceiveVO> selectPageList(IPage<SpReceiveVO> page, SpReceiveVO receiveVO) { |
|
|
|
public IPage<SpReceiveVO> selectPageList(IPage<SpReceiveVO> page, SpReceiveVO receiveVO) { |
|
|
|
|
|
|
|
return page.setRecords(this.selectList(page,receiveVO)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<SpReceiveVO> selectList(IPage<SpReceiveVO> page, SpReceiveVO receiveVO) { |
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
if(null !=receiveVO.getCode()){ |
|
|
|
params.put("code",receiveVO.getCode()); |
|
|
|
params.put("code",receiveVO.getCode()); |
|
|
|
params.put("status",receiveVO.getStatus()); |
|
|
|
} |
|
|
|
params.put("startDate",receiveVO.getStartDate()); |
|
|
|
if(null !=receiveVO.getStatus()){ |
|
|
|
params.put("endDate",receiveVO.getEndDate()); |
|
|
|
params.put("status",receiveVO.getStatus()); |
|
|
|
List<Long> deptIdList = new ArrayList<>(); |
|
|
|
} |
|
|
|
if(Func.isNotEmpty(receiveVO.getDeptId())) { |
|
|
|
if(null !=receiveVO.getStartDate()){ |
|
|
|
deptIdList.add(receiveVO.getDeptId()); |
|
|
|
params.put("startDate",receiveVO.getStartDate()); |
|
|
|
R<List<Dept>> deptListR = sysClient.getDeptChild(receiveVO.getDeptId()); |
|
|
|
} |
|
|
|
if(deptListR.isSuccess() && CollectionUtil.isNotEmpty(deptListR.getData())) { |
|
|
|
if(null !=receiveVO.getEndDate()){ |
|
|
|
deptIdList.addAll(deptListR.getData().stream().map(Dept::getId).collect(Collectors.toList())); |
|
|
|
params.put("endDate",receiveVO.getEndDate()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<Long> longList = new ArrayList<>(); |
|
|
|
|
|
|
|
if(null!=receiveVO.getDeptId()){ |
|
|
|
|
|
|
|
R<List<Dept>> deptList = sysClient.getDeptChild(receiveVO.getDeptId()); |
|
|
|
|
|
|
|
for (int i = 0; i < deptList.getData().size(); i++) { |
|
|
|
|
|
|
|
longList.add(deptList.getData().get(i).getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
longList.add(receiveVO.getDeptId()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
// longList = personClient.getShuiChangId(AuthUtil.getDeptId());
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(longList.size()>0){ |
|
|
|
|
|
|
|
params.put("deptList",longList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(null!=receiveVO.getStorageRoom()){ |
|
|
|
|
|
|
|
params.put("warehouseId",receiveVO.getStorageRoom()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<SpReceiveVO> result = new ArrayList<>(); |
|
|
|
|
|
|
|
BladeUser bladeUser = AuthUtil.getUser(); |
|
|
|
|
|
|
|
if(null!=receiveVO.getUserName()){ |
|
|
|
|
|
|
|
R<User> user = userClient.userByAccount(bladeUser.getTenantId(),receiveVO.getUserName()); |
|
|
|
|
|
|
|
if(null!=user){ |
|
|
|
|
|
|
|
if(null!=user.getData()){ |
|
|
|
|
|
|
|
params.put("createUser",user.getData().getId()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
return page.setRecords(result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
params.put("deptList",deptIdList); |
|
|
|
|
|
|
|
params.put("warehouseId",receiveVO.getStorageRoom()); |
|
|
|
|
|
|
|
params.put("createUser",receiveVO.getUserId()); |
|
|
|
params.put("tenantId", AuthUtil.getTenantId()); |
|
|
|
params.put("tenantId", AuthUtil.getTenantId()); |
|
|
|
List<SpReceiveVO> list = baseMapper.selectPageList(page,params); |
|
|
|
List<SpReceiveVO> list = baseMapper.selectPageList(page,params); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
return list.stream().peek(this::fillDetail).collect(Collectors.toList()); |
|
|
|
SpReceiveVO entity = list.get(i); |
|
|
|
} |
|
|
|
if(null!=entity.getCreateUser()){ |
|
|
|
|
|
|
|
R<User> user = userClient.userInfoById(entity.getCreateUser()); |
|
|
|
private void fillDetail(SpReceiveVO entity) { |
|
|
|
if(null!=user.getData()){ |
|
|
|
String userName = Optional.ofNullable(entity.getCreateUser()).map(UserCache::getUser).map(User::getName).orElse(null); |
|
|
|
entity.setUserName(user.getData().getName()); |
|
|
|
entity.setUserName(userName); |
|
|
|
} |
|
|
|
List<SpReceivesEntity> k=new ArrayList<>(); |
|
|
|
} |
|
|
|
QueryWrapper<SpReceivesEntity> queryWrapper = new QueryWrapper(); |
|
|
|
List<SpReceivesEntity> k=new ArrayList<>(); |
|
|
|
queryWrapper.lambda().eq(SpReceivesEntity::getVeceiveId,entity.getId()); |
|
|
|
QueryWrapper<SpReceivesEntity> queryWrapper = new QueryWrapper(); |
|
|
|
queryWrapper.lambda().eq(SpReceivesEntity::getStatus,1); |
|
|
|
queryWrapper.lambda().eq(SpReceivesEntity::getVeceiveId,entity.getId()); |
|
|
|
List<SpReceivesEntity> byId = iSpReceivesService.list(queryWrapper); |
|
|
|
queryWrapper.lambda().eq(SpReceivesEntity::getStatus,1); |
|
|
|
k.addAll(byId); |
|
|
|
List<SpReceivesEntity> byId = iSpReceivesService.list(queryWrapper); |
|
|
|
QueryWrapper<SpReceivesEntity> queryWrappers = new QueryWrapper(); |
|
|
|
k.addAll(byId); |
|
|
|
queryWrappers.lambda().eq(SpReceivesEntity::getVeceiveId,entity.getId()); |
|
|
|
QueryWrapper<SpReceivesEntity> queryWrappers = new QueryWrapper(); |
|
|
|
queryWrappers.lambda().eq(SpReceivesEntity::getStatus,3); |
|
|
|
queryWrappers.lambda().eq(SpReceivesEntity::getVeceiveId,entity.getId()); |
|
|
|
List<SpReceivesEntity> id = iSpReceivesService.list(queryWrappers); |
|
|
|
queryWrappers.lambda().eq(SpReceivesEntity::getStatus,3); |
|
|
|
k.addAll(id); |
|
|
|
List<SpReceivesEntity> id = iSpReceivesService.list(queryWrappers); |
|
|
|
if (null==k||0==k.size()){ |
|
|
|
k.addAll(id); |
|
|
|
entity.setSign(2L); |
|
|
|
if (null==k||0==k.size()){ |
|
|
|
}else { |
|
|
|
entity.setSign(2L); |
|
|
|
entity.setSign(1L); |
|
|
|
}else { |
|
|
|
|
|
|
|
entity.setSign(1L); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.add(entity); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return page.setRecords(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void export(HttpServletResponse response, SpReceiveVO receiveVO) { |
|
|
|
|
|
|
|
List<SpReceiveVO> spReceiveVOS = this.selectList(null, receiveVO); |
|
|
|
|
|
|
|
List<SpReceiveExportVO> data = JSONArray.parseArray(JSON.toJSONString(spReceiveVOS), SpReceiveExportVO.class); |
|
|
|
|
|
|
|
ExcelUtil.export(response,SpReceiveExportVO.class,data,"工具领用报表","工具领用"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized boolean updateStatus(SpReceiveEntity receiveEntity) { |
|
|
|
public synchronized boolean updateStatus(SpReceiveEntity receiveEntity) { |
|
|
|