fix
Helius
2021-08-09 35bfed834faee8b04988e9f202a0f5c79b13b405
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.xzx.gc.order.service;
 
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xzx.gc.common.constant.CommonEnum;
import com.xzx.gc.entity.OrderClockIn;
import com.xzx.gc.entity.OtherUserInfo;
import com.xzx.gc.model.admin.BatchInfoResModel;
import com.xzx.gc.model.system.ConfigInfoReq;
import com.xzx.gc.model.system.ConfigInfoVo;
import com.xzx.gc.order.mapper.OrderClockInMapper;
import com.xzx.gc.order.mapper.OtherUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.math.BigDecimal;
import java.util.*;
 
@Service
@Transactional
@Slf4j
public class OrderClockInService {
 
    @Autowired
    private OrderClockInMapper orderClockInMapper;
 
 
    @Autowired
    private OtherUserService otherUserService;
 
 
    @Autowired
    private CityPartnerService cityPartnerService;
 
    @Autowired
    private ConfigService configService;
 
 
 
    /**
     *  //特殊回收员可以进行扫码入库操作
     * @param userId
     * @return
     */
    public boolean notClock(String userId){
 
        ConfigInfoReq configInfoReq2=new ConfigInfoReq();
        configInfoReq2.setConfigTypeCode("NOT_CODE_SCAN_PERSON");
        List<ConfigInfoVo> configInfoVos2 = configService.configInfoQuery(configInfoReq2);
        if(CollUtil.isNotEmpty(configInfoVos2)) {
            String configValue2 = configInfoVos2.get(0).getConfigValue();
            String[] split = configValue2.split(",");
            String userIds="";
            for (String s : split) {
                if(StrUtil.isNotBlank(s)) {
                    OtherUserInfo otherUserInfo1 = otherUserService.findByMobileAndUserType(s,CommonEnum.回收员.getValue());
                    if (otherUserInfo1 != null) {
                        userIds = userIds + "," + otherUserInfo1.getUserId();
                    }
                }
            }
 
            if(StrUtil.isNotBlank(userIds)){
                String s = StrUtil.removePrefix(userIds, ",");
                List<String> strings = Arrays.asList(s.split(","));
                if(strings.contains(userId)){
                    return true;
                }
            }
        }
        return false;
    }
 
 
    public Map<String, Object> queryByConditionList(String name, String weightError, String startTime, String endTime, String page, String limit) {
        List<String> partnerIds = cityPartnerService.queryPartnerByCurrent();
        List<BatchInfoResModel> modelList = new ArrayList<>();
        if(null!=startTime&&!"".equals(startTime)){
            startTime = startTime+" 00:00:00";
        }
        if(null!=endTime&&!"".equals(endTime)){
            endTime = endTime+" 23:59:59";
        }
        page=StrUtil.isBlank(page)?"0":page;
        limit=StrUtil.isBlank(page)?"0":limit;
        PageHelper.startPage(Convert.toInt(page),Convert.toInt(limit));
        List<Map<String, Object>> maps = orderClockInMapper.queryByConditionList(name,weightError, startTime,endTime,partnerIds);
        //后台计算重量误差
        for (Map<String, Object> map:maps) {
            BatchInfoResModel resModel = new BatchInfoResModel();
            BigDecimal weight = new BigDecimal(map.get("weight").toString());
            BigDecimal vehicleweight = new BigDecimal(map.get("vehicleWeight").toString());
            BigDecimal weightErrorDemo = weight.subtract(vehicleweight);
            map.put("weightError",weightErrorDemo.toString());
            resModel.setDelFlag(map.get("delFlag").toString());
            BatchInfoResModel entity = JSON.parseObject(JSON.toJSONString(map), BatchInfoResModel.class);
            modelList.add(entity);
        }
        Map<String, Object> map = new HashMap<>();
        PageInfo<Map<String,Object>> pageInfo=new PageInfo(maps);
        map.put("data", modelList);
        map.put("count", pageInfo.getTotal());
        map.put("code", 0);
        return map;
    }
 
 
}