提交 a5677603 authored 作者: zhoushaopan's avatar zhoushaopan

feat(配套模块,阅知模块): 解决了市可以看到省的配套装备数量,配发阅知修改

解决了市可以看到省的配套装备数量,配发阅知修改
上级 4cf3bd67
......@@ -40,6 +40,7 @@ import com.tykj.dev.socket.MyWebSocket;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
......@@ -363,7 +364,12 @@ public class AllotBillController {
// messageService.add(messageBto);
// }
//给同单位专管员和收件单位专管员推阅知
MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "发起配发业务:" + MessageFormatUtil.spellTwoWicket(allotBillEntity.getSendUnit(),allotBillEntity.getReceiveUnit()), idList, 1);
// MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "发起配发业务:" + MessageFormatUtil.spellTwoWicket(allotBillEntity.getSendUnit(),allotBillEntity.getReceiveUnit()), idList, 1);
List<String> collect = allotBillSaveVo.getScriptSaveVos().stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList());
MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "发起配发出库:" +
MessageFormatUtil.spellTwoWicket(allotBillEntity.getSendUnit(),allotBillEntity.getReceiveUnit())+
"【型号:"+String.join(",",collect)+
"共"+allotBillSaveVo.getAllotCount()+"件装备】", idList, 1);
// MessageBto messageBto = new MessageBto(saveEntity.getId(), saveEntity.getBusinessType(), "对" + userPublicService.getAreaNameByUnitName(allotBillEntity.getReceiveUnit()) + "发起配发", idList, 1);
messageService.add(messageBto);
log.info("[配发模块]:" + allotBillEntity.getSendUnit() + "对" + allotBillEntity.getReceiveUnit() + "发起配发");
......@@ -501,9 +507,18 @@ public class AllotBillController {
messageService.add(messageBto);
}
//根据status判断是否业务完结,发送不同的阅知message
String message = allotReceiveVo.getStatus() == 0 ? "办结配发业务:" :"接收配发装备:";
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), message+MessageFormatUtil.spellTwoWicket(allotBillEntity.getSendUnit(),allotBillEntity.getReceiveUnit()), ids, 1);
messageService.add(messageBto);
// String message = allotReceiveVo.getStatus() == 0 ? "办结配发业务:" :"接收配发装备:";
String message = allotReceiveVo.getStatus() == 0 ? "办结配发业务:" :"接收配发入库:";
if (allotReceiveVo.getStatus() ==0){
// MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(), message+MessageFormatUtil.spellTwoWicket(allotBillEntity.getSendUnit(),allotBillEntity.getReceiveUnit()), ids, 1);
List<ScriptSaveVo> scriptSaveVos = JacksonUtil.readValue(allotBillEntity.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {});
List<String> collect = scriptSaveVos.stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList());
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(),
message+MessageFormatUtil.spellTwoWicket(allotBillEntity.getSendUnit(),allotBillEntity.getReceiveUnit())
+"【型号:"+String.join(",",collect)+
"共"+allotReceiveVo.getReceiveCount()+"件装备】", ids, 1);
messageService.add(messageBto);
}
log.info("[配发模块]:接收并发起入库");
myWebSocket.sendMessage1();
return ResponseEntity.ok("配发接收入库");
......@@ -718,9 +733,16 @@ public class AllotBillController {
.map(User::getUserId)
.collect(Collectors.toList()));
String content = "发起配发业务已办结";
// String content = "发起配发业务已办结";
// MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(),
// content, ids, 1);
String message = "接收配发入库";
List<ScriptSaveVo> scriptSaveVos = JacksonUtil.readValue(allotBill.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {});
List<String> collect = scriptSaveVos.stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList());
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(),
content, ids, 1);
message+MessageFormatUtil.spellTwoWicket(allotBill.getSendUnit(),allotBill.getReceiveUnit())
+"【型号:"+String.join(",",collect)+
"共"+allotBill.getReceiveCount()+"件装备】", ids, 1);
messageService.add(messageBto);
return ResponseEntity.ok("上传成功");
}
......@@ -805,7 +827,13 @@ public class AllotBillController {
// String content = allotBill.getReceiveUnit()+"单位的配发业务已办结";
String content = "办结配发业务";
// MessageBto messageBto = new MessageBto(taskBto.getParentTaskId(), taskBto.getBusinessType(), "业务办结", userIds, 1);
MessageBto messageBto = new MessageBto(taskBto.getParentTaskId(), taskBto.getBusinessType(), content+MessageFormatUtil.spellTwoWicket(allotBill.getSendUnit(),allotBill.getReceiveUnit()), userIds, 1);
List<ScriptSaveVo> scriptSaveVos = JacksonUtil.readValue(allotBill.getScriptJson(), new TypeReference<List<ScriptSaveVo>>() {});
List<String> collect = scriptSaveVos.stream().map(ScriptSaveVo::getModel).distinct().collect(Collectors.toList());
MessageBto messageBto = new MessageBto(taskBto.getId(), taskBto.getBusinessType(),
content+MessageFormatUtil.spellTwoWicket(allotBill.getSendUnit(),allotBill.getReceiveUnit())
+"【型号:"+String.join(",",collect)+
"共"+allotBill.getAllotedCount()+"件装备】", ids, 1);
messageService.add(messageBto);
return ResponseEntity.ok("OK");
}
......
......@@ -460,6 +460,7 @@ public class MatchingDeviceController {
DeviceLogDto deviceLogDto = new DeviceLogDto(1, matchingDeviceEditVo.getMatchingDeviceId(), remark, null,null);
deviceLogService.addLog(deviceLogDto);
m.setCreateUnit(matchingDeviceEditVo.getCreateUnit());
m.setCreateUnitId(matchingDeviceEditVo.getCreateUnitId());
}
if (matchingDeviceEditVo.getLifeStatus() != null && !m.getLifeStatus().equals(matchingDeviceEditVo.getLifeStatus())) {
//添加设备日志
......
......@@ -13,4 +13,6 @@ public interface MatchingDeviceLibraryDao extends JpaRepository<MatchingDeviceLi
List<MatchingDeviceLibrary> findAllByModel(String model);
List<MatchingDeviceLibrary> findAllByCreateUnitId(Integer unitId);
}
......@@ -136,12 +136,17 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
//获取区域等级
Integer selectLevel = userPublicService.getArea(selectAreaId).getType();
//获取区域下所有单位名称
List<String> units = userPublicService.findAllUnitNameByAreaId(selectAreaId);
// List<String> units = userPublicService.findAllUnitNameByAreaId(selectAreaId);
List<Integer> units = userPublicService.findAllUnitIdByAreaId(selectAreaId);
//如果是市或县,筛选出创建单位在units中的设备
if (selectLevel == 3 || selectLevel == 2) {
// List<MatchingDeviceLibrary> resultList = matchingDeviceLibraryDao.findAll(getPredicate(matchingDeviceSelectVo).build())
// .stream()
// .filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnit()))
// .collect(Collectors.toList());
List<MatchingDeviceLibrary> resultList = matchingDeviceLibraryDao.findAll(getPredicate(matchingDeviceSelectVo).build())
.stream()
.filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnit()))
.filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnitId()))
.collect(Collectors.toList());
// List<MatchingDeviceLibrary> resultList = matchingDeviceLibraryDao.findAll().stream()
// .filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnit()))
......@@ -182,12 +187,17 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
//获取区域等级
Integer selectLevel = userPublicService.getArea(selectAreaId).getType();
//获取区域下所有单位名称
List<String> units = userPublicService.findAllUnitNameByAreaId(selectAreaId);
// List<String> units = userPublicService.findAllUnitNameByAreaId(selectAreaId);
List<Integer> units = userPublicService.findAllUnitIdByAreaId(selectAreaId);
//如果是市或县,筛选出创建单位在units中的设备
if (selectLevel == 3 || selectLevel == 2) {
// List<MatchingDeviceLibrary> resultList = matchingDeviceLibraryDao.findAll(getPredicate(matchingDeviceSelectVo).build())
// .stream()
// .filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnit()))
// .collect(Collectors.toList());
List<MatchingDeviceLibrary> resultList = matchingDeviceLibraryDao.findAll(getPredicate(matchingDeviceSelectVo).build())
.stream()
.filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnit()))
.filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnitId()))
.collect(Collectors.toList());
// List<MatchingDeviceLibrary> resultList = matchingDeviceLibraryDao.findAll().stream()
// .filter(matchingDeviceLibraryEntity -> units.contains(matchingDeviceLibraryEntity.getCreateUnit()))
......
......@@ -61,6 +61,9 @@ public class MatchingDeviceLibrary {
*/
@ApiModelProperty(value = "创建单位")
private String createUnit;
@ApiModelProperty(value = "创建单位Id")
private Integer createUnitId;
/**
* 设备序列号
*/
......
......@@ -42,6 +42,9 @@ public class MatchingDeviceEditVo {
*/
@ApiModelProperty(value = "创建单位")
private String createUnit;
@ApiModelProperty(value = "创建单位Id")
private Integer createUnitId;
/**
* 设备序列号
*/
......
......@@ -36,6 +36,10 @@ public class MatchingDeviceSaveVo {
@ApiModelProperty(value = "创建单位")
private String createUnit;
@NotNull(message = "createUnitId不能为空")
@ApiModelProperty(value = "创建单位Id")
private Integer createUnitId;
@NotNull(message = "seqNumber不能为空")
@ApiModelProperty(value = "设备序列号")
private String seqNumber;
......
......@@ -9,6 +9,7 @@ import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao;
import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary;
import com.tykj.dev.device.packing.repository.PackingLibraryDao;
import com.tykj.dev.device.selfcheck.base.SelfCheckSchedulerTask;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
......@@ -517,14 +518,19 @@ public class StatisticalServiceImpl implements StatisticalService {
WorkBench workBench = new WorkBench();
DeviceLibrarySelectVo deviceLibrarySelectVo = new DeviceLibrarySelectVo();
// deviceLibrarySelectVo.setAreaId(areaCache.findByName("浙江省").getId());
deviceLibrarySelectVo.setAreaId(areaCache.findByName("浙江省").getId());
deviceLibrarySelectVo.setAreaId(areaService.findByType(1).getId());
deviceLibrarySelectVo.setAreaId(unitsService.findById(unit).getAreaId());
workBench.setPackingNum(packingLibraryDao.findAllByIsRootAndPackingStatus(0,2).size());
List<DeviceLibrary> deviceLibraries = deviceLibraryService.getCoreDevicePage(deviceLibrarySelectVo);
workBench.setAllDeviceNum(deviceLibraries.size());
workBench.setSelfDeviceNum(Long.valueOf(deviceLibraries.stream().filter(deviceLibrary ->
deviceLibrary.getOwnUnit().equals(unitName)).count()).intValue());
workBench.setMatchingDeviceNum(new Long(matchingDeviceLibraryDao.count()).intValue());
//查询当前登录单位的配套设备
List<MatchingDeviceLibrary> allByCreateUnitId = matchingDeviceLibraryDao.findAllByCreateUnitId(unit);
if (!allByCreateUnitId.isEmpty()){
workBench.setMatchingDeviceNum(allByCreateUnitId.size());
}else {
workBench.setMatchingDeviceNum(0);
}
workBench.setDailyDeviceNum(Long.valueOf(deviceLibraries.stream().filter(deviceLibrary ->
deviceLibrary.getOwnUnit().equals(unitName)&&Arrays.asList(2,14).contains(deviceLibrary.getLifeStatus()))
.count()).intValue());
......
......@@ -6,6 +6,8 @@ import com.tykj.dev.device.allot.subject.domin.AllotBackBill;
import com.tykj.dev.device.allot.subject.domin.AllotBill;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.matching.repository.MatchingDeviceLibraryDao;
import com.tykj.dev.device.matching.subject.domin.MatchingDeviceLibrary;
import com.tykj.dev.device.repair.repository.RepairBackBillDao;
import com.tykj.dev.device.repair.repository.RepairBillDao;
import com.tykj.dev.device.repair.repository.RepairDetailDao;
......@@ -58,6 +60,9 @@ public class DataInit {
@Autowired
private DeviceUseReportDao deviceUseReportDao;
@Autowired
private MatchingDeviceLibraryDao matchingDeviceLibraryDao;
private void initCheckDetailUnitName() {
// 对现有的数据补充unitId信息
allotBillDao.findAll().forEach(this::saveModifyDetail1);
......@@ -68,6 +73,7 @@ public class DataInit {
repairDetailDao.findAll().forEach(this::saveModifyDetail6);
repairBackBillDao.findAll().forEach(this::saveModifyDetail7);
deviceUseReportDao.findAll().forEach(this::saveModifyDetail8);
matchingDeviceLibraryDao.findAll().forEach(this::saveModifyDetail9);
}
......@@ -196,6 +202,18 @@ public class DataInit {
}
private void saveModifyDetail9(MatchingDeviceLibrary matchingDeviceLibrary) {
String createUnit = matchingDeviceLibrary.getCreateUnit();
Integer createUnitId = getUnitId(createUnit);
if (createUnitId != -1 ) {
matchingDeviceLibrary.setCreateUnitId(createUnitId);
log.info("[配套设备库] 修正MatchingDeviceLibrary历史数据,修正的单位:{},接收单位id:{}",
createUnit,createUnitId);
matchingDeviceLibraryDao.save(matchingDeviceLibrary);
}
}
private Integer getUnitId(String unitName) {
List<Units> units = unitsDao.findAllByName(unitName).orElse(Collections.emptyList());
return units.size() == 1 ? units.get(0).getUnitId() : -1;
......
......@@ -36,11 +36,5 @@ public interface AreaService extends PublicService<Area> {
Area findByIdTosuperiorArea(Integer areaId);
/**
* 根据类型查询区域
* @param type 1是省
* @return 区域对象
*/
Area findByType(Integer type);
}
......@@ -180,4 +180,11 @@ public interface UnitsService extends PublicService<Units> {
void addUnitSortMap();
boolean isProvUnit(Integer unitId);
/**
* 根据区域id查询所有的单位id
* @param areaId 区域id
* @return 所有的单位id
*/
List<Integer> findByAreaId2(Integer areaId);
}
......@@ -50,4 +50,9 @@ public interface UserPublicService {
String getAreaNameByUnitName(String unitName);
/**
* 根据区域id查询单位id
*/
List<Integer> findAllUnitIdByAreaId(Integer areaId);
}
......@@ -136,10 +136,6 @@ public class AreaServiceImpl implements AreaService {
return area;
}
@Override
public Area findByType(Integer type) {
return areaDao.findByType(type);
}
private List<Integer> areaId(List<Integer> ids,Integer areaId){
List<Area> areas= areaDao.findAllByFatherId(areaId);
......
......@@ -449,6 +449,11 @@ public class UnitsServiceImpl implements UnitsService {
}
}
@Override
public List<Integer> findByAreaId2(Integer areaId) {
return unitsDao.findByAreaId(areaId).stream().map(Units::getUnitId).distinct().collect(Collectors.toList());
}
@Override
public Units save(Units units) {
......
......@@ -124,6 +124,11 @@ public class UserPublicServiceImpl implements UserPublicService {
}
}
@Override
public List<Integer> findAllUnitIdByAreaId(Integer areaId) {
return unitsService.findByAreaId2(areaId);
}
@Override
public String findUnitsNameByUserId(Integer userId) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论