|
@@ -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,81 @@ 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");
|
|
|
+ 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;
|
|
|
+ //查找计时开始时间
|
|
|
+ List<Map<String, Object>> startTimeTaskIdList = tmstruckTimeTaskResultMapper.getStartTimeTask(mapValue);
|
|
|
+ Map<String,Object> map = tmstruckTimeTaskResultMapper.getResultValue(orderNumber);
|
|
|
+ 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");
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }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);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ throw new Exception("暂停时长不支持修改");
|
|
|
+ }
|
|
|
+ TmstruckTimeTaskResult tmstruckTimeTaskResult=new TmstruckTimeTaskResult();
|
|
|
+ tmstruckTimeTaskResult.setTimeTaskResultId(timeTaskResultId);
|
|
|
+ tmstruckTimeTaskResult.setResultTime(resultTimeNew);
|
|
|
+ tmstruckTimeTaskResult.setInsertUpdateRemark("管理员进行修改");
|
|
|
+ tmstruckTimeTaskResult.setUpdateTime(new Date());
|
|
|
+ tmstruckTimeTaskResult.setResultValue(resultValueNew);
|
|
|
+ tmstruckTimeTaskResult.setUpdateUsername("admin");
|
|
|
+ tmstruckTimeTaskResultMapper.updateByPrimaryKeySelective(tmstruckTimeTaskResult);
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
}
|