|
@@ -1,5 +1,6 @@
|
|
|
package org.jeecg.modules.appInterface.controller;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.sql.Connection;
|
|
|
import java.sql.DriverManager;
|
|
|
import java.util.Arrays;
|
|
@@ -89,14 +90,14 @@ public class FbsWorkingStatisticsController {
|
|
|
@ResponseBody
|
|
|
public ResponseEntity<ResHttpStatus> startOperation(FbsWorkingStatistics entity){
|
|
|
ResHttpStatus res = new ResHttpStatus();
|
|
|
- FbsWorkingStatistics fbsWorkingStatistics = new FbsWorkingStatistics();
|
|
|
- List<FbsPerson> aa = fbsPersonService.list();
|
|
|
- System.out.println(aa.size());
|
|
|
if(entity == null){
|
|
|
res.setCode("1");
|
|
|
res.setMsg("参数不能为空");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
+ if(StringUtils.isNotBlank(entity.getId())){
|
|
|
+ entity.setId(null);
|
|
|
+ }
|
|
|
if(StringUtils.isBlank(entity.getPersonnelCode())){
|
|
|
res.setCode("1");
|
|
|
res.setMsg("人员编码不能为空");
|
|
@@ -107,18 +108,14 @@ public class FbsWorkingStatisticsController {
|
|
|
res.setMsg("人员名称不能为空");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
- if(StringUtils.isBlank(entity.getOrderNumber())){
|
|
|
- res.setCode("1");
|
|
|
- res.setMsg("订单号不能为空");
|
|
|
- return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
- }
|
|
|
- if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
+ if(StringUtils.isBlank(entity.getPkWorkshopDispatchList())){
|
|
|
res.setCode("1");
|
|
|
- res.setMsg("订单id不能为空");
|
|
|
+ res.setMsg("派工单id不能为空");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
QueryWrapper<FbsWorkshopDispatchList> ypffscSaleorderBQueryWrapper = new QueryWrapper<>();
|
|
|
- ypffscSaleorderBQueryWrapper.eq("productionOrderNumberId", entity.getOrderId()).eq("del_flag", 0);
|
|
|
+ ypffscSaleorderBQueryWrapper.eq("id", entity.getPkWorkshopDispatchList()).eq("del_flag", 0);
|
|
|
List<FbsWorkshopDispatchList> list = fbsWorkshopDispatchListService.list(ypffscSaleorderBQueryWrapper);
|
|
|
if(list.size() < 1){
|
|
|
res.setCode("1");
|
|
@@ -133,17 +130,19 @@ public class FbsWorkingStatisticsController {
|
|
|
res.setMsg("该订单已开工或已结束,请勿再次操作"+entity.getOrderNumber());
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
+ entity.setStartDate(workshopDispatchList.getPlannedStartTime());//计划时间
|
|
|
+ entity.setEndDate(workshopDispatchList.getPlannedStartTime());//计划时间
|
|
|
|
|
|
- fbsWorkingStatistics.setTimeInfo(new Date());//获取当前时间
|
|
|
- fbsWorkingStatistics.setFinalInfo("开工");
|
|
|
- fbsWorkingStatistics.setFinalState("1");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
+ entity.setFirstTime(new Date());//获取当前时间
|
|
|
+ entity.setFinalInfo("开工");
|
|
|
+ entity.setFinalState("1");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
|
|
|
- fbsWorkingStatisticsService.save(fbsWorkingStatistics);
|
|
|
- fbsWorkshopDispatchListService.updateState("1",entity.getOrderId());
|
|
|
+ fbsWorkingStatisticsService.save(entity);
|
|
|
+ fbsWorkshopDispatchListService.updateState("1",entity.getPkWorkshopDispatchList());
|
|
|
|
|
|
res.setCode("0");
|
|
|
res.setMsg("成功");
|
|
|
- res.setData(fbsWorkingStatistics);
|
|
|
+ res.setData(entity);
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
@@ -158,15 +157,34 @@ public class FbsWorkingStatisticsController {
|
|
|
@ResponseBody
|
|
|
public ResponseEntity<ResHttpStatus> suspendOperation(FbsWorkingStatistics entity){
|
|
|
ResHttpStatus res = new ResHttpStatus();
|
|
|
- FbsWorkingStatistics fbsWorkingStatistics = new FbsWorkingStatistics();
|
|
|
+
|
|
|
+ long nd = 1000 * 24 * 60 * 60;
|
|
|
+ long nh = 1000 * 60 * 60;
|
|
|
+ long nm = 1000 * 60;
|
|
|
|
|
|
if(entity == null){
|
|
|
res.setCode("1");
|
|
|
res.setMsg("参数不能为空");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(entity.getId())){
|
|
|
- entity.setId(null);
|
|
|
+ if(StringUtils.isBlank(entity.getId())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("报工单id不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }else{
|
|
|
+ FbsWorkingStatistics par = fbsWorkingStatisticsService.getById(entity.getId());
|
|
|
+ if(par != null){
|
|
|
+ Date firstTime = par.getFirstTime();
|
|
|
+ long diff = new Date().getTime() - firstTime.getTime();
|
|
|
+ // 计算差多少天
|
|
|
+// long day = diff / nd;
|
|
|
+ // 计算差多少小时
|
|
|
+ long hour = diff % nd / nh;
|
|
|
+ // 计算差多少分钟
|
|
|
+ long min = diff / nm;
|
|
|
+ BigDecimal aa = new BigDecimal(min).divide(new BigDecimal("60"), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ entity.setWorkingHours(aa);
|
|
|
+ }
|
|
|
}
|
|
|
if(StringUtils.isBlank(entity.getPersonnelCode())){
|
|
|
res.setCode("1");
|
|
@@ -178,18 +196,18 @@ public class FbsWorkingStatisticsController {
|
|
|
res.setMsg("人员名称不能为空");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
- if(StringUtils.isBlank(entity.getOrderNumber())){
|
|
|
+ if(StringUtils.isBlank(entity.getPkWorkshopDispatchList())){
|
|
|
res.setCode("1");
|
|
|
- res.setMsg("订单号不能为空");
|
|
|
+ res.setMsg("派工单id不能为空");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
- if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
- res.setCode("1");
|
|
|
- res.setMsg("订单id不能为空");
|
|
|
- return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
- }
|
|
|
+// if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
+// res.setCode("1");
|
|
|
+// res.setMsg("订单id不能为空");
|
|
|
+// return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+// }
|
|
|
QueryWrapper<FbsWorkshopDispatchList> ypffscSaleorderBQueryWrapper = new QueryWrapper<>();
|
|
|
- ypffscSaleorderBQueryWrapper.eq("productionOrderNumberId", entity.getOrderId()).eq("del_flag", 0);
|
|
|
+ ypffscSaleorderBQueryWrapper.eq("id", entity.getPkWorkshopDispatchList()).eq("del_flag", 0);
|
|
|
List<FbsWorkshopDispatchList> list = fbsWorkshopDispatchListService.list(ypffscSaleorderBQueryWrapper);
|
|
|
if(list.size() < 1){
|
|
|
res.setCode("1");
|
|
@@ -204,16 +222,17 @@ public class FbsWorkingStatisticsController {
|
|
|
res.setMsg("该订单目前不在可暂停状态,无法暂停"+entity.getOrderNumber());
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
-
|
|
|
- fbsWorkingStatistics.setTimeInfo(new Date());//获取当前时间
|
|
|
- fbsWorkingStatistics.setFinalInfo("下岗/暂停");
|
|
|
- fbsWorkingStatistics.setFinalState("2");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
- fbsWorkingStatisticsService.save(fbsWorkingStatistics);
|
|
|
- fbsWorkshopDispatchListService.updateState("2",entity.getOrderId());
|
|
|
+ entity.setStartDate(workshopDispatchList.getPlannedStartTime());//计划时间
|
|
|
+ entity.setEndDate(workshopDispatchList.getPlannedStartTime());//计划时间
|
|
|
+ entity.setFinalTime(new Date());//获取当前时间
|
|
|
+ entity.setFinalInfo("下岗/暂停");
|
|
|
+ entity.setFinalState("2");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
+ fbsWorkingStatisticsService.updateById(entity);
|
|
|
+ fbsWorkshopDispatchListService.updateState("2",entity.getPkWorkshopDispatchList());
|
|
|
|
|
|
res.setCode("0");
|
|
|
res.setMsg("成功");
|
|
|
- res.setData(fbsWorkingStatistics);
|
|
|
+ res.setData(entity);
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
@@ -226,16 +245,46 @@ public class FbsWorkingStatisticsController {
|
|
|
@ResponseBody
|
|
|
public ResponseEntity<ResHttpStatus> finishDoing(FbsWorkingStatistics entity){
|
|
|
ResHttpStatus res = new ResHttpStatus();
|
|
|
- FbsWorkingStatistics fbsWorkingStatistics = new FbsWorkingStatistics();
|
|
|
+
|
|
|
+ long nd = 1000 * 24 * 60 * 60;
|
|
|
+ long nh = 1000 * 60 * 60;
|
|
|
+ long nm = 1000 * 60;
|
|
|
|
|
|
if(entity == null){
|
|
|
res.setCode("1");
|
|
|
res.setMsg("参数不能为空 ");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(entity.getId())){
|
|
|
- entity.setId(null);
|
|
|
+ if(StringUtils.isBlank(entity.getId())){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("报工单id不能为空");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+ FbsWorkingStatistics par = fbsWorkingStatisticsService.getById(entity.getId());
|
|
|
+ if(par != null){
|
|
|
+ if(par.getState().equals("1")){
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("该次已完成报工,请勿再次操作");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ if( par.getFinalTime() == null){
|
|
|
+ Date firstTime = par.getFirstTime();
|
|
|
+ long diff = new Date().getTime() - firstTime.getTime();
|
|
|
+ // 计算差多少分钟
|
|
|
+ long min = diff / nm;
|
|
|
+ BigDecimal aa = new BigDecimal(min).divide(new BigDecimal("60"), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ entity.setWorkingHours(aa);
|
|
|
+ entity.setFinalTime(new Date());//获取当前时间
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ res.setCode("1");
|
|
|
+ res.setMsg("报工单id不正确,没有查询到数据");
|
|
|
+ return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
+
|
|
|
if(StringUtils.isBlank(entity.getPersonnelCode())){
|
|
|
res.setCode("1");
|
|
|
res.setMsg("人员编码不能为空");
|
|
@@ -267,18 +316,18 @@ public class FbsWorkingStatisticsController {
|
|
|
res.setMsg("状态不能为空0保存,1提交");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
- if(StringUtils.isBlank(entity.getOrderNumber())){
|
|
|
+ if(StringUtils.isBlank(entity.getPkWorkshopDispatchList())){
|
|
|
res.setCode("1");
|
|
|
- res.setMsg("订单号不能为空");
|
|
|
+ res.setMsg("派工单id不能为空");
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
- if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
- res.setCode("1");
|
|
|
- res.setMsg("订单id不能为空");
|
|
|
- return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
- }
|
|
|
+// if(StringUtils.isBlank(entity.getOrderId())){
|
|
|
+// res.setCode("1");
|
|
|
+// res.setMsg("订单id不能为空");
|
|
|
+// return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
+// }
|
|
|
QueryWrapper<FbsWorkshopDispatchList> ypffscSaleorderBQueryWrapper = new QueryWrapper<>();
|
|
|
- ypffscSaleorderBQueryWrapper.eq("productionOrderNumberId", entity.getOrderId()).eq("del_flag", 0);
|
|
|
+ ypffscSaleorderBQueryWrapper.eq("id", entity.getPkWorkshopDispatchList()).eq("del_flag", 0);
|
|
|
List<FbsWorkshopDispatchList> list = fbsWorkshopDispatchListService.list(ypffscSaleorderBQueryWrapper);
|
|
|
if(list.size() < 1){
|
|
|
res.setCode("1");
|
|
@@ -288,20 +337,39 @@ public class FbsWorkingStatisticsController {
|
|
|
FbsWorkshopDispatchList workshopDispatchList = list.get(0);
|
|
|
|
|
|
//状态(0初始,1接单,2暂停,3完成)
|
|
|
- if(StringUtils.isNotBlank(workshopDispatchList.getState()) && !workshopDispatchList.getState().equals("1")){
|
|
|
+ if(workshopDispatchList.getState().equals("0") || workshopDispatchList.getState().equals("2")){
|
|
|
res.setCode("1");
|
|
|
res.setMsg("该订单目前正在进行中,无法报工"+entity.getOrderNumber());
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
- fbsWorkingStatistics.setFinalInfo("实时报工");
|
|
|
- fbsWorkingStatistics.setFinalState("3");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
- fbsWorkingStatisticsService.save(fbsWorkingStatistics);
|
|
|
- fbsWorkshopDispatchListService.updateState("3",entity.getOrderId());
|
|
|
+ entity.setStartDate(workshopDispatchList.getPlannedStartTime());//计划时间
|
|
|
+ entity.setEndDate(workshopDispatchList.getPlannedStartTime());//计划时间
|
|
|
+
|
|
|
+ entity.setFinalInfo("实时报工");
|
|
|
+ entity.setFinalState("3");//完结状态(1-开工,2-下岗/暂停,3-实时报工)
|
|
|
+ fbsWorkingStatisticsService.updateById(entity);
|
|
|
+ fbsWorkshopDispatchListService.updateState("3",entity.getPkWorkshopDispatchList());
|
|
|
+
|
|
|
+ if(!par.getState().equals("1")){
|
|
|
+ QueryWrapper<FbsWorkingStatistics> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("pk_Workshop_Dispatch_List", entity.getPkWorkshopDispatchList()).eq("del_flag", 0);
|
|
|
+ List<FbsWorkingStatistics> list1 = fbsWorkingStatisticsService.list(queryWrapper);
|
|
|
+ BigDecimal allHors = new BigDecimal("0");
|
|
|
+ for (FbsWorkingStatistics o:list1){
|
|
|
+ allHors = allHors.add(o.getWorkingHours());
|
|
|
+ }
|
|
|
+ fbsWorkshopDispatchListService.writeBackManHoursCompleted(allHors.toString(),entity.getPkWorkshopDispatchList());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(entity.getState().equals("1")){
|
|
|
+ //把数据传入u8数据库
|
|
|
+ }
|
|
|
|
|
|
res.setCode("0");
|
|
|
res.setMsg("成功");
|
|
|
- res.setData(fbsWorkingStatistics);
|
|
|
+ res.setData(entity);
|
|
|
return new ResponseEntity<ResHttpStatus>(res, HttpStatus.OK);
|
|
|
}
|
|
|
|