|
|
@@ -1,11 +1,13 @@
|
|
|
package com.jpsoft.employment.modules.base.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.employment.modules.base.dto.WorkOrderAllDataDTO;
|
|
|
+import com.jpsoft.employment.modules.base.entity.*;
|
|
|
+import com.jpsoft.employment.modules.base.service.*;
|
|
|
import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
-import com.jpsoft.employment.modules.base.entity.WorkOrder;
|
|
|
-import com.jpsoft.employment.modules.base.service.WorkOrderService;
|
|
|
+import com.jpsoft.employment.modules.sys.service.DataDictionaryService;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -24,11 +26,31 @@ public class WorkOrderController {
|
|
|
|
|
|
@Autowired
|
|
|
private WorkOrderService workOrderService;
|
|
|
-
|
|
|
-
|
|
|
- @ApiOperation(value="创建空记录")
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InstallationRequirementService installationRequirementService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ReceiveRequireService receiveRequireService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CommentInfoService commentInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CustomerInfoService customerInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TechnicianInfoService technicianInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ConstructionProgressService constructionProgressService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "创建空记录")
|
|
|
@GetMapping("create")
|
|
|
- public MessageResult<WorkOrder> create(){
|
|
|
+ public MessageResult<WorkOrder> create() {
|
|
|
MessageResult<WorkOrder> msgResult = new MessageResult<>();
|
|
|
|
|
|
WorkOrder workOrder = new WorkOrder();
|
|
|
@@ -39,14 +61,14 @@ public class WorkOrderController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="添加信息")
|
|
|
+ @ApiOperation(value = "添加信息")
|
|
|
@PostMapping("add")
|
|
|
- public MessageResult<WorkOrder> add(@RequestBody WorkOrder workOrder,@RequestAttribute String subject){
|
|
|
+ public MessageResult<WorkOrder> add(@RequestBody WorkOrder workOrder, @RequestAttribute String subject) {
|
|
|
MessageResult<WorkOrder> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
workOrder.setId(UUID.randomUUID().toString());
|
|
|
- workOrder.setDelFlag(false);
|
|
|
+ workOrder.setDelFlag(false);
|
|
|
workOrder.setCreateBy(subject);
|
|
|
workOrder.setCreateTime(new Date());
|
|
|
|
|
|
@@ -59,9 +81,8 @@ public class WorkOrderController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库添加失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -70,24 +91,93 @@ public class WorkOrderController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="获取信息")
|
|
|
+ @ApiOperation(value = "获取信息")
|
|
|
@GetMapping("edit/{id}")
|
|
|
- public MessageResult<WorkOrder> edit(@PathVariable("id") String id){
|
|
|
- MessageResult<WorkOrder> msgResult = new MessageResult<>();
|
|
|
+ public MessageResult<WorkOrderAllDataDTO> edit(@PathVariable("id") String id) {
|
|
|
+ MessageResult<WorkOrderAllDataDTO> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
+ WorkOrderAllDataDTO dto = new WorkOrderAllDataDTO();
|
|
|
WorkOrder workOrder = workOrderService.get(id);
|
|
|
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+
|
|
|
if (workOrder != null) {
|
|
|
+
|
|
|
+ InstallationRequirement installationRequirement = installationRequirementService.findByWorkOrderId(workOrder.getId());
|
|
|
+ dto.setInstallationRequirement(installationRequirement);
|
|
|
+
|
|
|
+ ReceiveRequire receiveRequire = receiveRequireService.findByWorkOrderId(id);
|
|
|
+ dto.setReceiveRequire(receiveRequire);
|
|
|
+
|
|
|
+ dto.setCustomerName(workOrder.getCustomerName());
|
|
|
+ dto.setCustomerPhone(workOrder.getCustomerPhone());
|
|
|
+
|
|
|
+ List<String> imageList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(workOrder.getImage())) {
|
|
|
+ String[] imageArr = workOrder.getImage().split(",");
|
|
|
+ imageList = Arrays.asList(imageArr);
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setImageList(imageList);
|
|
|
+
|
|
|
+ dto.setWorkOrder(workOrder);
|
|
|
+
|
|
|
+ TechnicianInfo technicianInfo = technicianInfoService.get(workOrder.getTechnicianId());
|
|
|
+
|
|
|
+ if (technicianInfo != null) {
|
|
|
+ dto.setTechnicianInfo(technicianInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CommentInfo> commentInfoList = commentInfoService.findByWorkOrderId(id);
|
|
|
+
|
|
|
+ for (CommentInfo commentInfo : commentInfoList) {
|
|
|
+ //获取评论人
|
|
|
+ CustomerInfo customerInfo = customerInfoService.get(commentInfo.getCompanyId());
|
|
|
+ if (customerInfo != null) {
|
|
|
+ commentInfo.setCompanyName(customerInfo.getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setCommentInfoList(commentInfoList);
|
|
|
+
|
|
|
+ List<ConstructionProgress> ConstructionProgressList = constructionProgressService.findByWorkOrderId(id);
|
|
|
+
|
|
|
+ for (ConstructionProgress constructionProgress : ConstructionProgressList) {
|
|
|
+ List<String> imageListPro = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotEmpty(constructionProgress.getImage())) {
|
|
|
+ String[] imageArr = constructionProgress.getImage().split(",");
|
|
|
+ imageListPro = Arrays.asList(imageArr);
|
|
|
+ }
|
|
|
+
|
|
|
+ constructionProgress.setImageList(imageListPro);
|
|
|
+
|
|
|
+ if("1".equals(constructionProgress.getSubmitType())){
|
|
|
+ CustomerInfo customerInfo = customerInfoService.get(constructionProgress.getSubmitBy());
|
|
|
+ if(customerInfo!=null){
|
|
|
+ constructionProgress.setSubmitByN(customerInfo.getRealName());
|
|
|
+ }
|
|
|
+ }else if("2".equals(constructionProgress.getSubmitType())){
|
|
|
+ TechnicianInfo technicianInfo1 = technicianInfoService.get(constructionProgress.getSubmitBy());
|
|
|
+ if(technicianInfo1!=null){
|
|
|
+ constructionProgress.setSubmitByN(technicianInfo1.getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ constructionProgress.setSubmitDate(sdf.format(constructionProgress.getSubmitTime()));
|
|
|
+ }
|
|
|
+
|
|
|
+ dto.setConstructionProgressList(ConstructionProgressList);
|
|
|
+
|
|
|
msgResult.setResult(true);
|
|
|
- msgResult.setData(workOrder);
|
|
|
+ msgResult.setData(dto);
|
|
|
} else {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -96,15 +186,15 @@ public class WorkOrderController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="更新用户")
|
|
|
+ @ApiOperation(value = "更新用户")
|
|
|
@PostMapping("update")
|
|
|
- public MessageResult<WorkOrder> update(@RequestBody WorkOrder workOrder,@RequestAttribute String subject){
|
|
|
+ public MessageResult<WorkOrder> update(@RequestBody WorkOrder workOrder, @RequestAttribute String subject) {
|
|
|
MessageResult<WorkOrder> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
- workOrder.setUpdateBy(subject);
|
|
|
+ workOrder.setUpdateBy(subject);
|
|
|
workOrder.setUpdateTime(new Date());
|
|
|
-
|
|
|
+
|
|
|
int affectCount = workOrderService.update(workOrder);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
@@ -114,9 +204,8 @@ public class WorkOrderController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库更新失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -125,19 +214,19 @@ public class WorkOrderController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="删除用户")
|
|
|
+ @ApiOperation(value = "删除用户")
|
|
|
@PostMapping("delete/{id}")
|
|
|
- public MessageResult<WorkOrder> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
+ public MessageResult<WorkOrder> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
MessageResult<WorkOrder> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
-
|
|
|
- WorkOrder workOrder = workOrderService.get(id);
|
|
|
+
|
|
|
+ WorkOrder workOrder = workOrderService.get(id);
|
|
|
workOrder.setDelFlag(true);
|
|
|
workOrder.setUpdateBy(subject);
|
|
|
workOrder.setUpdateTime(new Date());
|
|
|
-
|
|
|
- int affectCount = workOrderService.update(workOrder);
|
|
|
+
|
|
|
+ int affectCount = workOrderService.update(workOrder);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
@@ -145,9 +234,8 @@ public class WorkOrderController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库删除失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -157,9 +245,9 @@ public class WorkOrderController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @ApiOperation(value="批量删除")
|
|
|
+ @ApiOperation(value = "批量删除")
|
|
|
@PostMapping("batchDelete")
|
|
|
- public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
|
|
|
MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
@@ -181,9 +269,8 @@ public class WorkOrderController {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("删除失败");
|
|
|
}
|
|
|
- }
|
|
|
- catch(Exception ex){
|
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage(ex.getMessage());
|
|
|
@@ -192,31 +279,38 @@ public class WorkOrderController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value="列表")
|
|
|
- @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
public MessageResult<Map> pageList(
|
|
|
String id,
|
|
|
- @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
- @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
- HttpServletRequest request){
|
|
|
- String subject = (String)request.getAttribute("subject");
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
|
|
|
//当前用户ID
|
|
|
System.out.println(subject);
|
|
|
|
|
|
MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
|
|
- Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
|
|
|
List<Sort> sortList = new ArrayList<>();
|
|
|
- sortList.add(new Sort("id_","asc"));
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
|
- searchParams.put("id","%" + id + "%");
|
|
|
+ searchParams.put("id", "%" + id + "%");
|
|
|
}
|
|
|
|
|
|
|
|
|
- Page<WorkOrder> page = workOrderService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+ Page<WorkOrder> page = workOrderService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+
|
|
|
+ for (WorkOrder workOrder:page) {
|
|
|
+ CustomerInfo customerInfo = customerInfoService.get(workOrder.getCompanyId());
|
|
|
+ if(customerInfo!=null){
|
|
|
+ workOrder.setCompanyName(customerInfo.getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
msgResult.setResult(true);
|