|
@@ -1,5 +1,6 @@
|
|
|
package com.steerinfo.dil.service.impl;
|
|
|
|
|
|
+import com.alibaba.druid.sql.visitor.functions.If;
|
|
|
import com.steerinfo.dil.feign.AmsFeign;
|
|
|
import com.steerinfo.dil.feign.BmsTruckFeign;
|
|
|
import com.steerinfo.dil.feign.OmsFeign;
|
|
@@ -15,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.xml.crypto.Data;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -479,4 +482,127 @@ public class TmstruckTimeTaskResultServiceImpl implements ITmstruckTimeTaskResul
|
|
|
|
|
|
return i;
|
|
|
}
|
|
|
+
|
|
|
+ //修改计时时长
|
|
|
+ @Transactional(rollbackFor = {Exception.class})
|
|
|
+ @Override
|
|
|
+ public int modifyTimeTaskResult(Map<String, Object> mapValue) throws Exception {
|
|
|
+ String orderNumber =(String) mapValue.get("orderNumber");
|
|
|
+ int i=0;
|
|
|
+ Date resultTimeNew = null;
|
|
|
+ SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String resultTime1 = (String) mapValue.get("resultTime");
|
|
|
+ try {
|
|
|
+ resultTimeNew = simpleDateFormat.parse( resultTime1);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ long resultTime;
|
|
|
+ BigDecimal resultValueNew=null;
|
|
|
+ BigDecimal resultTimeEnd=null;
|
|
|
+ TmstruckTimeTaskResult tmstruckTimeTaskResult=new TmstruckTimeTaskResult();
|
|
|
+ //查找计时开始时间
|
|
|
+ List<Map<String, Object>> startTimeTaskIdList = tmstruckTimeTaskResultMapper.getStartTimeTask(mapValue);
|
|
|
+ Map<String,Object> map = tmstruckTimeTaskResultMapper.getResultValue(orderNumber);
|
|
|
+ BigDecimal orderId =DataChange.dataToBigDecimal(map.get("orderId"));
|
|
|
+ BigDecimal timeTaskResultId = DataChange.dataToBigDecimal(map.get("timeTaskResultId"));
|
|
|
+ BigDecimal resultValue =DataChange.dataToBigDecimal(map.get("resultValue"));
|
|
|
+ if (startTimeTaskIdList.size() != 1) {
|
|
|
+ //根据运输订单查找是否有多条计时开始时间
|
|
|
+ throw new Exception("计时开始超过一条或者没有计时开始时间");
|
|
|
+ } else {
|
|
|
+ Map<String, Object> stringObjectMap = startTimeTaskIdList.get(0);
|
|
|
+ //获取计时总时长的实绩id
|
|
|
+ Date resultTimeOld =(Date)stringObjectMap.get("resultTime");
|
|
|
+ BigDecimal timeTaskResultIdStart = DataChange.dataToBigDecimal(stringObjectMap.get("timeTaskResultId"));
|
|
|
+ if (DataChange.dataToBigDecimal(mapValue.get("resultType")).intValue()==1) {
|
|
|
+ //修改计时开始时间
|
|
|
+ //获取修改之前的计时开始时间,如果修改之前的计时开始时间大于修改之后的修改时间就date(resultTimeOld)-date(resultTimeNew)
|
|
|
+ //resultValue+相差时长
|
|
|
+ if (resultTimeOld.getTime()>resultTimeNew.getTime()) {
|
|
|
+ resultTime = resultTimeOld.getTime() - resultTimeNew.getTime();
|
|
|
+ resultTimeEnd = new BigDecimal(resultTime / (1000 * 60));
|
|
|
+ resultValueNew = resultTimeEnd.add(resultValue);
|
|
|
+ }
|
|
|
+ //获取修改之前的计时开始时间,如果修改之前的计时开始时间大于修改之后的修改时间就date(resultTimeNew)-date(resultTimeOld)
|
|
|
+ //resultValue-相差时长
|
|
|
+ if (resultTimeNew.getTime()>resultTimeOld.getTime()) {
|
|
|
+ resultTime = resultTimeNew.getTime() - resultTimeOld.getTime();
|
|
|
+ resultTimeEnd = new BigDecimal(resultTime / (1000 * 60));
|
|
|
+ resultValueNew = resultValue.subtract(resultTimeEnd);
|
|
|
+ }
|
|
|
+ tmstruckTimeTaskResult.setTimeTaskResultId(timeTaskResultIdStart);
|
|
|
+ tmstruckTimeTaskResult.setResultTime(resultTimeNew);
|
|
|
+ i+= tmstruckTimeTaskResultMapper.updateByPrimaryKeySelective(tmstruckTimeTaskResult);
|
|
|
+ }else if (DataChange.dataToBigDecimal(mapValue.get("resultType")).intValue()==3){
|
|
|
+ //修改计时结束时间
|
|
|
+ //获取修改之后的计时结束时间,如果修改之前的计时结束时间大于修改之后的修改时间就date(resultTimeOld)-date(resultTimeNew)
|
|
|
+ //resultValue-相差时长
|
|
|
+ if (resultTimeOld.getTime()>resultTimeNew.getTime()) {
|
|
|
+ resultTime = resultTimeOld.getTime() - resultTimeNew.getTime();
|
|
|
+ resultTimeEnd = new BigDecimal(resultTime / (1000 * 60));
|
|
|
+ resultValueNew=resultValue.subtract(resultTimeEnd);
|
|
|
+ }
|
|
|
+ //获取修改之后的计时结束时间,如果修改之前的计时结束时间大于修改之后的修改时间就date(resultTimeNew)-date(resultTimeOld)
|
|
|
+ //resultValue+相差时长
|
|
|
+ if (resultTimeNew.getTime()>resultTimeOld.getTime()) {
|
|
|
+ resultTime = resultTimeNew.getTime() - resultTimeOld.getTime();
|
|
|
+ System.out.println(resultTime);
|
|
|
+ resultTimeEnd = new BigDecimal(resultTime / (1000 * 60));
|
|
|
+ //新的计时时长
|
|
|
+ resultValueNew=resultValue.add(resultTimeEnd);
|
|
|
+ }
|
|
|
+ tmstruckTimeTaskResult.setTimeTaskResultId(timeTaskResultIdStart);
|
|
|
+ tmstruckTimeTaskResult.setResultTime(resultTimeNew);
|
|
|
+ i+= tmstruckTimeTaskResultMapper.updateByPrimaryKeySelective(tmstruckTimeTaskResult);
|
|
|
+ }else {
|
|
|
+ throw new Exception("暂停时长不支持修改");
|
|
|
+ }
|
|
|
+ TmstruckTimeTaskResult tmstruckTimeTaskResult1=new TmstruckTimeTaskResult();
|
|
|
+ tmstruckTimeTaskResult1.setTimeTaskResultId(timeTaskResultId);
|
|
|
+ Map<String, Object> requirementInfo = tmstruckTimeTaskResultMapper.getRequirementInfo(orderId);
|
|
|
+ String capacityTypeName =(String) requirementInfo.get("capacityTypeName");
|
|
|
+ if (capacityTypeName.contains("吊车")) {
|
|
|
+ //100吨以下
|
|
|
+ if (resultValueNew==null){
|
|
|
+ throw new Exception("请确认是否修改了计时开始/结束时间");
|
|
|
+ }
|
|
|
+ BigDecimal hours=new BigDecimal(resultValueNew.intValue() / 60);
|
|
|
+ BigDecimal minutes=new BigDecimal(resultValueNew.intValue()%60);
|
|
|
+ int hour = Integer.parseInt(String.valueOf(hours));
|
|
|
+ if (TwoHour.contains(capacityTypeName)) {
|
|
|
+ //判断是否小于2个小时
|
|
|
+ if (hour<2&&hour>0){
|
|
|
+ //设置为两个小时
|
|
|
+ tmstruckTimeTaskResult1.setResultAboutTime(2+"小时");
|
|
|
+ }else {
|
|
|
+ //设置实际作业时长-dateTime3
|
|
|
+ tmstruckTimeTaskResult1.setResultAboutTime(hour+"小时"+minutes+"分钟");
|
|
|
+ }
|
|
|
+ //如果为100吨以上吊车
|
|
|
+ }else if (FourHour.contains(capacityTypeName)){
|
|
|
+ //1、如实际使用时间不足4小时按照(使用时间+4小时)进行最终结算
|
|
|
+ if (hour<0) {
|
|
|
+ tmstruckTimeTaskResult1.setResultAboutTime("4小时");
|
|
|
+ }
|
|
|
+ else if (hour<4&&hour>=0){
|
|
|
+ //计算小时和分钟
|
|
|
+ tmstruckTimeTaskResult1.setResultAboutTime(4+hours.intValue()+"小时"+minutes+"分钟");
|
|
|
+ }else if (hour>=4&&hour<8){
|
|
|
+ //2、如实际使用时间超出4小时加上车辆往返时间4小时超过8小时的按8小时计算
|
|
|
+ tmstruckTimeTaskResult1.setResultAboutTime(8+"小时");
|
|
|
+ }else if (hour>=8){
|
|
|
+ tmstruckTimeTaskResult1.setResultAboutTime(hours+"小时"+minutes+"分钟");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ tmstruckTimeTaskResult1.setInsertUpdateRemark("管理员修改时间");
|
|
|
+ tmstruckTimeTaskResult1.setUpdateTime(new Date());
|
|
|
+ tmstruckTimeTaskResult1.setResultValue(resultValueNew);
|
|
|
+ tmstruckTimeTaskResult1.setUpdateUsername("admin");
|
|
|
+ i+=tmstruckTimeTaskResultMapper.updateByPrimaryKeySelective(tmstruckTimeTaskResult1);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
+ }
|
|
|
}
|