|
|
@ -10,6 +10,7 @@ import com.win.framework.operatelog.core.annotations.OperateLog; |
|
|
|
import com.win.module.system.api.user.AdminUserApi; |
|
|
|
import com.win.module.wms.controller.scrapRecord.vo.*; |
|
|
|
import com.win.module.wms.convert.scrapRecord.ScrapRecordDetailConvert; |
|
|
|
import com.win.module.wms.dal.dataobject.scrapJob.ScrapJobDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.scrapRecord.ScrapRecordDetailDO; |
|
|
|
import com.win.module.wms.dal.dataobject.scrapRecord.ScrapRecordMainDO; |
|
|
|
import com.win.module.wms.dal.mysql.scrapRecord.ScrapRecordMainMapper; |
|
|
@ -27,6 +28,7 @@ import javax.validation.Valid; |
|
|
|
import java.io.IOException; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static com.win.framework.common.pojo.CommonResult.success; |
|
|
|
import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
|
|
@ -88,42 +90,49 @@ public class ScrapRecordDetailController { |
|
|
|
@Operation(summary = "获得报废出库记录子分页") |
|
|
|
public CommonResult<PageResult<ScrapRecordDetailRespVO>> getScrapRecordDetailPage(@Valid ScrapRecordDetailPageReqVO pageVO) { |
|
|
|
PageResult<ScrapRecordDetailDO> pageResult = scrapRecordDetailService.getScrapRecordDetailPage(pageVO); |
|
|
|
PageResult<ScrapRecordDetailRespVO> result = getScrapRecordDetailRespVOPageResult(pageResult); |
|
|
|
return success(result); |
|
|
|
} |
|
|
|
|
|
|
|
private PageResult<ScrapRecordDetailRespVO> getScrapRecordDetailRespVOPageResult(PageResult<ScrapRecordDetailDO> pageResult) { |
|
|
|
PageResult<ScrapRecordDetailRespVO> result = ScrapRecordDetailConvert.INSTANCE.convertPage(pageResult); |
|
|
|
if(pageResult.getList().size() > 0){ |
|
|
|
Set<Long> masterIdSet = new HashSet<>(); |
|
|
|
for(ScrapRecordDetailDO scrapRecordDetailDO:pageResult.getList()){ |
|
|
|
masterIdSet.add(scrapRecordDetailDO.getMasterId()); |
|
|
|
} |
|
|
|
if (pageResult.getList().size() > 0) { |
|
|
|
Set<Long> masterIdSet = pageResult.getList().stream().map(ScrapRecordDetailDO::getMasterId).collect(Collectors.toSet()); |
|
|
|
Map<Long, ScrapRecordMainDO> mainMap = scrapRecordMainMapper.queryMainListToMap(masterIdSet); |
|
|
|
//用户
|
|
|
|
Set<String> userIdSet = pageResult.getList().stream().map(ScrapRecordDetailDO::getCreator).collect(Collectors.toSet()); |
|
|
|
userIdSet.addAll(pageResult.getList().stream().map(ScrapRecordDetailDO::getUpdater).collect(Collectors.toSet())); |
|
|
|
Map<String, String> userNicknameMap = userApi.getUserNicknameToString(userIdSet); |
|
|
|
|
|
|
|
CopyOptions options = CopyOptions.create().setIgnoreNullValue(true); |
|
|
|
for(ScrapRecordDetailRespVO vo : result.getList()) { |
|
|
|
vo.setCreator(userApi.getUserNickname(vo.getCreator())); |
|
|
|
vo.setUpdater(userApi.getUserNickname(vo.getUpdater())); |
|
|
|
result.getList().stream().iterator().forEachRemaining(vo -> { |
|
|
|
vo.setCreator(Optional.ofNullable(userNicknameMap.get(vo.getCreator())).orElse("")); |
|
|
|
vo.setUpdater(Optional.ofNullable(userNicknameMap.get(vo.getUpdater())).orElse("")); |
|
|
|
ScrapRecordMainDO scrapRecordMainDO = mainMap.get(vo.getMasterId()); |
|
|
|
if(scrapRecordMainDO != null){ |
|
|
|
if (scrapRecordMainDO != null) { |
|
|
|
scrapRecordMainDO.setId(null); |
|
|
|
scrapRecordMainDO.setCreator(null); |
|
|
|
scrapRecordMainDO.setCreateTime(null); |
|
|
|
scrapRecordMainDO.setUpdateTime(null); |
|
|
|
scrapRecordMainDO.setUpdater(null); |
|
|
|
String remarkMain =Optional.ofNullable(scrapRecordMainDO.getRemark()).orElse(""); |
|
|
|
String remarkSub=Optional.ofNullable(vo.getRemark()).orElse(""); |
|
|
|
BeanUtil.copyProperties(scrapRecordMainDO,vo,options); |
|
|
|
if(vo.getQty() != null){ |
|
|
|
String remarkMain = Optional.ofNullable(scrapRecordMainDO.getRemark()).orElse(""); |
|
|
|
String remarkSub = Optional.ofNullable(vo.getRemark()).orElse(""); |
|
|
|
BeanUtil.copyProperties(scrapRecordMainDO, vo, options); |
|
|
|
if (vo.getQty() != null) { |
|
|
|
vo.setQty(vo.getQty().setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
if(vo.getSinglePrice() != null){ |
|
|
|
vo.setSinglePrice(vo.getSinglePrice().setScale(2,RoundingMode.HALF_UP)); |
|
|
|
if (vo.getSinglePrice() != null) { |
|
|
|
vo.setSinglePrice(vo.getSinglePrice().setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
if(vo.getAmount() != null){ |
|
|
|
vo.setAmount(vo.getAmount().setScale(2,RoundingMode.HALF_UP)); |
|
|
|
if (vo.getAmount() != null) { |
|
|
|
vo.setAmount(vo.getAmount().setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
vo.setRemarkMain(remarkMain); |
|
|
|
vo.setRemark(remarkSub); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return success(result); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("/senior") |
|
|
@ -131,34 +140,34 @@ public class ScrapRecordDetailController { |
|
|
|
public CommonResult<PageResult<ScrapRecordDetailRespVO>> getScrapRecordDetailSenior(@Valid @RequestBody CustomConditions conditions) { |
|
|
|
PageResult<ScrapRecordDetailDO> pageResult = scrapRecordDetailService.getScrapRecordDetailSenior(conditions); |
|
|
|
PageResult<ScrapRecordDetailRespVO> result = ScrapRecordDetailConvert.INSTANCE.convertPage(pageResult); |
|
|
|
if(pageResult.getList().size() > 0){ |
|
|
|
if (pageResult.getList().size() > 0) { |
|
|
|
Set<Long> masterIdSet = new HashSet<>(); |
|
|
|
for(ScrapRecordDetailDO scrapRecordDetailDO:pageResult.getList()){ |
|
|
|
for (ScrapRecordDetailDO scrapRecordDetailDO : pageResult.getList()) { |
|
|
|
masterIdSet.add(scrapRecordDetailDO.getMasterId()); |
|
|
|
} |
|
|
|
Map<Long, ScrapRecordMainDO> mainMap = scrapRecordMainMapper.queryMainListToMap(masterIdSet); |
|
|
|
CopyOptions options = CopyOptions.create().setIgnoreNullValue(true); |
|
|
|
for(ScrapRecordDetailRespVO vo : result.getList()) { |
|
|
|
for (ScrapRecordDetailRespVO vo : result.getList()) { |
|
|
|
vo.setCreator(userApi.getUserNickname(vo.getCreator())); |
|
|
|
vo.setUpdater(userApi.getUserNickname(vo.getUpdater())); |
|
|
|
ScrapRecordMainDO scrapRecordMainDO = mainMap.get(vo.getMasterId()); |
|
|
|
if(scrapRecordMainDO != null){ |
|
|
|
if (scrapRecordMainDO != null) { |
|
|
|
scrapRecordMainDO.setId(null); |
|
|
|
scrapRecordMainDO.setCreator(null); |
|
|
|
scrapRecordMainDO.setCreateTime(null); |
|
|
|
scrapRecordMainDO.setUpdateTime(null); |
|
|
|
scrapRecordMainDO.setUpdater(null); |
|
|
|
String remarkMain =Optional.ofNullable(scrapRecordMainDO.getRemark()).orElse(""); |
|
|
|
String remarkSub=Optional.ofNullable(vo.getRemark()).orElse(""); |
|
|
|
BeanUtil.copyProperties(scrapRecordMainDO,vo,options); |
|
|
|
if(vo.getQty() != null){ |
|
|
|
String remarkMain = Optional.ofNullable(scrapRecordMainDO.getRemark()).orElse(""); |
|
|
|
String remarkSub = Optional.ofNullable(vo.getRemark()).orElse(""); |
|
|
|
BeanUtil.copyProperties(scrapRecordMainDO, vo, options); |
|
|
|
if (vo.getQty() != null) { |
|
|
|
vo.setQty(vo.getQty().setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
if(vo.getSinglePrice() != null){ |
|
|
|
vo.setSinglePrice(vo.getSinglePrice().setScale(2,RoundingMode.HALF_UP)); |
|
|
|
if (vo.getSinglePrice() != null) { |
|
|
|
vo.setSinglePrice(vo.getSinglePrice().setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
if(vo.getAmount() != null){ |
|
|
|
vo.setAmount(vo.getAmount().setScale(2,RoundingMode.HALF_UP)); |
|
|
|
if (vo.getAmount() != null) { |
|
|
|
vo.setAmount(vo.getAmount().setScale(2, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
vo.setRemarkMain(remarkMain); |
|
|
|
vo.setRemark(remarkSub); |
|
|
@ -173,7 +182,7 @@ public class ScrapRecordDetailController { |
|
|
|
@PreAuthorize("@ss.hasPermission('wms:scrap-record-detail:export')") |
|
|
|
@OperateLog(type = EXPORT) |
|
|
|
public void exportScrapRecordDetailExcel(@Valid ScrapRecordDetailExportReqVO exportReqVO, |
|
|
|
HttpServletResponse response) throws IOException { |
|
|
|
HttpServletResponse response) throws IOException { |
|
|
|
List<ScrapRecordDetailDO> list = scrapRecordDetailService.getScrapRecordDetailList(exportReqVO); |
|
|
|
// 导出 Excel
|
|
|
|
List<ScrapRecordDetailExcelVO> datas = ScrapRecordDetailConvert.INSTANCE.convertList02(list); |
|
|
|