|
|
@@ -5,6 +5,7 @@ import com.dk.common.exception.BaseBusinessException;
|
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
|
import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
|
+import com.dk.common.infrastructure.xxl.XxlJobUtils;
|
|
|
import com.dk.common.model.pojo.PageList;
|
|
|
import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
@@ -20,6 +21,8 @@ import com.dk.common.service.BaseService;
|
|
|
import com.dk.common.mapper.BaseMapper;
|
|
|
import com.dk.mdm.model.pojo.ivt.FreezeItem;
|
|
|
import com.dk.mdm.model.pojo.ivt.Inventory;
|
|
|
+import com.dk.mdm.model.pojo.mst.CusFollow;
|
|
|
+import com.dk.mdm.model.pojo.mst.FollowPlan;
|
|
|
import com.dk.mdm.model.pojo.sale.Order;
|
|
|
import com.dk.mdm.model.pojo.sale.OrderItem;
|
|
|
import com.dk.mdm.model.query.ivt.FreezeItemQuery;
|
|
|
@@ -37,17 +40,20 @@ import com.dk.mdm.model.vo.sale.OrderVO;
|
|
|
import com.dk.mdm.service.common.CommonService;
|
|
|
import com.dk.mdm.service.ivt.inventory.InventoryService;
|
|
|
import com.dk.mdm.service.sale.OrderItemService;
|
|
|
+import com.xxl.job.core.context.XxlJobHelper;
|
|
|
+import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
+import java.time.*;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class FreezeService extends BaseService<Freeze> {
|
|
|
@@ -80,6 +86,9 @@ public class FreezeService extends BaseService<Freeze> {
|
|
|
|
|
|
@Autowired
|
|
|
private InventoryMapper inventoryMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private XxlJobUtils xxlJobUtils;
|
|
|
/**
|
|
|
* @desc : 重写主键
|
|
|
* @author : 宋扬
|
|
|
@@ -110,7 +119,7 @@ public class FreezeService extends BaseService<Freeze> {
|
|
|
public ResponseResultVO<?> insert(FreezeVO freezeVO) {
|
|
|
// 转化实体
|
|
|
Freeze freeze = freezeConvert.convertToPo(freezeVO);
|
|
|
- Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.Freeze.getName(), true);
|
|
|
+ Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.Freeze.getName(), false);
|
|
|
// 获取冻结状态 获取冻结日期(当前日期) 插入冻结表的实体
|
|
|
freeze.setFreezeStatus(Constant.FreezeStatusType.ALLFREEZE.getName()).setFreezeDate(LocalDate.now())
|
|
|
.setCusId(freezeVO.getCusId()).setMakeStaff(freezeVO.getMakeStaff()).setOrgId(freezeVO.getOrgId())
|
|
|
@@ -145,10 +154,79 @@ public class FreezeService extends BaseService<Freeze> {
|
|
|
inventoryService.updateByUuid(inventoryUpdate);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 只要有自动解冻日期
|
|
|
+ if (freezeVO.getAutoUnfreezeDate() != null) {
|
|
|
+ // 保存跟进信息
|
|
|
+ saveToXxlJob(freeze);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return ResponseResultUtil.success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @desc : 保存跟进信息到xxl job
|
|
|
+ * @author : 王英杰
|
|
|
+ * @date : 2022-05-27 09:53
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ public void saveToXxlJob(Freeze freeze) {
|
|
|
+ xxlJobUtils.create(Math.toIntExact(
|
|
|
+ (LocalDateTime.of(freeze.getAutoUnfreezeDate(),LocalTime.of(23, 59, 59)).toInstant(ZoneOffset.of("+8")).toEpochMilli() - System.currentTimeMillis()) / 1000
|
|
|
+ ), freeze.getFreezeId(), Constant.XxlJobInfo.FREEZE.getValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 客户跟进提醒回调
|
|
|
+ * @author : 姜永辉
|
|
|
+ * @date : 2022-06-29 14:22
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ @XxlJob("freeze-reminder")
|
|
|
+ public ResponseResultVO customerReminder() {
|
|
|
+// log.info("@XxlJob(\"freeze-reminder\")");
|
|
|
+// log.info("followPlan id: {}", XxlJobHelper.getJobParam());
|
|
|
+// String planid = "10112024-0715-0000-0000-0004a8b4d1e6";
|
|
|
+ String id = XxlJobHelper.getJobParam();
|
|
|
+// String id = "10112024-0808-0000-0000-0004da956d40";
|
|
|
+ // 赋值全部解冻
|
|
|
+ String freezeStatus=Constant.FreezeStatusType.ALLUNFREEZE.getName();
|
|
|
+ // 查询冻结单明细
|
|
|
+ FreezeItemQuery freezeItemQuery = new FreezeItemQuery();
|
|
|
+ freezeItemQuery.setFreezeId(id);
|
|
|
+ List<FreezeItemResponse> itemList = freezeItemMapper.selectByCond(freezeItemQuery);
|
|
|
+ // 解冻
|
|
|
+ for (FreezeItemResponse freezeItemVO : itemList) {
|
|
|
+
|
|
|
+ FreezeItem freezeItem = new FreezeItem();
|
|
|
+ // 赋值实体
|
|
|
+ freezeItem.setItemId(freezeItemVO.getItemId()).setUnfreezeQty(freezeItemVO.getSurplusQty())
|
|
|
+ .setSurplusQty(BigDecimal.ZERO);
|
|
|
+ // 修改冻结单明细解冻量
|
|
|
+ freezeItemService.updateByUuid(freezeItem);
|
|
|
+ // 查询库存信息
|
|
|
+ Inventory inventoryForUpdate=inventoryMapper.selectByIdForUpdate(freezeItemVO.getInvId());
|
|
|
+ // 库存冻结量=库存冻结量-实际解冻量
|
|
|
+ BigDecimal freezeqty=inventoryForUpdate.getFreezeQty().subtract(freezeItemVO.getSurplusQty());
|
|
|
+ // 库存可售量=库存可售量+实际解冻量
|
|
|
+ BigDecimal usableQt=inventoryForUpdate.getUsableQty().add(freezeItemVO.getSurplusQty());
|
|
|
+ // 更新修改内容信息
|
|
|
+ Inventory inventoryUpdate = new Inventory();
|
|
|
+ // 赋值库存可售量、冻结量和库存ID值
|
|
|
+ inventoryUpdate.setInvId(freezeItemVO.getInvId()).setFreezeQty(freezeqty).setUsableQty(usableQt);
|
|
|
+ // 修改库存冻结量、可售量
|
|
|
+ inventoryService.updateByUuid(inventoryUpdate);
|
|
|
+ }
|
|
|
+ // 赋值冻结表状态和ID
|
|
|
+ Freeze freeze=new Freeze();
|
|
|
+ freeze.setFreezeId(id).setFreezeStatus(freezeStatus).setUnfreezeDate(LocalDate.now());
|
|
|
+ // 更新主表冻结状态
|
|
|
+ return ResponseResultUtil.success(super.updateByUuid(freeze));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* @desc : 获取冻结单信息(解冻用)
|
|
|
* @author : 宋扬
|
|
|
* @date : 2024/3/19 15:29
|
|
|
@@ -253,7 +331,7 @@ public class FreezeService extends BaseService<Freeze> {
|
|
|
}
|
|
|
// 赋值冻结表状态和ID
|
|
|
Freeze freeze=new Freeze();
|
|
|
- freeze.setFreezeId(id).setFreezeStatus(freezeStatus);
|
|
|
+ freeze.setFreezeId(id).setFreezeStatus(freezeStatus).setUnfreezeDate(LocalDate.now());
|
|
|
// 更新主表冻结状态
|
|
|
return ResponseResultUtil.success(super.updateByUuid(freeze));
|
|
|
}
|