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;
}
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("合同编号已存在!");
}
}
}
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();
}
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();
}
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);
}
Aggregations