提交 5c9be097 authored 作者: zhoushaopan's avatar zhoushaopan

feat(配套设备库模块): 新增接口

新增接口
上级 4089c749
...@@ -3,9 +3,15 @@ package com.tykj.dev.device.allot.repository; ...@@ -3,9 +3,15 @@ package com.tykj.dev.device.allot.repository;
import com.tykj.dev.device.allot.subject.domin.AllotBill; import com.tykj.dev.device.allot.subject.domin.AllotBill;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.Date;
/** /**
* @author dengdiyi * @author dengdiyi
*/ */
public interface AllotBillDao extends JpaRepository<AllotBill, Integer>, JpaSpecificationExecutor<AllotBill> { public interface AllotBillDao extends JpaRepository<AllotBill, Integer>, JpaSpecificationExecutor<AllotBill> {
@Query(value = "SELECT count(*) as num FROM allot_bill WHERE delete_tag = 0 AND receive_unit_id = ?1 AND update_time BETWEEN ?2 AND ?3",nativeQuery = true)
Long getReceiveCountByTime(Integer unitId, Date startTime, Date endTime);
} }
...@@ -1085,6 +1085,14 @@ public class MatchingDeviceController { ...@@ -1085,6 +1085,14 @@ public class MatchingDeviceController {
public ResponseEntity exportExcel(@RequestBody List<MatchingDeviceLibrary> matchingDeviceLibraryList) { public ResponseEntity exportExcel(@RequestBody List<MatchingDeviceLibrary> matchingDeviceLibraryList) {
return ResponseEntity.ok(matchingDeviceLibraryService.exportExcel(matchingDeviceLibraryList)); return ResponseEntity.ok(matchingDeviceLibraryService.exportExcel(matchingDeviceLibraryList));
} }
@ApiOperation(value = "启用配套设备", notes = "启用配套设备")
@PostMapping("/startMatchingLibrary")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity startMatchingLibrary(@RequestBody List<Integer> matchingDeviceIds) {
matchingDeviceLibraryService.startMatchingLibrary(matchingDeviceIds);
return ResponseEntity.ok("启用成功");
}
/** /**
* @return 生成配套设备附件的序列号 * @return 生成配套设备附件的序列号
*/ */
......
...@@ -31,9 +31,9 @@ public interface MatchingDeviceLibraryDao extends JpaRepository<MatchingDeviceLi ...@@ -31,9 +31,9 @@ public interface MatchingDeviceLibraryDao extends JpaRepository<MatchingDeviceLi
@Transactional @Transactional
@Modifying @Modifying
@Query("update MatchingDeviceLibrary m set m.lifeStatus = :status, m.remake = :remake, m.statusJson = :statusJson, m.stopUnitId = :stopUnitId where m.id in :matchingDeviceIds") @Query("update MatchingDeviceLibrary m set m.lifeStatus = :status, m.stopReason = :stopReason, m.statusJson = :statusJson, m.stopUnitId = :stopUnitId where m.id in :matchingDeviceIds")
int batchUpdateStatus(@Param("status") Integer status, int batchUpdateStatus(@Param("status") Integer status,
@Param("remake") String remake, @Param("stopReason") String stopReason,
@Param("statusJson") String statusJson, @Param("statusJson") String statusJson,
@Param("matchingDeviceIds") List<Integer> matchingDeviceIds, @Param("matchingDeviceIds") List<Integer> matchingDeviceIds,
@Param("stopUnitId") Integer stopUnitId); @Param("stopUnitId") Integer stopUnitId);
......
...@@ -171,4 +171,10 @@ public interface MatchingDeviceLibraryService { ...@@ -171,4 +171,10 @@ public interface MatchingDeviceLibraryService {
*/ */
String exportExcel(List<MatchingDeviceLibrary> matchingDeviceLibraries); String exportExcel(List<MatchingDeviceLibrary> matchingDeviceLibraries);
/**
* 启用配套设备库
* @param matchingDeviceIds
* @return
*/
void startMatchingLibrary(List<Integer> matchingDeviceIds);
} }
...@@ -9,6 +9,7 @@ import com.github.wenhao.jpa.Specifications; ...@@ -9,6 +9,7 @@ import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash; import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil; import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.TaskBeanConfig; import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.library.service.DeviceLogService; import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto; import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
...@@ -253,16 +254,19 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -253,16 +254,19 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
predicateBuilder.like(matchingDeviceSelectVo.getDeployAddressLike() != null, predicateBuilder.like(matchingDeviceSelectVo.getDeployAddressLike() != null,
"deployAddress","%"+matchingDeviceSelectVo.getDeployAddressLike()+"%"); "deployAddress","%"+matchingDeviceSelectVo.getDeployAddressLike()+"%");
predicateBuilder.like(matchingDeviceSelectVo.getYiNameLike() != null,"yiName","%"+matchingDeviceSelectVo.getYiNameLike()+"%"); predicateBuilder.like(matchingDeviceSelectVo.getYiNameLike() != null,"yiName","%"+matchingDeviceSelectVo.getYiNameLike()+"%");
if (matchingDeviceSelectVo.getSignStartDate() != null ){ // if (matchingDeviceSelectVo.getSignStartDate() != null ){
predicateBuilder.ge("signDate",matchingDeviceSelectVo.getSignStartDate()); // predicateBuilder.ge("signDate",matchingDeviceSelectVo.getSignStartDate());
} // }
if(matchingDeviceSelectVo.getSignEndDate() != null){ // if(matchingDeviceSelectVo.getSignEndDate() != null){
predicateBuilder.le("signDate",matchingDeviceSelectVo.getSignEndDate()); // predicateBuilder.le("signDate",matchingDeviceSelectVo.getSignEndDate());
} // }
predicateBuilder.eq(matchingDeviceSelectVo.getSignDate() != null,"signDate",matchingDeviceSelectVo.getSignDate());
predicateBuilder.like(matchingDeviceSelectVo.getRemakeLike() != null,"remake","%"+matchingDeviceSelectVo.getRemakeLike()+"%"); predicateBuilder.like(matchingDeviceSelectVo.getRemakeLike() != null,"remake","%"+matchingDeviceSelectVo.getRemakeLike()+"%");
if (matchingDeviceSelectVo.getMatchingType() == 0){ if (matchingDeviceSelectVo.getMatchingType() == 0){
predicateBuilder.eq(matchingDeviceSelectVo.getMatchingType() != null,"lifeStatus",2); predicateBuilder.in(matchingDeviceSelectVo.getMatchingType() != null,"lifeStatus",2,14,4);
} }
//筛选生命状态
predicateBuilder.eq(matchingDeviceSelectVo.getLifeStatus() != null,"lifeStatus",matchingDeviceSelectVo.getLifeStatus());
if (matchingDeviceSelectVo.getMatchingType() == 1){ if (matchingDeviceSelectVo.getMatchingType() == 1){
predicateBuilder.eq(matchingDeviceSelectVo.getMatchingType() != null,"lifeStatus",23); predicateBuilder.eq(matchingDeviceSelectVo.getMatchingType() != null,"lifeStatus",23);
} }
...@@ -270,6 +274,12 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -270,6 +274,12 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
if (matchingDeviceSelectVo.getUnitIds() != null){ if (matchingDeviceSelectVo.getUnitIds() != null){
predicateBuilder.in("createUnitId",matchingDeviceSelectVo.getUnitIds().toArray()); predicateBuilder.in("createUnitId",matchingDeviceSelectVo.getUnitIds().toArray());
} }
//装备序列号
predicateBuilder.like(matchingDeviceSelectVo.getSeqNumberLike() != null,"seqNumber","%"+matchingDeviceSelectVo.getSeqNumberLike()+"%");
//合同金额
predicateBuilder.like(matchingDeviceSelectVo.getAmountLike() != null,"amount","%"+matchingDeviceSelectVo.getAmountLike()+"%");
//采购方式
predicateBuilder.like(matchingDeviceSelectVo.getPurchaseWayLike() != null,"purchaseWay","%"+matchingDeviceSelectVo.getPurchaseWayLike()+"%");
return matchingDeviceLibraryDao.findAll(predicateBuilder.build(),matchingDeviceSelectVo.getPageable()); return matchingDeviceLibraryDao.findAll(predicateBuilder.build(),matchingDeviceSelectVo.getPageable());
} }
...@@ -494,7 +504,7 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -494,7 +504,7 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
MatchingDeviceSaveVo matchingDeviceSaveVo = new MatchingDeviceSaveVo(); MatchingDeviceSaveVo matchingDeviceSaveVo = new MatchingDeviceSaveVo();
MatchingDeviceLibrary matchingDeviceLibrary = matchingDeviceLibraries.get(i); MatchingDeviceLibrary matchingDeviceLibrary = matchingDeviceLibraries.get(i);
BeanUtils.copyProperties(matchingDeviceLibrary,matchingDeviceSaveVo); BeanUtils.copyProperties(matchingDeviceLibrary,matchingDeviceSaveVo);
if (matchingDeviceSaveVo.getSignDate() != null){ if (matchingDeviceLibrary.getSignDate() != null){
matchingDeviceSaveVo.setSignDate(DateUtil.localDate2String(matchingDeviceLibrary.getSignDate())); matchingDeviceSaveVo.setSignDate(DateUtil.localDate2String(matchingDeviceLibrary.getSignDate()));
} }
matchingDeviceSaveVo.setNum((i+1)); matchingDeviceSaveVo.setNum((i+1));
...@@ -527,6 +537,22 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe ...@@ -527,6 +537,22 @@ public class MatchingDeviceLibraryServiceImpl implements MatchingDeviceLibrarySe
return null; return null;
} }
@Override
public void startMatchingLibrary(List<Integer> matchingDeviceIds) {
if (matchingDeviceIds.size() >0){
List<MatchingDeviceLibrary> deviceLibraryList = matchingDeviceLibraryDao.findAllById(matchingDeviceIds);
deviceLibraryList.forEach(device -> {
device.setLifeStatus(DeviceLifeStatus.IN_LIBRARY.id);
device.setStopReason(null);
//更新
matchingDeviceLibraryDao.save(device);
//同时记录日志
DeviceLogDto deviceLogDto = new DeviceLogDto(1, device.getId(), "将设备从停用修改为在库", null, null);
deviceLogService.addLog(deviceLogDto);
});
}
}
/** /**
* @param matchingDeviceSelectVo 配套设备查询vo * @param matchingDeviceSelectVo 配套设备查询vo
......
...@@ -194,6 +194,10 @@ public class MatchingDeviceLibrary { ...@@ -194,6 +194,10 @@ public class MatchingDeviceLibrary {
@Column(name = "remake",columnDefinition = "TEXT") @Column(name = "remake",columnDefinition = "TEXT")
private String remake; private String remake;
@ApiModelProperty(value = "停用原因")
@Column(name = "stop_reason",columnDefinition = "TEXT")
private String stopReason;
@ApiModelProperty(value = "停用设备信息的单位id") @ApiModelProperty(value = "停用设备信息的单位id")
private Integer stopUnitId = 0; private Integer stopUnitId = 0;
......
...@@ -83,15 +83,29 @@ public class MatchingDeviceSelectVo extends CustomPage { ...@@ -83,15 +83,29 @@ public class MatchingDeviceSelectVo extends CustomPage {
@ApiModelProperty(value = "乙方名称 模糊查询") @ApiModelProperty(value = "乙方名称 模糊查询")
private String yiNameLike; private String yiNameLike;
@ApiModelProperty(value = "签订开始日期") @ApiModelProperty(value = "装备序列号 模糊查询")
@DateTimeFormat(pattern = "yyyy-MM-dd") private String seqNumberLike;
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
private LocalDate signStartDate; @ApiModelProperty(value = "合同金额 模糊查询")
private String amountLike;
@ApiModelProperty(value = "采购方式 模糊查询")
private String purchaseWayLike;
@ApiModelProperty(value = "签订结束日期") // @ApiModelProperty(value = "签订开始日期")
// @DateTimeFormat(pattern = "yyyy-MM-dd")
// @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
// private LocalDate signStartDate;
//
// @ApiModelProperty(value = "签订结束日期")
// @DateTimeFormat(pattern = "yyyy-MM-dd")
// @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
// private LocalDate signEndDate;
@ApiModelProperty(value = "签订日期")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd") @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
private LocalDate signEndDate; private LocalDate signDate;
@ApiModelProperty(value = "备注 模糊查询") @ApiModelProperty(value = "备注 模糊查询")
private String remakeLike; private String remakeLike;
...@@ -99,8 +113,11 @@ public class MatchingDeviceSelectVo extends CustomPage { ...@@ -99,8 +113,11 @@ public class MatchingDeviceSelectVo extends CustomPage {
@ApiModelProperty(value = "类型 1 代表只查询停用的") @ApiModelProperty(value = "类型 1 代表只查询停用的")
private Integer matchingType ; private Integer matchingType ;
@ApiModelProperty(value = "生命状态字段")
private Integer lifeStatus ;
@ApiModelProperty(value = "单位ID的集合") @ApiModelProperty(value = "单位ID的集合")
private List<Integer> unitIds; ; private List<Integer> unitIds;
......
...@@ -4,7 +4,9 @@ import com.tykj.dev.config.domin.MapCheckVO; ...@@ -4,7 +4,9 @@ import com.tykj.dev.config.domin.MapCheckVO;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.config.vo.ConfigVo; import com.tykj.dev.config.vo.ConfigVo;
import com.tykj.dev.device.screen.subject.entity.CheckArg; import com.tykj.dev.device.screen.subject.entity.CheckArg;
import com.tykj.dev.device.screen.subject.entity.DynamicData;
import com.tykj.dev.device.screen.subject.service.CheckMapTask; import com.tykj.dev.device.screen.subject.service.CheckMapTask;
import com.tykj.dev.device.screen.subject.service.DynamicDataService;
import com.tykj.dev.device.screen.subject.service.ScreeService; import com.tykj.dev.device.screen.subject.service.ScreeService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -37,6 +39,9 @@ public class ScreenController { ...@@ -37,6 +39,9 @@ public class ScreenController {
@Resource @Resource
private ScreeService screeService; private ScreeService screeService;
@Resource
private DynamicDataService dynamicDataService;
@ApiOperation(value = "自核查接口", notes = "添加系统配置变量值") @ApiOperation(value = "自核查接口", notes = "添加系统配置变量值")
@GetMapping(value = "/check") @GetMapping(value = "/check")
public ResponseEntity<HashMap<String, List<MapCheckVO>>> add() { public ResponseEntity<HashMap<String, List<MapCheckVO>>> add() {
...@@ -55,5 +60,11 @@ public class ScreenController { ...@@ -55,5 +60,11 @@ public class ScreenController {
return ResponseEntity.ok(screeService.getAreaData(flag,id)); return ResponseEntity.ok(screeService.getAreaData(flag,id));
} }
@ApiOperation(value = "查询去年的动态数据", notes = "查询去年的动态数据")
@GetMapping(value = "/findHis")
public ResponseEntity<List<DynamicData>> findHis() {
return ResponseEntity.ok(dynamicDataService.findByEndYear());
}
} }
package com.tykj.dev.device.screen.subject.dao;
import com.tykj.dev.device.screen.subject.entity.DynamicData;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @author: zsp
* @create: 2022-12-02 15:54
**/
public interface DynamicDataDao extends JpaRepository<DynamicData,Integer> {
List<DynamicData> findAllByEndYear(Integer endYear);
}
package com.tykj.dev.device.screen.subject.entity;
import com.alibaba.fastjson.JSONObject;
import com.tykj.dev.misc.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.List;
/**
* @author: zsp
* @create: 2022-12-02 14:01
**/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Table(name = "zb_dynamic_data")
@Entity
public class DynamicData extends BaseEntity {
@ApiModelProperty(value = "结算时间",notes = "2022 就是2022年 2011 就是2011年")
private Integer endYear;
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "数据json")
@Lob
@Column(columnDefinition = "text")
private String dataJson;
@ApiModelProperty(value = "数据json转换实体")
@Transient
private JSONObject json;
}
package com.tykj.dev.device.screen.subject.service;
import com.tykj.dev.device.screen.subject.entity.DynamicData;
import java.util.List;
/**
* @author: zsp
* @create: 2022-12-02 15:52
**/
public interface DynamicDataService {
/**
* 保存对象
* @param dynamicData 实体对象
*/
void addEntity(DynamicData dynamicData);
List<DynamicData> findByEndYear();
}
package com.tykj.dev.device.screen.subject.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.tykj.dev.device.screen.subject.dao.DynamicDataDao;
import com.tykj.dev.device.screen.subject.entity.DynamicData;
import com.tykj.dev.device.screen.subject.service.DynamicDataService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;
/**
* @author: zsp
* @create: 2022-12-02 15:53
**/
@Service
public class DynamicDataServiceImpl implements DynamicDataService {
@Resource
private DynamicDataDao dynamicDataDao;
@Override
@Transactional(rollbackFor = Exception.class)
public void addEntity(DynamicData dynamicData) {
dynamicDataDao.save(dynamicData);
}
@Override
public List<DynamicData> findByEndYear() {
int year = LocalDate.now().getYear()-1;
List<DynamicData> dataList = dynamicDataDao.findAllByEndYear(year);
if (dataList != null && dataList.size() > 0){
dataList.forEach(dynamicData -> {
dynamicData.setJson(JSONObject.parseObject(dynamicData.getDataJson(),JSONObject.class));
});
}
return dataList;
}
}
...@@ -13,7 +13,9 @@ import com.tykj.dev.device.loss.repository.LossDao; ...@@ -13,7 +13,9 @@ import com.tykj.dev.device.loss.repository.LossDao;
import com.tykj.dev.device.repair.repository.RepairBillDao; import com.tykj.dev.device.repair.repository.RepairBillDao;
import com.tykj.dev.device.scrap.repository.ScrapDao; import com.tykj.dev.device.scrap.repository.ScrapDao;
import com.tykj.dev.device.screen.subject.controller.InitUnitScree; import com.tykj.dev.device.screen.subject.controller.InitUnitScree;
import com.tykj.dev.device.screen.subject.entity.DynamicData;
import com.tykj.dev.device.screen.subject.service.CheckMapTask; import com.tykj.dev.device.screen.subject.service.CheckMapTask;
import com.tykj.dev.device.screen.subject.service.DynamicDataService;
import com.tykj.dev.device.screen.subject.service.ScreeService; import com.tykj.dev.device.screen.subject.service.ScreeService;
import com.tykj.dev.device.screen.subject.vo.LeftOneVO; import com.tykj.dev.device.screen.subject.vo.LeftOneVO;
import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao; import com.tykj.dev.device.selfcheck.repository.SelfCheckBillDao;
...@@ -26,14 +28,13 @@ import com.tykj.dev.device.user.cache.UnitsCache; ...@@ -26,14 +28,13 @@ import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.cache.UserCache; import com.tykj.dev.device.user.cache.UserCache;
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.Units; import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.misc.utils.TimestampUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.text.ParseException;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -103,6 +104,9 @@ public class ScreeServiceImpl implements ScreeService { ...@@ -103,6 +104,9 @@ public class ScreeServiceImpl implements ScreeService {
@Autowired @Autowired
RepelQueryService repelQueryService; RepelQueryService repelQueryService;
@Resource
private DynamicDataService dynamicDataService;
@Override @Override
public Map<String, Object> getScreeAroundData() { public Map<String, Object> getScreeAroundData() {
...@@ -111,16 +115,16 @@ public class ScreeServiceImpl implements ScreeService { ...@@ -111,16 +115,16 @@ public class ScreeServiceImpl implements ScreeService {
LeftOneVO leftOneVO = new LeftOneVO(); LeftOneVO leftOneVO = new LeftOneVO();
//入库数量 //入库数量
leftOneVO.setStorageCount(storageBillDao.getStorageCount()); leftOneVO.setStorageCount(storageBillDao.getStorageCount());
//清退数量 todo --zjm //清退数量
leftOneVO.setSendBackCount(repelQueryService.queryCountSameLevel()); Integer queryCountSameLevel = repelQueryService.queryCountSameLevel();
leftOneVO.setSendBackCount(queryCountSameLevel);
//库存总数量 //库存总数量
leftOneVO.setTotalDevicesCount(deviceLibraryDao.getInLibraryCount()); leftOneVO.setTotalDevicesCount(deviceLibraryDao.getInLibraryCount());
map.put("leftOneVO", leftOneVO); map.put("leftOneVO", leftOneVO);
//todo --zjm 人员管理 //todo --zjm 人员管理
long count = userCache.findAll().stream().filter(user -> user.getPosition() != 2).count(); long count = userCache.findAll().stream().filter(user -> user.getPosition() != null && user.getPosition() != 2).count();
//左边第三个(ZB库存) //左边第三个(ZB库存)
// List<Map<String, Object>> leftThree = deviceLibraryDao.getInCountByUnit(); // List<Map<String, Object>> leftThree = deviceLibraryDao.getInCountByUnit();
...@@ -183,6 +187,41 @@ public class ScreeServiceImpl implements ScreeService { ...@@ -183,6 +187,41 @@ public class ScreeServiceImpl implements ScreeService {
//右边第一部分 (设备形态分布) //右边第一部分 (设备形态分布)
List<Map<String, Object>> inCountByModel = deviceLibraryDao.getInCountByModel(); List<Map<String, Object>> inCountByModel = deviceLibraryDao.getInCountByModel();
map.put("modelData", inCountByModel); map.put("modelData", inCountByModel);
//右边第二部分
//入库对于省来说就是入库业务 对于市来说就是配发
//库存 省就是浙江省以及省同级 市就是市本级以及下级所有的区
//清退 省清退 市清退
try {
Date startYear = TimestampUtil.getYearStart();
Date endYear = TimestampUtil.getYearEnd();
JSONObject rightData = new JSONObject();
JSONObject jsonObject = new JSONObject();
Long proIn = storageBillDao.queryByStartAndEnd(startYear, endYear);
jsonObject.put("入库",proIn);
jsonObject.put("在库",inUnitList);
jsonObject.put("清退",queryCountSameLevel);
rightData.put("省级",jsonObject);
//市
unitIdList.forEach(integer -> {
JSONObject jsonObject1 = new JSONObject();
Units units = unitsCache.findById(integer);
// DynamicData dynamicData2 = new DynamicData();
jsonObject1.put("入库",allotBillDao.getReceiveCountByTime(integer, startYear,endYear));
List<Units> unitsList = unitsCache.findByIdSubordinateAndOneself(integer);
Long num = deviceLibraryDao.getDevNumInUnitList(unitsList.stream().map(Units::getName).collect(Collectors.toList()));
Integer queryDeviceCount = repelQueryService.queryDeviceCount(integer, startYear, endYear);
jsonObject1.put("在库",num);
jsonObject1.put("清退",queryDeviceCount);
rightData.put(units.getName().substring(0,2),jsonObject1);
// dynamicData2.setEndYear(2021);
// dynamicData2.setUnitName(units.getName().substring(0,2));
// dynamicData2.setDataJson(jsonObject1.toJSONString());
// dynamicDataService.addEntity(dynamicData2);
});
map.put("rightData",rightData);
} catch (ParseException e) {
e.printStackTrace();
}
return map; return map;
} }
......
package com.tykj.dev.device.screen.subject.task; package com.tykj.dev.device.screen.subject.task;
import com.alibaba.fastjson.JSONObject;
import com.tykj.dev.device.allot.repository.AllotBillDao;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.screen.subject.controller.InitUnitScree;
import com.tykj.dev.device.screen.subject.entity.DynamicData;
import com.tykj.dev.device.screen.subject.service.CheckMapTask; import com.tykj.dev.device.screen.subject.service.CheckMapTask;
import com.tykj.dev.device.screen.subject.service.DynamicDataService;
import com.tykj.dev.device.sendback.service.RepelQueryService;
import com.tykj.dev.device.storage.repository.StorageBillDao;
import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.subject.entity.Units;
import com.tykj.dev.misc.utils.TimestampUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.ParseException;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* @AUTHOR: cnljj1995@gmail.com * @AUTHOR: cnljj1995@gmail.com
* @DATE: 2022/11/28 * @DATE: 2022/11/28
...@@ -17,6 +35,27 @@ public class CheckScreenTask { ...@@ -17,6 +35,27 @@ public class CheckScreenTask {
@Autowired @Autowired
private CheckMapTask checkMapTask; private CheckMapTask checkMapTask;
@Resource
private StorageBillDao storageBillDao;
@Resource
private DeviceLibraryDao deviceLibraryDao;
@Resource
private InitUnitScree initUnitScree;
@Resource
private UnitsCache unitsCache;
@Resource
private AllotBillDao allotBillDao;
@Resource
private DynamicDataService dynamicDataService;
@Autowired
RepelQueryService repelQueryService;
@Scheduled(cron = "0 * * * * ? ") @Scheduled(cron = "0 * * * * ? ")
public void checkMap() { public void checkMap() {
...@@ -26,4 +65,50 @@ public class CheckScreenTask { ...@@ -26,4 +65,50 @@ public class CheckScreenTask {
log.info("大屏自核查定时任务完成,用时:{}", System.currentTimeMillis() - startTime); log.info("大屏自核查定时任务完成,用时:{}", System.currentTimeMillis() - startTime);
} }
@Scheduled(cron = "0 00 23 31 12 ?")
public void initDynamicData() {
long startTime = System.currentTimeMillis();
log.info("大屏动态数据开始");
List<String> provinceNameList = initUnitScree.getProvinceNameList();
try {
int year = LocalDate.now().getYear();
DynamicData dynamicData1 = new DynamicData();
Date startYear = TimestampUtil.getYearStart();
Date endYear = TimestampUtil.getYearEnd();
JSONObject jsonObject = new JSONObject();
Long proIn = storageBillDao.queryByStartAndEnd(startYear, endYear);
jsonObject.put("入库",proIn);
Long inUnitList = deviceLibraryDao.getDevNumInUnitList(provinceNameList);
jsonObject.put("在库",inUnitList);
//todo
jsonObject.put("清退",repelQueryService.queryCountSameLevel());
dynamicData1.setEndYear(year);
dynamicData1.setUnitName("省级");
dynamicData1.setDataJson(jsonObject.toJSONString());
dynamicDataService.addEntity(dynamicData1);
//市
List<Integer> cityIdList = initUnitScree.getCityIdList();
cityIdList.forEach(integer -> {
DynamicData dynamicData2 = new DynamicData();
JSONObject jsonObject1 = new JSONObject();
Units units = unitsCache.findById(integer);
jsonObject1.put("入库",allotBillDao.getReceiveCountByTime(integer, startYear,endYear));
List<Units> unitsList = unitsCache.findByIdSubordinateAndOneself(integer);
Long num = deviceLibraryDao.getDevNumInUnitList(unitsList.stream().map(Units::getName).collect(Collectors.toList()));
jsonObject1.put("在库",num);
Integer queryDeviceCount = repelQueryService.queryDeviceCount(integer, startYear, endYear);
jsonObject1.put("清退",queryDeviceCount);
dynamicData2.setEndYear(year);
dynamicData2.setUnitName(units.getName().substring(0,2));
dynamicData2.setDataJson(jsonObject1.toJSONString());
dynamicDataService.addEntity(dynamicData2);
});
} catch (ParseException e) {
e.printStackTrace();
}
log.info("大屏动态数据结束,用时:{}", System.currentTimeMillis() - startTime);
}
} }
package com.tykj.dev.device.screen.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author: zsp
* @create: 2022-12-02 14:09
**/
@AllArgsConstructor
@NoArgsConstructor
@Data
@ApiModel("ZB动态vo")
public class DynamicDataJsonVO {
@ApiModelProperty(value = "单位ID")
private Integer unitId;
@ApiModelProperty(value = "入库数量")
private Integer storageCount;
@ApiModelProperty(value = "清退数量")
private Integer sendBackCount;
@ApiModelProperty(value = "在库数量")
private Integer inLibraryNum;
}
...@@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository; ...@@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -19,4 +20,11 @@ public interface StorageBillDao extends JpaRepository<StorageBill, Integer>, Jpa ...@@ -19,4 +20,11 @@ public interface StorageBillDao extends JpaRepository<StorageBill, Integer>, Jpa
*/ */
@Query(value = "SELECT SUM(storaged_count) FROM storage_bill WHERE delete_tag = 0 AND storaged_count is not NULL",nativeQuery = true) @Query(value = "SELECT SUM(storaged_count) FROM storage_bill WHERE delete_tag = 0 AND storaged_count is not NULL",nativeQuery = true)
Long getStorageCount(); Long getStorageCount();
/**
* 根据时间查询入库数量
* @return 数量
*/
@Query(value = "SELECT count(*) as num FROM storage_bill WHERE delete_tag = 0 AND update_time BETWEEN ?1 AND ?2",nativeQuery = true)
Long queryByStartAndEnd(Date startDate, Date endDate);
} }
...@@ -124,8 +124,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -124,8 +124,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// return o; // return o;
// } // }
// }) // })
// .anyRequest().authenticated() .anyRequest().authenticated()
.anyRequest().permitAll() // .anyRequest().permitAll()
.and() .and()
.formLogin() .formLogin()
.loginProcessingUrl("/userLogin") .loginProcessingUrl("/userLogin")
......
...@@ -198,4 +198,10 @@ public class UnitsController { ...@@ -198,4 +198,10 @@ public class UnitsController {
return ResponseEntity.ok(unitsService.updateUnit(units)); return ResponseEntity.ok(unitsService.updateUnit(units));
} }
@GetMapping("/queryAreaExhibitionIdUnitIds")
@ApiOperation(value = "[单位管理]根据区域ID查询单位ID的集合", notes = "根据区域ID查询单位ID的集合")
public ResponseEntity queryAreaExhibitionIdUnitIds(Integer areaExhibitionId){
return ResponseEntity.ok(unitsService.queryAreaExhibitionIdUnitIds(areaExhibitionId));
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论