|
@@ -2,21 +2,29 @@ package com.fjhx.service.water.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+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.material.Material;
|
|
|
import com.fjhx.entity.water.WaterBack;
|
|
|
import com.fjhx.entity.water.WaterBackDetails;
|
|
|
+import com.fjhx.feign.IUserClient;
|
|
|
import com.fjhx.mapper.water.WaterBackMapper;
|
|
|
import com.fjhx.params.water.WaterBackAddVo;
|
|
|
import com.fjhx.params.water.WaterBackVo;
|
|
|
import com.fjhx.service.material.MaterialService;
|
|
|
import com.fjhx.service.water.WaterBackDetailsService;
|
|
|
import com.fjhx.service.water.WaterBackService;
|
|
|
+import com.fjhx.utils.Assert;
|
|
|
import com.fjhx.utils.UserClientUtil;
|
|
|
+import org.springblade.core.mp.base.BaseEntity;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -42,6 +50,9 @@ public class WaterBackServiceImpl extends ServiceImpl<WaterBackMapper, WaterBack
|
|
|
@Autowired
|
|
|
private MaterialService materialService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserClient userClient;
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void add(List<WaterBackAddVo> waterBackAddVoList) {
|
|
@@ -79,7 +90,7 @@ public class WaterBackServiceImpl extends ServiceImpl<WaterBackMapper, WaterBack
|
|
|
List<Map<String, Object>> list = listMaps(Wrappers.<WaterBack>lambdaQuery()
|
|
|
.eq(WaterBack::getStatus, StatusConstant.NO));
|
|
|
|
|
|
- Map<Long, String> userNameMap = UserClientUtil.getUserNameMapFunctionLong(list,
|
|
|
+ Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(list,
|
|
|
item -> Convert.toLong(item.get("createUser")));
|
|
|
|
|
|
for (Map<String, Object> map : list) {
|
|
@@ -163,4 +174,88 @@ public class WaterBackServiceImpl extends ServiceImpl<WaterBackMapper, WaterBack
|
|
|
.notIn(StorageBaseEntity::getId, waterBackIdList));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getUserByAppointDept() {
|
|
|
+
|
|
|
+ List<Long> list = Arrays.asList(1552549406245404674L, 1552549638060392449L, 1552549107359301633L);
|
|
|
+ R<List<User>> userListByDeptIdListR = userClient.getUserListByDeptIdList(list);
|
|
|
+ List<User> userList = Assert.result(userListByDeptIdListR);
|
|
|
+
|
|
|
+ Map<Integer, Map<String, Object>> collect = userList.stream().collect(Collectors.toMap(
|
|
|
+ item -> 1,
|
|
|
+ item -> {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (item.getDeptId().contains("1552549406245404674")) {
|
|
|
+ map.put("deptId", 1552549406245404674L);
|
|
|
+ map.put("deptName", "直喷");
|
|
|
+ } else if (item.getDeptId().contains("1552549638060392449")) {
|
|
|
+ map.put("deptId", 1552549638060392449L);
|
|
|
+ map.put("deptName", "打纸");
|
|
|
+ } else {
|
|
|
+ map.put("deptId", 1552549107359301633L);
|
|
|
+ map.put("deptName", "热转");
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("list", Collections.singletonList(item));
|
|
|
+ return map;
|
|
|
+ },
|
|
|
+ (v1, v2) -> {
|
|
|
+ List<User> v1List = new ArrayList<>((List<User>) v1.get("list"));
|
|
|
+ List<User> v2List = new ArrayList<>((List<User>) v2.get("list"));
|
|
|
+ v1List.addAll(v2List);
|
|
|
+ v1.put("list", v1List);
|
|
|
+ return v1;
|
|
|
+ }
|
|
|
+ ));
|
|
|
+
|
|
|
+ return collect.get(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Long> getUserIdByAppointDept() {
|
|
|
+ List<Long> list = Arrays.asList(1552549406245404674L, 1552549638060392449L, 1552549107359301633L);
|
|
|
+ R<List<User>> userListByDeptIdListR = userClient.getUserListByDeptIdList(list);
|
|
|
+ List<User> userList = Assert.result(userListByDeptIdListR);
|
|
|
+
|
|
|
+ return userList.stream().map(BaseEntity::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ @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;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, String> userNameMap = UserClientUtil.getUserNameMap(records, item -> item.get("createUser"));
|
|
|
+ for (Map<String, Object> record : records) {
|
|
|
+ record.put("createUserName", userNameMap.get(Convert.toLong(record.get("createUser"))));
|
|
|
+ }
|
|
|
+
|
|
|
+ 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("wbd.del_flag", StatusConstant.NOT_DELETED)
|
|
|
+ .eq(ObjectUtil.isNotEmpty(userId), "wb.create_user", userId)
|
|
|
+ .between(ObjectUtil.isAllNotEmpty(beginTime, endTime), "wb.create_time", beginTime, endTime);
|
|
|
+ }
|
|
|
+
|
|
|
}
|