|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.Condition;
|
|
|
import com.fjhx.entity.apply.ApplyPurchase;
|
|
|
+import com.fjhx.entity.product.ProductInfo;
|
|
|
+import com.fjhx.enums.apply.ApplyPurchaseStatusEnum;
|
|
|
import com.fjhx.mapper.apply.ApplyPurchaseMapper;
|
|
|
import com.fjhx.params.apply.ApplyPurchaseVo;
|
|
|
import com.fjhx.service.apply.ApplyPurchaseService;
|
|
@@ -41,16 +43,7 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
|
|
|
|
|
|
IWrapper<ApplyPurchase> wrapper = IWrapper.getWrapper(condition);
|
|
|
|
|
|
- wrapper.eq("t1", ApplyPurchase::getReceiptWarehouseId, condition.get("warehouseId"))
|
|
|
- .eq("t1", ApplyPurchase::getStatus)
|
|
|
- .apply(Func.isNotEmpty(condition.get("code")), "instr(t1.`code`, '" + condition.get("code") + "') > 0")
|
|
|
- .apply(Func.isNotEmpty(condition.get("goodsCode")), "instr(t2.`code`, '" + condition.get("goodsCode") + "') > 0")
|
|
|
- .apply(Func.isNotEmpty(condition.get("goodsName")), "instr(t2.`name`, '" + condition.get("goodsName") + "') > 0")
|
|
|
- .eq("t1", ApplyPurchase::getCreateUser, condition.get("applyUserId"))
|
|
|
- .ge("t1", ApplyPurchase::getCreateTime, condition.get("startTime"))
|
|
|
- .le("t1", ApplyPurchase::getCreateTime, condition.get("endTime"))
|
|
|
- .and(Func.isNotEmpty(condition.get("keyword")), o -> o.apply("instr(t1.`code`, '" + condition.get("keyword") + "') > 0").or().apply("instr(t2.`code`, '" + condition.get("keyword") + "') > 0").or().apply("instr(t2.`name`, '" + condition.get("keyword") + "') > 0"))
|
|
|
- .orderByDesc("t1", ApplyPurchase::getCreateTime);
|
|
|
+ wrapper.eq("t1", ApplyPurchase::getReceiptWarehouseId, condition.get("warehouseId")).eq("t1", ApplyPurchase::getStatus).apply(Func.isNotEmpty(condition.get("code")), "instr(t1.`code`, '" + condition.get("code") + "') > 0").apply(Func.isNotEmpty(condition.get("goodsCode")), "instr(t2.`code`, '" + condition.get("goodsCode") + "') > 0").apply(Func.isNotEmpty(condition.get("goodsName")), "instr(t2.`name`, '" + condition.get("goodsName") + "') > 0").eq("t1", ApplyPurchase::getCreateUser, condition.get("applyUserId")).ge("t1", ApplyPurchase::getCreateTime, condition.get("startTime")).le("t1", ApplyPurchase::getCreateTime, condition.get("endTime")).and(Func.isNotEmpty(condition.get("keyword")), o -> o.apply("instr(t1.`code`, '" + condition.get("keyword") + "') > 0").or().apply("instr(t2.`code`, '" + condition.get("keyword") + "') > 0").or().apply("instr(t2.`name`, '" + condition.get("keyword") + "') > 0")).orderByDesc("t1", ApplyPurchase::getCreateTime);
|
|
|
|
|
|
Page<ApplyPurchase> page = baseMapper.getPage(createPage(condition), wrapper);
|
|
|
if (Func.isNotEmpty(page.getRecords())) {
|
|
@@ -67,31 +60,24 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
|
|
|
|
|
|
@Override
|
|
|
public void add(List<ApplyPurchase> list) {
|
|
|
- if (
|
|
|
- !redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
|
|
|
- //获取编码
|
|
|
- String code = CodeEnum.APPLY_PURCHASE.getCode();
|
|
|
- //查询编码是否已存在
|
|
|
- if (!checkCodeIsExist(null, code)) {
|
|
|
- throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + code);
|
|
|
- }
|
|
|
- list.forEach(item -> {
|
|
|
- item.setCode(code);
|
|
|
- });
|
|
|
- saveBatch(list);
|
|
|
- return true;
|
|
|
- })
|
|
|
- ) {
|
|
|
+ if (!redisLockClient.lockFair(REDIS_LOCK_CACHE_KEY, () -> {
|
|
|
+ //获取编码
|
|
|
+ String code = CodeEnum.APPLY_PURCHASE.getCode();
|
|
|
+ //查询编码是否已存在
|
|
|
+ if (!checkCodeIsExist(null, code)) {
|
|
|
+ throw new ServiceException("后台自增编码存在重复,请重试或联系管理员!编码:" + code);
|
|
|
+ }
|
|
|
+ list.forEach(item -> item.setCode(code));
|
|
|
+ saveBatch(list);
|
|
|
+ return true;
|
|
|
+ })) {
|
|
|
throw new ServiceException("当前系统繁忙,请稍后重试!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private Boolean checkCodeIsExist(Long id, String code) {
|
|
|
List<ApplyPurchase> list = lambdaQuery().ne(Func.isNotEmpty(id), ApplyPurchase::getId, id).eq(ApplyPurchase::getCode, code).list();
|
|
|
- if (Func.isNotEmpty(list)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
+ return !Func.isNotEmpty(list);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -111,10 +97,21 @@ public class ApplyPurchaseServiceImpl extends ServiceImpl<ApplyPurchaseMapper, A
|
|
|
public Page<Map<String, Object>> applyInPage(Condition condition) {
|
|
|
IWrapper<Object> wrapper = IWrapper.getWrapper(condition);
|
|
|
wrapper.func(q -> {
|
|
|
-// condition.getLong("")
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
+ Integer status = condition.getStatus();
|
|
|
+ if (status == null) {
|
|
|
+ q.in("ap", ApplyPurchase::getStatus,
|
|
|
+ ApplyPurchaseStatusEnum.STATUS_30.getKey(),
|
|
|
+ ApplyPurchaseStatusEnum.STATUS_40.getKey(),
|
|
|
+ ApplyPurchaseStatusEnum.STATUS_50.getKey());
|
|
|
+ } else {
|
|
|
+ q.eq("ap", ApplyPurchase::getStatus);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .eq("ap", ApplyPurchase::getReceiptWarehouseId, condition.getLong("warehouseId"))
|
|
|
+ .like("ap", ApplyPurchase::getCode)
|
|
|
+ .like("pi", ProductInfo::getName, condition.getStr("productName"))
|
|
|
+ .eq("ap", ApplyPurchase::getCreateUser)
|
|
|
+ .periodTime("ap", ApplyPurchase::getReceiptTime);
|
|
|
|
|
|
Page<Map<String, Object>> page = baseMapper.applyInPage(createPage(condition), wrapper);
|
|
|
UserClientUtil.setUserName(page.getRecords(), "createUser", "createUserName");
|