提交 dd56a246 authored 作者: 133's avatar 133

[zjm] 用户判断是否冻结

上级 c11ce3d0
...@@ -14,14 +14,12 @@ import lombok.extern.slf4j.Slf4j; ...@@ -14,14 +14,12 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest; import org.springframework.web.multipart.MultipartRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
...@@ -63,12 +61,10 @@ public class FileController { ...@@ -63,12 +61,10 @@ public class FileController {
/** /**
* 文件下载 * 文件下载
*/ */
@ApiOperation(value = "文件下载") @PostMapping("/download")
@GetMapping("/download") public void download(@RequestBody FileRet fileRet, HttpServletResponse response, HttpServletRequest httpServletRequest){
public void download(@RequestParam String url, @RequestParam String name, HttpServletResponse response, HttpServletRequest httpServletRequest) { useReportFIleService.download(fileRet.getFilePath(),fileRet.getName(),response,httpServletRequest);
} }
@ApiOperation(value = "多文件上传") @ApiOperation(value = "多文件上传")
@PostMapping(value = "/many/upload") @PostMapping(value = "/many/upload")
public ResponseEntity<List<FileRet>> manyFileUpload(HttpServletRequest request) { public ResponseEntity<List<FileRet>> manyFileUpload(HttpServletRequest request) {
......
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
<version>29.0-jre</version> <version>29.0-jre</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
/** /**
* <h4>Description : </h4> * <h4>Description : </h4>
* *
* @Author czq * @Author zjm
* @Date 2020-08-15 18:15 * @Date 2020-08-15 18:15
* @Version 1.0 * @Version 1.0
*/ */
...@@ -94,30 +94,36 @@ public interface SendBackService { ...@@ -94,30 +94,36 @@ public interface SendBackService {
ResponseEntity sendBackIn(Integer taskIdy, Integer userId, Integer type); ResponseEntity sendBackIn(Integer taskIdy, Integer userId, Integer type);
/* /**
查看业务详情,只显示表格和异常装备 查看业务详情,只显示表格和异常装备
*/ */
ResponseEntity bussiness(Integer task); ResponseEntity bussiness(Integer task);
/* /**
查询清退单 查询清退单
*/ */
ResponseEntity getList(SendBackOutFormVo sendBackOutFormVo); ResponseEntity getList(SendBackOutFormVo sendBackOutFormVo);
/* /**
造数据用 造数据用
*/ */
ResponseEntity save(SendBackBillDetail sendBackBillDetailEntity); ResponseEntity save(SendBackBillDetail sendBackBillDetailEntity);
/* /**
查看此次清退的某个型号的装备 查看此次清退的某个型号的装备
*/ */
ResponseEntity getDeviceByModel(List<Integer> deviceList); ResponseEntity getDeviceByModel(List<Integer> deviceList);
/**
* 保存入库单接口
*/
ResponseEntity saveSendBackBillDetailEntity(SendBackBillDetail sendBackBillDetailEntity); ResponseEntity saveSendBackBillDetailEntity(SendBackBillDetail sendBackBillDetailEntity);
/**
* 入库申请接口
*/
ResponseEntity sendBackInCheck(Integer taskId, SendBackOutVo sendBackOut, Integer userId); ResponseEntity sendBackInCheck(Integer taskId, SendBackOutVo sendBackOut, Integer userId);
/** /**
...@@ -133,5 +139,4 @@ public interface SendBackService { ...@@ -133,5 +139,4 @@ public interface SendBackService {
*/ */
ResponseEntity exceptionSelect(Integer task); ResponseEntity exceptionSelect(Integer task);
} }
...@@ -27,7 +27,6 @@ import com.tykj.dev.device.user.subject.entity.Units; ...@@ -27,7 +27,6 @@ import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.entity.User; import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.misc.base.BusinessEnum; import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.StatusEnum; import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.utils.Snowflake;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -43,77 +42,60 @@ import java.util.stream.Collectors; ...@@ -43,77 +42,60 @@ import java.util.stream.Collectors;
/** /**
* <h4>Description : 装备清退</h4> * <h4>Description : 装备清退</h4>
* *
* @Author czq * @Author zjm
* @Date 2020-08-15 18:15 * @Date 2020-08-15 18:15
* @Version 1.0 * @Version 1.0
*/ */
@Service @Service
public class SendBackServiceImpl implements SendBackService { public class SendBackServiceImpl implements SendBackService {
private final DeviceLibraryDao deviceLibraryDao;
private final SendBackBillDao sendBackBillEntityDao;
private final TaskDao taskDao;
private final UnitsDao unitsDao;
private final AreaDao areaDao;
private final TaskService taskService;
private final UserDao userDao;
private final SendBackBillDetailDao sendBackBillDetailEntityDao;
@Autowired @Autowired
DeviceLibraryService deviceLibraryService; private DeviceLibraryDao deviceLibraryDao;
@Autowired @Autowired
DeviceLogService deviceLogService; private SendBackBillDao sendBackBillEntityDao;
@Autowired @Autowired
private Snowflake snowflake; private TaskDao taskDao;
@Autowired @Autowired
public SendBackServiceImpl(TaskService taskService, DeviceLibraryDao deviceLibraryDao, SendBackBillDao sendBackBillEntityDao, TaskDao taskDao, UnitsDao unitsDao, AreaDao areaDao, UserDao userDao, UserDao userDao1, SendBackBillDetailDao sendBackBillDetailEntityDao) { private UnitsDao unitsDao;
this.taskService = taskService; @Autowired
this.deviceLibraryDao = deviceLibraryDao; private AreaDao areaDao;
this.sendBackBillEntityDao = sendBackBillEntityDao; @Autowired
this.taskDao = taskDao; private TaskService taskService;
this.unitsDao = unitsDao; @Autowired
this.areaDao = areaDao; private UserDao userDao;
this.userDao = userDao; @Autowired
this.sendBackBillDetailEntityDao = sendBackBillDetailEntityDao; private SendBackBillDetailDao sendBackBillDetailEntityDao;
} @Autowired
private DeviceLibraryService deviceLibraryService;
@Autowired
private DeviceLogService deviceLogService;
/** /**
* 添加设备 * 添加设备
*
* @param deviceIdList 待清退装备的id集合 * @param deviceIdList 待清退装备的id集合
* @return 清退单 * @return 清退单
*/ */
@Override @Override
public ResponseEntity addDeviceToSendBack(List<Integer> deviceIdList, Integer type) { public ResponseEntity addDeviceToSendBack(List<Integer> deviceIdList, Integer type) {
if (type == 2) { if(type == 2){
return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList)); return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList));
} else { }else {
SendBackVo newSend = newStatistical(deviceIdList, type, null, true); SendBackVo newSend = newStatistical(deviceIdList, type, null, true);
List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(newSend.getMap().values()); List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(newSend.getMap().values());
newSend.setDataList(dataList); newSend.setDataList(dataList);
return ResponseEntity.ok(newSend); return ResponseEntity.ok(newSend);
} }
} }
/** /**
* 确定待审核清退单 * 确定待审核清退单
* * @param sendBackVo 待清退装备的表单
* @param sendBackVo 待清退装备的表单
* @param startUserId 操作用户id * @param startUserId 操作用户id
* @return 成功 * @return 成功
*/ */
@Transactional @Transactional
@Override @Override
public ResponseEntity addSendBackTask(SendBackVo sendBackVo, Integer startUserId) { public ResponseEntity addSendBackTask(SendBackVo sendBackVo,Integer startUserId) {
/* /*
1、获取清退装备的idList 1、获取清退装备的idList
...@@ -122,7 +104,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -122,7 +104,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
2、根据idList生成待清退装备的初始表单,浙江省的id 2、根据idList生成待清退装备的初始表单,浙江省的id
*/ */
SendBackVo sendBack = newStatistical(deviceIdList, 0, null, true); SendBackVo sendBack = newStatistical(deviceIdList, 0,null,true);
sendBack.setName(sendBackVo.getName()); sendBack.setName(sendBackVo.getName());
sendBack.setTime(sendBackVo.getTime()); sendBack.setTime(sendBackVo.getTime());
sendBack.setDeviceIdList(null); sendBack.setDeviceIdList(null);
...@@ -132,12 +114,12 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -132,12 +114,12 @@ public class SendBackServiceImpl implements SendBackService {
添加省级任务和账单 添加省级任务和账单
*/ */
List<Area> area = areaDao.findByFatherId(null); List<Area> area = areaDao.findByFatherId(null);
TaskBto taskBto = addTaskStatus(JSON.toJSONString(sendBack), idString.toString(), area.get(0).getId(), startUserId, sendBackVo.getTime()); TaskBto taskBto = addTaskStatus( JSON.toJSONString(sendBack), idString.toString(),area.get(0).getId(),startUserId,sendBackVo.getTime());
/* /*
添加各单位的Task 添加各单位的Task
*/ */
addTaskById(deviceIdList, taskBto.getId(), startUserId, sendBackVo.getTime(), sendBackVo.getName()); addTaskById(deviceIdList,taskBto.getId(),startUserId,sendBackVo.getTime(),sendBackVo.getName());
return ResponseEntity.ok(taskBto.getId()); return ResponseEntity.ok(taskBto.getId());
...@@ -146,7 +128,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -146,7 +128,6 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 点击查看Task,返回请退单或出库单 * 点击查看Task,返回请退单或出库单
*
* @return 清退单 * @return 清退单
*/ */
@Transactional @Transactional
...@@ -164,19 +145,19 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -164,19 +145,19 @@ public class SendBackServiceImpl implements SendBackService {
List<Integer> idList = stringToList(billEntity.getInvoleDevice()); List<Integer> idList = stringToList(billEntity.getInvoleDevice());
String send = billEntity.getSendBackStatistical(); String send = billEntity.getSendBackStatistical();
if (billStatus == 1200 || billStatus.equals(StatusEnum.SEND_BACK_1201.id)) { if(billStatus == 1200 || billStatus.equals(StatusEnum.SEND_BACK_1201.id)){
Units unit = unitsDao.getOne(taskBto.getOwnUnit()); Units unit = unitsDao.getOne(taskBto.getOwnUnit());
HashMap<String, Integer> areaToTaskId = areaToTask(unit, taskBto); HashMap<String,Integer> areaToTaskId = areaToTask(unit,taskBto);
/* /*
统计单 统计单
*/ */
if (send == null || send.equals("null")) { if(send == null || send.equals("null")){
if (unit.getLevel() == 2) { if(unit.getLevel() == 2){
SendBackVo sendBackVo = newStatistical(idList, 1, null, true); SendBackVo sendBackVo = newStatistical(idList, 1, null, true);
TaskBto parentTask = taskService.get(taskBto.getParentTaskId()); TaskBto parentTask = taskService.get(taskBto.getParentTaskId());
SendBackBill parentBill = sendBackBillEntityDao.getOne(parentTask.getBillId()); SendBackBill parentBill = sendBackBillEntityDao.getOne(parentTask.getBillId());
SendBackVo parentVo = JSONObject.parseObject(parentBill.getSendBackStatistical(), SendBackVo.class); SendBackVo parentVo = JSONObject.parseObject(parentBill.getSendBackStatistical(),SendBackVo.class);
sendBackVo.setName(parentVo.getName()); sendBackVo.setName(parentVo.getName());
sendBackVo.setTime(parentVo.getTime()); sendBackVo.setTime(parentVo.getTime());
billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo)); billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo));
...@@ -184,11 +165,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -184,11 +165,11 @@ public class SendBackServiceImpl implements SendBackService {
List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values()); List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values());
sendBackVo.setDataList(dataList); sendBackVo.setDataList(dataList);
return ResponseEntity.ok(sendBackVo); return ResponseEntity.ok(sendBackVo);
} else { }else {
return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)); return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
} }
} else { }else {
SendBackVo sendBackVo = JSONObject.parseObject(send, SendBackVo.class); SendBackVo sendBackVo = JSONObject.parseObject(send,SendBackVo.class);
sendBackVo.setAreaToTaskId(areaToTaskId); sendBackVo.setAreaToTaskId(areaToTaskId);
sendBackVo.setTime(sendBackVo.getTime()); sendBackVo.setTime(sendBackVo.getTime());
sendBackVo.setName(sendBackVo.getName()); sendBackVo.setName(sendBackVo.getName());
...@@ -197,43 +178,43 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -197,43 +178,43 @@ public class SendBackServiceImpl implements SendBackService {
return ResponseEntity.ok(sendBackVo); return ResponseEntity.ok(sendBackVo);
} }
//27 出库待校验 18 入库待审核 //27 出库待校验 18 入库待审核
} else if (billStatus.equals(StatusEnum.SEND_BACK_1202.id)) { }else if(billStatus.equals(StatusEnum.SEND_BACK_1202.id) ){
String sendBackOut = billEntity.getSendBackOut(); String sendBackOut = billEntity.getSendBackOut();
return ResponseEntity.ok(JSON.parseObject(sendBackOut, new TypeReference<SendBackOutVo>() { return ResponseEntity.ok(JSON.parseObject(sendBackOut,new TypeReference<SendBackOutVo>() {}));
}));
} else if (billStatus.equals(StatusEnum.SEND_BACK_1204.id)) { }else if (billStatus.equals(StatusEnum.SEND_BACK_1204.id)){
SendBackBillDetail sendBackBillDetail = sendBackBillDetailEntityDao.findSendBackBillDetailById(billEntity.getFormId()); SendBackBillDetail sendBackBillDetail= sendBackBillDetailEntityDao.findSendBackBillDetailById(billEntity.getFormId());
List<DeviceLibrary> deviceLibraryEntities = new ArrayList<>(); List<DeviceLibrary> deviceLibraryEntities = new ArrayList<>();
String str2 = sendBackBillDetail.getReceiveCheckDetail(); String str2=sendBackBillDetail.getReceiveCheckDetail();
if (str2 != null) { if (str2!=null) {
String[] strings1 = str2.split("x"); String[] strings1 = str2.split("x");
for (String s : strings1) { for (String s : strings1) {
if (s.length() >= 2 && "1".equals(s.substring(s.length() - 1))) { if (s.length() >= 2 && "1".equals(s.substring(s.length() - 1))) {
Integer id = Integer.parseInt(s.substring(0, s.length() - 1)); Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
Integer checkResult = Integer.parseInt(s.substring(s.length() - 1)); Integer checkResult = Integer.parseInt(s.substring(s.length() - 1));
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id); DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
deviceLibraryEntity.setCheckResult(checkResult); deviceLibraryEntity.setCheckResult(checkResult);
deviceLibraryEntities.add(deviceLibraryEntity); deviceLibraryEntities.add(deviceLibraryEntity);
}
} }
} }
}
sendBackBillDetail.setDeviceLibraryEntities(deviceLibraryEntities); sendBackBillDetail.setDeviceLibraryEntities(deviceLibraryEntities);
return ResponseEntity.ok(sendBackBillDetail); return ResponseEntity.ok(sendBackBillDetail);
} else if (billStatus == 10 || billStatus.equals(StatusEnum.SEND_BACK_1206.id)) { } else if(billStatus == 10 || billStatus.equals(StatusEnum.SEND_BACK_1206.id)){
//10待审核 28入库待校验 //10待审核 28入库待校验
if (send == null || send.equals("null")) { if (send==null || send.equals("null")){
send = billEntity.getSendBackOut(); send=billEntity.getSendBackOut();
} }
SendBackBillDetail one = sendBackBillDetailEntityDao.findSendBackBillDetailById(billEntity.getFormId()); SendBackBillDetail one = sendBackBillDetailEntityDao.findSendBackBillDetailById(billEntity.getFormId());
one.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)); one.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
SendBackVo sendBackVo = JSONObject.parseObject(send, SendBackVo.class); SendBackVo sendBackVo = JSONObject.parseObject(send,SendBackVo.class);
one.setTime(sendBackVo.getTime()); one.setTime(sendBackVo.getTime());
SendBackOutVo sendBackOutVo = JSONObject.parseObject(billEntity.getSendBackOut(), SendBackOutVo.class); SendBackOutVo sendBackOutVo = JSONObject.parseObject(billEntity.getSendBackOut(), SendBackOutVo.class);
one.setBillFileName(sendBackOutVo.getReturnNoteName()); one.setBillFileName(sendBackOutVo.getReturnNoteName());
...@@ -247,7 +228,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -247,7 +228,7 @@ public class SendBackServiceImpl implements SendBackService {
@Transactional @Transactional
@Override @Override
public ResponseEntity exceptionTask(SendBackRequst sendBackRequst, Integer parentTaskId, Integer userId) { public ResponseEntity exceptionTask(SendBackRequst sendBackRequst,Integer parentTaskId,Integer userId) {
List<Integer> deviceIdList = sendBackRequst.getDeviceIdList(); List<Integer> deviceIdList = sendBackRequst.getDeviceIdList();
...@@ -256,42 +237,42 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -256,42 +237,42 @@ public class SendBackServiceImpl implements SendBackService {
unDeviceDes.setName(user.getName()); unDeviceDes.setName(user.getName());
unDeviceDes.setTime(new Date()); unDeviceDes.setTime(new Date());
unDeviceDes.setUnitName(unitsDao.findById(user.getUnitsId()).get().getName()); unDeviceDes.setUnitName(unitsDao.findById(user.getUnitsId()).get().getName());
List<AbnormalDescribe> abnormalDescribes = new ArrayList<>(); List<AbnormalDescribe> abnormalDescribes=new ArrayList<>();
if (unDeviceDes.getDes() != null) { if (unDeviceDes.getDes()!=null){
abnormalDescribes = unDeviceDes.getDes(); abnormalDescribes=unDeviceDes.getDes();
} }
Map<Integer, AbnormalDescribe> map = new HashMap<>(); Map<Integer,AbnormalDescribe> map=new HashMap<>();
abnormalDescribes.forEach( abnormalDescribes.forEach(
abnormalDescribe -> { abnormalDescribe -> {
map.put(abnormalDescribe.getId(), abnormalDescribe); map.put(abnormalDescribe.getId(),abnormalDescribe);
} }
); );
/* /*
将异常的装备根据所在进行分类,然后给所在地task 将异常的装备根据所在进行分类,然后给所在地task
*/ */
List<DeviceLibrary> deviceLibraryEntitiesByIdIn = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList); List<DeviceLibrary> deviceLibraryEntitiesByIdIn = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(deviceIdList);
HashMap<String, List<Integer>> locationUnitList = new HashMap<>(); HashMap<String,List<Integer>> locationUnitList = new HashMap<>();
HashMap<String, List<AbnormalDescribe>> desList = new HashMap<>(); HashMap<String,List<AbnormalDescribe>> desList = new HashMap<>();
for (DeviceLibrary deviceLibraryEntity : deviceLibraryEntitiesByIdIn) { for (DeviceLibrary deviceLibraryEntity : deviceLibraryEntitiesByIdIn) {
String locationUnit = deviceLibraryEntity.getLocationUnit(); String locationUnit = deviceLibraryEntity.getLocationUnit();
List<Integer> ids = locationUnitList.get(locationUnit); List<Integer> ids = locationUnitList.get(locationUnit);
if (ids == null) { if(ids == null){
ids = new ArrayList<>(); ids = new ArrayList<>();
} }
ids.add(deviceLibraryEntity.getId()); ids.add(deviceLibraryEntity.getId());
locationUnitList.put(locationUnit, ids); locationUnitList.put(locationUnit,ids);
List<AbnormalDescribe> unDeviceDesVos = desList.get(locationUnit); List<AbnormalDescribe> unDeviceDesVos = desList.get(locationUnit);
if (unDeviceDesVos == null) { if(unDeviceDesVos == null){
unDeviceDesVos = new ArrayList<>(); unDeviceDesVos = new ArrayList<>();
} }
unDeviceDesVos.add(map.get(deviceLibraryEntity.getId())); unDeviceDesVos.add(map.get(deviceLibraryEntity.getId()));
desList.put(locationUnit, unDeviceDesVos); desList.put(locationUnit,unDeviceDesVos);
} }
TaskBto parentTask = taskService.get(parentTaskId); TaskBto parentTask = taskService.get(parentTaskId);
...@@ -301,7 +282,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -301,7 +282,7 @@ public class SendBackServiceImpl implements SendBackService {
Set<String> locationKey = locationUnitList.keySet(); Set<String> locationKey = locationUnitList.keySet();
for (String location : locationKey) { for (String location:locationKey) {
TaskBto taskSaveVo = new TaskBto(); TaskBto taskSaveVo = new TaskBto();
/* /*
一个task,绑定一个账单,账单中存放装备ID 一个task,绑定一个账单,账单中存放装备ID
...@@ -334,7 +315,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -334,7 +315,7 @@ public class SendBackServiceImpl implements SendBackService {
taskSaveVo.setOwnUnit(unit.getUnitId()); taskSaveVo.setOwnUnit(unit.getUnitId());
taskSaveVo.setParentTaskId(parentTask.getParentTaskId()); taskSaveVo.setParentTaskId(parentTask.getParentTaskId());
taskSaveVo.setNodeIdDetail(""); taskSaveVo.setNodeIdDetail("");
List<Integer> integerList = new ArrayList<>(); List<Integer> integerList=new ArrayList<>();
integerList.add(0); integerList.add(0);
taskSaveVo.setCurrentPoint(0); taskSaveVo.setCurrentPoint(0);
taskSaveVo.setInvolveUserIdList(integerList); taskSaveVo.setInvolveUserIdList(integerList);
...@@ -347,7 +328,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -347,7 +328,7 @@ public class SendBackServiceImpl implements SendBackService {
*/ */
// addJob(task.getId(),task.getBillStatus(),userId,null,0,0); // addJob(task.getId(),task.getBillStatus(),userId,null,0,0);
} }
taskService.moveToEnd(parentTask); taskService.moveToEnd(parentTask);
return ResponseEntity.ok("提交成功"); return ResponseEntity.ok("提交成功");
} }
...@@ -355,17 +336,16 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -355,17 +336,16 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 点击"确认后",开始处理异常 * 点击"确认后",开始处理异常
* 1、将装备的所属单位改为处理人的所属单位 * 1、将装备的所属单位改为处理人的所属单位
*
* @param * @param
* @return 成功 * @return 成功
*/ */
@Transactional @Transactional
@Override @Override
public ResponseEntity endException(Integer taskId, Integer userId, Integer type) { public ResponseEntity endException(Integer taskId,Integer userId,Integer type) {
User user = userDao.getOne(userId); User user = userDao.getOne(userId);
Units units = unitsDao.getOne(user.getUnitsId()); Units units = unitsDao.getOne(user.getUnitsId());
TaskBto taskBto = taskService.get(taskId); TaskBto taskBto=taskService.get(taskId);
/* /*
获取该Task的账单 获取该Task的账单
*/ */
...@@ -374,7 +354,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -374,7 +354,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
获取关联的设备id 获取关联的设备id
*/ */
String involeDevice = sendBackBill.getInvoleDevice(); String involeDevice=sendBackBill.getInvoleDevice();
List<Integer> idList = stringToList(involeDevice); List<Integer> idList = stringToList(involeDevice);
/* /*
...@@ -382,7 +362,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -382,7 +362,7 @@ public class SendBackServiceImpl implements SendBackService {
*/ */
List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList); List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
deviceList.forEach(devices -> { deviceList.forEach(devices -> {
DeviceLogDto deviceLogDto = new DeviceLogDto(devices.getId(), "清退异常将装备的所属单位从" + devices.getOwnUnit() + "改为" + units.getName(), null); DeviceLogDto deviceLogDto = new DeviceLogDto(devices.getId(),"清退异常将装备的所属单位从"+devices.getOwnUnit()+"改为"+units.getName(),null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
devices.setOwnUnit(units.getName()); devices.setOwnUnit(units.getName());
deviceLibraryService.update(devices); deviceLibraryService.update(devices);
...@@ -394,22 +374,22 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -394,22 +374,22 @@ public class SendBackServiceImpl implements SendBackService {
TaskBto parentTask = taskService.get(taskBto.getParentTaskId()); TaskBto parentTask = taskService.get(taskBto.getParentTaskId());
Integer parentTaskBillId = parentTask.getBillId(); Integer parentTaskBillId = parentTask.getBillId();
SendBackBill parentTaskBill = sendBackBillEntityDao.getOne(parentTaskBillId); SendBackBill parentTaskBill = sendBackBillEntityDao.getOne(parentTaskBillId);
parentTaskBill.setInvoleDevice(parentTaskBill.getInvoleDevice().replaceAll(involeDevice, "")); parentTaskBill.setInvoleDevice(parentTaskBill.getInvoleDevice().replaceAll(involeDevice,""));
if (parentTaskBill.getInvoleDevice().equals("")) { if (parentTaskBill.getInvoleDevice().equals("")){
taskService.moveToEnd(parentTask); taskService.moveToEnd(parentTask);
s(parentTask, parentTaskBill, idList); s(parentTask,parentTaskBill,idList);
} }
sendBackBillEntityDao.save(parentTaskBill); sendBackBillEntityDao.save(parentTaskBill);
taskService.moveToEnd(taskBto); taskService.moveToEnd(taskBto);
if (units.getLevel() == 2) { if (units.getLevel()==2){
TaskBto cityTask = taskService.get(parentTask.getParentTaskId()); TaskBto cityTask = taskService.get(parentTask.getParentTaskId());
Integer cityTaskBillId = cityTask.getBillId(); Integer cityTaskBillId = cityTask.getBillId();
SendBackBill cityTaskBill = sendBackBillEntityDao.getOne(cityTaskBillId); SendBackBill cityTaskBill = sendBackBillEntityDao.getOne(cityTaskBillId);
parentTaskBill.setInvoleDevice(cityTaskBill.getInvoleDevice() + involeDevice); parentTaskBill.setInvoleDevice(cityTaskBill.getInvoleDevice()+involeDevice);
sendBackBillEntityDao.save(parentTaskBill); sendBackBillEntityDao.save(parentTaskBill);
} }
...@@ -419,12 +399,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -419,12 +399,11 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 清退装备出库校验 * 清退装备出库校验
*
* @return 成功 * @return 成功
*/ */
@Transactional @Transactional
@Override @Override
public ResponseEntity sendBackOutCheck(Integer taskId, Integer userId) { public ResponseEntity sendBackOutCheck(Integer taskId,Integer userId) {
TaskBto taskEntity = taskService.get(taskId); TaskBto taskEntity = taskService.get(taskId);
...@@ -433,7 +412,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -433,7 +412,7 @@ public class SendBackServiceImpl implements SendBackService {
*/ */
SendBackBill billEntity = sendBackBillEntityDao.getOne(taskEntity.getBillId()); SendBackBill billEntity = sendBackBillEntityDao.getOne(taskEntity.getBillId());
List<String> idStringList = Arrays.asList(billEntity.getInvoleDevice().split("x")); List<String> idStringList = Arrays.asList(billEntity.getInvoleDevice().split("x"));
List<String> idListString = idStringList.stream().filter(list2 -> !list2.equals("")).collect(Collectors.toList()); List<String> idListString = idStringList.stream().filter(list2->!list2.equals("")).collect(Collectors.toList());
System.out.println(idListString); System.out.println(idListString);
List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList()); List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
...@@ -449,14 +428,14 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -449,14 +428,14 @@ public class SendBackServiceImpl implements SendBackService {
*/ */
sendBackOutVo.setActualOut(idList.size()); sendBackOutVo.setActualOut(idList.size());
sendBackOutVo.setShouldOut(idList.size()); sendBackOutVo.setShouldOut(idList.size());
List<DeviceLibrary> deviceLibraries = new ArrayList<>(); List<DeviceLibrary> deviceLibraries= new ArrayList<>();
boolean flag = false; boolean flag=false;
for (DeviceLibrary deviceLibrary : deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)) { for (DeviceLibrary deviceLibrary:deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)) {
if (!deviceLibrary.getOwnUnit().equals(deviceLibrary.getLocationUnit())) { if (!deviceLibrary.getOwnUnit().equals(deviceLibrary.getLocationUnit())){
deviceLibrary.setManageStatus(0); deviceLibrary.setManageStatus(0);
sendBackOutVo.setIsNotOutbound(1); sendBackOutVo.setIsNotOutbound(1);
flag = true; flag=true;
} else { }else {
deviceLibrary.setManageStatus(1); deviceLibrary.setManageStatus(1);
} }
deviceLibraries.add(deviceLibrary); deviceLibraries.add(deviceLibrary);
...@@ -471,12 +450,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -471,12 +450,11 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 装备出库发起——专管员A * 装备出库发起——专管员A
*
* @return 成功 * @return 成功
*/ */
@Transactional @Transactional
@Override @Override
public ResponseEntity sendBackOut(Integer taskId, SendBackOutVo sendBackOut, Integer userId) { public ResponseEntity sendBackOut(Integer taskId,SendBackOutVo sendBackOut,Integer userId) {
/* /*
保存出库清单 保存出库清单
*/ */
...@@ -490,7 +468,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -490,7 +468,7 @@ public class SendBackServiceImpl implements SendBackService {
SendBackBill bill = sendBackBillEntityDao.getOne(taskEntity.getBillId()); SendBackBill bill = sendBackBillEntityDao.getOne(taskEntity.getBillId());
bill.setSendBackOut(JSON.toJSONString(sendBackOut)); bill.setSendBackOut(JSON.toJSONString(sendBackOut));
taskService.moveToSpecial(taskEntity, StatusEnum.SEND_BACK_1202, sendBackOut.getReviewerNameId()); taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1202,sendBackOut.getReviewerNameId());
/* /*
...@@ -515,7 +493,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -515,7 +493,7 @@ public class SendBackServiceImpl implements SendBackService {
sendBackBillDetailEntity.setReceiveUserAId(0); sendBackBillDetailEntity.setReceiveUserAId(0);
sendBackBillDetailEntity.setSendCheckDetail(sendBackOut.getReceiveCheckDetail()); sendBackBillDetailEntity.setSendCheckDetail(sendBackOut.getReceiveCheckDetail());
sendBackBillDetailEntity.setSendCheckResult(sendBackOut.getReceiveCheckResult()); sendBackBillDetailEntity.setSendCheckResult(sendBackOut.getReceiveCheckResult());
sendBackBillDetailEntity.setNum("第" + new Date().getYear() + "QT" + taskEntity.getBillId() + "号"); sendBackBillDetailEntity.setNum("第"+new Date().getYear()+"QT"+taskEntity.getBillId()+"号");
SendBackBillDetail backBillDetailEntity = sendBackBillDetailEntityDao.save(sendBackBillDetailEntity); SendBackBillDetail backBillDetailEntity = sendBackBillDetailEntityDao.save(sendBackBillDetailEntity);
bill.setFormId(backBillDetailEntity.getId()); bill.setFormId(backBillDetailEntity.getId());
...@@ -529,12 +507,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -529,12 +507,11 @@ public class SendBackServiceImpl implements SendBackService {
* 1、修改task状态 * 1、修改task状态
* 2、生成清退单详情 * 2、生成清退单详情
* 3、生成入库的Task * 3、生成入库的Task
*
* @return 成功 * @return 成功
*/ */
@Transactional @Transactional
@Override @Override
public ResponseEntity sendBackOutExamine(Integer taskId, Integer userId, Integer type) { public ResponseEntity sendBackOutExamine(Integer taskId,Integer userId,Integer type) {
TaskBto taskEntity = taskService.get(taskId); TaskBto taskEntity = taskService.get(taskId);
Units unit = unitsDao.getOne(taskEntity.getOwnUnit()); Units unit = unitsDao.getOne(taskEntity.getOwnUnit());
...@@ -542,22 +519,17 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -542,22 +519,17 @@ public class SendBackServiceImpl implements SendBackService {
Area area = areaDao.getOne(unit.getAreaId()); Area area = areaDao.getOne(unit.getAreaId());
List<Units> fatherUnit = unitsDao.findByAreaId(area.getFatherId()); List<Units> fatherUnit = unitsDao.findByAreaId(area.getFatherId());
Units father = fatherUnit.get(0); Units father=fatherUnit.get(0);
taskEntity.setOwnUnit(father.getUnitId()); taskEntity.setOwnUnit(father.getUnitId());
SendBackBill sendBackBill = sendBackBillEntityDao.getOne(taskEntity.getBillId()); SendBackBill sendBackBill= sendBackBillEntityDao.getOne(taskEntity.getBillId());
SendBackBillDetail sendBackBillDetail = sendBackBillDetailEntityDao.findSendBackBillDetailById(sendBackBill.getFormId()); List<Integer> idList=stringToList(sendBackBill.getInvoleDevice());
//生成发件单位签章id
Long signId = snowflake.creatNextId();
sendBackBillDetail.setLeftSignatureId(signId.toString());
sendBackBillDetailEntityDao.save(sendBackBillDetail);
List<Integer> idList = stringToList(sendBackBill.getInvoleDevice());
deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList).forEach( deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList).forEach(
deviceLibrary -> { deviceLibrary -> {
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceLibrary.getId(), "清退装备出库等待" + father.getName() + "签收", null); DeviceLogDto deviceLogDto = new DeviceLogDto(deviceLibrary.getId(),"清退装备出库等待"+father.getName()+"签收",null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
); );
taskService.moveToSpecial(taskEntity, StatusEnum.SEND_BACK_1206, 0); taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1206,0);
return ResponseEntity.ok("装配入库申请发送成功"); return ResponseEntity.ok("装配入库申请发送成功");
} }
...@@ -568,12 +540,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -568,12 +540,11 @@ public class SendBackServiceImpl implements SendBackService {
* 1、通过,完结task * 1、通过,完结task
* 2、修改装备的所属地 * 2、修改装备的所属地
* 3、通知fatherTask,清退完成 * 3、通知fatherTask,清退完成
*
* @return 成功 * @return 成功
*/ */
@Transactional @Transactional
@Override @Override
public ResponseEntity sendBackIn(Integer taskId, Integer userId, Integer type) { public ResponseEntity sendBackIn(Integer taskId,Integer userId,Integer type) {
TaskBto taskEntity = taskService.get(taskId); TaskBto taskEntity = taskService.get(taskId);
Units unit = unitsDao.getOne(taskEntity.getOwnUnit()); Units unit = unitsDao.getOne(taskEntity.getOwnUnit());
...@@ -589,15 +560,10 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -589,15 +560,10 @@ public class SendBackServiceImpl implements SendBackService {
SendBackBill bill = sendBackBillEntityDao.getOne(billId); SendBackBill bill = sendBackBillEntityDao.getOne(billId);
bill.setIsComplete(1); bill.setIsComplete(1);
sendBackBillEntityDao.save(bill); sendBackBillEntityDao.save(bill);
//生成收件单位签章id
SendBackBillDetail sendBackBillDetail = sendBackBillDetailEntityDao.findSendBackBillDetailById(bill.getFormId());
Long signId = snowflake.creatNextId();
sendBackBillDetail.setRightSignatureId(signId.toString());
sendBackBillDetailEntityDao.save(sendBackBillDetail);
List<Integer> idList = stringToList(bill.getInvoleDevice()); List<Integer> idList = stringToList(bill.getInvoleDevice());
List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList); List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
for (DeviceLibrary d : deviceList) { for (DeviceLibrary d:deviceList) {
DeviceLogDto deviceLogDto = new DeviceLogDto(d.getId(), "清退装备签收入库完成", null); DeviceLogDto deviceLogDto = new DeviceLogDto(d.getId(),"清退装备签收入库完成",null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
d.setLocationUnit(unit.getName()); d.setLocationUnit(unit.getName());
d.setOwnUnit(unit.getName()); d.setOwnUnit(unit.getName());
...@@ -606,60 +572,58 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -606,60 +572,58 @@ public class SendBackServiceImpl implements SendBackService {
} }
deviceLibraryDao.saveAll(deviceList); deviceLibraryDao.saveAll(deviceList);
s(taskEntity, bill, idList); s(taskEntity,bill,idList);
return ResponseEntity.ok(signId.toString()); return ResponseEntity.ok("装备已入库");
} }
/** /**
* 判断是否全部提交 * 判断是否全部提交
* 全部提交把跟踪业务改为代办 * 全部提交把跟踪业务改为代办
*/ */
private void s(TaskBto taskEntity, SendBackBill bill, List<Integer> idList) { private void s(TaskBto taskEntity,SendBackBill bill,List<Integer> idList){
//父类task //父类task
TaskBto fatherTaskBto = taskService.get(taskEntity.getParentTaskId()); TaskBto fatherTaskBto = taskService.get(taskEntity.getParentTaskId());;
;
SendBackBill fatherBill = sendBackBillEntityDao.getOne(fatherTaskBto.getBillId()); SendBackBill fatherBill = sendBackBillEntityDao.getOne(fatherTaskBto.getBillId());
String send = fatherBill.getSendBackStatistical(); String send=fatherBill.getSendBackStatistical();
SendBackVo sendBackVo = JSONObject.parseObject(send, SendBackVo.class); SendBackVo sendBackVo= JSONObject.parseObject(send,SendBackVo.class);
/* /*
将入库结果反馈给下级,由于两个task使用的是同一个账单,所以数据已反馈 将入库结果反馈给下级,由于两个task使用的是同一个账单,所以数据已反馈
*/ */
SendBackBillDetail sendBackBillDetail = sendBackBillDetailEntityDao.findSendBackBillDetailById(bill.getFormId()); SendBackBillDetail sendBackBillDetail= sendBackBillDetailEntityDao.findSendBackBillDetailById(bill.getFormId());
Units units = unitsDao.findByName(sendBackBillDetail.getSendUnit()); Units units= unitsDao.findByName(sendBackBillDetail.getSendUnit());
Area area = areaDao.findById(units.getAreaId()).get(); Area area= areaDao.findById(units.getAreaId()).get();
updateStatistical(idList, area.getName(), sendBackVo); updateStatistical(idList,area.getName(),sendBackVo);
//查询当前task上级task //查询当前task上级task
//查询当前task上级task所有子task //查询当前task上级task所有子task
List<Task> taskList = taskDao.findAllByParentTaskId(fatherTaskBto.getId()); List<Task> taskList=taskDao.findAllByParentTaskId(fatherTaskBto.getId());
//判断对应的bill是否完成 //判断对应的bill是否完成
List<Integer> integers = taskList.stream().map(Task::getBillId).collect(Collectors.toList()); List<Integer> integers=taskList.stream().map(Task::getBillId).collect(Collectors.toList());
boolean flag = sendBackBillEntityDao.findAllById(integers).stream().allMatch(e -> e.getIsComplete() == 1); boolean flag = sendBackBillEntityDao.findAllById(integers).stream().allMatch(e->e.getIsComplete()==1);
if (flag) { if (flag){
if (fatherTaskBto.getParentTaskId() != null) { if (fatherTaskBto.getParentTaskId()!=null) {
taskService.moveToSpecial(fatherTaskBto, StatusEnum.SEND_BACK_1203, 0); taskService.moveToSpecial(fatherTaskBto, StatusEnum.SEND_BACK_1203, 0);
SendBackBill billEntity = sendBackBillEntityDao.getOne(fatherTaskBto.getBillId()); SendBackBill billEntity = sendBackBillEntityDao.getOne(fatherTaskBto.getBillId());
List<Integer> integerList = findInvoleDevice(billEntity.getInvoleDevice()).stream().map(DeviceLibrary::getId).collect(Collectors.toList()); List<Integer> integerList= findInvoleDevice(billEntity.getInvoleDevice()).stream().map(DeviceLibrary::getId).collect(Collectors.toList());
addExceptionTask(fatherTaskBto.getId(), integerList, fatherTaskBto.getOwnUnit(), 0, fatherBill.getDeadLine()); addExceptionTask(fatherTaskBto.getId(),integerList,fatherTaskBto.getOwnUnit(),0,fatherBill.getDeadLine());
} else { }else {
sendBackVo.setStatus(0); sendBackVo.setStatus(0);
fatherBill.setSendBackStatistical(JSON.toJSONString(sendBackVo)); fatherBill.setSendBackStatistical(JSON.toJSONString(sendBackVo));
sendBackBillEntityDao.save(fatherBill); sendBackBillEntityDao.save(fatherBill);
taskService.moveToSpecial(fatherTaskBto, StatusEnum.SEND_BACK_1201, fatherTaskBto.getCreateUserId()); taskService.moveToSpecial(fatherTaskBto,StatusEnum.SEND_BACK_1201,fatherTaskBto.getCreateUserId());
} }
} }
} }
private List<DeviceLibrary> findInvoleDevice(String involeDevice){
private List<DeviceLibrary> findInvoleDevice(String involeDevice) {
List<String> idStringList = Arrays.asList(involeDevice.split("x")); List<String> idStringList = Arrays.asList(involeDevice.split("x"));
List<String> idListString = idStringList.stream().filter(list2 -> !list2.equals("")).collect(Collectors.toList()); List<String> idListString = idStringList.stream().filter(list2->!list2.equals("")).collect(Collectors.toList());
System.out.println(idListString); System.out.println(idListString);
List<Integer> devIds = idListString.stream().map(Integer::parseInt).collect(Collectors.toList()); List<Integer> devIds = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
...@@ -669,7 +633,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -669,7 +633,6 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 业务详情 * 业务详情
*
* @param taskId taskid * @param taskId taskid
* @return 成功 * @return 成功
*/ */
...@@ -682,7 +645,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -682,7 +645,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
区域对应的Task,方便点击进入下一级 区域对应的Task,方便点击进入下一级
*/ */
HashMap<String, Integer> areaToTaskId = areaToTask(unit, taskEntity); HashMap<String,Integer> areaToTaskId = areaToTask(unit,taskEntity);
/* /*
获取账单信息 获取账单信息
*/ */
...@@ -692,8 +655,8 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -692,8 +655,8 @@ public class SendBackServiceImpl implements SendBackService {
统计单 统计单
*/ */
String send = billEntity.getSendBackStatistical(); String send = billEntity.getSendBackStatistical();
if (send == null || send.equals("null") || send.equals("")) { if(send == null || send.equals("null") || send.equals("")){
if (unit.getLevel() == 2) { if(unit.getLevel() == 2){
SendBackVo sendBackVo = newStatistical(idList, 1, null, true); SendBackVo sendBackVo = newStatistical(idList, 1, null, true);
billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo)); billEntity.setSendBackStatistical(JSON.toJSONString(sendBackVo));
sendBackVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(), UnDeviceDesVo.class)); sendBackVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(), UnDeviceDesVo.class));
...@@ -701,18 +664,18 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -701,18 +664,18 @@ public class SendBackServiceImpl implements SendBackService {
List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values()); List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(sendBackVo.getMap().values());
sendBackVo.setDataList(dataList); sendBackVo.setDataList(dataList);
return ResponseEntity.ok(sendBackVo); return ResponseEntity.ok(sendBackVo);
} else { }else {
return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)); return ResponseEntity.ok(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
} }
} else { }else {
int type = 1; int type = 1;
if (unit.getLevel() == 1) { if(unit.getLevel() == 1){
type = 0; type = 0;
} }
SendBackVo sendBackVo = JSONObject.parseObject(send, new TypeReference<SendBackVo>() { SendBackVo sendBackVo = JSONObject.parseObject(send, new TypeReference<SendBackVo>() {
}); });
SendBackVo backVo = newStatistical(idList, type, sendBackVo, false); SendBackVo backVo = newStatistical(idList, type, sendBackVo, false);
backVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(), UnDeviceDesVo.class)); backVo.setUnDeviceDes(JSONObject.parseObject(billEntity.getExceptionDes(),UnDeviceDesVo.class));
List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(backVo.getMap().values()); List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(backVo.getMap().values());
backVo.setDataList(dataList); backVo.setDataList(dataList);
backVo.setAreaToTaskId(areaToTaskId); backVo.setAreaToTaskId(areaToTaskId);
...@@ -725,7 +688,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -725,7 +688,6 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 业务详情列表查询 * 业务详情列表查询
*
* @param sendBackOutFormVo 查询条件 * @param sendBackOutFormVo 查询条件
* @return 数量和列表 * @return 数量和列表
*/ */
...@@ -740,22 +702,21 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -740,22 +702,21 @@ public class SendBackServiceImpl implements SendBackService {
.build(); .build();
Pageable pageable = PageRequest.of(sendBackOutFormVo.getPage() - 1, sendBackOutFormVo.getSize(), Sort.Direction.DESC, "id"); Pageable pageable = PageRequest.of(sendBackOutFormVo.getPage() - 1, sendBackOutFormVo.getSize(), Sort.Direction.DESC, "id");
List<SendBackBillDetail> list = sendBackBillDetailEntityDao.findAll(specification, pageable).getContent(); List<SendBackBillDetail> list = sendBackBillDetailEntityDao.findAll(specification, pageable).getContent();
for (SendBackBillDetail s : list) { for (SendBackBillDetail s:list) {
String deviceIds = s.getDeviceIds(); String deviceIds = s.getDeviceIds();
String[] idString = deviceIds.split("x"); String[] idString = deviceIds.split("x");
List<String> idStringList = Arrays.asList(idString); List<String> idStringList = Arrays.asList(idString);
List<String> idListString = idStringList.stream().filter(list2 -> !list2.equals("")).collect(Collectors.toList()); List<String> idListString = idStringList.stream().filter(list2->!list2.equals("")).collect(Collectors.toList());
System.out.println(); System.out.println();
List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList()); List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
s.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList)); s.setDeviceLibraryEntities(deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList));
} }
long count = sendBackBillDetailEntityDao.count(specification); long count = sendBackBillDetailEntityDao.count(specification);
return ResponseEntity.ok(new ListVo(count, list)); return ResponseEntity.ok(new ListVo(count,list));
} }
/** /**
* 造数据用 * 造数据用
*
* @param sendBackBillDetailEntity 保存的清退单 * @param sendBackBillDetailEntity 保存的清退单
* @return null * @return null
*/ */
...@@ -769,7 +730,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -769,7 +730,6 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 查看某个型号的装备 * 查看某个型号的装备
*
* @param deviceList 装备list * @param deviceList 装备list
* @return 装备 * @return 装备
*/ */
...@@ -780,7 +740,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -780,7 +740,6 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 保存入库单 * 保存入库单
*
* @param sendBackBillDetailEntity 清退单 * @param sendBackBillDetailEntity 清退单
* @return 成功 * @return 成功
*/ */
...@@ -817,7 +776,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -817,7 +776,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
task 推入 19 task 推入 19
*/ */
taskService.moveToSpecial(taskEntity, StatusEnum.SEND_BACK_1204, sendBackOut.getReviewerNameId()); taskService.moveToSpecial(taskEntity,StatusEnum.SEND_BACK_1204,sendBackOut.getReviewerNameId());
// JobEntity job = jobDao.findByTaskIdAndIsDone(taskEntity.getId(), 0); // JobEntity job = jobDao.findByTaskIdAndIsDone(taskEntity.getId(), 0);
// job.setIsDone(1); // job.setIsDone(1);
// addJob(taskEntity.getId(),taskEntity.getBillStatus(),userId,job,sendBackOut.getReviewerNameId(),0); // addJob(taskEntity.getId(),taskEntity.getBillStatus(),userId,job,sendBackOut.getReviewerNameId(),0);
...@@ -833,7 +792,6 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -833,7 +792,6 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 办结任务 * 办结任务
*
* @param taskId 任务id * @param taskId 任务id
* @return 成功 * @return 成功
*/ */
...@@ -841,56 +799,46 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -841,56 +799,46 @@ public class SendBackServiceImpl implements SendBackService {
public ResponseEntity endTask(Integer taskId) { public ResponseEntity endTask(Integer taskId) {
TaskBto taskEntity = taskService.get(taskId); TaskBto taskEntity = taskService.get(taskId);
taskService.moveToEnd(taskEntity); taskService.moveToEnd(taskEntity);
// taskEntity.setBillStatus(13);
// SendBackBillEntity bill = sendBackBillEntityDao.getOne(taskEntity.getBillId());
// addLog(taskId,stringToList(bill.getInvoleDevice()),"清退成功","");
return ResponseEntity.ok("清退已办结"); return ResponseEntity.ok("清退已办结");
} }
@Override @Override
public ResponseEntity exceptionSelect(Integer task) { public ResponseEntity exceptionSelect(Integer task) {
UnDeviceDesVo unDeviceDesVo = null; UnDeviceDesVo unDeviceDesVo =null;
TaskBto taskBto = taskService.get(task); TaskBto taskBto = taskService.get(task);
SendBackBill sendBackBill = sendBackBillEntityDao.getOne(taskBto.getBillId()); SendBackBill sendBackBill= sendBackBillEntityDao.getOne(taskBto.getBillId());
if (sendBackBill.getExceptionDes() != null) { if (sendBackBill.getExceptionDes()!=null) {
unDeviceDesVo = JSONObject.parseObject(sendBackBill.getExceptionDes(), UnDeviceDesVo.class); unDeviceDesVo = JSONObject.parseObject(sendBackBill.getExceptionDes(), UnDeviceDesVo.class);
} }
List<Integer> idList = stringToList(sendBackBill.getInvoleDevice()); List<Integer> idList=stringToList(sendBackBill.getInvoleDevice());
return ResponseEntity.ok(new AbnormalVo("", null, sendBackBill.getDeadLine(), deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList), unDeviceDesVo)); return ResponseEntity.ok(new AbnormalVo("",null,sendBackBill.getDeadLine(),deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList),unDeviceDesVo));
} }
/** /**
* 新建task * 新建task
*
* @param sendBackVo 初始清退表单 * @param sendBackVo 初始清退表单
* @param idString id集合 * @param idString id集合
*/ */
private TaskBto addTask(int parentTaskId, String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine) { private TaskBto addTask(int parentTaskId, String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine){
/*
一个task,绑定一个账单,账单中存放装备ID和初始化清退单 //一个task,绑定一个账单,账单中存放装备ID和初始化清退单
*/
SendBackBill sendBackBillEntity = new SendBackBill(); SendBackBill sendBackBillEntity = new SendBackBill();
sendBackBillEntity.setSendBackStatistical(sendBackVo); sendBackBillEntity.setSendBackStatistical(sendBackVo);
sendBackBillEntity.setInvoleDevice(idString); sendBackBillEntity.setInvoleDevice(idString);
sendBackBillEntity.setDeadLine(deadLine); sendBackBillEntity.setDeadLine(deadLine);
sendBackBillEntity.setReviewUserId(startUserId); sendBackBillEntity.setReviewUserId(startUserId);
sendBackBillEntity.setTitle("清退账单"); sendBackBillEntity.setTitle("清退账单");
SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity); SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity);
//生成省级及以下的Task
/* List<Integer> integers=new ArrayList<>();
生成省级及以下的Task integers= userDao.findAllByUnitsId(unitId).stream().map(User::getUserId).collect(Collectors.toList());
*/
List<Integer> integers = new ArrayList<>();
integers = userDao.findAllByUnitsId(unitId).stream().map(User::getUserId).collect(Collectors.toList());
integers.add(-1); integers.add(-1);
return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id, "装备清退", parentTaskId, ".", billEntity.getId(), BusinessEnum.SEND_BACK.id, unitId, integers.size() - 1, null, integers)); return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,integers.size()-1,null,integers));
} }
/** /**
* 代办 * 代办
*
* @param parentTaskId * @param parentTaskId
* @param sendBackVo * @param sendBackVo
* @param idString * @param idString
...@@ -899,7 +847,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -899,7 +847,7 @@ public class SendBackServiceImpl implements SendBackService {
* @param deadLine * @param deadLine
* @return * @return
*/ */
private TaskBto addTask1203(int parentTaskId, String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine) { private TaskBto addTask1203(int parentTaskId, String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine){
/* /*
一个task,绑定一个账单,账单中存放装备ID和初始化清退单 一个task,绑定一个账单,账单中存放装备ID和初始化清退单
...@@ -916,7 +864,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -916,7 +864,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
生成省级及以下的Task 生成省级及以下的Task
*/ */
List<Integer> integers = new ArrayList<>(); List<Integer> integers=new ArrayList<>();
integers.add(0); integers.add(0);
/* /*
...@@ -926,20 +874,21 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -926,20 +874,21 @@ public class SendBackServiceImpl implements SendBackService {
// addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0); // addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0);
return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1203.id, "装备清退", parentTaskId, ".", billEntity.getId(), BusinessEnum.SEND_BACK.id, unitId, 0, null, integers)); return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1203.id,"装备清退",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,0,null,integers));
} }
/** /**
* 县生成异常事件 * 县生成异常事件
*
*/ */
private TaskBto addExceptionTask(int parentTaskId, List<Integer> idString, Integer unitId, Integer startUserId, Date deadLine) { private TaskBto addExceptionTask(int parentTaskId, List<Integer> idString, Integer unitId, Integer startUserId, Date deadLine){
/* /*
一个task,绑定一个账单,账单中存放装备ID和初始化清退单 一个task,绑定一个账单,账单中存放装备ID和初始化清退单
*/ */
StringBuffer localIds = new StringBuffer(); StringBuffer localIds =new StringBuffer();
idString.forEach( idString.forEach(
id -> localIds.append("x").append(id) id-> localIds.append("x").append(id)
); );
...@@ -955,7 +904,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -955,7 +904,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
生成省级及以下的Task 生成省级及以下的Task
*/ */
List<Integer> integers = new ArrayList<>(); List<Integer> integers=new ArrayList<>();
integers.add(0); integers.add(0);
/* /*
...@@ -965,17 +914,16 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -965,17 +914,16 @@ public class SendBackServiceImpl implements SendBackService {
// addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0); // addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0);
return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1205.id, "异常装备描述", parentTaskId, ".", billEntity.getId(), BusinessEnum.SEND_BACK.id, unitId, 0, null, integers)); return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1205.id,"异常装备描述",parentTaskId,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,0,null,integers));
} }
/** /**
* 新建task * 新建task
*
* @param sendBackVo 初始清退表单 * @param sendBackVo 初始清退表单
* @param idString id集合 * @param idString id集合
*/ */
private TaskBto addTaskStatus(String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine) { private TaskBto addTaskStatus( String sendBackVo, String idString, Integer unitId, Integer startUserId, Date deadLine){
/* /*
一个task,绑定一个账单,账单中存放装备ID和初始化清退单 一个task,绑定一个账单,账单中存放装备ID和初始化清退单
...@@ -986,40 +934,30 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -986,40 +934,30 @@ public class SendBackServiceImpl implements SendBackService {
sendBackBillEntity.setDeadLine(deadLine); sendBackBillEntity.setDeadLine(deadLine);
sendBackBillEntity.setReviewUserId(startUserId); sendBackBillEntity.setReviewUserId(startUserId);
sendBackBillEntity.setTitle("清退账单"); sendBackBillEntity.setTitle("清退账单");
SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity); SendBackBill billEntity = sendBackBillEntityDao.save(sendBackBillEntity);
/* /*
生成省级及以下的Task 生成省级及以下的Task
*/ */
List<Integer> integers = new ArrayList<>(); List<Integer> integers=new ArrayList<>();
integers.add(startUserId); integers.add(startUserId);
integers.add(-1); integers.add(-1);
/* return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id,"装备清退",null,".",billEntity.getId(), BusinessEnum.SEND_BACK.id,unitId,1,null,integers));
保存省级的task
*/
// addJob(task.getId(),task.getBillStatus(),startUserId,null,0,0);
return taskService.start(new TaskBto(StatusEnum.SEND_BACK_1200.id, "装备清退", null, ".", billEntity.getId(), BusinessEnum.SEND_BACK.id, unitId, 1, null, integers));
} }
/** /**
* 按照需求返回单位和区域的映射关系 * 按照需求返回单位和区域的映射关系
*
* @param type 0:单位-市和省 1:单位-区 * @param type 0:单位-市和省 1:单位-区
* @return * @return
*/ */
private HashMap<String, Area> unitToArea(Integer type) { private HashMap<String,Area> unitToArea(Integer type){
/* /*
查询所有的区域 查询所有的区域
*/ */
HashMap<Integer, Area> areaHashMap = new HashMap<>(); HashMap<Integer,Area> areaHashMap = new HashMap<>();
areaDao.findAll().forEach(area -> areaHashMap.put(area.getId(), area)); areaDao.findAll().forEach(area -> areaHashMap.put(area.getId(),area));
/* /*
查询所有单位 查询所有单位
...@@ -1029,22 +967,22 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1029,22 +967,22 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
单位和区域的映射关系 单位和区域的映射关系
*/ */
HashMap<String, Area> unitToArea = new HashMap<>(); HashMap<String,Area> unitToArea = new HashMap<>();
for (Units unit : units) { for (Units unit:units) {
/* /*
根据等级判断单位的区域 根据等级判断单位的区域
*/ */
Integer level = unit.getLevel(); Integer level = unit.getLevel();
Area localArea = areaHashMap.get(unit.getAreaId()); Area localArea = areaHashMap.get(unit.getAreaId());
if (type == 0 && level > 2) { if(type == 0 && level>2){
/* /*
单位与市的映射关系,区级设备需要找到上级区域; 单位与市的映射关系,区级设备需要找到上级区域;
*/ */
Area fatherArea = areaHashMap.get(localArea.getFatherId()); Area fatherArea = areaHashMap.get(localArea.getFatherId());
unitToArea.put(unit.getName(), fatherArea); unitToArea.put(unit.getName(),fatherArea);
} else { }else {
unitToArea.put(unit.getName(), localArea); unitToArea.put(unit.getName(),localArea);
} }
} }
return unitToArea; return unitToArea;
...@@ -1054,18 +992,18 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1054,18 +992,18 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 修改统计内容 有提交需要修改提交状态 * 修改统计内容 有提交需要修改提交状态
*/ */
private SendBackVo updateStatistical(List<Integer> idList, String areaName, SendBackVo sendBack) { private SendBackVo updateStatistical(List<Integer> idList,String areaName,SendBackVo sendBack){
HashMap<String, HashMap<String, StatisticalVo>> list = sendBack.getMap(); HashMap<String,HashMap<String,StatisticalVo>> list= sendBack.getMap();
HashMap<String, String> map = new HashMap<>(); HashMap<String,String> map=new HashMap<>();
idList.forEach( idList.forEach(
id -> { id -> {
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(id); DeviceLibrary deviceLibrary= deviceLibraryService.getOne(id);
map.put(deviceLibrary.getModel(), ""); map.put(deviceLibrary.getModel(),"");
} }
); );
for (String name : map.keySet()) { for (String name:map.keySet()){
StatisticalVo statisticalVo = list.get(name).get(areaName); StatisticalVo statisticalVo = list.get(name).get(areaName);
statisticalVo.setStatus(3); statisticalVo.setStatus(3);
} }
...@@ -1075,13 +1013,13 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1075,13 +1013,13 @@ public class SendBackServiceImpl implements SendBackService {
/** /**
* 统计表 * 统计表
*/ */
private SendBackVo newStatistical(List<Integer> idList, Integer type, SendBackVo sendBack, boolean first) { private SendBackVo newStatistical(List<Integer> idList,Integer type,SendBackVo sendBack,boolean first){
HashMap<String, HashMap<String, StatisticalVo>> list; HashMap<String,HashMap<String,StatisticalVo>> list;
if (sendBack == null) { if(sendBack == null){
list = new HashMap<>(); list = new HashMap<>();
} else { }else {
list = sendBack.getMap(); list = sendBack.getMap();
} }
/* /*
...@@ -1100,41 +1038,41 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1100,41 +1038,41 @@ public class SendBackServiceImpl implements SendBackService {
List<String> modelList = new ArrayList<>(); List<String> modelList = new ArrayList<>();
List<String> areaList = new ArrayList<>(); List<String> areaList = new ArrayList<>();
for (DeviceLibrary DeviceLibrary : deviceList) { for (DeviceLibrary DeviceLibrary:deviceList) {
//装备型号 //装备型号
String model = DeviceLibrary.getModel(); String model = DeviceLibrary.getModel();
if (!modelList.contains(model)) { if(!modelList.contains(model)){
modelList.add(model); modelList.add(model);
} }
String areaName = unitToArea.get(DeviceLibrary.getOwnUnit()).getName(); String areaName = unitToArea.get(DeviceLibrary.getOwnUnit()).getName();
if (!areaList.contains(areaName)) { if(!areaList.contains(areaName)){
areaList.add(areaName); areaList.add(areaName);
} }
if (!DeviceLibrary.getOwnUnit().equals(DeviceLibrary.getLocationUnit())) { if(!DeviceLibrary.getOwnUnit().equals(DeviceLibrary.getLocationUnit())){
unDevice.add(DeviceLibrary); unDevice.add(DeviceLibrary);
} }
} }
//类型-(区域,统计) //类型-(区域,统计)
HashMap<String, HashMap<String, StatisticalVo>> newList = new HashMap<>(); HashMap<String,HashMap<String,StatisticalVo>> newList = new HashMap<>();
//延迟状态 //延迟状态
int delayStatus = 1; int delayStatus = 1;
if (sendBack == null) { if(sendBack == null){
/* /*
生成一张新的空表 生成一张新的空表
*/ */
for (String model : modelList) { for (String model:modelList) {
HashMap<String, StatisticalVo> areaMap = new HashMap<>(); HashMap<String,StatisticalVo> areaMap = new HashMap<>();
for (String area : areaList) { for ( String area:areaList) {
areaMap.put(area, new StatisticalVo()); areaMap.put(area,new StatisticalVo());
} }
areaMap.put("总数", new StatisticalVo()); areaMap.put("总数",new StatisticalVo());
newList.put(model, areaMap); newList.put(model,areaMap);
} }
} else { }else {
/* /*
初始化旧的表格 初始化旧的表格
*/ */
...@@ -1145,7 +1083,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1145,7 +1083,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
判断是否延期 判断是否延期
*/ */
if (new Date().getTime() > sendBack.getTime().getTime()) { if(new Date().getTime() > sendBack.getTime().getTime()){
delayStatus = 2; delayStatus = 2;
} }
} }
...@@ -1153,12 +1091,12 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1153,12 +1091,12 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
存放区域所对应的idList 存放区域所对应的idList
*/ */
HashMap<String, List<Integer>> areaIdList = new HashMap<>(); HashMap<String,List<Integer>> areaIdList = new HashMap<>();
/* /*
存放型号所对应的idList 存放型号所对应的idList
*/ */
HashMap<String, List<Integer>> modelIdList = new HashMap<>(); HashMap<String,List<Integer>> modelIdList = new HashMap<>();
/* /*
...@@ -1173,19 +1111,19 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1173,19 +1111,19 @@ public class SendBackServiceImpl implements SendBackService {
*/ */
List<Integer> modelIds = modelIdList.getOrDefault(model, new ArrayList<>()); List<Integer> modelIds = modelIdList.getOrDefault(model, new ArrayList<>());
modelIds.add(d.getId()); modelIds.add(d.getId());
modelIdList.put(model, modelIds); modelIdList.put(model,modelIds);
/* /*
按区域归类 按区域归类
*/ */
List<Integer> areaIds = areaIdList.getOrDefault(areaName, new ArrayList<>()); List<Integer> areaIds = areaIdList.getOrDefault(areaName, new ArrayList<>());
areaIds.add(d.getId()); areaIds.add(d.getId());
areaIdList.put(areaName, areaIds); areaIdList.put(areaName,areaIds);
StatisticalVo statisticalVo = newList.get(model).get(areaName); StatisticalVo statisticalVo = newList.get(model).get(areaName);
if (statisticalVo != null) { if (statisticalVo!=null) {
statisticalVo.setValCount(statisticalVo.getValCount() + 1); statisticalVo.setValCount(statisticalVo.getValCount() + 1);
if (first) { if (first) {
...@@ -1199,21 +1137,22 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1199,21 +1137,22 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
存放总数和名字 存放总数和名字
*/ */
if (first) { if(first){
StatisticalVo all = newList.get(model).getOrDefault("总数", new StatisticalVo()); StatisticalVo all = newList.get(model).getOrDefault("总数",new StatisticalVo());
all.setAllCount(all.getAllCount() + 1); all.setAllCount(all.getAllCount() + 1);
newList.get(model).put("总数", all); newList.get(model).put("总数",all);
StatisticalVo name = newList.get(model).getOrDefault("名称", new StatisticalVo()); StatisticalVo name = newList.get(model).getOrDefault("名称",new StatisticalVo());
name.setName(d.getName()); name.setName(d.getName());
newList.get(model).put("名称", name); newList.get(model).put("名称",name);
StatisticalVo deviceModel = newList.get(model).getOrDefault("型号", new StatisticalVo()); StatisticalVo deviceModel = newList.get(model).getOrDefault("型号",new StatisticalVo());
deviceModel.setName(model); deviceModel.setName(model);
newList.get(model).put("型号", deviceModel); newList.get(model).put("型号",deviceModel);
} }
} }
/* /*
返回的对象 返回的对象
...@@ -1226,19 +1165,19 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1226,19 +1165,19 @@ public class SendBackServiceImpl implements SendBackService {
int allStatus = 0; int allStatus = 0;
Set<String> strings = newList.keySet(); Set<String> strings = newList.keySet();
// List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>(); // List<HashMap<String, StatisticalVo>> dataList = new ArrayList<>();
for (String s : strings) { for (String s:strings) {
HashMap<String, StatisticalVo> stringStatisticalVoHashMap = newList.get(s); HashMap<String, StatisticalVo> stringStatisticalVoHashMap = newList.get(s);
List<StatisticalVo> statisticalVos = new ArrayList<>(stringStatisticalVoHashMap.values()); List<StatisticalVo> statisticalVos = new ArrayList<>(stringStatisticalVoHashMap.values());
for (StatisticalVo statisticalVo : statisticalVos) { for (StatisticalVo statisticalVo:statisticalVos) {
Integer status = statisticalVo.status(delayStatus); Integer status = statisticalVo.status(delayStatus);
if (status == 1) { if(status == 1){
allStatus = 1; allStatus = 1;
} }
} }
// dataList.add(stringStatisticalVoHashMap); // dataList.add(stringStatisticalVoHashMap);
} }
if (sendBack == null) { if (sendBack==null) {
SendBackVo sendBackVo = new SendBackVo(); SendBackVo sendBackVo = new SendBackVo();
sendBackVo.setHeader(areaList); sendBackVo.setHeader(areaList);
sendBackVo.setDeviceIdList(idList); sendBackVo.setDeviceIdList(idList);
...@@ -1247,11 +1186,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1247,11 +1186,11 @@ public class SendBackServiceImpl implements SendBackService {
sendBackVo.setModelToIds(modelIdList); sendBackVo.setModelToIds(modelIdList);
sendBackVo.setStatus(allStatus); sendBackVo.setStatus(allStatus);
sendBackVo.setMap(newList); sendBackVo.setMap(newList);
return sendBackVo; return sendBackVo;
} else { }else {
sendBack.setStatus(allStatus); sendBack.setStatus(allStatus);
sendBack.setMap(newList); sendBack.setMap(newList);
return sendBack; return sendBack;
} }
} }
...@@ -1260,7 +1199,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1260,7 +1199,7 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
计算各单位的清退装备,市的清退装备包括市本级和下属单位 计算各单位的清退装备,市的清退装备包括市本级和下属单位
*/ */
private HashMap<Integer, StringBuffer> addTaskById(List<Integer> idList, Integer parentId, Integer userId, Date time, String name) { private HashMap<Integer,StringBuffer> addTaskById(List<Integer> idList,Integer parentId,Integer userId,Date time,String name){
List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList); List<DeviceLibrary> deviceList = deviceLibraryDao.getDeviceLibraryEntitiesByIdIn(idList);
...@@ -1272,36 +1211,36 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1272,36 +1211,36 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
存放各单位需清退的装备id,用于生成task 存放各单位需清退的装备id,用于生成task
*/ */
HashMap<Integer, StringBuffer> unitDeviceIds = new HashMap<>(); HashMap<Integer,StringBuffer> unitDeviceIds = new HashMap<>();
//区县 //区县
HashMap<Integer, Integer> county = new HashMap<>(); HashMap<Integer,Integer> county=new HashMap<>();
//市 //市
HashMap<Integer, Integer> city = new HashMap<>(); HashMap<Integer,Integer> city=new HashMap<>();
//区县不在库装备存储 //区县不在库装备存储
HashMap<Integer, List<Integer>> cityNoLibrary = new HashMap<>(); HashMap<Integer,List<Integer>> cityNoLibrary=new HashMap<>();
//区县不在库装备存储 //区县不在库装备存储
HashMap<Integer, List<Integer>> countyNoLibrary = new HashMap<>(); HashMap<Integer,List<Integer>> countyNoLibrary=new HashMap<>();
/* /*
存放各单位的装备集合 存放各单位的装备集合
*/ */
HashMap<Integer, List<Integer>> unitDevices = new HashMap<>(); HashMap<Integer,List<Integer>> unitDevices = new HashMap<>();
for (DeviceLibrary device : deviceList) { for (DeviceLibrary device:deviceList) {
Units unit = unitsDao.findByName(device.getOwnUnit()); Units unit = unitsDao.findByName(device.getOwnUnit());
Integer level = unit.getLevel(); Integer level = unit.getLevel();
/* /*
省级装备不参与分类 省级装备不参与分类
*/ */
if (level == 1) { if(level == 1){
List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>()); List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
deviceIds.add(device.getId()); deviceIds.add(device.getId());
unitDevices.put(0, deviceIds); unitDevices.put(0,deviceIds);
} else if (level == 2) { }else if (level == 2) {
List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>()); List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
deviceIds.add(device.getId()); deviceIds.add(device.getId());
unitDevices.put(unit.getUnitId(), deviceIds); unitDevices.put(unit.getUnitId(), deviceIds);
...@@ -1317,8 +1256,8 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1317,8 +1256,8 @@ public class SendBackServiceImpl implements SendBackService {
StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer()); StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer());
localIds.append("x").append(device.getId()); localIds.append("x").append(device.getId());
unitDeviceIds.put(unit.getUnitId(), localIds); unitDeviceIds.put(unit.getUnitId(), localIds);
city.put(unit.getUnitId(), 0); city.put(unit.getUnitId(),0);
} else if (level == 3) { }else if(level == 3){
List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>()); List<Integer> deviceIds = unitDevices.getOrDefault(unit.getUnitId(), new ArrayList<>());
deviceIds.add(device.getId()); deviceIds.add(device.getId());
...@@ -1336,7 +1275,7 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1336,7 +1275,7 @@ public class SendBackServiceImpl implements SendBackService {
StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer()); StringBuffer localIds = unitDeviceIds.getOrDefault(unit.getUnitId(), new StringBuffer());
localIds.append("x").append(device.getId()); localIds.append("x").append(device.getId());
unitDeviceIds.put(unit.getUnitId(), localIds); unitDeviceIds.put(unit.getUnitId(), localIds);
county.put(unit.getUnitId(), 0); county.put(unit.getUnitId(),0);
/* /*
所属市 所属市
*/ */
...@@ -1345,13 +1284,13 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1345,13 +1284,13 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
将装备加入上属的市 将装备加入上属的市
*/ */
StringBuffer parentIds = unitDeviceIds.getOrDefault(parentUnit.getUnitId(), new StringBuffer()); StringBuffer parentIds = unitDeviceIds.getOrDefault(parentUnit.getUnitId(),new StringBuffer());
parentIds.append("x").append(device.getId()); parentIds.append("x").append(device.getId());
unitDeviceIds.put(parentUnit.getUnitId(), parentIds); unitDeviceIds.put(parentUnit.getUnitId(),parentIds);
if (city.containsKey(parentUnit.getUnitId())) { if (city.containsKey(parentUnit.getUnitId())){
city.put(parentUnit.getUnitId(), 1); city.put(parentUnit.getUnitId(),1);
} else { }else {
city.put(parentUnit.getUnitId(), 2); city.put(parentUnit.getUnitId(),2);
} }
} }
...@@ -1359,34 +1298,34 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1359,34 +1298,34 @@ public class SendBackServiceImpl implements SendBackService {
// Set<Integer> keySet = unitDeviceIds.keySet(); // Set<Integer> keySet = unitDeviceIds.keySet();
HashMap<Integer, Integer> unitsAndTaskid = new HashMap<>(); HashMap<Integer,Integer> unitsAndTaskid=new HashMap<>();
for (Integer key : city.keySet()) { for (Integer key:city.keySet()){
StringBuffer ids = unitDeviceIds.get(key); StringBuffer ids = unitDeviceIds.get(key);
if (city.get(key) == 1) { if (city.get(key)==1) {
SendBackVo sendBack = newStatistical(stringToList(ids.toString()), 1, null, true); SendBackVo sendBack = newStatistical(stringToList(ids.toString()), 1,null,true);
sendBack.setName(name); sendBack.setName(name);
sendBack.setTime(time); sendBack.setTime(time);
sendBack.setDeviceIdList(null); sendBack.setDeviceIdList(null);
TaskBto taskBto = addTask(parentId, JSON.toJSONString(sendBack), ids.toString(), key, userId, time); TaskBto taskBto=addTask(parentId, JSON.toJSONString(sendBack), ids.toString(), key, userId, time);
unitsAndTaskid.put(key, taskBto.getId()); unitsAndTaskid.put(key,taskBto.getId());
} else { }else {
TaskBto taskBto = addTask1203(parentId, null, ids.toString(), key, userId, time); TaskBto taskBto= addTask1203(parentId, null, ids.toString(), key, userId, time);
unitsAndTaskid.put(key, taskBto.getId()); unitsAndTaskid.put(key,taskBto.getId());
if (cityNoLibrary.containsKey(key)) { if (cityNoLibrary.containsKey(key)){
addExceptionTask(taskBto.getId(), cityNoLibrary.get(key), key, userId, time); addExceptionTask(taskBto.getId(),cityNoLibrary.get(key),key,userId,time);
}
} }
}
} }
for (Integer key : county.keySet()) { for (Integer key:county.keySet()){
StringBuffer ids = unitDeviceIds.get(key); StringBuffer ids = unitDeviceIds.get(key);
Units units = unitsDao.findById(key).get(); Units units = unitsDao.findById(key).get();
Area parentArea = unitToArea.get(units.getName()); Area parentArea = unitToArea.get(units.getName());
Units parentUnit = unitsDao.findByAreaIdAndLevel(parentArea.getId(), 2); Units parentUnit = unitsDao.findByAreaIdAndLevel(parentArea.getId(), 2);
TaskBto taskBto = addTask1203(unitsAndTaskid.get(parentUnit.getUnitId()), null, ids.toString(), key, userId, time); TaskBto taskBto= addTask1203(unitsAndTaskid.get(parentUnit.getUnitId()), null, ids.toString(), key, userId, time);
if (countyNoLibrary.containsKey(key)) { if (countyNoLibrary.containsKey(key)){
addExceptionTask(taskBto.getId(), countyNoLibrary.get(key), key, userId, time); addExceptionTask(taskBto.getId(),countyNoLibrary.get(key),key,userId,time);
} }
} }
...@@ -1398,10 +1337,10 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1398,10 +1337,10 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
x1x2x1 -> [1,2,3] 装备id组合字段 转换成id集合 x1x2x1 -> [1,2,3] 装备id组合字段 转换成id集合
*/ */
private List<Integer> stringToList(String idString) { private List<Integer> stringToList(String idString){
String[] ids = idString.split("x"); String[] ids = idString.split("x");
List<String> idStringList = Arrays.asList(ids); List<String> idStringList = Arrays.asList(ids);
List<String> idListString = idStringList.stream().filter(list2 -> !list2.equals("")).collect(Collectors.toList()); List<String> idListString = idStringList.stream().filter(list2->!list2.equals("")).collect(Collectors.toList());
List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList()); List<Integer> idList = idListString.stream().map(Integer::parseInt).collect(Collectors.toList());
return idList; return idList;
} }
...@@ -1409,15 +1348,15 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1409,15 +1348,15 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
区域名对应的任务id,方便进入下一级 区域名对应的任务id,方便进入下一级
*/ */
private HashMap<String, Integer> areaToTask(Units unit, TaskBto taskBto) { private HashMap<String,Integer> areaToTask(Units unit,TaskBto taskBto){
HashMap<String, Integer> areaToTaskId = new HashMap<>(); HashMap<String,Integer> areaToTaskId = new HashMap<>();
List<TaskBto> kidTask = new ArrayList<>(); List<TaskBto> kidTask = new ArrayList<>();
if (unit.getLevel() == 1) { if(unit.getLevel() == 1){
/* /*
省级的业务详情 省级的业务详情
*/ */
kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList()); kidTask = taskDao.findTaskEntitiesByParentTaskId(taskBto.getId()).stream().map(Task::parse2Bto).collect(Collectors.toList());
} else if (unit.getLevel() == 2) { }else if(unit.getLevel() == 2){
/* /*
市级的业务详情 市级的业务详情
*/ */
...@@ -1426,11 +1365,11 @@ public class SendBackServiceImpl implements SendBackService { ...@@ -1426,11 +1365,11 @@ public class SendBackServiceImpl implements SendBackService {
/* /*
区域名和任务id的映射,方便进入下一级 区域名和任务id的映射,方便进入下一级
*/ */
for (TaskBto t : kidTask) { for (TaskBto t:kidTask) {
Integer ownUnit = t.getOwnUnit(); Integer ownUnit = t.getOwnUnit();
Units units = unitsDao.getOne(ownUnit); Units units = unitsDao.getOne(ownUnit);
Area area = areaDao.getOne(units.getAreaId()); Area area = areaDao.getOne(units.getAreaId());
areaToTaskId.put(area.getName(), t.getId()); areaToTaskId.put(area.getName(),t.getId());
} }
return areaToTaskId; return areaToTaskId;
} }
......
...@@ -40,6 +40,9 @@ public class MyUserDetailsServiceImpl implements UserDetailsService { ...@@ -40,6 +40,9 @@ public class MyUserDetailsServiceImpl implements UserDetailsService {
if (user == null) { if (user == null) {
throw new UsernameNotFoundException("用户名不正确"); throw new UsernameNotFoundException("用户名不正确");
} else { } else {
if (user.getIsDel()==1){
throw new UsernameNotFoundException("账号已冻结,请联系管理人员");
}
List<UserRole> userRoles = userRoleService.findByUserId(user.getUserId()); List<UserRole> userRoles = userRoleService.findByUserId(user.getUserId());
List<Integer> roleIds = new ArrayList<>(); List<Integer> roleIds = new ArrayList<>();
if (userRoles != null) { if (userRoles != null) {
......
package com.tykj.dev.device.user.subject.controller; package com.tykj.dev.device.user.subject.controller;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.service.UnitsService; import com.tykj.dev.device.user.subject.service.UnitsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
/** /**
* @author zjm * @author zjm
...@@ -46,8 +49,8 @@ public class UnitsController { ...@@ -46,8 +49,8 @@ public class UnitsController {
@GetMapping(value = "/area") @GetMapping(value = "/area")
@ApiOperation(value = "根据等级查询对应等级的单位集合", notes = "单位集合") @ApiOperation(value = "根据等级查询对应等级的单位集合", notes = "单位集合")
public ResponseEntity deleteUser() { public ResponseEntity selectOrganizationUnits(@ApiIgnore @AuthenticationPrincipal SecurityUser securityUser) {
return ResponseEntity.ok(unitsService.findListAreaUnitsVo()); return ResponseEntity.ok(unitsService.findListAreaUnitsVo(securityUser));
} }
......
...@@ -31,7 +31,6 @@ public interface MgrcertService { ...@@ -31,7 +31,6 @@ public interface MgrcertService {
/** /**
* 根据用户id查询用户对应对证书 * 根据用户id查询用户对应对证书
*
* @param userId 用户id * @param userId 用户id
* @return 证书信息 * @return 证书信息
*/ */
......
...@@ -3,6 +3,7 @@ package com.tykj.dev.device.user.subject.service; ...@@ -3,6 +3,7 @@ package com.tykj.dev.device.user.subject.service;
import com.tykj.dev.device.user.base.ret.AreaVo; import com.tykj.dev.device.user.base.ret.AreaVo;
import com.tykj.dev.device.user.base.ret.UnitsTrainVo; import com.tykj.dev.device.user.base.ret.UnitsTrainVo;
import com.tykj.dev.device.user.base.ret.UnitsVo; import com.tykj.dev.device.user.base.ret.UnitsVo;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.Units; import com.tykj.dev.device.user.subject.entity.Units;
import java.util.List; import java.util.List;
...@@ -20,7 +21,7 @@ public interface UnitsService extends PublicService<Units> { ...@@ -20,7 +21,7 @@ public interface UnitsService extends PublicService<Units> {
List<Units> findListById(Integer leven); List<Units> findListById(Integer leven);
List<AreaVo> findListAreaUnitsVo(); List<AreaVo> findListAreaUnitsVo(SecurityUser securityUser);
List<Units> findListlevenGreaterThanEqual(Integer leven); List<Units> findListlevenGreaterThanEqual(Integer leven);
......
...@@ -6,6 +6,7 @@ import com.tykj.dev.device.user.base.ret.UnitsVo; ...@@ -6,6 +6,7 @@ import com.tykj.dev.device.user.base.ret.UnitsVo;
import com.tykj.dev.device.user.subject.dao.AreaDao; import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao; import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.entity.Area; import com.tykj.dev.device.user.subject.entity.Area;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.device.user.subject.entity.Units; import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.device.user.subject.service.UnitsService; import com.tykj.dev.device.user.subject.service.UnitsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -29,7 +30,6 @@ public class UnitsServiceImpl implements UnitsService { ...@@ -29,7 +30,6 @@ public class UnitsServiceImpl implements UnitsService {
UnitsDao unitsDao; UnitsDao unitsDao;
@Autowired @Autowired
AreaDao areaDao; AreaDao areaDao;
@Override @Override
public Units findById(Integer unitId) { public Units findById(Integer unitId) {
Optional<Units> unit = unitsDao.findById(unitId); Optional<Units> unit = unitsDao.findById(unitId);
...@@ -42,23 +42,53 @@ public class UnitsServiceImpl implements UnitsService { ...@@ -42,23 +42,53 @@ public class UnitsServiceImpl implements UnitsService {
} }
@Override @Override
public List<AreaVo> findListAreaUnitsVo() { public List<AreaVo> findListAreaUnitsVo(SecurityUser securityUser) {
List<AreaVo> areaVos = new ArrayList<>(); List<AreaVo> areaVos=new ArrayList<>();
//查询当前登入用户所属单位 的区域
List<Area> list = areaDao.findAll(); Integer areaId=securityUser.getCurrentUserInfo().getUnits().getAreaId();
int i = 0; Area belongsArea= areaDao.findById(areaId).get();
if (belongsArea.getType()==1){
for (Area area : list) { int i=10000;
AreaVo areaVo = area.toVo(); AreaVo areaVo = belongsArea.toVo();
areaVo.setFrontEnd(i++); areaVo.setFrontEnd(i++);
List<UnitsVo> unitsList = unitsDao.findAllByAreaId(area.getId()).stream().map(Units::toVo).collect(Collectors.toList()); List<UnitsVo> unitsList = unitsDao.findAllByAreaId(belongsArea.getId()).stream().map(Units::toVo).collect(Collectors.toList());
for (UnitsVo unitsVo : unitsList) {
unitsVo.setFrontEnd(i++);
}
areaVo.setUnits(unitsList);
areaVos.add(areaVo);
}
List<Area> areas= areaDao.findAllByFatherId(areaId);
if (areas.size()!=0) {
areas.forEach(area -> {
int i = 1;
AreaVo areaVo = area.toVo();
areaVo.setFrontEnd(i++);
List<UnitsVo> unitsList = unitsDao.findAllByAreaId(area.getId()).stream().map(Units::toVo).collect(Collectors.toList());
List<Area> countys = areaDao.findAllByFatherId(areaId);
if (countys != null && countys.size() != 0) {
List<UnitsVo> countyUnitsList = unitsDao.findAllByAreaId(area.getId()).stream().map(Units::toVo).collect(Collectors.toList());
unitsList.addAll(countyUnitsList);
}
for (UnitsVo unitsVo : unitsList) {
unitsVo.setFrontEnd(i++);
}
areaVo.setUnits(unitsList);
areaVos.add(areaVo);
});
}else {
int i=0;
AreaVo areaVo = belongsArea.toVo();
areaVo.setFrontEnd(i++);
List<UnitsVo> unitsList = unitsDao.findAllByAreaId(belongsArea.getId()).stream().map(Units::toVo).collect(Collectors.toList());
for (UnitsVo unitsVo : unitsList) { for (UnitsVo unitsVo : unitsList) {
unitsVo.setFrontEnd(i++); unitsVo.setFrontEnd(i++);
} }
areaVo.setUnits(unitsList); areaVo.setUnits(unitsList);
areaVos.add(areaVo); areaVos.add(areaVo);
} }
//查询区域下所有的区域
//根据区域查看
return areaVos; return areaVos;
} }
...@@ -70,17 +100,17 @@ public class UnitsServiceImpl implements UnitsService { ...@@ -70,17 +100,17 @@ public class UnitsServiceImpl implements UnitsService {
@Override @Override
public List<Integer> findListSubordinateId(Integer unitsId) { public List<Integer> findListSubordinateId(Integer unitsId) {
Integer areaId = unitsDao.findById(unitsId).get().getAreaId(); Integer areaId = unitsDao.findById(unitsId).get().getAreaId();
List<Integer> areaIds = areaDao.findAllByFatherId(areaId).stream().map(Area::getId).collect(Collectors.toList()); List<Integer> areaIds=areaDao.findAllByFatherId(areaId).stream().map(Area::getId).collect(Collectors.toList());
return unitsDao.findAllByAreaIdIn(areaIds).stream().map(Units::getUnitId).collect(Collectors.toList()); return unitsDao.findAllByAreaIdIn(areaIds).stream().map(Units::getUnitId).collect(Collectors.toList());
} }
@Override @Override
public List<UnitsVo> findListVoSubordinateAreaId(Integer areaId) { public List<UnitsVo> findListVoSubordinateAreaId(Integer areaId) {
List<UnitsVo> unitsVos = new ArrayList<>(); List<UnitsVo> unitsVos=new ArrayList<>();
List<Integer> areaIds = areaDao.findAllByFatherId(areaId).stream().map(Area::getId).collect(Collectors.toList()); List<Integer> areaIds=areaDao.findAllByFatherId(areaId).stream().map(Area::getId).collect(Collectors.toList());
if (areaIds.size() != 0) { if (areaIds.size() != 0) {
unitsVos = unitsDao.findAllByAreaIdIn(areaIds).stream().map(Units::toVo).collect(Collectors.toList()); unitsVos= unitsDao.findAllByAreaIdIn(areaIds).stream().map(Units::toVo).collect(Collectors.toList());
} }
return unitsVos; return unitsVos;
} }
...@@ -93,20 +123,20 @@ public class UnitsServiceImpl implements UnitsService { ...@@ -93,20 +123,20 @@ public class UnitsServiceImpl implements UnitsService {
@Override @Override
public List<UnitsTrainVo> findListUnitsTrainVo(Integer unitsId) { public List<UnitsTrainVo> findListUnitsTrainVo(Integer unitsId) {
Integer areaId = unitsDao.findById(unitsId).get().getAreaId(); Integer areaId = unitsDao.findById(unitsId).get().getAreaId();
List<Integer> areaIds = areaDao.findAllByFatherId(areaId).stream().map(Area::getId).collect(Collectors.toList()); List<Integer> areaIds=areaDao.findAllByFatherId(areaId).stream().map(Area::getId).collect(Collectors.toList());
return unitsDao.findAllByAreaIdIn(areaIds).stream().map(Units::toUnitsTrainVo).collect(Collectors.toList()); return unitsDao.findAllByAreaIdIn(areaIds).stream().map(Units::toUnitsTrainVo).collect(Collectors.toList());
} }
@Override @Override
public List<Integer> findSuperiorByunitsId(Integer unitsId) { public List<Integer> findSuperiorByunitsId(Integer unitsId) {
Area area = areaDao.findById(this.findById(unitsId).getAreaId()).get(); Area area= areaDao.findById(this.findById(unitsId).getAreaId()).get();
return unitsDao.findAllByAreaId(area.getFatherId()).stream().map(Units::getUnitId).collect(Collectors.toList()); return unitsDao.findAllByAreaId(area.getFatherId()).stream().map(Units::getUnitId).collect(Collectors.toList());
} }
@Override @Override
public Units findByAreaId(Integer unitsId) { public Units findByAreaId(Integer unitsId) {
return unitsDao.findAllByAreaId(areaDao.findById(findById(unitsId).getAreaId()).get().getFatherId()).get(0); return unitsDao.findAllByAreaId(areaDao.findById(findById(unitsId).getAreaId()).get().getFatherId()).get(0);
} }
......
...@@ -39,6 +39,10 @@ public class UserServiceImpl implements UserService { ...@@ -39,6 +39,10 @@ public class UserServiceImpl implements UserService {
public User save(User user) { public User save(User user) {
String encode = bCryptPasswordEncoder.encode("qwer1234"); String encode = bCryptPasswordEncoder.encode("qwer1234");
user.setPassword(encode); user.setPassword(encode);
Units units = unitsService.findById(user.getUnitsId());
return userDao.save(user); return userDao.save(user);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论