|
@@ -1,17 +1,15 @@
|
1
|
1
|
package com.ruoyi.web.controller.oa;
|
2
|
2
|
|
3
|
3
|
import java.math.BigDecimal;
|
4
|
|
-import java.util.Date;
|
5
|
|
-import java.util.List;
|
6
|
|
-import java.util.Objects;
|
|
4
|
+import java.util.*;
|
7
|
5
|
import javax.servlet.http.HttpServletResponse;
|
8
|
6
|
|
9
|
7
|
import com.alibaba.fastjson2.JSONObject;
|
10
|
|
-import com.ruoyi.common.utils.DateUtils;
|
11
|
8
|
import com.ruoyi.oa.domain.*;
|
12
|
9
|
import com.ruoyi.oa.service.ICmcCarService;
|
13
|
10
|
import com.ruoyi.oa.service.ICmcProjectService;
|
14
|
11
|
import com.ruoyi.system.service.ISysUserService;
|
|
12
|
+import org.apache.commons.collections.CollectionUtils;
|
15
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
14
|
import org.springframework.web.bind.annotation.*;
|
17
|
15
|
import com.ruoyi.common.annotation.Log;
|
|
@@ -168,26 +166,20 @@ public class CmcCarApprovalController extends BaseController
|
168
|
166
|
cmcCarApproval.setDispatcher(getLoginUser().getUserId());
|
169
|
167
|
cmcCarApproval.setDispatchComment(formDataJson.getString("dispatchComment"));
|
170
|
168
|
cmcCarApproval.setDispatchTime(new Date());
|
171
|
|
- }
|
172
|
|
- if (formDataJson.getJSONArray("cars").size() > 0 && formDataJson.getJSONArray("drivers").size() > 0) {
|
173
|
|
- cmcCarApproval.setDispatcher(getLoginUser().getUserId());
|
174
|
|
- cmcCarApproval.setKilometers(formDataJson.getString("kilometers"));
|
175
|
169
|
cmcCarApproval.setReturnDate(formDataJson.getDate("returnDate"));
|
|
170
|
+ cmcCarApproval.setKilometers(formDataJson.getString("kilometers"));
|
|
171
|
+ }
|
|
172
|
+ if (formDataJson.getJSONArray("cars").size() > 0) {
|
176
|
173
|
String carString = formDataJson.getString("cars").substring(1, formDataJson.getString("cars").length() - 1);
|
177
|
174
|
cmcCarApproval.setCars(carString);
|
178
|
|
- cmcCarApproval.setDrivers(formDataJson.getString("drivers").substring(1, formDataJson.getString("drivers").length() - 1));
|
179
|
175
|
if (formDataJson.getString("projectId") != null && !formDataJson.getString("projectId").equals("")) {
|
180
|
176
|
CmcProject cmcProject = new CmcProject();
|
181
|
177
|
cmcProject.setProjectId(formDataJson.getString("projectId"));
|
182
|
178
|
CmcProject project = cmcProjectService.selectCmcProjectByProjectId(cmcProject.getProjectId());
|
183
|
|
- if (project.getDrivers() != null && !project.getDrivers().equals(cmcCarApproval.getDrivers()))
|
184
|
|
- project.setDrivers(project.getDrivers() + "," + cmcCarApproval.getDrivers());
|
185
|
|
- if (project.getDrivers() == null)
|
186
|
|
- project.setDrivers(cmcCarApproval.getDrivers());
|
187
|
|
- if (project.getCars() != null && !project.getCars().equals(carString))
|
188
|
|
- project.setCars(project.getCars() + "," + carString);
|
189
|
|
- if (project.getCars() == null)
|
190
|
|
- project.setCars(carString);
|
|
179
|
+ String[] projectCars = project.getCars().split(",");
|
|
180
|
+ String[] cars = carString.split(",");
|
|
181
|
+ Collection union = CollectionUtils.union(Arrays.asList(projectCars), Arrays.asList(cars));
|
|
182
|
+ project.setCars(String.join(",",union));
|
191
|
183
|
cmcProjectService.updateCmcProject(project);
|
192
|
184
|
}
|
193
|
185
|
String[] cars = carString.split(",");
|
|
@@ -199,6 +191,19 @@ public class CmcCarApprovalController extends BaseController
|
199
|
191
|
}
|
200
|
192
|
cmcCarApproval.setEstimateCost(estimateCost);
|
201
|
193
|
}
|
|
194
|
+ if (formDataJson.getJSONArray("drivers").size() > 0) {
|
|
195
|
+ cmcCarApproval.setDrivers(formDataJson.getString("drivers").substring(1, formDataJson.getString("drivers").length() - 1));
|
|
196
|
+ if (formDataJson.getString("projectId") != null && !formDataJson.getString("projectId").equals("")) {
|
|
197
|
+ CmcProject cmcProject = new CmcProject();
|
|
198
|
+ cmcProject.setProjectId(formDataJson.getString("projectId"));
|
|
199
|
+ CmcProject project = cmcProjectService.selectCmcProjectByProjectId(cmcProject.getProjectId());
|
|
200
|
+ String[] projectDrivers = project.getDrivers().split(",");
|
|
201
|
+ String[] drivers = formDataJson.getString("drivers").substring(1, formDataJson.getString("drivers").length() - 1).split(",");
|
|
202
|
+ Collection union = CollectionUtils.union(Arrays.asList(projectDrivers), Arrays.asList(drivers));
|
|
203
|
+ project.setDrivers(String.join(",",union));
|
|
204
|
+ cmcProjectService.updateCmcProject(project);
|
|
205
|
+ }
|
|
206
|
+ }
|
202
|
207
|
cmcCarApprovalService.updateCmcCarApproval(cmcCarApproval);
|
203
|
208
|
return AjaxResult.success("修改用车审批表成功");
|
204
|
209
|
}
|