Search in sources :

Example 26 with Condition

use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.

the class PanoramicRealTimeConsumptionGatherServiceImpl method queryDayStatisticsByDate.

/**
 * 取得指定时间的消耗值
 */
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicRealTimeConsumptionGatherDto queryDayStatisticsByDate(String date, String code) {
    if (StringUtils.equalsIgnoreCase(code, HG_01_XY_7505) || StringUtils.equalsIgnoreCase(code, HG_01_XY_7504) || StringUtils.equalsIgnoreCase(code, HG_01_XY_7500)) {
        return this.queryStatisticsForDay(date, code);
    }
    Condition condition = new Condition(PanoramicRealTimeConsumptionGather.class, false);
    condition.createCriteria().andCondition(" code ='" + code + "' AND f_id=2 AND delete_flag=1 " + " AND date_format(gather_time,'%Y%m%d') = date_format('" + date + "','%Y%m%d')");
    condition.setOrderByClause(" gather_time asc ");
    List<PanoramicRealTimeConsumptionGather> recordList = realTimeConsumptionGatherMapper.selectByCondition(condition);
    PanoramicRealTimeConsumptionGatherDto gather = new PanoramicRealTimeConsumptionGatherDto();
    gather.setCode(code);
    gather.setValue(0.0);
    gather.setRecordValues(0.0);
    gather.setCtime(DateUtil.parseTimestamp(date, "yyyy-MM-dd"));
    gather.setGatherTime(date);
    if (null != recordList && recordList.size() > 0) {
        recordList.forEach(e -> {
            gather.setValue(e.getValue() + gather.getValue());
            gather.setDeleteFlag(e.getDeleteFlag());
            gather.setfId(e.getfId());
            gather.setId(null);
            gather.setName(e.getName());
            gather.setOperator(e.getOperator());
            gather.setUnit(e.getUnit());
            gather.setDtime(null);
            gather.setUtime(e.getUtime());
        });
    }
    return gather;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicRealTimeConsumptionGather(com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather) PanoramicRealTimeConsumptionGatherDto(com.monitor.dto.realtimeconsumptiongather.PanoramicRealTimeConsumptionGatherDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with Condition

use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.

the class ContractController method isContractExist.

@PostMapping("/isContractExist")
public Result isContractExist(@RequestParam String contractNum) {
    if (contractNum == null) {
        return ResultGenerator.genFailResult("请输入合同编号!");
    } else {
        Condition condition = new Condition(Contract.class);
        condition.createCriteria().andCondition("contract_num = ", contractNum);
        List<Contract> list = contractService.findByCondition(condition);
        if (list.size() == 0) {
            return ResultGenerator.genSuccessResult();
        } else {
            return ResultGenerator.genFailResult("合同编号已存在!");
        }
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) Contract(com.eservice.api.model.contract.Contract) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 28 with Condition

use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.

the class ContractController method startSign.

@PostMapping("/startSign")
@Transactional(rollbackFor = Exception.class)
public Result startSign(@RequestParam Integer contractId) {
    if (contractId == null) {
        ResultGenerator.genFailResult("合同ID为空!");
    } else {
        ContractSign contractSign = contractSignService.detailByContractId(String.valueOf(contractId));
        if (contractSign == null) {
            return ResultGenerator.genFailResult("根据合同号获取合同签核信息失败!");
        } else {
            // 更新合同状态为“CONTRACT_CHECKING”
            Contract contract = contractService.findById(contractId);
            if (contract == null) {
                return ResultGenerator.genFailResult("合同编号ID无效");
            } else {
                contract.setStatus(Constant.CONTRACT_CHECKING);
                contract.setUpdateTime(new Date());
                contractService.update(contract);
            }
            // 设置该合同下的需求单状态,如果处于“ORDER_INITIAL”状态,则设置为“ORDER_CHECKING”
            Condition tempCondition = new Condition(MachineOrder.class);
            tempCondition.createCriteria().andCondition("contract_id = ", contractId);
            tempCondition.createCriteria().andCondition("status = ", Constant.ORDER_INITIAL);
            List<MachineOrder> orderList = machineOrderService.findByCondition(tempCondition);
            for (MachineOrder orderItem : orderList) {
                if (orderItem.getStatus().equals(Constant.ORDER_INITIAL)) {
                    orderItem.setStatus(Constant.ORDER_CHECKING);
                    machineOrderService.update(orderItem);
                }
            }
            // 更新签核记录
            contractSign.setUpdateTime(new Date());
            String currentStep = commonService.getCurrentSignStep(contractId);
            if (currentStep == null) {
                return ResultGenerator.genFailResult("获取当前签核steps失败!");
            }
            contractSign.setCurrentStep(currentStep);
            // 设置完状态后更新签核记录
            contractSignService.update(contractSign);
        }
    }
    return ResultGenerator.genSuccessResult();
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) ContractSign(com.eservice.api.model.contract_sign.ContractSign) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) Contract(com.eservice.api.model.contract.Contract) Date(java.util.Date) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 29 with Condition

use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.

the class ContractSignController method update.

@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(String contractSign) {
    ContractSign contractSignObj = JSON.parseObject(contractSign, ContractSign.class);
    contractSignObj.setUpdateTime(new Date());
    contractSignService.update(contractSignObj);
    String step = commonService.getCurrentSignStep(contractSignObj.getContractId());
    if (step == null) {
        throw new RuntimeException();
    } else {
        Contract contract = contractService.findById(contractSignObj.getContractId());
        if (step.equals(Constant.SIGN_FINISHED)) {
            // 表示签核已经完成
            contract.setStatus(Constant.CONTRACT_CHECKING_FINISHED);
            // 需求单也需要设置为签核完成状态“ORDER_CHECKING_FINISHED”
            Condition tempCondition = new Condition(ContractSign.class);
            tempCondition.createCriteria().andCondition("contract_id = ", contract.getId());
            List<MachineOrder> machineOrderList = machineOrderService.findByCondition(tempCondition);
            for (MachineOrder item : machineOrderList) {
                if (item.getStatus().equals(Constant.ORDER_CHECKING)) {
                    item.setStatus(Constant.ORDER_CHECKING_FINISHED);
                }
                machineOrderService.update(item);
            }
            // 根据合同中的需求单进行机器添加
            commonService.createMachineByContractId(contractSignObj.getContractId());
        } else {
            // 更新合同状态
            List<SignContentItem> contractSignContentList = JSON.parseArray(contractSignObj.getSignContent(), SignContentItem.class);
            boolean haveReject = false;
            for (SignContentItem item : contractSignContentList) {
                // 如果签核内容中有“拒绝”状态的签核信息,需要将该
                if (item.getResult().equals(Constant.SIGN_REJECT)) {
                    haveReject = true;
                    break;
                }
            }
            if (haveReject) {
                contract.setStatus(Constant.CONTRACT_REJECTED);
                // 合同相关
                for (SignContentItem item : contractSignContentList) {
                    item.setResult(Constant.SIGN_INITIAL);
                }
                contractSignObj.setSignContent(JSONObject.toJSONString(contractSignContentList));
                // 当前审核步骤变成空
                step = "";
                // 需求单相关
                List<OrderSign> orderSignList = orderSignService.getValidOrderSigns(contractSignObj.getContractId());
                for (OrderSign item : orderSignList) {
                    // 之前把正在签核中,或者驳回状态的需求单的签核状态设置为“SIGN_INITIAL”
                    MachineOrder machineOrder = machineOrderService.findById(item.getOrderId());
                    Byte status = machineOrder.getStatus();
                    if (Constant.ORDER_CHECKING.equals(status) || Constant.ORDER_REJECTED.equals(status)) {
                        List<SignContentItem> signContentItemList = JSONObject.parseArray(item.getSignContent(), SignContentItem.class);
                        for (SignContentItem signContentItem : signContentItemList) {
                            signContentItem.setResult(Constant.SIGN_INITIAL);
                        }
                        item.setSignContent(JSONObject.toJSONString(signContentItemList));
                        orderSignService.update(item);
                        // 需求单状态设置为“ORDER_REJECTED”
                        machineOrder.setStatus(Constant.ORDER_REJECTED);
                        machineOrderService.update(machineOrder);
                    }
                }
            } else {
                // 已驳回的重新审核后,更改合同状态为审核中.
                if (contract.getStatus() == Constant.CONTRACT_REJECTED) {
                    contract.setStatus(Constant.CONTRACT_CHECKING);
                    // 需求单也需要重新设置为审核中
                    Condition tempCondition = new Condition(ContractSign.class);
                    tempCondition.createCriteria().andCondition("contract_id = ", contract.getId());
                    List<MachineOrder> machineOrderList = machineOrderService.findByCondition(tempCondition);
                    for (MachineOrder item : machineOrderList) {
                        if (item.getStatus() == Constant.ORDER_REJECTED) {
                            item.setStatus(Constant.ORDER_CHECKING);
                        }
                        machineOrderService.update(item);
                    }
                }
            }
        }
        contract.setUpdateTime(new Date());
        contractService.update(contract);
    }
    contractSignObj.setCurrentStep(step);
    contractSignService.update(contractSignObj);
    return ResultGenerator.genSuccessResult();
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) Date(java.util.Date) OrderSign(com.eservice.api.model.order_sign.OrderSign) SignContentItem(com.eservice.api.model.contract_sign.SignContentItem) ContractSign(com.eservice.api.model.contract_sign.ContractSign) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) Contract(com.eservice.api.model.contract.Contract) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with Condition

use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.

the class ContractSignController method list.

@PostMapping("/list")
public Result list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0") Integer size, @RequestParam(defaultValue = "0") Integer contractId) {
    PageHelper.startPage(page, size);
    List<ContractSign> list;
    if (contractId == 0) {
        list = new ArrayList<>();
    } else {
        // 获取摸个合同号对应的全部签核记录
        Condition tempCondition = new Condition(ContractSign.class);
        tempCondition.createCriteria().andCondition("contract_id = ", contractId);
        list = contractSignService.findByCondition(tempCondition);
    }
    PageInfo pageInfo = new PageInfo(list);
    return ResultGenerator.genSuccessResult(pageInfo);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PageInfo(com.github.pagehelper.PageInfo) ContractSign(com.eservice.api.model.contract_sign.ContractSign) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Condition (tk.mybatis.mapper.entity.Condition)59 Criteria (tk.mybatis.mapper.entity.Example.Criteria)25 Transactional (org.springframework.transaction.annotation.Transactional)17 PostMapping (org.springframework.web.bind.annotation.PostMapping)13 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)10 Machine (com.eservice.api.model.machine.Machine)8 PageInfo (com.github.pagehelper.PageInfo)8 TaskRecord (com.eservice.api.model.task_record.TaskRecord)6 PanoramicRealTimeConsumptionGather (com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather)6 Date (java.util.Date)6 Contract (com.eservice.api.model.contract.Contract)5 ContractSign (com.eservice.api.model.contract_sign.ContractSign)5 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)5 User (com.cas.sim.tis.entity.User)4 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)4 Task (com.eservice.api.model.task.Task)4 OrderSign (com.eservice.api.model.order_sign.OrderSign)3 Library (com.cas.sim.tis.entity.Library)2 Resource (com.cas.sim.tis.entity.Resource)2 ResourceMapper (com.cas.sim.tis.mapper.ResourceMapper)2