zjh
2024-05-16 adaaa23c789be3313a0e554fbf7beaa8ab261e68
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjTollCollectorController.java
@@ -13,8 +13,11 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ltkj.common.core.domain.entity.SysDictData;
import com.ltkj.common.core.redis.RedisCache;
import com.ltkj.common.utils.SecurityUtils;
import com.ltkj.common.utils.StringUtils;
import com.ltkj.framework.config.MatchUtils;
import com.ltkj.framework.config.UserHoder;
import com.ltkj.hosp.domain.*;
import com.ltkj.hosp.service.*;
import com.ltkj.hosp.vodomain.ChargeStatisticsVo;
@@ -58,11 +61,12 @@
    private ITjCustomerService tjCustomerService;
    @Resource
    private ISysDictDataService dictDataService;
    @Resource
    private RedisCache redisCache;
    /**
     * 查询收费员日结列表
     */
    @PreAuthorize("@ss.hasPermi('hosp:collector:list')")
    //@PreAuthorize("@ss.hasPermi('hosp:collector:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询收费员日结列表")
    public AjaxResult list(@RequestParam(required = false) @ApiParam(value = "收费员id") String tollCollectorId,
@@ -80,7 +84,6 @@
        if (null != accountBeginTime && null != accountEndTime) {
            wqq.between(TjTollCollector::getCreateTime, accountBeginTime, accountEndTime);
        } else {
            DateTime dateTime = DateUtil.lastWeek();
            wqq.between(TjTollCollector::getCreateTime, DateUtil.lastWeek(),DateUtil.date());
        }
        wqq.orderByDesc(TjTollCollector::getCreateTime);
@@ -103,7 +106,7 @@
    /**
     * 导出收费员日结列表
     */
    @PreAuthorize("@ss.hasPermi('hosp:collector:export')")
    //@PreAuthorize("@ss.hasPermi('hosp:collector:export')")
    @Log(title = "收费员日结", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出收费员日结列表")
@@ -116,7 +119,7 @@
    /**
     * 获取收费员日结详细信息
     */
    @PreAuthorize("@ss.hasPermi('hosp:collector:query')")
    // @PreAuthorize("@ss.hasPermi('hosp:collector:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取收费员日结详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id) {
@@ -126,7 +129,7 @@
    /**
     * 点击结算 新增收费员日结
     */
    @PreAuthorize("@ss.hasPermi('hosp:collector:add')")
    //@PreAuthorize("@ss.hasPermi('hosp:collector:add')")
    @Log(title = "收费员日结", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "点击结算 新增收费员日结")
@@ -139,10 +142,15 @@
                collectorDetail.setAccountId(tjTollCollector.getAccountId());
                collectorDetailService.save(collectorDetail);
            }
            for (String id : tjTollCollector.getIds()) {
                TjFlowingWater water = tjFlowingWaterService.getById(id);
                water.setIsCheckout("Y");
                tjFlowingWaterService.updateById(water);
            if(redisCache.hasKey("longList"+tjTollCollector.getTollCollectorId())){
                List<Long> longList= redisCache.getCacheObject("longList" + tjTollCollector.getTollCollectorId());
                for (Long id : longList) {
                    TjFlowingWater water = tjFlowingWaterService.getById(id);
                    water.setIsCheckout(tjTollCollector.getId());
                    water.setUpdateTime(new Date());
                    tjFlowingWaterService.updateById(water);
                }
                redisCache.deleteObject("longList"+tjTollCollector.getTollCollectorId());
            }
            return AjaxResult.success(accountId);
        }
@@ -150,7 +158,7 @@
    }
    @PreAuthorize("@ss.hasPermi('hosp:collector:remove')")
    //@PreAuthorize("@ss.hasPermi('hosp:collector:remove')")
    @DeleteMapping("/removeTjTollCollectorById")
    @ApiOperation(value = "收费员撤销账单操作接口")
    public AjaxResult removeTjTollCollectorById(@RequestParam @ApiParam(value = "结账id") String id,
@@ -159,32 +167,25 @@
        if (!userId.equals(tollCollectorId)) {
            return AjaxResult.error("非当前用户禁止操作");
        }
//        LambdaQueryWrapper<TjTollCollector> wqq = new LambdaQueryWrapper<>();
//        wqq.orderByDesc(TjTollCollector::getCreateTime);
//        List<TjTollCollector> list = tjTollCollectorService.list(wqq);
//        if (null != list && list.size() > 0) {
//            TjTollCollector collector = list.get(0);
//            if (null != collector && !collector.getId().equals(id)) {
//                return AjaxResult.error("请撤销最后一次结账记录");
//            }
//        }
        String ids = tjTollCollectorService.getTjTollCollectorByLastOne();
        if (null != ids && !id.equals(ids)) {
                return AjaxResult.error("请撤销最后一次结账记录");
            }
//        TjTollCollector collector = tjTollCollectorService.getById(id);
        TjTollCollector collector = tjTollCollectorService.getTjTollCollectorById(id);
        if (null != collector) {
            if(null !=collector.getIsHz()){
                return AjaxResult.error("该账单已汇总不可撤销");
            }
            LambdaQueryWrapper<TjTollCollectorDetail> wq = new LambdaQueryWrapper<>();
            wq.eq(TjTollCollectorDetail::getAccountId, collector.getAccountId());
            collectorDetailService.remove(wq);
            tjTollCollectorService.removeById(collector);
            LambdaQueryWrapper<TjFlowingWater> wqq1 = new LambdaQueryWrapper<>();
            wqq1.eq(TjFlowingWater::getIsCheckout, "Y");
            wqq1.between(TjFlowingWater::getUpdateTime, collector.getAccountBeginTime(), collector.getAccountEndTime());
            wqq1.eq(TjFlowingWater::getIsCheckout,id);
            List<TjFlowingWater> waterList = tjFlowingWaterService.list(wqq1);
            for (TjFlowingWater tjFlowingWater : waterList) {
                tjFlowingWater.setIsCheckout("N");
                tjFlowingWater.setIsCheckout(null);
                tjFlowingWater.setUpdateTime(new Date());
                tjFlowingWaterService.updateById(tjFlowingWater);
            }
            return AjaxResult.success("该账单已成功撤销");
@@ -207,7 +208,9 @@
        wq.orderByDesc(TjTollCollector::getAccountEndTime);
        List<TjTollCollector> list = tjTollCollectorService.list(wq);
        if (null != list && list.size() > 0) return success(list.get(0).getAccountEndTime());
        return AjaxResult.success("1970-01-01 00:00:00");
        String dateStr = "2023-10-01 00:00:00";
        Date date = DateUtil.parse(dateStr, "yyyy-MM-dd HH:mm:ss");
        return AjaxResult.success(date);
    }
@@ -224,11 +227,16 @@
        Map<String, Object> map = new HashMap<>();
        LambdaQueryWrapper<TjFlowingWater> wq = new LambdaQueryWrapper<>();
        wq.eq(TjFlowingWater::getTollCollectorId, userId);
        wq.eq(TjFlowingWater::getIsCheckout, "N");
        wq.isNull(TjFlowingWater::getIsCheckout);
        wq.ne(TjFlowingWater::getPayStasus,0);
        wq.between(TjFlowingWater::getUpdateTime, beginTime, endTime);
        Page<TjFlowingWater> page =new Page<>(pageNum,pageSize);
        Page<TjFlowingWater> waterPage = tjFlowingWaterService.page(page, wq);
        //缓存所统计的流水id
        List<Long> longList = tjFlowingWaterService.getFlowingWaterIdList(userId, beginTime, endTime);
        redisCache.setCacheObject("longList"+userId,longList);
        List<TjFlowingWater> list1 = waterPage.getRecords();
        List<TjFlowingWater> list = tjFlowingWaterService.list(wq);
        for (TjFlowingWater tjFlowingWater : list1) {
@@ -243,7 +251,7 @@
        List<Map<String, Object>> cc = new ArrayList<>();
        //统计总集合
        //付款方式
        Map<Long, List<TjFlowingWater>> m = list.stream().collect(Collectors.groupingBy(TjFlowingWater::getPayType));
        Map<Long, List<TjFlowingWater>> m = list.stream().filter(item-> StringUtils.isNotNull(item.getPayType())).collect(Collectors.groupingBy(TjFlowingWater::getPayType));
        BigDecimal zshoukuan = new BigDecimal("0.00");
        BigDecimal ztuikuan = new BigDecimal("0.00");
        BigDecimal zyingjiao = new BigDecimal("0.00");