package com.ibeetl.admin.console.service; import com.ibeetl.admin.console.dao.XzxOrderBatchInfoDao; import com.ibeetl.admin.core.entity.XzxOrderBatchInfo; import com.ibeetl.admin.core.service.CoreBaseService; import com.ibeetl.admin.core.util.PlatformException; import org.beetl.sql.core.engine.PageQuery; 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.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * XzxOrderBatchInfo Service */ @Service @Transactional public class XzxOrderBatchInfoService extends CoreBaseService { @Autowired private XzxOrderBatchInfoDao xzxOrderBatchInfoDao; public PageQueryqueryByCondition(PageQuery query){ PageQuery ret = xzxOrderBatchInfoDao.queryByCondition(query); queryListAfter(ret.getList()); return ret; } public void batchDelXzxOrderBatchInfo(List ids){ try { xzxOrderBatchInfoDao.batchDelXzxOrderBatchInfoByIds(ids); } catch (Exception e) { throw new PlatformException("批量删除XzxOrderBatchInfo失败", e); } } public Map queryBatchInfoDetailList(String weightError, String startTime,String endTime,String userId,String vehicleId,String page, String limit){ int p = 0; int lm = 10; if(null!=page&&!"".equals(page)){ p = (Integer.parseInt(page) - 1) * Integer.parseInt(limit); } if(null!=limit&&!"".equals(limit)){ lm = Integer.parseInt(limit); } List> data = xzxOrderBatchInfoDao.queryBatchInfoDetailList(weightError, startTime,endTime,userId,vehicleId,p,lm); List> dataTimeWeightList = new ArrayList<>(); for (Map obj:data) { //同一天的空车重量相同,对应打卡空车重量也相同。 String orderId = obj.get("orderId").toString(); if(orderId.equals("0")){ Map map = new HashMap<>(); String time = obj.get("createtime").toString(); String[] dayStr = time.split(" "); String cweight = obj.get("cweight").toString(); map.put("day",dayStr[0]); map.put("clockWeight",cweight); dataTimeWeightList.add(map); obj.put("clockWeight","-"); } } //赋值给载重车的空车重量 for (Map obj:data) { String orderId = obj.get("orderId").toString(); BigDecimal we = new BigDecimal("0"); if(!"0".equals(orderId)){ String time = obj.get("createtime").toString(); String timeStr = time.split(" ")[0]; Map clockObj =xzxOrderBatchInfoDao.queryEmptyWeight(weightError, timeStr+" 00:00:00",timeStr+" 23:59:59",userId,vehicleId); if(null!=clockObj){ obj.put("clockWeight",clockObj.get("cweight").toString()); we = new BigDecimal(obj.get("cweight").toString()).subtract(new BigDecimal(clockObj.get("cweight").toString())); } }else{ we = new BigDecimal(obj.get("cweight").toString()).subtract(new BigDecimal(obj.get("vweight").toString())); } obj.put("weightError",we.toString()); } Map map = new HashMap<>(); map.put("data", data); map.put("count", xzxOrderBatchInfoDao.queryBatchInfoDetailCount(weightError, startTime,endTime,userId,vehicleId)); map.put("code", 0); return map; } public Map queryClockDetailList(String weightError, String startTime,String endTime,String userId,String vehicleId,String page, String limit){ int p = 0; int lm = 10; if(null!=page&&!"".equals(page)){ p = (Integer.parseInt(page) - 1) * Integer.parseInt(limit); } if(null!=limit&&!"".equals(limit)){ lm = Integer.parseInt(limit); } List> data = xzxOrderBatchInfoDao.queryClockDetailList(weightError, startTime,endTime,userId,vehicleId,p,lm); for (Map obj:data) { obj.put("clockWeight","-"); BigDecimal we = new BigDecimal("0"); we = new BigDecimal(obj.get("cweight").toString()).subtract(new BigDecimal(obj.get("vweight").toString())); obj.put("weightError",we.toString()); } Map map = new HashMap<>(); map.put("data", data); map.put("count", xzxOrderBatchInfoDao.queryClockDetailCount(weightError, startTime,endTime,userId,vehicleId)); map.put("code", 0); return map; } public Map queryBatchDetailList(String weightError, String startTime,String endTime,String userId,String vehicleId,String page, String limit){ int p = 0; int lm = 10; if(null!=page&&!"".equals(page)){ p = (Integer.parseInt(page) - 1) * Integer.parseInt(limit); } if(null!=limit&&!"".equals(limit)){ lm = Integer.parseInt(limit); } List> data = xzxOrderBatchInfoDao.queryBatchDetailList(weightError, startTime,endTime,userId,vehicleId,p,lm); for (Map obj:data) { //计算当天打卡空车重量 String time = obj.get("createtime").toString(); String timeStr = time.split(" ")[0]; Map clockObj =xzxOrderBatchInfoDao.queryEmptyWeight(weightError, timeStr+" 00:00:00",timeStr+" 23:59:59",userId,vehicleId); if(null!=clockObj){ obj.put("clockWeight",clockObj.get("cweight").toString()); BigDecimal we = new BigDecimal("0"); we = new BigDecimal(obj.get("bweight").toString()).subtract(new BigDecimal(clockObj.get("cweight").toString())); obj.put("weightError",we.toString()); } } Map map = new HashMap<>(); map.put("data", data); map.put("count", xzxOrderBatchInfoDao.queryBatchDetailCount(weightError, startTime,endTime,userId,vehicleId)); map.put("code", 0); return map; } }