From 9328e1b87ef53c7210a7d8342d8af8800c91809e Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 27 十一月 2024 10:52:00 +0800
Subject: [PATCH] 开发更新
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java | 148 +++++++++++++++++++++++++++++++++---------------
1 files changed, 101 insertions(+), 47 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java
index 9b12603..54dea5a 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwPatrolLineServiceImpl.java
@@ -1,20 +1,30 @@
package com.doumee.service.business.impl;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
+import com.doumee.dao.business.YwLinePointMapper;
import com.doumee.dao.business.YwPatrolLineMapper;
-import com.doumee.dao.business.model.YwPatrolLine;
+import com.doumee.dao.business.model.*;
import com.doumee.service.business.YwPatrolLineService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
+import java.util.Date;
import java.util.List;
+import java.util.Objects;
/**
* 杩愮淮宸℃璺嚎淇℃伅琛⊿ervice瀹炵幇
@@ -27,14 +37,45 @@
@Autowired
private YwPatrolLineMapper ywPatrolLineMapper;
+ @Autowired
+ private YwLinePointMapper ywLinePointMapper;
+
@Override
+ @Transactional(rollbackFor = {Exception.class,BusinessException.class})
public Integer create(YwPatrolLine ywPatrolLine) {
+ if(Objects.isNull(ywPatrolLine)
+ || StringUtils.isBlank(ywPatrolLine.getName())
+ || com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywPatrolLine.getLinePointList())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+
+ LoginUserInfo loginUserInfo = ywPatrolLine.getLoginUserInfo();
+ ywPatrolLine.setCreateDate(new Date());
+ ywPatrolLine.setCreator(loginUserInfo.getId());
+ ywPatrolLine.setIsdeleted(Constants.ZERO);
+ ywPatrolLine.setStatus(Constants.ZERO);
ywPatrolLineMapper.insert(ywPatrolLine);
+ //寰幆澶勭悊 瀛愰泦鏁版嵁
+
+ List<YwLinePoint> ywLinePointList = ywPatrolLine.getLinePointList();
+ for (YwLinePoint ywLinePoint:ywLinePointList) {
+ if(Objects.isNull(ywLinePoint)
+ || Objects.isNull(ywLinePoint.getPointId())
+ || Objects.isNull(ywLinePoint.getNeedScancode())
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"宸℃鐐归厤缃敊璇�");
+ }
+ ywLinePoint.setCreateDate(new Date());
+ ywLinePoint.setCreator(loginUserInfo.getId());
+ ywLinePoint.setIsdeleted(Constants.ZERO);
+ ywLinePoint.setLineId(ywPatrolLine.getId());
+ }
+ ywLinePointMapper.insert(ywLinePointList);
return ywPatrolLine.getId();
}
@Override
- public void deleteById(Integer id) {
+ public void deleteById(Integer id, LoginUserInfo user) {
ywPatrolLineMapper.deleteById(id);
}
@@ -45,7 +86,7 @@
}
@Override
- public void deleteByIdInBatch(List<Integer> ids) {
+ public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
@@ -54,7 +95,34 @@
@Override
public void updateById(YwPatrolLine ywPatrolLine) {
+ if(Objects.isNull(ywPatrolLine)
+ || StringUtils.isBlank(ywPatrolLine.getName())
+ || com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywPatrolLine.getLinePointList())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+
+ LoginUserInfo loginUserInfo = ywPatrolLine.getLoginUserInfo();
+ ywPatrolLine.setEditDate(new Date());
+ ywPatrolLine.setEditor(loginUserInfo.getId());
ywPatrolLineMapper.updateById(ywPatrolLine);
+ //鍒犻櫎瀛愭暟鎹�
+ ywLinePointMapper.delete(new QueryWrapper<YwLinePoint>().lambda()
+ .eq(YwLinePoint::getLineId,ywPatrolLine.getId()));
+ //寰幆澶勭悊 瀛愰泦鏁版嵁
+ List<YwLinePoint> ywLinePointList = ywPatrolLine.getLinePointList();
+ for (YwLinePoint ywLinePoint:ywLinePointList) {
+ if(Objects.isNull(ywLinePoint)
+ || Objects.isNull(ywLinePoint.getPointId())
+ || Objects.isNull(ywLinePoint.getNeedScancode())
+ ){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"宸℃鐐归厤缃敊璇�");
+ }
+ ywLinePoint.setLineId(ywPatrolLine.getId());
+ ywLinePoint.setCreateDate(new Date());
+ ywLinePoint.setCreator(loginUserInfo.getId());
+ ywLinePoint.setIsdeleted(Constants.ZERO);
+ }
+ ywLinePointMapper.insert(ywLinePointList);
}
@Override
@@ -72,6 +140,26 @@
return ywPatrolLineMapper.selectById(id);
}
+
+ @Override
+ public YwPatrolLine getDetail(Integer id) {
+ YwPatrolLine ywPatrolLine = ywPatrolLineMapper.selectById(id);
+
+ List<YwLinePoint> ywLinePointList = ywLinePointMapper.selectJoinList(YwLinePoint.class,new MPJLambdaWrapper<YwLinePoint>()
+ .selectAll(YwLinePoint.class)
+ .selectAs(YwPatrolPoint::getName,YwLinePoint::getPointName)
+ .selectAs(YwPatrolPoint::getCode,YwLinePoint::getCode)
+ .leftJoin(YwPatrolPoint.class,YwPatrolPoint::getId,YwLinePoint::getPointId)
+ .eq(YwLinePoint::getLineId,id)
+ .orderByAsc(YwLinePoint::getSortnum)
+ );
+
+ ywPatrolLine.setLinePointList(ywLinePointList);
+
+ return ywPatrolLine;
+ }
+
+
@Override
public YwPatrolLine findOne(YwPatrolLine ywPatrolLine) {
QueryWrapper<YwPatrolLine> wrapper = new QueryWrapper<>(ywPatrolLine);
@@ -87,51 +175,17 @@
@Override
public PageData<YwPatrolLine> findPage(PageWrap<YwPatrolLine> pageWrap) {
IPage<YwPatrolLine> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
- QueryWrapper<YwPatrolLine> queryWrapper = new QueryWrapper<>();
+ MPJLambdaWrapper<YwPatrolLine> queryWrapper = new MPJLambdaWrapper<YwPatrolLine>();
Utils.MP.blankToNull(pageWrap.getModel());
- if (pageWrap.getModel().getId() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getId, pageWrap.getModel().getId());
- }
- if (pageWrap.getModel().getCreator() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getCreator, pageWrap.getModel().getCreator());
- }
- if (pageWrap.getModel().getCreateDate() != null) {
- queryWrapper.lambda().ge(YwPatrolLine::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate()));
- queryWrapper.lambda().le(YwPatrolLine::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate()));
- }
- if (pageWrap.getModel().getEditor() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getEditor, pageWrap.getModel().getEditor());
- }
- if (pageWrap.getModel().getEditDate() != null) {
- queryWrapper.lambda().ge(YwPatrolLine::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate()));
- queryWrapper.lambda().le(YwPatrolLine::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate()));
- }
- if (pageWrap.getModel().getIsdeleted() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getIsdeleted, pageWrap.getModel().getIsdeleted());
- }
- if (pageWrap.getModel().getName() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getName, pageWrap.getModel().getName());
- }
- if (pageWrap.getModel().getRemark() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getRemark, pageWrap.getModel().getRemark());
- }
- if (pageWrap.getModel().getStatus() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getStatus, pageWrap.getModel().getStatus());
- }
- if (pageWrap.getModel().getSortnum() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getSortnum, pageWrap.getModel().getSortnum());
- }
- if (pageWrap.getModel().getImgurl() != null) {
- queryWrapper.lambda().eq(YwPatrolLine::getImgurl, pageWrap.getModel().getImgurl());
- }
- for(PageWrap.SortData sortData: pageWrap.getSorts()) {
- if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
- queryWrapper.orderByDesc(sortData.getProperty());
- } else {
- queryWrapper.orderByAsc(sortData.getProperty());
- }
- }
- return PageData.from(ywPatrolLineMapper.selectPage(page, queryWrapper));
+ YwPatrolLine model = pageWrap.getModel();
+ queryWrapper.selectAll(YwPatrolLine.class)
+ .select(" ( select count(1) from yw_line_point y where y.LINE_ID = t.id ) as lineAmount ")
+ .like(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getName()),YwPatrolLine::getName,model.getName())
+ .eq(YwPatrolLine::getIsdeleted,Constants.ZERO)
+ .orderByDesc(YwPatrolLine::getCreateDate)
+ ;
+ IPage iPage = ywPatrolLineMapper.selectJoinPage(page,YwPatrolLine.class,queryWrapper);
+ return PageData.from(iPage);
}
@Override
--
Gitblit v1.9.3