123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.mapper.OffSiteTransportationMapper;
- import com.steerinfo.dil.mapper.TmstruckAbnormalResultMapper;
- import com.steerinfo.dil.mapper.TmstruckInTransitWarnMapper;
- import com.steerinfo.dil.model.TmstruckAbnormalResult;
- import com.steerinfo.dil.model.TmstruckInTransitWarn;
- import com.steerinfo.dil.model.TmstruckReceiptResult;
- import com.steerinfo.dil.service.ITmstruckReceiptResultService;
- import com.steerinfo.dil.service.OffSiteTransportationService;
- import com.steerinfo.framework.controller.RESTfulResult;
- import com.steerinfo.route.mapper.TmstruckArrivalResultMapper;
- import com.steerinfo.route.model.TmstruckReceiptResultChild;
- import com.steerinfo.route.service.ITmstruckReceiptResultChildService;
- import com.steerinfo.route.service.impl.RouteServiceImpl;
- import com.steerinfo.route.vo.Map.RouteVo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.web.bind.annotation.RequestBody;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.CompletableFuture;
- @Service
- public class OffSiteTransportationServiceImpl implements OffSiteTransportationService {
- @Autowired
- private RouteServiceImpl routeService;
- @Autowired
- OffSiteTransportationMapper offSiteTransportationMapper;
- @Autowired
- private TmstruckArrivalResultMapper tmstruckArrivalResultMapper;
- @Autowired
- private ITmstruckReceiptResultService tmstruckReceiptResultService;
- @Autowired
- private ITmstruckReceiptResultChildService tmstruckReceiptResultChildService;
- @Autowired
- private TmstruckInTransitWarnMapper tmstruckInTransitWarnMapper;
- @Autowired
- private TmstruckAbnormalResultMapper tmstruckAbnormalResultMapper;
- @Override
- public List<Map<String, Object>> getInTransitTransportation(Map<String, Object> mapValue) {
- return offSiteTransportationMapper.getInTransitTransportation(mapValue);
- }
- @Override
- public Integer getOrderStatus(Map<String, Object> map) {
- String orderNumber = (String) map.get("orderNumber");
- //判断是否已经结束
- Integer statu= offSiteTransportationMapper.getOrderStatu(orderNumber);
- if (statu==null){
- return 1;
- }
- return statu;
- }
- @Override
- public Map<String, Object> getStartAndEndCapacityNumber(Map<String,Object> map) {
- return offSiteTransportationMapper.getStartAndEndCapacityNumber(map);
- }
- @Override
- public void insertOrderMileage(Map<String, Object> map) {
- //获取运输订单号
- String orderNumber = (String) map.get("orderNumber");
- //获取并插入总实绩Id
- BigDecimal truckTotalId = tmstruckArrivalResultMapper.getTotalIdByOrderNumber(orderNumber);
- //获取总距离
- String orderMileage = (String) map.get("orderMileage");
- //将两个属性放到运输订单中
- HashMap<String,Object> omstruckOrder=new HashMap<>();
- omstruckOrder.put("truckTotalId",truckTotalId);
- omstruckOrder.put("orderMileage",orderMileage);
- offSiteTransportationMapper.insertOrderMileage(omstruckOrder);
- }
- @Override
- public void removeDate() {
- List<Map<String,Object>> list= offSiteTransportationMapper.getReceiptData();
- for (Map<String,Object> map:list){
- int i= offSiteTransportationMapper.insertReceive(map);
- }
- }
- public int orderClose(String orderNumber){
- return offSiteTransportationMapper.orderClose(orderNumber);
- }
- @Override
- public Map<String,Object> selectWarnSwitch() {
- return offSiteTransportationMapper.selectWarnSwitch();
- }
- @Override
- public int insertOrderTripId(Map<String, Object> map) {
- //获取运输订单号
- String orderNumber = (String) map.get("orderNumber");
- //获取行程线路id
- String tripId = (String) map.get("rid");
- //将两个属性放到运输订单中
- return offSiteTransportationMapper.insertOrderTripId(map);
- }
- public int addTransportationAlarm(Map<String,Object> map) {
- String label = (String) map.get("label");
- //获取行程id
- String rid = (String) map.get("rid");
- //查询是否已经收货
- BigDecimal orderStatus = offSiteTransportationMapper.selectIsReceiving(rid);
- if (orderStatus!=null){
- if(label.equals("1")&&orderStatus.intValue()==1){
- //获取异常地点
- String abnormalAddress = (String) map.get("adr");
- //获取异常选型
- String abnormalType = (String) map.get("type");
- System.out.println("map.get(time)");
- System.out.println(map);
- System.out.println(map.get("time"));
- //获取异常时间
- String time = map.get("time").toString().length()>13?map.get("time").toString().substring(0,13):map.get("time").toString();
- long lt = new Long(time);
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = new Date(lt);
- //获取异常持续时间
- BigDecimal abnormalDuration1 = null;
- if(map.get("warnTime")!=null){
- Integer abnormalDuration = (Integer) map.get("warnTime");
- abnormalDuration1 = new BigDecimal(abnormalDuration);
- }
- //插入"偏离"、"停车"、"离线"运输报警
- TmstruckAbnormalResult tmstruckAbnormalResult = new TmstruckAbnormalResult();
- tmstruckAbnormalResult.setAbnormalAddress(abnormalAddress);
- tmstruckAbnormalResult.setAbnormalType(new BigDecimal(abnormalType.toString()));
- tmstruckAbnormalResult.setAbnormalTime(date);
- tmstruckAbnormalResult.setAbnormalDuration(abnormalDuration1);
- addTransportationAlarm(tmstruckAbnormalResult,rid);
- }
- }
- return 1;
- }
- @Override
- public List<Map<String, Object>> getHaveAbnormalTruckOrderInfo(Map<String, Object> mapValue) {
- return offSiteTransportationMapper.getHaveAbnormalTruckOrderInfo(mapValue);
- }
- @Override
- public List<Map<String, Object>> getTransportAbnormalInfo(Map<String, Object> mapValue) {
- return offSiteTransportationMapper.getTransportAbnormalInfo(mapValue);
- }
- public synchronized int addTransportationAlarm(TmstruckAbnormalResult tmstruckAbnormalResult,String tripId) {
- long id;
- if(tmstruckAbnormalResultMapper.selectMaxId()==null){
- id = 1;
- }else {
- id = tmstruckAbnormalResultMapper.selectMaxId().longValue()+1;
- }
- //生成主键id
- tmstruckAbnormalResult.setAbnormalId(new BigDecimal(id));
- //获取并插入总实绩Id
- BigDecimal truckTotalId = tmstruckAbnormalResultMapper.getTotalIdByTripId(tripId);
- tmstruckAbnormalResult.setResultTotalId(truckTotalId);
- //常规字段
- tmstruckAbnormalResult.setInsertUsername("admin");
- tmstruckAbnormalResult.setInsertTime(new Date());
- tmstruckAbnormalResult.setUpdateUsername("admin");
- tmstruckAbnormalResult.setUpdateTime(new Date());
- tmstruckAbnormalResult.setInsertUpdateRemark("无");
- return tmstruckAbnormalResultMapper.insert(tmstruckAbnormalResult);
- }
- public String savePath() throws Exception {
- Map<String, Object> parem=offSiteTransportationMapper.getTruckFactoryResult("WYSDD2021091000000002");
- parem.put("turnOf","0");
- return routeService.saveRoute(parem).toString();
- //运输订单号:orderNumber、车牌号:capacityNumber、出厂时间:resultOutGateTime、预警开关:turnOf、发货地址:shipperName、收货地址:receiveAddress
- //初始化请求参数
- // HashMap<String,Object> mapValue=new HashMap<>();
- // mapValue.put("orderNumber","WYSDD2021091000000001");
- // mapValue.put("capacityNumber","豫SB6238");
- // mapValue.put("resultOutGateTime","2021-11-17 14:20:19");
- // mapValue.put("turnOf","0");
- // mapValue.put("shipperName","四川达州钢铁集团有限");
- // mapValue.put("receiveAddress","长沙市");
- // return routeService.saveRoute(parem).toString();
- }
- public Integer addTmstruckReceiptResult(@RequestBody(required = false) Map<String,Object> map){
- BigDecimal alreadyExistsArrivalResult = tmstruckArrivalResultMapper.alreadyExistsArrivalResult((String) map.get("orderNumber"));
- if(alreadyExistsArrivalResult!=null){
- TmstruckReceiptResult tmstruckReceiptResult = new TmstruckReceiptResult();
- //获取运输订单号和收货点地址
- String orderNumber = (String) map.get("orderNumber");
- String resultArrivalAddress = (String) map.get("resultArrivalAddress");
- //获取空货箱照片、已签字的送货单照片
- String resultEmptyContainerPhoto = (String) map.get("url0");
- String resultSignedNotePhoto = (String) map.get("url1");
- tmstruckReceiptResult.setResultArrivalAddress(resultArrivalAddress);
- tmstruckReceiptResult.setResultEmptyContainerPhoto(resultEmptyContainerPhoto);
- tmstruckReceiptResult.setResultSignedNotePhoto(resultSignedNotePhoto);
- if(map.containsKey("url3")){
- //如果有,获取客户签收单照片
- String resultReceiveNotePhoto = (String) map.get("url3");
- tmstruckReceiptResult.setResultReceiveNotePhoto(resultReceiveNotePhoto);
- }
- //新增收货实绩主表
- BigDecimal receiptResultId = tmstruckReceiptResultService.addTmstruckReceiptResult(orderNumber, tmstruckReceiptResult);
- //初始化收货实绩子表信息
- TmstruckReceiptResultChild tmstruckReceiptResultChild = new TmstruckReceiptResultChild();
- //关联收货实绩主表
- tmstruckReceiptResultChild.setReceiptResultId(receiptResultId);
- //如果有,获取最多三张其他照片
- if(map.containsKey("fourFiles")){
- List<String> fourFiles = (List<String>) map.get("fourFiles");
- if(fourFiles.size()==0){}
- else if(fourFiles.size()==1){
- tmstruckReceiptResultChild.setOtherPhoto1(fourFiles.get(0));
- }else if(fourFiles.size()==2){
- tmstruckReceiptResultChild.setOtherPhoto1(fourFiles.get(0));
- tmstruckReceiptResultChild.setOtherPhoto2(fourFiles.get(1));
- }else {
- tmstruckReceiptResultChild.setOtherPhoto1(fourFiles.get(0));
- tmstruckReceiptResultChild.setOtherPhoto2(fourFiles.get(1));
- tmstruckReceiptResultChild.setOtherPhoto3(fourFiles.get(2));
- }
- }
- //新增收货实绩子表
- int i = tmstruckReceiptResultChildService.addTmstruckReceiptResultChild(tmstruckReceiptResultChild);
- return i;
- }else{
- return 4;
- }
- }
- @Override
- public int updateWarnSwitch(String warnSwitch,String radio) {
- // //查询数据库中是否有运输预警数据,有,则修改运输报警信息,无,则新增运输报警信息
- TmstruckInTransitWarn tmstruckInTransitWarn = tmstruckInTransitWarnMapper.selectByPrimaryKey(new BigDecimal(1));
- if(tmstruckInTransitWarn!=null){
- tmstruckInTransitWarn.setWarnSwitch(warnSwitch);
- tmstruckInTransitWarn.setWarnType(radio);
- return tmstruckInTransitWarnMapper.updateByPrimaryKey(tmstruckInTransitWarn);
- }else {
- TmstruckInTransitWarn tmstruckInTransitWarn1 = new TmstruckInTransitWarn();
- tmstruckInTransitWarn1.setWarnId(new BigDecimal(1));
- tmstruckInTransitWarn1.setWarnSwitch(warnSwitch);
- tmstruckInTransitWarn1.setInsertUsername("admin");
- tmstruckInTransitWarn1.setInsertTime(new Date());
- tmstruckInTransitWarn1.setUpdateUsername("admin");
- tmstruckInTransitWarn1.setUpdateTime(new Date());
- tmstruckInTransitWarn1.setInsertUpdateRemark("无");
- tmstruckInTransitWarn1.setWarnType("0");
- return tmstruckInTransitWarnMapper.insertSelective(tmstruckInTransitWarn1);
- }
- }
- }
|