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;
|
}
|
|
|
}
|