|
@@ -1,13 +1,31 @@
|
|
package cn.ezhizao.project.business.workOrder.controller;
|
|
package cn.ezhizao.project.business.workOrder.controller;
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.MathContext;
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Calendar;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
+import cn.ezhizao.common.utils.SecurityUtils;
|
|
import cn.ezhizao.common.utils.uuid.SnowflakeIdWorker;
|
|
import cn.ezhizao.common.utils.uuid.SnowflakeIdWorker;
|
|
|
|
+import cn.ezhizao.framework.security.LoginUser;
|
|
|
|
+import cn.ezhizao.project.business.collection.domain.BizCollection;
|
|
|
|
+import cn.ezhizao.project.business.collection.service.impl.BizCollectionServiceImpl;
|
|
import cn.ezhizao.project.business.entrust.domain.BizEntrust;
|
|
import cn.ezhizao.project.business.entrust.domain.BizEntrust;
|
|
import cn.ezhizao.project.business.entrust.service.IBizEntrustService;
|
|
import cn.ezhizao.project.business.entrust.service.IBizEntrustService;
|
|
|
|
+import cn.ezhizao.project.business.order.domain.BizArchiveInput;
|
|
|
|
+import cn.ezhizao.project.business.order.domain.BizArchiveInputDetail;
|
|
|
|
+import cn.ezhizao.project.business.order.domain.BizArchiveInputDetailProcess;
|
|
|
|
+import cn.ezhizao.project.business.order.service.IBizArchiveInputDetailProcessService;
|
|
|
|
+import cn.ezhizao.project.business.order.service.IBizArchiveInputDetailService;
|
|
|
|
+import cn.ezhizao.project.business.order.service.impl.BizArchiveInputServiceImpl;
|
|
|
|
+import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderDetail;
|
|
|
|
+import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderDetailService;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -35,32 +53,42 @@ import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/business/workOrder")
|
|
@RequestMapping("/business/workOrder")
|
|
-public class BizWorkOrderController extends BaseController
|
|
|
|
-{
|
|
|
|
|
|
+public class BizWorkOrderController extends BaseController {
|
|
@Resource
|
|
@Resource
|
|
private IBizWorkOrderService bizWorkOrderService;
|
|
private IBizWorkOrderService bizWorkOrderService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private IBizEntrustService entrustService;
|
|
private IBizEntrustService entrustService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private BizCollectionServiceImpl bizCollectionService;
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private SnowflakeIdWorker snowflakeIdWorker;
|
|
private SnowflakeIdWorker snowflakeIdWorker;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private BizArchiveInputServiceImpl bizArchiveInputService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizArchiveInputDetailService bizArchiveInputDetailService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private IBizWorkOrderDetailService bizWorkOrderDetailService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询工单信息列表
|
|
* 查询工单信息列表
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasAnyPermi('business:workOrder:list,business:workOrder:noContract:list')")
|
|
@PreAuthorize("@ss.hasAnyPermi('business:workOrder:list,business:workOrder:noContract:list')")
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
- public TableDataInfo list(BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
- {
|
|
|
|
|
|
+ public TableDataInfo list(BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
setTenantId(bizWorkOrder);
|
|
setTenantId(bizWorkOrder);
|
|
|
|
|
|
startPage();
|
|
startPage();
|
|
//排序
|
|
//排序
|
|
startOrderBy();
|
|
startOrderBy();
|
|
//根据客户名称模糊查询去除两边空格
|
|
//根据客户名称模糊查询去除两边空格
|
|
- if( bizWorkOrder.getCompanyName()!=null){
|
|
|
|
- if(!bizWorkOrder.getCompanyName().equals(""))
|
|
|
|
|
|
+ if (bizWorkOrder.getCompanyName() != null) {
|
|
|
|
+ if (!bizWorkOrder.getCompanyName().equals(""))
|
|
bizWorkOrder.setCompanyName(bizWorkOrder.getCompanyName().trim());
|
|
bizWorkOrder.setCompanyName(bizWorkOrder.getCompanyName().trim());
|
|
}
|
|
}
|
|
List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
|
|
List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
|
|
@@ -70,17 +98,148 @@ public class BizWorkOrderController extends BaseController
|
|
list.forEach(v -> {
|
|
list.forEach(v -> {
|
|
v.setEntrusts(entrusts.stream().filter(e -> e.getWorkOrderId().equals(v.getId())).collect(Collectors.toList()));
|
|
v.setEntrusts(entrusts.stream().filter(e -> e.getWorkOrderId().equals(v.getId())).collect(Collectors.toList()));
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ //判断是否是合同查询
|
|
|
|
+ if (bizWorkOrder.getNoContract() == 0) {
|
|
|
|
+ for (BizWorkOrder v : list) {
|
|
|
|
+ BizWorkOrderDetail workOrderDetail = new BizWorkOrderDetail();
|
|
|
|
+ workOrderDetail.setWorkOrderId(v.getId());
|
|
|
|
+ //查询工单明细
|
|
|
|
+ List<BizWorkOrderDetail> detailList = bizWorkOrderDetailService.getList(workOrderDetail);
|
|
|
|
+
|
|
|
|
+ //查询合同收款金额
|
|
|
|
+ BizArchiveInput bizArchiveInput = bizArchiveInputService.getById(v.getContractId());
|
|
|
|
+ BigDecimal money=new BigDecimal(0);
|
|
|
|
+ if(bizArchiveInput!=null){
|
|
|
|
+ money = bizArchiveInput.getTrueAmount();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //如果是单次工单
|
|
|
|
+ if (v.getType() == 2) {
|
|
|
|
+ BizCollection collection =new BizCollection();
|
|
|
|
+ collection.setContractId(v.getContractId());
|
|
|
|
+ collection.setStatus(1);
|
|
|
|
+ //查询收款数据
|
|
|
|
+ List<BizCollection> colList =bizCollectionService.getList(collection);
|
|
|
|
+ //已收款金额
|
|
|
|
+ BigDecimal collectionMoney = new BigDecimal(0);
|
|
|
|
+ //计算收款金额
|
|
|
|
+ for (BizCollection d : colList) {
|
|
|
|
+ BigDecimal addMoney = d.getAmount();
|
|
|
|
+ if (addMoney!=null) {
|
|
|
|
+ collectionMoney=collectionMoney.add(addMoney);
|
|
|
|
+ }else{
|
|
|
|
+ addMoney=new BigDecimal(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //判断是否全部收款
|
|
|
|
+ if (collectionMoney.compareTo(money) == 0) {
|
|
|
|
+ v.setOnceContractStatus("已收款");
|
|
|
|
+ } else if (collectionMoney.compareTo(money) < 0) {
|
|
|
|
+ v.setOnceContractStatus("部分收款");
|
|
|
|
+ }else if (collectionMoney.compareTo(new BigDecimal(0)) == 0) {
|
|
|
|
+ v.setOnceContractStatus("未收款");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //如果是循环工单
|
|
|
|
+ if (v.getType() == 1 && detailList.size()>0) {
|
|
|
|
+
|
|
|
|
+ //判断是否有起始月份
|
|
|
|
+ BizArchiveInputDetail detail = new BizArchiveInputDetail();
|
|
|
|
+ detail.setContractId(v.getContractId());
|
|
|
|
+ detail.setTaskTypeId(v.getTaskTypeId());
|
|
|
|
+ detail = bizArchiveInputDetailService.getDetail(detail);
|
|
|
|
+ if (v.getStartMonth() != null) {
|
|
|
|
+ //月数
|
|
|
|
+ Integer monthNum = 0;
|
|
|
|
+ //如果只有一个合同
|
|
|
|
+ if(detailList.size()==1){
|
|
|
|
+ //且收款金额为0
|
|
|
|
+ if(detailList.get(0).getTotalityMoney()==null||detailList.get(0).getTotalityMoney().compareTo(new BigDecimal(0))==0){
|
|
|
|
+ v.setClosingMonth("未收款");
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //根据单价计算月数
|
|
|
|
+ for (BizWorkOrderDetail d : detailList) {
|
|
|
|
+ //如果收款金额大于0
|
|
|
|
+ if (d.getTotalityMoney() != null && d.getTotalityMoney().compareTo(new BigDecimal(0)) > 0) {
|
|
|
|
+ detail.setContractId(d.getContractId());
|
|
|
|
+ detail.setTaskTypeId(d.getTaskTypeId());
|
|
|
|
+ detail = bizArchiveInputDetailService.getDetail(detail);
|
|
|
|
+ BigDecimal price = detail.getPrice();
|
|
|
|
+ monthNum += d.getTotalityMoney().divide(price, MathContext.DECIMAL64).setScale(0, RoundingMode.DOWN).intValue();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //判断收款月数是否等于服务月数
|
|
|
|
+ if (detail.getServiceNum() == monthNum) {
|
|
|
|
+ //如果服务月数等于收款月数则加上赠送月数
|
|
|
|
+ monthNum += detail.getFreeNum();
|
|
|
|
+ }
|
|
|
|
+ //设置收款截止月
|
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
|
+ rightNow.setTime(v.getStartMonth());
|
|
|
|
+ rightNow.add(Calendar.MONTH, monthNum == 0 ? monthNum : monthNum - 1);
|
|
|
|
+ Date closingMonth = rightNow.getTime();
|
|
|
|
+ // 创建一个SimpleDateFormat对象,指定日期格式
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
|
|
|
|
+ // 将Date对象转换为字符串
|
|
|
|
+ String dateString = sdf.format(closingMonth);
|
|
|
|
+ v.setClosingMonth("收款截止" + dateString);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ v.setClosingMonth("-");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 导出工单信息列表
|
|
|
|
|
|
+ * 首页查询工单信息列表
|
|
*/
|
|
*/
|
|
|
|
+ @GetMapping("/indexList")
|
|
|
|
+ public TableDataInfo indexList(BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
|
+ setTenantId(bizWorkOrder);
|
|
|
|
+ //排序
|
|
|
|
+ startOrderBy();
|
|
|
|
+ //获取当前登录用户Id
|
|
|
|
+ bizWorkOrder.setServiceId(SecurityUtils.getLoginUser().getUserId());
|
|
|
|
+ //根据客户名称模糊查询去除两边空格
|
|
|
|
+ if (bizWorkOrder.getCompanyName() != null) {
|
|
|
|
+ if (!bizWorkOrder.getCompanyName().equals(""))
|
|
|
|
+ bizWorkOrder.setCompanyName(bizWorkOrder.getCompanyName().trim());
|
|
|
|
+ }
|
|
|
|
+ List<BizWorkOrder> list = bizWorkOrderService.getIndexList(bizWorkOrder);
|
|
|
|
+ BizEntrust entrustConditions = new BizEntrust();
|
|
|
|
+ entrustConditions.setWorkOrderIds(list.stream().map(BizWorkOrder::getId).collect(Collectors.toList()));
|
|
|
|
+ List<BizEntrust> entrusts = entrustService.getList(entrustConditions);
|
|
|
|
+ list.forEach(v -> {
|
|
|
|
+ v.setEntrusts(entrusts.stream().filter(e -> e.getWorkOrderId().equals(v.getId())).collect(Collectors.toList()));
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ for (BizWorkOrder v:list){
|
|
|
|
+ if(v.getNoContract()==1){
|
|
|
|
+ v.setTaskTypeName(v.getRemark());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return getDataTable(list);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导出工单信息列表
|
|
|
|
+ */
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:export')")
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:export')")
|
|
@Log(title = "工单信息", businessType = BusinessType.EXPORT)
|
|
@Log(title = "工单信息", businessType = BusinessType.EXPORT)
|
|
@PostMapping("/export")
|
|
@PostMapping("/export")
|
|
- public void export(HttpServletResponse response, BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
- {
|
|
|
|
|
|
+ public void export(HttpServletResponse response, BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
setTenantId(bizWorkOrder);
|
|
setTenantId(bizWorkOrder);
|
|
List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
|
|
List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
|
|
ExcelUtil<BizWorkOrder> util = new ExcelUtil<BizWorkOrder>(BizWorkOrder.class);
|
|
ExcelUtil<BizWorkOrder> util = new ExcelUtil<BizWorkOrder>(BizWorkOrder.class);
|
|
@@ -92,8 +251,7 @@ public class BizWorkOrderController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:query')")
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:query')")
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
return success(bizWorkOrderService.getById(id));
|
|
return success(bizWorkOrderService.getById(id));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -103,8 +261,7 @@ public class BizWorkOrderController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:add')")
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:add')")
|
|
@Log(title = "工单信息", businessType = BusinessType.INSERT)
|
|
@Log(title = "工单信息", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
@PostMapping
|
|
- public AjaxResult add(@RequestBody BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
setTenantId(bizWorkOrder);
|
|
setTenantId(bizWorkOrder);
|
|
bizWorkOrder.setWorkOrderNo("workOrder_" + snowflakeIdWorker.nextId());
|
|
bizWorkOrder.setWorkOrderNo("workOrder_" + snowflakeIdWorker.nextId());
|
|
return toAjax(bizWorkOrderService.save(bizWorkOrder));
|
|
return toAjax(bizWorkOrderService.save(bizWorkOrder));
|
|
@@ -116,8 +273,7 @@ public class BizWorkOrderController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:edit')")
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:edit')")
|
|
@Log(title = "工单信息", businessType = BusinessType.UPDATE)
|
|
@Log(title = "工单信息", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
@PutMapping
|
|
- public AjaxResult edit(@RequestBody BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException
|
|
|
|
- {
|
|
|
|
|
|
+ public AjaxResult edit(@RequestBody BizWorkOrder bizWorkOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
setTenantId(bizWorkOrder);
|
|
setTenantId(bizWorkOrder);
|
|
return toAjax(bizWorkOrderService.updateById(bizWorkOrder));
|
|
return toAjax(bizWorkOrderService.updateById(bizWorkOrder));
|
|
}
|
|
}
|
|
@@ -127,9 +283,8 @@ public class BizWorkOrderController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:remove')")
|
|
@PreAuthorize("@ss.hasPermi('business:workOrder:remove')")
|
|
@Log(title = "工单信息", businessType = BusinessType.DELETE)
|
|
@Log(title = "工单信息", businessType = BusinessType.DELETE)
|
|
- @DeleteMapping("/{ids}")
|
|
|
|
- public AjaxResult remove(@PathVariable List<Long> ids)
|
|
|
|
- {
|
|
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
+ public AjaxResult remove(@PathVariable List<Long> ids) {
|
|
return toAjax(bizWorkOrderService.removeBatchByIds(ids));
|
|
return toAjax(bizWorkOrderService.removeBatchByIds(ids));
|
|
}
|
|
}
|
|
|
|
|