|
@@ -10,12 +10,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.Condition;
|
|
|
import com.fjhx.base.StorageBaseEntity;
|
|
|
import com.fjhx.constants.StatusConstant;
|
|
|
+import com.fjhx.entity.contract.Contract;
|
|
|
import com.fjhx.entity.water.WaterBatch;
|
|
|
import com.fjhx.entity.water.WaterTag;
|
|
|
import com.fjhx.enums.CheckStateEnum;
|
|
|
+import com.fjhx.enums.InTypeEnum;
|
|
|
import com.fjhx.enums.PurchaseProgressEnum;
|
|
|
import com.fjhx.mapper.water.WaterTagMapper;
|
|
|
import com.fjhx.params.water.WaterTagVo;
|
|
|
+import com.fjhx.service.contract.ContractService;
|
|
|
import com.fjhx.service.water.WaterBatchService;
|
|
|
import com.fjhx.service.water.WaterTagService;
|
|
|
import com.fjhx.utils.Assert;
|
|
@@ -25,11 +28,13 @@ import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
* <p>
|
|
@@ -45,6 +50,9 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
@Autowired
|
|
|
private WaterBatchService waterBatchService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ContractService contractService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<Map<String, Object>> getPage(Condition condition) {
|
|
|
|
|
@@ -56,6 +64,7 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
return baseMapper.getPage(condition.getPage(), wrapper);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public synchronized void add(WaterTagVo waterTagVo) {
|
|
|
BigDecimal quantity = waterTagVo.getQuantity();
|
|
@@ -75,6 +84,7 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
Integer number = waterTag.getNumber();
|
|
|
for (int i = 1; i <= num; i++) {
|
|
|
WaterTag waterTagTemp = createWaterTag(waterTag.getMaterialId(), quantity, waterTag.getPrice(),
|
|
|
+ waterTag.getContractId(), waterTag.getContractDetailsId(),
|
|
|
waterTag.getWaterBatchId(), waterTag.getWaterBatchCode(), number + i);
|
|
|
waterTagList.add(waterTagTemp);
|
|
|
}
|
|
@@ -82,13 +92,18 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
WaterBatch waterBatch = waterBatchService.getById(waterBatchId);
|
|
|
for (int i = 1; i <= num; i++) {
|
|
|
WaterTag waterTagTemp = createWaterTag(waterBatch.getMaterialId(), quantity, waterBatch.getPrice(),
|
|
|
+ waterBatch.getContractId(), waterBatch.getContractDetailsId(),
|
|
|
waterBatch.getId(), waterBatch.getCode(), i);
|
|
|
waterTagList.add(waterTagTemp);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ updateContractProcessed(waterBatch.getContractId());
|
|
|
}
|
|
|
saveBatch(waterTagList);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void uploadTag(MultipartFile file, Long waterBatchId) {
|
|
|
|
|
@@ -96,18 +111,18 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
|
|
|
|
|
|
List<BigDecimal> quantityList = getQuantityListByExcel(file);
|
|
|
-
|
|
|
Assert.gtZero(quantityList.size(), "导入标签数量为空");
|
|
|
|
|
|
+
|
|
|
WaterTag waterTag = getNewestWaterTag(waterBatchId);
|
|
|
|
|
|
List<WaterTag> waterTagList = new ArrayList<>();
|
|
|
-
|
|
|
if (waterTag != null) {
|
|
|
Integer number = waterTag.getNumber() + 1;
|
|
|
|
|
|
for (BigDecimal quantity : quantityList) {
|
|
|
WaterTag waterTagTemp = createWaterTag(waterTag.getMaterialId(), quantity, waterTag.getPrice(),
|
|
|
+ waterTag.getContractId(), waterTag.getContractDetailsId(),
|
|
|
waterTag.getWaterBatchId(), waterTag.getWaterBatchCode(), number);
|
|
|
number++;
|
|
|
waterTagList.add(waterTagTemp);
|
|
@@ -120,11 +135,14 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
|
|
|
for (BigDecimal quantity : quantityList) {
|
|
|
WaterTag waterTagTemp = createWaterTag(waterBatch.getMaterialId(), quantity, waterBatch.getPrice(),
|
|
|
+ waterBatch.getContractId(), waterBatch.getContractDetailsId(),
|
|
|
waterBatch.getId(), waterBatch.getCode(), number);
|
|
|
number++;
|
|
|
waterTagList.add(waterTagTemp);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ updateContractProcessed(waterBatch.getContractId());
|
|
|
}
|
|
|
saveBatch(waterTagList);
|
|
|
}
|
|
@@ -172,6 +190,32 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
return baseMapper.getDetailsByRfid(rfidCode);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void editInHouse(Enum<?> typeEnum, List<WaterTag> waterTagList, Long stockHouseId) {
|
|
|
+ List<Long> waterTagIdList = waterTagList.stream().map(StorageBaseEntity::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ if (typeEnum instanceof InTypeEnum) {
|
|
|
+ update(Wrappers.<WaterTag>lambdaUpdate()
|
|
|
+ .in(StorageBaseEntity::getId, waterTagIdList)
|
|
|
+ .set(WaterTag::getInHouse, StatusConstant.YES)
|
|
|
+ .set(WaterTag::getStockHouseId, stockHouseId)
|
|
|
+ .set(WaterTag::getPurchaseProgress, PurchaseProgressEnum.WAREHOUSING.getType())
|
|
|
+ .set(StorageBaseEntity::getUpdateTime, new Date())
|
|
|
+ .set(StorageBaseEntity::getUpdateUser, AuthUtil.getUserId())
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ update(Wrappers.<WaterTag>lambdaUpdate()
|
|
|
+ .in(StorageBaseEntity::getId, waterTagIdList)
|
|
|
+ .set(WaterTag::getInHouse, StatusConstant.NO)
|
|
|
+ .set(WaterTag::getStockHouseId, null)
|
|
|
+ .set(StorageBaseEntity::getUpdateTime, new Date())
|
|
|
+ .set(StorageBaseEntity::getUpdateUser, AuthUtil.getUserId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 解析excel文件中的数据
|
|
|
*/
|
|
@@ -244,20 +288,24 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
|
|
|
* 创建标签
|
|
|
*
|
|
|
- * @param materialId 物料id
|
|
|
- * @param quantity 数量
|
|
|
- * @param price 单价
|
|
|
- * @param waterBatchId 批次id
|
|
|
- * @param waterBatchCodee 批次编码
|
|
|
- * @param number 二维码编码
|
|
|
+ * @param materialId 物料id
|
|
|
+ * @param quantity 数量
|
|
|
+ * @param price 单价
|
|
|
+ * @param contractId 合同id
|
|
|
+ * @param contractDetailsId 合同明细id
|
|
|
+ * @param waterBatchId 批次id
|
|
|
+ * @param waterBatchCodee 批次编码
|
|
|
+ * @param number 二维码编码
|
|
|
*/
|
|
|
- private WaterTag createWaterTag(Long materialId, BigDecimal quantity, BigDecimal price,
|
|
|
- Long waterBatchId, String waterBatchCodee, Integer number) {
|
|
|
+ private WaterTag createWaterTag(Long materialId, BigDecimal quantity, BigDecimal price, Long contractId,
|
|
|
+ Long contractDetailsId, Long waterBatchId, String waterBatchCodee, Integer number) {
|
|
|
WaterTag waterTagTemp = new WaterTag();
|
|
|
waterTagTemp.setMaterialId(materialId);
|
|
|
waterTagTemp.setQuantity(quantity);
|
|
|
waterTagTemp.setPrice(price);
|
|
|
waterTagTemp.setQrCode(UUID.fastUUID().toString());
|
|
|
+ waterTagTemp.setContractId(contractId);
|
|
|
+ waterTagTemp.setContractDetailsId(contractDetailsId);
|
|
|
waterTagTemp.setWaterBatchId(waterBatchId);
|
|
|
waterTagTemp.setWaterBatchCode(waterBatchCodee);
|
|
|
waterTagTemp.setNumber(number);
|
|
@@ -271,8 +319,6 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
|
|
|
|
|
|
* 获取最新添加标签
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
private WaterTag getNewestWaterTag(Long waterBatchId) {
|
|
|
return getOne(Wrappers.<WaterTag>lambdaQuery()
|
|
@@ -281,5 +327,17 @@ public class WaterTagServiceImpl extends ServiceImpl<WaterTagMapper, WaterTag> i
|
|
|
.last("limit 1"));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 修改合同处理状态为已处理,后续操作不再允许删除合同
|
|
|
+ *
|
|
|
+ * @param contractId 合同id
|
|
|
+ */
|
|
|
+ private void updateContractProcessed(Long contractId) {
|
|
|
+ contractService.update(Wrappers.<Contract>lambdaUpdate()
|
|
|
+ .eq(StorageBaseEntity::getId, contractId)
|
|
|
+ .eq(Contract::getProcessed, StatusConstant.NO)
|
|
|
+ .set(Contract::getProcessed, StatusConstant.YES)
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
}
|