|
@@ -1,5 +1,10 @@
|
|
|
package com.jeeplus.test.materialManagement.wareHouse.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -11,6 +16,7 @@ import com.jeeplus.sys.service.dto.UserDTO;
|
|
|
import com.jeeplus.sys.utils.StringUtils;
|
|
|
import com.jeeplus.sys.utils.UserUtils;
|
|
|
import com.jeeplus.test.cw.contractRegistration.service.ContractInfoService;
|
|
|
+import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
|
|
|
import com.jeeplus.test.materialManagement.purchase.domain.MaterialBasic;
|
|
|
import com.jeeplus.test.materialManagement.purchase.domain.MaterialDetailed;
|
|
|
import com.jeeplus.test.materialManagement.purchase.mapper.MaterialBasicMapper;
|
|
@@ -18,9 +24,11 @@ import com.jeeplus.test.materialManagement.purchase.mapper.MaterialDetailedMappe
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.domain.WareHouseBasic;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.domain.WareHouseDetailed;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.domain.WareHouseSummary;
|
|
|
+import com.jeeplus.test.materialManagement.wareHouse.domain.WarehouseUpHi;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.mapper.WareHouseBasicMapper;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.mapper.WareHouseDetailedMapper;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.mapper.WareHouseSummaryMapper;
|
|
|
+import com.jeeplus.test.materialManagement.wareHouse.mapper.WarehouseUpHiMapper;
|
|
|
import com.jeeplus.test.materialManagement.wareHouse.service.dto.WareHouseDto;
|
|
|
import com.jeeplus.test.mould.service.SerialnumTplService;
|
|
|
import com.jeeplus.test.oss.domain.WorkAttachment;
|
|
@@ -31,10 +39,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
/**
|
|
@@ -72,6 +79,9 @@ public class WareHouseBasicService {
|
|
|
@Resource
|
|
|
private FlowTaskService flowTaskService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private WarehouseUpHiMapper warehouseUpHiMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 列表查询
|
|
@@ -155,13 +165,38 @@ public class WareHouseBasicService {
|
|
|
return "操作成功";
|
|
|
}
|
|
|
|
|
|
- public WareHouseDto findById(String id) {
|
|
|
+ public WareHouseDto findById(String id, String status) {
|
|
|
WareHouseDto dto = new WareHouseDto();
|
|
|
// 查询基础信息表
|
|
|
WareHouseBasic info = basicMapper.selectById(id);
|
|
|
BeanUtils.copyProperties(info, dto);
|
|
|
//将入库详情数据查出
|
|
|
List<WareHouseDetailed> wareHouseList = detailedMapper.getByBasicId(id);
|
|
|
+ if ("audit".equals(status) || "taskFormDetail".equals(status)) {
|
|
|
+ List<WareHouseDetailed> wareList = new ArrayList<>();
|
|
|
+ List<WareHouseDetailed> finalWareHouseList = detailedMapper.getByBasicIdAll(id);
|
|
|
+ List<WareHouseDetailed> detailedList = wareHouseList; // 这里不copy一下会报错
|
|
|
+ detailedList.stream().forEach(item2 -> {
|
|
|
+ if (StringUtils.isBlank(item2.getSourceId())) {
|
|
|
+ wareList.add(item2);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ finalWareHouseList.stream().forEach(item -> {
|
|
|
+ if("2".equals(item.getUpFlag())) {
|
|
|
+ wareList.add(item);
|
|
|
+ } else if ("1".equals(item.getUpFlag())) {
|
|
|
+ wareList.add(item);
|
|
|
+ detailedList.stream().forEach(item2 -> {
|
|
|
+ if (StringUtils.isNotBlank(item2.getSourceId())) {
|
|
|
+ if (item2.getSourceId().equals(item.getId())) {
|
|
|
+ wareList.add(item2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ wareHouseList = new ArrayList<>(wareList);
|
|
|
+ }
|
|
|
if (CollectionUtils.isNotEmpty(wareHouseList)){
|
|
|
wareHouseList.forEach(detailed->{
|
|
|
//附件信息
|
|
@@ -223,138 +258,185 @@ public class WareHouseBasicService {
|
|
|
}
|
|
|
|
|
|
public String update(WareHouseDto dto, UserDTO userDTO) {
|
|
|
+ if (StringUtils.isNotBlank(dto.getFunctionFlag())) {
|
|
|
+ if ("start".equals(dto.getFunctionFlag())) { // 送审时执行
|
|
|
+ // 添加当前修改申请人
|
|
|
+ basicMapper.saveUpdateUser(dto.getId(),UserUtils.getCurrentUserDTO().getId());
|
|
|
+ // 判断是否为第一次送审(排除撤回后送审或者驳回后送审)
|
|
|
+ List<WarehouseUpHi> warehouseUpHis = warehouseUpHiMapper.selectList(new LambdaQueryWrapper<WarehouseUpHi>()
|
|
|
+ .eq(WarehouseUpHi::getWarehouseId, dto.getId()).eq(WarehouseUpHi::getEndflag, "0"));
|
|
|
+ if (CollectionUtil.isEmpty(warehouseUpHis)) { // 当前送审操作为第一次送审
|
|
|
+ // 将未修改的数据添加到历史数据表中
|
|
|
+ WareHouseDto byId = this.findById(dto.getId(),"false");
|
|
|
+ String jsonString = JSON.toJSONString(byId);
|
|
|
+ WarehouseUpHi warehouseUpHi = new WarehouseUpHi();
|
|
|
+ warehouseUpHi.setEndflag("0");
|
|
|
+ warehouseUpHi.setJsonData(jsonString);
|
|
|
+ warehouseUpHi.setWarehouseId(dto.getId());
|
|
|
+ warehouseUpHiMapper.insert(warehouseUpHi);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("agree".equals(dto.getFunctionFlag())) { // 审核通过时执行
|
|
|
+ // 将历史数据表中的原始数据删除(end_flag = 0并且warehouse_id = 当前数据id)
|
|
|
+ warehouseUpHiMapper.delete(new LambdaQueryWrapper<WarehouseUpHi>().eq(WarehouseUpHi::getEndflag,"0").eq(WarehouseUpHi::getWarehouseId,dto.getId()));
|
|
|
+ WarehouseUpHi warehouseUpHi = new WarehouseUpHi();
|
|
|
+ WareHouseDto byId = this.findById(dto.getId(),"audit");
|
|
|
+ if (ObjectUtil.isNotEmpty(byId)) {
|
|
|
+ // 获取修改数据的商品名称、商品类型
|
|
|
+ if (CollectionUtil.isNotEmpty(byId.getWareHouse())){
|
|
|
+ List<WareHouseDetailed> updateData = byId.getWareHouse().stream().filter(i -> {
|
|
|
+ if ("1".equals(i.getUpFlag()) || "2".equals(i.getUpFlag())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<String> updateTradeNameList = updateData.stream().map(WareHouseDetailed::getTradeName).collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(updateTradeNameList)) {
|
|
|
+ warehouseUpHi.setUpdateTradeName(String.join(",",updateTradeNameList)); //获取修改数据的商品名称
|
|
|
+ }
|
|
|
+ List<String> updateTradeTypeList = updateData.stream().map(WareHouseDetailed::getWareHouseType).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
|
|
|
+ if (CollectionUtil.isNotEmpty(updateTradeTypeList)) {
|
|
|
+ warehouseUpHi.setUpdateTradeType(String.join(",",updateTradeTypeList)); //获取修改数据的商品类型
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 将审核页面的数据存储到历史数据表中
|
|
|
+ String jsonString = JSON.toJSONString(byId);
|
|
|
+ warehouseUpHi.setJsonData(jsonString);
|
|
|
+ }
|
|
|
+ // 获取数据修改申请人
|
|
|
+ String updateUser = basicMapper.getUpdateUser(dto.getId());
|
|
|
+ if (StringUtils.isNotBlank(updateUser)) {
|
|
|
+ warehouseUpHi.setUpdateUser(updateUser);
|
|
|
+ basicMapper.deleteUpdateUser(dto.getId()); // 删除数据修改申请人
|
|
|
+ }
|
|
|
+ warehouseUpHi.setEndflag("1");
|
|
|
+ warehouseUpHi.setWarehouseId(dto.getId());
|
|
|
+ warehouseUpHiMapper.insert(warehouseUpHi);
|
|
|
+ // 修改基础信息
|
|
|
+ WareHouseBasic info = new WareHouseBasic();
|
|
|
+ BeanUtils.copyProperties(dto, info);
|
|
|
+ info.setHandledBy(dto.getHandledById());
|
|
|
+ basicMapper.updateById(info);
|
|
|
+ // 入库详情修改
|
|
|
+ List<WareHouseDetailed> wareHouseDetaileds = detailedMapper.selectList(new LambdaQueryWrapper<WareHouseDetailed>()
|
|
|
+ .eq(WareHouseDetailed::getBasicId,info.getId()));
|
|
|
+ wareHouseDetaileds.stream().forEach(item -> {
|
|
|
+ if ("1".equals(item.getUpFlag()) || "2".equals(item.getUpFlag())) { // 将修改前的数据以及删除标记的数据删除
|
|
|
+ detailedMapper.deleteById(item.getId());
|
|
|
+ } else if ("0".equals(item.getUpFlag())) {
|
|
|
+ if (StringUtils.isNotBlank(item.getSourceId())) { // 将修改后数据的sourceId置空
|
|
|
+ detailedMapper.upSourceIdEmpty(item.getId()); // 根据入库详情id置空sourceId
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return dto.getId();
|
|
|
+ }
|
|
|
+ if ("back".equals(dto.getFunctionFlag())) {
|
|
|
+ // 修改基础信息
|
|
|
+ WareHouseBasic info = new WareHouseBasic();
|
|
|
+ BeanUtils.copyProperties(dto, info);
|
|
|
+ info.setHandledBy(dto.getHandledById());
|
|
|
+ basicMapper.updateById(info);
|
|
|
+ basicMapper.deleteUpdateUser(dto.getId()); // 删除数据修改申请人
|
|
|
+ // 修改附件信息列表
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getFiles())) {
|
|
|
+ infoService.updateFiles(dto.getFiles(), userDTO, dto.getId());
|
|
|
+ }
|
|
|
+ // 入库详情修改
|
|
|
+ // 物理删除此入库的全部入库关联的附件表数据,然后再新增附件。因为如果不物理删除,新增时会有主键冲突
|
|
|
+ List<WareHouseDetailed> wareHouseDetaileds = detailedMapper.selectList(new QueryWrapper<WareHouseDetailed>().lambda().eq(WareHouseDetailed::getBasicId, dto.getId()));
|
|
|
+ List<String> detailedIdList = wareHouseDetaileds.stream().map(WareHouseDetailed::getId).collect(Collectors.toList());
|
|
|
+ detailedMapper.deleteFilesByIdList(detailedIdList);
|
|
|
+ // 物理删除此入库的全部入库详情,然后再新增。因为如果不物理删除,新增时会有主键冲突
|
|
|
+ detailedMapper.deleteByBasicId(dto.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getWareHouse())) {
|
|
|
+ dto.getWareHouse().stream().forEach(item -> {
|
|
|
+ item.setWareHouseMan(item.getWareHouseManId());
|
|
|
+ item.setWareHouseType(item.getWareHouseTypeId());
|
|
|
+ detailedMapper.insert(item);
|
|
|
+ // 保存附件信息列表
|
|
|
+ if (CollectionUtils.isNotEmpty(item.getFileInfoLost())) {
|
|
|
+ infoService.updateFiles(item.getFileInfoLost(), userDTO, item.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 删除送审时在历史修改表添加的数据
|
|
|
+ warehouseUpHiMapper.delete(new QueryWrapper<WarehouseUpHi>().lambda()
|
|
|
+ .eq(WarehouseUpHi::getWarehouseId,dto.getId()).eq(WarehouseUpHi::getEndflag,"0"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 修改基础信息
|
|
|
WareHouseBasic info = new WareHouseBasic();
|
|
|
BeanUtils.copyProperties(dto, info);
|
|
|
- info.setUpdateBy(userDTO.getId());
|
|
|
- info.setUpdateDate(new Date());
|
|
|
info.setHandledBy(dto.getHandledById());
|
|
|
basicMapper.updateById(info);
|
|
|
- // 修改报销详情列表信息
|
|
|
- // 删除原有数据
|
|
|
-// LambdaQueryWrapper<WareHouseDetailed> detailWrapper = new LambdaQueryWrapper<>();
|
|
|
-// detailWrapper.eq(WareHouseDetailed::getBasicId, dto.getId());
|
|
|
-// detailedMapper.delete(detailWrapper);
|
|
|
- if (CollectionUtils.isNotEmpty(dto.getWareHouse())) {
|
|
|
|
|
|
- List<String> idList = detailedMapper.getIdByBasicId(info.getId());
|
|
|
- for (WareHouseDetailed detailInfo : dto.getWareHouse()) {
|
|
|
- //删除多余的领用详情
|
|
|
- //根据基础表id获取所有的详情表id
|
|
|
- if (null != idList) {
|
|
|
- if (idList.contains(detailInfo.getId())){
|
|
|
- idList.remove(detailInfo.getId());
|
|
|
- }
|
|
|
+ // 入库详情修改
|
|
|
+ if (CollectionUtils.isNotEmpty(dto.getWareHouse())) {
|
|
|
+ // 获取前端删除的入库详情
|
|
|
+ List<String> liveIds = dto.getWareHouse().stream().map(WareHouseDetailed::getId).collect(Collectors.toList());
|
|
|
+ List<WareHouseDetailed> wareHouseDetaileds = detailedMapper.selectList(new LambdaQueryWrapper<WareHouseDetailed>()
|
|
|
+ .eq(WareHouseDetailed::getBasicId,info.getId()).notIn(WareHouseDetailed::getId, liveIds));
|
|
|
+ wareHouseDetaileds.stream().forEach(d -> {
|
|
|
+ if ("0".equals(d.getUpFlag())) {
|
|
|
+ d.setUpFlag("2"); // 已删除标记
|
|
|
+ dto.getWareHouse().add(d);
|
|
|
}
|
|
|
- }
|
|
|
- if (null != idList & idList.size()>0) {
|
|
|
- idList.forEach(id->{
|
|
|
- detailedMapper.deleteById(id);
|
|
|
- //汇总表中的数据也删除掉
|
|
|
-// summaryMapper.deleteByDetailedId(id);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- for (WareHouseDetailed detailInfo : dto.getWareHouse()) {
|
|
|
- // 生成id
|
|
|
- WareHouseDetailed wareHouseDetailed = detailedMapper.selectById(detailInfo.getId());
|
|
|
- if (null == wareHouseDetailed) {
|
|
|
- String detailId = UUID.randomUUID().toString().replace("-", "");
|
|
|
- detailInfo.setId(detailId);
|
|
|
- detailInfo.setWareHouseMan(detailInfo.getWareHouseManId());
|
|
|
- detailInfo.setCreateBy(userDTO.getId());
|
|
|
- detailInfo.setCreateDate(new Date());
|
|
|
- detailInfo.setWareHouseMan(detailInfo.getWareHouseManId());
|
|
|
- detailInfo.setUpdateBy(userDTO.getId());
|
|
|
- detailInfo.setUpdateDate(new Date());
|
|
|
- detailInfo.setWareHouseType(detailInfo.getWareHouseTypeId());
|
|
|
- detailInfo.setDelFlag(0);
|
|
|
- // 保存基础表信息主键值
|
|
|
- detailInfo.setBasicId(dto.getId());
|
|
|
- detailInfo.setTradeTotalPrice(dto.getWareHouseTotalPrice());
|
|
|
- detailedMapper.insert(detailInfo);
|
|
|
- //保存详情列表附件信息
|
|
|
- if (CollectionUtils.isNotEmpty(detailInfo.getFileInfoLost())){
|
|
|
- infoService.saveFiles(detailInfo.getFileInfoLost(), userDTO, detailId);
|
|
|
+ });
|
|
|
+ dto.getWareHouse().stream().forEach(detailInfo -> {
|
|
|
+ detailInfo.setWareHouseMan(detailInfo.getWareHouseManId());
|
|
|
+ detailInfo.setWareHouseType(detailInfo.getWareHouseTypeId());
|
|
|
+ detailInfo.setBasicId(dto.getId()); // 保存基础表信息主键值
|
|
|
+ detailInfo.setTradeTotalPrice(dto.getWareHouseTotalPrice());
|
|
|
+ if ("1".equals(detailInfo.getUpFlag())) { // 已修改标记数据
|
|
|
+ if(StringUtils.isBlank(detailInfo.getSourceId())) {
|
|
|
+ WareHouseDetailed ware = detailedMapper.selectById(detailInfo.getId());
|
|
|
+ boolean is = false;
|
|
|
+ if (judgmentEquals(detailInfo.getWareHouseMan(),ware.getWareHouseMan())) {
|
|
|
+ is = true;
|
|
|
+ } else if (judgmentEquals(detailInfo.getWareHouseType(),ware.getWareHouseType())) {
|
|
|
+ is = true;
|
|
|
+ } else if (judgmentEquals(detailInfo.getTradeName(),ware.getTradeName())) {
|
|
|
+ is = true;
|
|
|
+ } else if (judgmentEquals(detailInfo.getTradeNumber(),ware.getTradeNumber())) {
|
|
|
+ is = true;
|
|
|
+ } else if (judgmentEquals(detailInfo.getCompany(),ware.getCompany())) {
|
|
|
+ is = true;
|
|
|
+ } else if (judgmentEquals(detailInfo.getTradePrice(),ware.getTradePrice())) {
|
|
|
+ is = true;
|
|
|
+ } else if (judgmentEquals(detailInfo.getActualPrice(),ware.getActualPrice())) {
|
|
|
+ is = true;
|
|
|
+ } else if (judgmentEquals(detailInfo.getRemarks(),ware.getRemarks())) {
|
|
|
+ is = true;
|
|
|
+ }
|
|
|
+ if (is) {
|
|
|
+ ware.setUpFlag("1");
|
|
|
+ detailedMapper.updateById(ware);
|
|
|
+ detailInfo.setSourceId(ware.getId());
|
|
|
+ detailInfo.setId(new String());
|
|
|
+ detailInfo.setUpFlag("0");
|
|
|
+ detailedMapper.insert(detailInfo);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ detailInfo.setUpFlag("0");
|
|
|
+ detailedMapper.updateById(detailInfo);
|
|
|
}
|
|
|
- //将入库详情商品信息汇总处理
|
|
|
- //根据商品名称及入库类型查是否有相关数据
|
|
|
-// WareHouseSummary summary = summaryMapper.getInfoByTradeName(detailInfo.getTradeName(),detailInfo.getWareHouseType());;
|
|
|
-// if (null != summary) {
|
|
|
-// if (summary.getTradeName().equals(detailInfo.getTradeName()) &&
|
|
|
-// summary.getWareHouseType().equals(detailInfo.getWareHouseType())) {
|
|
|
-// String num = Double.valueOf(detailInfo.getTradeNumber())
|
|
|
-// + Double.valueOf(summary.getTradeNumber()) + "";
|
|
|
-// summary.setTradeNumber(num);
|
|
|
-// summary.setWareHouseType(detailInfo.getWareHouseType());
|
|
|
-// summary.setUpdateBy(userDTO.getId());
|
|
|
-// summary.setUpdateDate(new Date());
|
|
|
-// summary.setDetailedId(detailInfo.getId());
|
|
|
-// summaryMapper.updateById(summary);
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// summary = new WareHouseSummary();
|
|
|
-// // 生成id
|
|
|
-// String summaryId = UUID.randomUUID().toString().replace("-", "");
|
|
|
-// summary.setDetailedId(detailInfo.getId());
|
|
|
-// summary.setId(summaryId);
|
|
|
-// summary.setCreateBy(userDTO.getId());
|
|
|
-// summary.setCreateDate(new Date());
|
|
|
-// summary.setUpdateBy(userDTO.getId());
|
|
|
-// summary.setUpdateDate(new Date());
|
|
|
-// summary.setDelFlag(0);
|
|
|
-// summary.setWareHouseType(detailInfo.getWareHouseType());
|
|
|
-// summary.setTradeName(detailInfo.getTradeName());
|
|
|
-// summary.setTradeNumber(detailInfo.getTradeNumber());
|
|
|
-// summaryMapper.insert(summary);
|
|
|
-// }
|
|
|
- } else {
|
|
|
- detailInfo.setWareHouseMan(detailInfo.getWareHouseManId());
|
|
|
- detailInfo.setUpdateBy(userDTO.getId());
|
|
|
- detailInfo.setUpdateDate(new Date());
|
|
|
- detailInfo.setDelFlag(0);
|
|
|
- detailInfo.setWareHouseType(detailInfo.getWareHouseTypeId());
|
|
|
- // 保存基础表信息主键值
|
|
|
- detailInfo.setBasicId(dto.getId());
|
|
|
- detailInfo.setTradeTotalPrice(dto.getWareHouseTotalPrice());
|
|
|
- detailedMapper.updateById(detailInfo);
|
|
|
- // 修改附件信息列表
|
|
|
- if (CollectionUtils.isNotEmpty(detailInfo.getFileInfoLost())) {
|
|
|
- infoService.updateFiles(detailInfo.getFileInfoLost(), userDTO, detailInfo.getId());
|
|
|
+ } else if ("2".equals(detailInfo.getUpFlag())) { // 已删除标记数据
|
|
|
+ if(StringUtils.isBlank(detailInfo.getSourceId())) {
|
|
|
+ detailedMapper.updateById(detailInfo);
|
|
|
+ }else{
|
|
|
+ WareHouseDetailed wareHouseDetailed = detailedMapper.selectById(detailInfo.getSourceId());
|
|
|
+ wareHouseDetailed.setUpFlag("2");
|
|
|
+ detailedMapper.updateById(wareHouseDetailed);
|
|
|
+ detailedMapper.deleteById(detailInfo.getId());
|
|
|
}
|
|
|
- //将入库详情商品信息汇总处理
|
|
|
- //根据商品名称及入库类型查是否有相关数据
|
|
|
-// WareHouseSummary summary = summaryMapper.getInfoByTradeName(detailInfo.getTradeName(),detailInfo.getWareHouseType());;
|
|
|
-// if (null != summary) {
|
|
|
-// if (wareHouseDetailed.getTradeNumber().equals(detailInfo.getTradeNumber()) &&
|
|
|
-// !wareHouseDetailed.getTradeName().equals(detailInfo.getTradeName())) {
|
|
|
-// String num = Double.valueOf(detailInfo.getTradeNumber())
|
|
|
-// + Double.valueOf(summary.getTradeNumber()) + "";
|
|
|
-// summary.setTradeNumber(num);
|
|
|
-// summary.setUpdateBy(userDTO.getId());
|
|
|
-// summary.setWareHouseType(detailInfo.getWareHouseType());
|
|
|
-// summary.setUpdateDate(new Date());
|
|
|
-// summary.setDetailedId(detailInfo.getId());
|
|
|
-// summaryMapper.updateById(summary);
|
|
|
-// }
|
|
|
-// } else {
|
|
|
-// summary = new WareHouseSummary();
|
|
|
-// // 生成id
|
|
|
-// String summaryId = UUID.randomUUID().toString().replace("-", "");
|
|
|
-// summary.setDetailedId(detailInfo.getId());
|
|
|
-// summary.setId(summaryId);
|
|
|
-// summary.setCreateBy(userDTO.getId());
|
|
|
-// summary.setCreateDate(new Date());
|
|
|
-// summary.setUpdateBy(userDTO.getId());
|
|
|
-// summary.setUpdateDate(new Date());
|
|
|
-// summary.setDelFlag(0);
|
|
|
-// summary.setWareHouseType(detailInfo.getWareHouseType());
|
|
|
-// summary.setTradeName(detailInfo.getTradeName());
|
|
|
-// summary.setTradeNumber(detailInfo.getTradeNumber());
|
|
|
-// summaryMapper.insert(summary);
|
|
|
-// }
|
|
|
}
|
|
|
- }
|
|
|
+ // 修改附件信息列表
|
|
|
+ if (CollectionUtils.isNotEmpty(detailInfo.getFileInfoLost())) {
|
|
|
+ infoService.updateFiles(detailInfo.getFileInfoLost(), userDTO, detailInfo.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
// 修改附件信息列表
|
|
|
if (CollectionUtils.isNotEmpty(dto.getFiles())) {
|
|
@@ -363,6 +445,36 @@ public class WareHouseBasicService {
|
|
|
return dto.getId();
|
|
|
}
|
|
|
|
|
|
+ // 判断两个字符串是否不相等 true不相等 false相等
|
|
|
+ public boolean judgmentEquals(String a,String b) {
|
|
|
+ if (StringUtils.isNotBlank(a) && StringUtils.isBlank(b)) { // a非空 b空
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(a) && StringUtils.isNotBlank(b)) { // a空 b非空
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(a) && StringUtils.isNotBlank(b) && !a.equals(b)) { // a非空 b非空 a、b相等
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 流程结束将全部修改的数据撤回到未修改
|
|
|
+ public Map<String,String> backSourceData(String id){
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("result","error");
|
|
|
+ String sourceData = warehouseUpHiMapper.getSourceData(id);
|
|
|
+ if (StringUtils.isNotBlank(sourceData)) {
|
|
|
+ WareHouseDto wareHouseDto = JSON.parseObject(sourceData, WareHouseDto.class);
|
|
|
+ if (ObjectUtil.isNotEmpty(wareHouseDto)){
|
|
|
+ wareHouseDto.setFunctionFlag("back");
|
|
|
+ this.update(wareHouseDto,UserUtils.getCurrentUserDTO());
|
|
|
+ map.replace("result","success");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
public String add(WareHouseDto dto, UserDTO userDTO) throws Exception{
|
|
|
// 生成id
|
|
|
String id = UUID.randomUUID().toString().replace("-", "");
|
|
@@ -398,6 +510,7 @@ public class WareHouseBasicService {
|
|
|
// 保存基础表信息主键值
|
|
|
detailed.setBasicId(id);
|
|
|
detailed.setTradeTotalPrice(dto.getWareHouseTotalPrice());
|
|
|
+ detailed.setUpFlag("0");
|
|
|
detailedMapper.insert(detailed);
|
|
|
//保存详情列表附件信息
|
|
|
if (CollectionUtils.isNotEmpty(detailed.getFileInfoLost())){
|
|
@@ -433,6 +546,17 @@ public class WareHouseBasicService {
|
|
|
if (CollectionUtils.isNotEmpty(dto.getFiles())) {
|
|
|
infoService.saveFiles(dto.getFiles(), userDTO, id);
|
|
|
}
|
|
|
+
|
|
|
+ // 将新增的数据保存到历史数据表中
|
|
|
+ WareHouseDto byId = this.findById(info.getId(),"false");
|
|
|
+ String jsonString = JSON.toJSONString(byId);
|
|
|
+ WarehouseUpHi warehouseUpHi = new WarehouseUpHi();
|
|
|
+ warehouseUpHi.setUpdateUser(byId.getCreateBy());
|
|
|
+ warehouseUpHi.setWarehouseId(byId.getId());
|
|
|
+ warehouseUpHi.setEndflag("2");
|
|
|
+ warehouseUpHi.setJsonData(jsonString);
|
|
|
+ warehouseUpHiMapper.insert(warehouseUpHi);
|
|
|
+
|
|
|
return id;
|
|
|
}
|
|
|
|
|
@@ -569,4 +693,55 @@ public class WareHouseBasicService {
|
|
|
return "操作成功";
|
|
|
}
|
|
|
|
|
|
+ // 根据入库表id查询其全部历史修改数据
|
|
|
+ public List<WarehouseUpHi> findHiById(String warehouseId) {
|
|
|
+ return warehouseUpHiMapper.findHiById(warehouseId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据历史表id查询历史表数据
|
|
|
+ public WareHouseDto findHiByHiId(String hiId) {
|
|
|
+ WareHouseDto wareHouseDto = new WareHouseDto();
|
|
|
+ WarehouseUpHi hiByHiId = warehouseUpHiMapper.findHiByHiId(hiId); // 根据历史表id查询历史表数据
|
|
|
+ if (ObjectUtil.isNotEmpty(hiByHiId) && StringUtils.isNotBlank(hiByHiId.getJsonData())) {
|
|
|
+ wareHouseDto = JSON.parseObject(hiByHiId.getJsonData(), WareHouseDto.class); // json字符串解析为java对象
|
|
|
+ // 入库详情中的附件数据获取。
|
|
|
+ // 在这里要重新获取一下入库详情附件的原因是,json字符串中的附件createBy值存储不正确,所以重新获取一下
|
|
|
+ if(ObjectUtil.isNotEmpty(wareHouseDto) && CollectionUtil.isNotEmpty(wareHouseDto.getWareHouse())) {
|
|
|
+ wareHouseDto.getWareHouse().forEach(detailed->{
|
|
|
+ List<WorkAttachmentDto> acList = detailedMapper.getByAttachmentId(detailed.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(acList)) {
|
|
|
+ for (WorkAttachmentDto i : acList) {
|
|
|
+ i.setCreateBy(UserUtils.get(i.getBy()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detailed.setFileInfoLost(acList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return wareHouseDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据入库表id查询最近的一个修改历史
|
|
|
+ public WareHouseDto findLastHiByid(String warehouseId) {
|
|
|
+ WareHouseDto wareHouseDto = new WareHouseDto();
|
|
|
+ WarehouseUpHi hiByHiId = warehouseUpHiMapper.findLastHiByid(warehouseId); // 根据入库表id查询最近的一个修改历史
|
|
|
+ if (ObjectUtil.isNotEmpty(hiByHiId) && StringUtils.isNotBlank(hiByHiId.getJsonData())) {
|
|
|
+ wareHouseDto = JSON.parseObject(hiByHiId.getJsonData(), WareHouseDto.class); // json字符串解析为java对象
|
|
|
+ // 入库详情中的附件数据获取。
|
|
|
+ // 在这里要重新获取一下入库详情附件的原因是,json字符串中的附件createBy值存储不正确,所以重新获取一下
|
|
|
+ if(ObjectUtil.isNotEmpty(wareHouseDto) && CollectionUtil.isNotEmpty(wareHouseDto.getWareHouse())) {
|
|
|
+ wareHouseDto.getWareHouse().forEach(detailed->{
|
|
|
+ List<WorkAttachmentDto> acList = detailedMapper.getByAttachmentId(detailed.getId());
|
|
|
+ if (CollectionUtils.isNotEmpty(acList)) {
|
|
|
+ for (WorkAttachmentDto i : acList) {
|
|
|
+ i.setCreateBy(UserUtils.get(i.getBy()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ detailed.setFileInfoLost(acList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return wareHouseDto;
|
|
|
+ }
|
|
|
+
|
|
|
}
|