|
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
import com.jeeplus.flowable.service.FlowTaskService;
|
|
|
import com.jeeplus.sys.service.dto.UserDTO;
|
|
@@ -17,6 +18,8 @@ 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.help.domain.Help;
|
|
|
+import com.jeeplus.test.help.domain.HelpTree;
|
|
|
import com.jeeplus.test.materialManagement.purchase.domain.MaterialBasic;
|
|
|
import com.jeeplus.test.materialManagement.purchase.domain.MaterialDetailed;
|
|
|
import com.jeeplus.test.materialManagement.purchase.mapper.MaterialBasicMapper;
|
|
@@ -39,6 +42,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -526,6 +530,15 @@ public class WareHouseBasicService {
|
|
|
detailed.setBasicId(id);
|
|
|
detailed.setTradeTotalPrice(dto.getWareHouseTotalPrice());
|
|
|
detailed.setUpFlag("0");
|
|
|
+ if (StringUtils.isNotBlank(detailed.getWareHouseType()) && StringUtils.isNotBlank(detailed.getTradeName())) {
|
|
|
+ // 根据商品名称和入库类型查询 警告数量、警告标记
|
|
|
+ List<WareHouseDto> byTypeAndTradeName = wareHouseBasicMapper.getByTypeAndTradeName(detailed.getTradeName(), detailed.getWareHouseType());
|
|
|
+ // 如果存在,则将当前新增数据的 警告数量、警告标记 赋值为查询到的值
|
|
|
+ if (CollectionUtil.isNotEmpty(byTypeAndTradeName)) {
|
|
|
+ detailed.setWarnNum(byTypeAndTradeName.get(0).getWarnNum()); // 提醒数量
|
|
|
+ detailed.setWarnFlag(byTypeAndTradeName.get(0).getWarnFlag()); // 提醒标记
|
|
|
+ }
|
|
|
+ }
|
|
|
//获取该商品对应的库存数据
|
|
|
WareHouseDto wareHouseDto = wareHouseBasicMapper.getByTypeAndGoodsName(detailed.getTradeName(), detailed.getWareHouseTypeId());
|
|
|
//设置当前库存
|
|
@@ -704,8 +717,37 @@ public class WareHouseBasicService {
|
|
|
//
|
|
|
// queryWrapper.between("c.ware_house_date", contractDates[0], contractDates[1]);
|
|
|
// }
|
|
|
-
|
|
|
- return basicMapper.summaryList(page, queryWrapper);
|
|
|
+ IPage<WareHouseDto> wareHouseDtoIPage = basicMapper.summaryList(page, queryWrapper);
|
|
|
+ wareHouseDtoIPage.getRecords().forEach(item -> {
|
|
|
+ // 将小数点后无效的0删除
|
|
|
+ // 总量 格式化
|
|
|
+ if (StringUtils.isNotBlank(item.getAllNumber())) {
|
|
|
+ String s = convertByBigDecimal(item.getAllNumber());
|
|
|
+ item.setAllNumber(s);
|
|
|
+ }
|
|
|
+ //领用量 格式化
|
|
|
+ if (StringUtils.isNotBlank(item.getBorrowNumber())) {
|
|
|
+ String s = convertByBigDecimal(item.getBorrowNumber());
|
|
|
+ item.setBorrowNumber(s);
|
|
|
+ }
|
|
|
+ //剩余量 格式化
|
|
|
+ if (StringUtils.isNotBlank(item.getTradeNumber())) {
|
|
|
+ String s = convertByBigDecimal(item.getTradeNumber());
|
|
|
+ item.setTradeNumber(s);
|
|
|
+ }
|
|
|
+ //提醒数量 格式化
|
|
|
+ if (StringUtils.isNotBlank(item.getWarnNum())) {
|
|
|
+ String s = convertByBigDecimal(item.getWarnNum());
|
|
|
+ item.setWarnNum(s);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return wareHouseDtoIPage;
|
|
|
+ }
|
|
|
+ // 去除小数点后无效的0
|
|
|
+ public String convertByBigDecimal(String value) {
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(value);
|
|
|
+ BigDecimal res = bigDecimal.stripTrailingZeros();
|
|
|
+ return res.toPlainString();
|
|
|
}
|
|
|
|
|
|
public String findRequestId(String purchaseNo) {
|
|
@@ -770,4 +812,41 @@ public class WareHouseBasicService {
|
|
|
return wareHouseDto;
|
|
|
}
|
|
|
|
|
|
+ // 根据商品名称和入库类型修改提醒状态
|
|
|
+ public ResponseEntity updateWarnFlagByTradeNameAndType(WareHouseDto wareHouseDto) {
|
|
|
+ if (ObjectUtil.isNotEmpty(wareHouseDto.getTradeName()) && StringUtils.isNotBlank(wareHouseDto.getWareHouseType())) {
|
|
|
+ // 查询此数据的状态
|
|
|
+ List<WareHouseDto> wareHouseDtoList = basicMapper.getByTypeAndTradeName(wareHouseDto.getTradeName(),wareHouseDto.getWareHouseType());
|
|
|
+ if (CollectionUtil.isNotEmpty(wareHouseDtoList)) {
|
|
|
+ if ("1".equals(wareHouseDtoList.get(0).getWarnFlag())) { // 当前状态为启用
|
|
|
+ basicMapper.updateWarnFlagByTradeNameAndType("0", wareHouseDto.getTradeName(), wareHouseDto.getWareHouseType()); // 设置为停用
|
|
|
+ return ResponseEntity.ok("修改提醒状态成功");
|
|
|
+ } else if ("0".equals(wareHouseDtoList.get(0).getWarnFlag())) { // 当前状态为停用
|
|
|
+ basicMapper.updateWarnFlagByTradeNameAndType("1", wareHouseDto.getTradeName(), wareHouseDto.getWareHouseType()); // 设置为启用
|
|
|
+ return ResponseEntity.ok("修改提醒状态成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseEntity.badRequest().body("修改提醒状态失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 根据商品名称和入库类型修改提醒数量
|
|
|
+ public ResponseEntity updateWarnNumByTradeNameAndType(WareHouseDto wareHouseDto) {
|
|
|
+ if (ObjectUtil.isNotEmpty(wareHouseDto.getTradeName()) && StringUtils.isNotBlank(wareHouseDto.getWareHouseType())) {
|
|
|
+ if (StringUtils.isNotBlank(wareHouseDto.getWarnNum())) {
|
|
|
+ // 查询此数据的状态
|
|
|
+ List<WareHouseDto> wareHouseDtoList = basicMapper.getByTypeAndTradeName(wareHouseDto.getTradeName(),wareHouseDto.getWareHouseType());
|
|
|
+ if (CollectionUtil.isNotEmpty(wareHouseDtoList)) {
|
|
|
+ if (wareHouseDto.getWarnNum().equals(wareHouseDtoList.get(0).getWarnNum())) { // 如果查询到的提醒数量与修改的提醒数量相同则直接返回修改成功
|
|
|
+ return ResponseEntity.ok("修改提醒数量成功");
|
|
|
+ } else { // 如果查询到的提醒数量与修改的提醒数量不相同则修改提醒数量
|
|
|
+ basicMapper.updateWarnNumByTradeNameAndType(wareHouseDto.getWarnNum(), wareHouseDto.getTradeName(), wareHouseDto.getWareHouseType()); // 修改提醒数量
|
|
|
+ return ResponseEntity.ok("修改提醒数量成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResponseEntity.badRequest().body("修改提醒数量失败");
|
|
|
+ }
|
|
|
}
|