| | |
| | | package com.gkhy.safePlatform.emergency.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService; |
| | | import com.gkhy.safePlatform.commons.enums.E; |
| | | import com.gkhy.safePlatform.commons.enums.ResultCodes; |
| | | import com.gkhy.safePlatform.commons.exception.BusinessException; |
| | | import com.gkhy.safePlatform.commons.query.PageQuery; |
| | | import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; |
| | | import com.gkhy.safePlatform.commons.vo.ResultVO; |
| | | import com.gkhy.safePlatform.commons.vo.SearchResultVO; |
| | | import com.gkhy.safePlatform.emergency.entity.*; |
| | | import com.gkhy.safePlatform.emergency.model.dto.resp.*; |
| | | import com.gkhy.safePlatform.emergency.query.EmergencyDrillExecuteCountQuery; |
| | | import com.gkhy.safePlatform.emergency.query.EmergencySuppliesCountQuery; |
| | | import com.gkhy.safePlatform.emergency.service.EmergencyCountService; |
| | | import com.gkhy.safePlatform.emergency.service.EmergencySuppliesService; |
| | | import com.gkhy.safePlatform.emergency.service.baseService.EmergencyDrillExecuteInfoService; |
| | | import com.gkhy.safePlatform.emergency.service.baseService.EmergencySuppliesInfoService; |
| | | import com.gkhy.safePlatform.emergency.utils.TimeUtils; |
| | | import org.apache.dubbo.config.annotation.DubboReference; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @DubboReference(check = false) |
| | | private AccountDepartmentService accountDepartmentService; |
| | | |
| | | @Autowired |
| | | private EmergencySuppliesInfoService emergencySuppliesInfoService; |
| | | |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | return new ResultVO<>(ResultCodes.OK,emergencyDrillExecuteCountRespDTO); |
| | | } |
| | | |
| | | @Override |
| | | public ResultVO<List<EmergencySuppliesCountRespDTO>> countEmergencySupplies(PageQuery<EmergencySuppliesCountQuery> pageQuery) { |
| | | List<EmergencySuppliesCountRespDTO> respList = new ArrayList<>(); |
| | | |
| | | Long pageIndex = pageQuery.getPageIndex(); |
| | | Long pageSize = pageQuery.getPageSize(); |
| | | Page<EmergencySuppliesInfoDetailDO> page = new Page<>(pageIndex,pageSize); |
| | | List<EmergencySuppliesInfoDetailDO> emergencySuppliesInfoDetailDOList = emergencySuppliesInfoService.countEmergencySupplies(page,pageQuery.getSearchParams()); |
| | | |
| | | if (!CollectionUtils.isEmpty(emergencySuppliesInfoDetailDOList)){ |
| | | for (EmergencySuppliesInfoDetailDO emergencySuppliesInfoDetailDO :emergencySuppliesInfoDetailDOList){ |
| | | EmergencySuppliesCountRespDTO emergencySuppliesCountRespDTO = new EmergencySuppliesCountRespDTO(); |
| | | // 名称+数量 |
| | | emergencySuppliesCountRespDTO.setName(emergencySuppliesInfoDetailDO.getName()); |
| | | emergencySuppliesCountRespDTO.setTotalNum(emergencySuppliesInfoDetailDO.getCount()); |
| | | // // 保质期内数量 |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//格式化一下 |
| | | // Date produceDate = emergencySuppliesInfoDetailDO.getProductionDate(); |
| | | // Integer usePeriod = emergencySuppliesInfoDetailDO.getUsePeriod(); |
| | | // |
| | | // String[] arr = sdf.format(produceDate).split("-"); |
| | | // |
| | | // Calendar calendar = Calendar.getInstance();//获取对日期操作的类对象 |
| | | // calendar.clear(); |
| | | // calendar.set(Calendar.YEAR, Integer.parseInt(arr[0])); |
| | | // calendar.set(Calendar.MONTH, Integer.parseInt(arr[1])); |
| | | // calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(arr[2])); |
| | | // |
| | | // calendar.set(Calendar.DAY_OF_YEAR,calendar.get(Calendar.DAY_OF_YEAR) +usePeriod); |
| | | // |
| | | // Date qualityD = calendar.getTime(); |
| | | // String time= sdf.format(calendar.getTime()); |
| | | // System.out.println(time); |
| | | |
| | | respList.add(emergencySuppliesCountRespDTO); |
| | | } |
| | | } |
| | | return new SearchResultVO<>( |
| | | true, |
| | | pageIndex, |
| | | pageSize,page.getPages(), |
| | | page.getTotal(), |
| | | respList, |
| | | ResultCodes.OK |
| | | ); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | Date date = new Date();//获取当前日期 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//格式化一下 |
| | | Calendar calendar1 = Calendar.getInstance();//获取对日期操作的类对象 |
| | | //两种写法都可以获取到前三天的日期 |
| | | calendar1.set(Calendar.DAY_OF_YEAR,calendar1.get(Calendar.DAY_OF_YEAR) -40); |
| | | //在当前时间的基础上获取前三天的日期 |
| | | // calendar1.add(Calendar.DATE, -40); |
| | | //add方法 参数也可传入 月份,获取的是前几月或后几月的日期 |
| | | //calendar1.add(Calendar.MONTH, -3); |
| | | Date today = calendar1.getTime(); |
| | | String time= sdf.format(today); |
| | | System.out.println(time); |
| | | } |
| | | } |