|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
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.water.WaterTransfer;
|
|
@@ -16,7 +17,6 @@ import com.fjhx.service.material.MaterialService;
|
|
|
import com.fjhx.service.water.WaterTransferDetailsService;
|
|
|
import com.fjhx.service.water.WaterTransferService;
|
|
|
import com.fjhx.utils.UserClientUtil;
|
|
|
-import com.fjhx.utils.WrapperUtil;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -43,23 +43,6 @@ public class WaterTransferServiceImpl extends ServiceImpl<WaterTransferMapper, W
|
|
|
@Autowired
|
|
|
private MaterialService materialService;
|
|
|
|
|
|
- @Override
|
|
|
- public Page<WaterTransfer> getPage(Map<String, String> condition) {
|
|
|
-
|
|
|
- QueryWrapper<WaterTransfer> wrapper = Wrappers.query();
|
|
|
-
|
|
|
- WrapperUtil.init(condition, wrapper)
|
|
|
- .createTimeDesc();
|
|
|
-
|
|
|
- Page<WaterTransfer> page = page(condition, wrapper);
|
|
|
- return page;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void edit(WaterTransferVo waterTransferVo) {
|
|
|
- updateById(waterTransferVo);
|
|
|
- }
|
|
|
-
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void add(List<WaterTransferVo> waterTransferVoList) {
|
|
@@ -168,4 +151,49 @@ public class WaterTransferServiceImpl extends ServiceImpl<WaterTransferMapper, W
|
|
|
.notIn(StorageBaseEntity::getId, waterTransferDetailsIdList));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> statistics(Condition condition) {
|
|
|
+ QueryWrapper<Object> wrapper = getWrapper(condition);
|
|
|
+
|
|
|
+ return baseMapper.getStatistics(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Map<String, Object>> getPage(Condition condition) {
|
|
|
+ QueryWrapper<Object> wrapper = getWrapper(condition);
|
|
|
+ Page<Map<String, Object>> page = baseMapper.getPage(condition.getPage(), wrapper);
|
|
|
+ List<Map<String, Object>> records = page.getRecords();
|
|
|
+ if (records.size() == 0) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> userIdSet = new HashSet<>();
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ userIdSet.add(Convert.toLong(record.get("createUser")));
|
|
|
+ userIdSet.add(Convert.toLong(record.get("receiveId")));
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(userIdSet);
|
|
|
+
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ record.put("createUserName", userNameMap.get(Convert.toLong(record.get("createUser"))));
|
|
|
+ record.put("receiveUserName", userNameMap.get(Convert.toLong(record.get("receiveId"))));
|
|
|
+ }
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ private QueryWrapper<Object> getWrapper(Condition condition) {
|
|
|
+ QueryWrapper<Object> wrapper = Wrappers.query();
|
|
|
+
|
|
|
+ Date beginTime = condition.getBeginTime();
|
|
|
+ Date endTime = condition.getEndTime();
|
|
|
+ Long userId = condition.getUserId();
|
|
|
+
|
|
|
+ return wrapper
|
|
|
+ .eq("wtd.del_flag", StatusConstant.NOT_DELETED)
|
|
|
+ .and(ObjectUtil.isNotEmpty(userId), q -> q.eq("wtd.create_user", userId).or().eq("wtd.receive_id", userId))
|
|
|
+ .between(ObjectUtil.isAllNotEmpty(beginTime, endTime), "wtd.create_time", beginTime, endTime);
|
|
|
+ }
|
|
|
+
|
|
|
}
|