use of tk.mybatis.mapper.entity.Condition in project TeachingInSimulation by ScOrPiOzzy.
the class ResourceServiceImpl method findResourcesByCreator.
@Override
public PageInfo<Resource> findResourcesByCreator(int pagination, int pageSize, List<Integer> resourceTypes, String keyword, String orderByClause, Integer creator) {
// 获取当前登陆者身份信息
Condition condition = new Condition(Resource.class);
// 条件1、查找用户指定的几种资源类型
if (resourceTypes.size() == 0) {
return new PageInfo<Resource>(new ArrayList<Resource>());
} else {
Criteria criteria = condition.createCriteria();
criteria.andIn("type", resourceTypes);
}
// 条件2、关键字搜索
if (keyword != null && !"".equals(keyword)) {
Criteria criteria = condition.createCriteria();
List<String> words = StringUtil.split(keyword, ' ');
for (String word : words) {
criteria.orLike("keyword", "%" + word + "%");
}
condition.and(criteria);
}
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("creator", creator);
condition.and(criteria);
// 开始分页查询
PageHelper.startPage(pagination, pageSize, orderByClause);
List<Resource> result = findByCondition(condition);
PageInfo<Resource> page = new PageInfo<Resource>(result);
// 查到的总记录数
// 解释一下:这个page.getTotal(),是所有符合条件的记录数。
// result.size():是当前页中的数据量 <= pageSize
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pagination, pageSize, page.getPages());
return page;
}
use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.
the class AbnormalRecordController method update.
@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(String abnormalRecord) {
AbnormalRecord abnormalRecord1 = JSON.parseObject(abnormalRecord, AbnormalRecord.class);
abnormalRecord1.setSolveTime(new Date());
// 修改对应工序的状态为"安装中"或者“质检中”,需要检查安装开始时间和质检开始时间,质检已开始则状态为质检中
AbnormalRecord completeInfo = abnormalRecordService.findById(abnormalRecord1.getId());
Integer taskRecordId = completeInfo.getTaskRecordId();
if (taskRecordId != null && taskRecordId > 0) {
TaskRecord tr = taskRecordService.findById(taskRecordId);
// MQTT 异常解决后,通知工序的安装组长或者质检员,取决于之前是处于安装中还是质检中
String taskName = tr.getTaskName();
Condition condition = new Condition(Task.class);
condition.createCriteria().andCondition("task_name = ", taskName);
List<Task> taskList = taskService.findByCondition(condition);
if (taskList == null || taskList.size() <= 0) {
throw new RuntimeException();
}
ProcessRecord pr = processRecordService.findById(tr.getProcessRecordId());
Machine machine = machineService.findById(pr.getMachineId());
MachineOrder machineOrder = machineOrderService.findById(machine.getOrderId());
ServerToClientMsg msg = new ServerToClientMsg();
msg.setOrderNum(machineOrder.getOrderNum());
msg.setNameplate(machine.getNameplate());
if (tr.getQualityBeginTime() != null) {
tr.setStatus(Constant.TASK_QUALITY_DOING);
mqttMessageHelper.sendToClient(Constant.S2C_QUALITY_ABNORMAL_RESOLVE + taskList.get(0).getQualityUserId(), JSON.toJSONString(msg));
} else {
tr.setStatus(Constant.TASK_INSTALLING);
mqttMessageHelper.sendToClient(Constant.S2C_INSTALL_ABNORMAL_RESOLVE + taskList.get(0).getGroupId(), JSON.toJSONString(msg));
}
taskRecordService.update(tr);
} else {
throw new RuntimeException();
}
abnormalRecordService.update(abnormalRecord1);
return ResultGenerator.genSuccessResult();
}
use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.
the class ContractController method changeOrder.
@PostMapping("/changeOrder")
@Transactional(rollbackFor = Exception.class)
public Result changeOrder(String contract, String contractSign, String requisitionForms) {
if (contract == null || "".equals(contract)) {
return ResultGenerator.genFailResult("合同信息为空!");
}
if (contractSign == null || "".equals(contractSign)) {
return ResultGenerator.genFailResult("合同审核初始化信息为空!");
}
if (requisitionForms == null || "".equals(requisitionForms)) {
return ResultGenerator.genFailResult("订单信息为空!");
}
Contract contract1 = JSONObject.parseObject(contract, Contract.class);
if (contract1 == null) {
return ResultGenerator.genFailResult("Contract对象JSON解析失败!");
}
// 更改合同的状态为“改单”
contract1.setStatus(Constant.CONTRACT_CHANGED);
contract1.setUpdateTime(new Date());
contractService.update(contract1);
Integer contractId = contract1.getId();
// /插入新的contract审核记录
ContractSign contractSignObj = new ContractSign();
contractSignObj.setContractId(contractId);
contractSignObj.setCreateTime(new Date());
contractSignObj.setSignContent(contractSign);
// /插入空值
contractSignObj.setCurrentStep("");
contractSignService.save(contractSignObj);
// 新增的改单处理
List<MachineOrderWrapper> machineOrderWrapperList = JSONObject.parseArray(requisitionForms, MachineOrderWrapper.class);
for (MachineOrderWrapper orderItem : machineOrderWrapperList) {
MachineOrder machineOrder = orderItem.getMachineOrder();
if (machineOrder.getStatus().equals(Constant.ORDER_INITIAL) && machineOrder.getOriginalOrderId() != 0) {
// 插入新增改单项的detail
OrderDetail temp = orderItem.getOrderDetail();
orderDetailService.saveAndGetID(temp);
machineOrder.setOrderDetailId(temp.getId());
machineOrder.setContractId(contract1.getId());
machineOrder.setStatus(Constant.ORDER_INITIAL);
machineOrderService.saveAndGetID(machineOrder);
// 初始化需求单审核记录
OrderSign orderSignData = orderItem.getOrderSign();
OrderSign orderSign = new OrderSign();
orderSign.setSignContent(orderSignData.getSignContent());
orderSign.setOrderId(machineOrder.getId());
orderSign.setCreateTime(new Date());
orderSignService.save(orderSign);
// 改单记录(插入或者修改)
OrderChangeRecord changeRecord = orderItem.getOrderChangeRecord();
if (changeRecord.getId() == null) {
changeRecord.setChangeTime(new Date());
orderChangeRecordService.save(changeRecord);
} else {
changeRecord.setChangeTime(new Date());
orderChangeRecordService.update(changeRecord);
}
}
}
for (MachineOrderWrapper orderItem : machineOrderWrapperList) {
MachineOrder machineOrder = orderItem.getMachineOrder();
// 设置被改单的需求单状态(machine_order/order_sign)
if (machineOrder.getStatus().equals(Constant.ORDER_CHANGED)) {
// 更新了被改的需求单为“改单”,持久化至数据库
machineOrderService.update(machineOrder);
// 获取被改单对应机器,设置改单状态(machine)
Condition tempCondition = new Condition(Machine.class);
tempCondition.createCriteria().andCondition("order_id = ", machineOrder.getId());
List<Machine> machineList = machineService.findByCondition(tempCondition);
// 寻找对应新需求单,比较机器数
MachineOrder newOrder = null;
for (MachineOrderWrapper wrapper : machineOrderWrapperList) {
if (wrapper.getMachineOrder().getOriginalOrderId().equals(machineOrder.getId())) {
newOrder = wrapper.getMachineOrder();
break;
}
}
if (newOrder != null) {
// /改单前后机器数相等或者大于原需求单数中对应的机器数;多出部分机器在审核完成以后自动添加
for (Machine machine : machineList) {
// /初始化、取消状态,直接将机器的上的需求单号直接绑定到新需求单
if (machine.getStatus().equals(Constant.MACHINE_INITIAL) || machine.getStatus().equals(Constant.MACHINE_CANCELED)) {
} else {
machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
// /有改单状态的机器,通知全部安装组长
ServerToClientMsg msg = new ServerToClientMsg();
msg.setOrderNum(newOrder.getOrderNum());
msg.setNameplate(machine.getNameplate());
msg.setType(ServerToClientMsg.MsgType.ORDER_CHANGE);
mqttMessageHelper.sendToClient(Constant.S2C_MACHINE_STATUS_CHANGE, JSON.toJSONString(msg));
}
machine.setOrderId(newOrder.getId());
machine.setUpdateTime(new Date());
machineService.update(machine);
}
/* 20180323精简了算法,对于被改的需求单,除了初始化和取消状态的机器保持状态不变,其他机器都设置为该到为状态
if (newOrder.getMachineNum() >= machineOrder.getMachineNum()) {
for (Machine machine : machineList) {
///初始化状态,直接将机器的上的需求单号直接绑定到新需求单
if (machine.getStatus().equals(Constant.MACHINE_INITIAL)) {
} else {
machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
}
machine.setOrderId(newOrder.getId());
machine.setUpdateTime(new Date());
machineService.update(machine);
}
} else {
List<Machine> originalInitialMachine = new ArrayList<>();
List<Machine> originalInitialedMachine = new ArrayList<>();
List<Machine> originalOtherMachine = new ArrayList<>();
for (Machine machine : machineList) {
if (machine.getStatus().equals(Constant.MACHINE_CONFIGURED)
||machine.getStatus().equals(Constant.MACHINE_PLANING)
|| machine.getStatus().equals( Constant.MACHINE_INSTALLING)
|| machine.getStatus().equals(Constant.MACHINE_INSTALLED)
|| machine.getStatus().equals(Constant.MACHINE_SPLITED)) {
///查找已配置、计划中、生产中、被拆单、生产完成的机器
originalInitialedMachine.add(machine);
} else if (machine.getStatus().equals(Constant.MACHINE_INITIAL)) {
///初始化状态,未开始计划
originalInitialMachine.add(machine);
} else {
originalOtherMachine.add(machine);
}
}
int addedNum = 0;
//生产中的机器优先处理
for (int i = 0; i < originalInitialedMachine.size(); i++) {
if (addedNum < newOrder.getMachineNum()) {
originalInitialedMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
addedNum++;
} else {
originalInitialedMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CANCELED)));
}
originalInitialedMachine.get(i).setOrderId(newOrder.getId());
//更新
machineService.update(originalInitialedMachine.get(i));
}
//未计划的机器其次处理
for (int i = 0; i < originalInitialMachine.size(); i++) {
if (addedNum < newOrder.getMachineNum()) {
///TODO:是否可以保持“MACHINE_INITIAL”状态不变,因为此时机器还没有计划,也就是说没有对其设置安装流程
//originalInitialMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
addedNum++;
originalInitialMachine.get(i).setOrderId(newOrder.getId());
machineService.update(originalInitialMachine.get(i));
} else {
//删除
machineService.deleteById(originalInitialMachine.get(i).getId());
}
}
//目前只有删除状态的机器(MACHINE_CANCELED)
for (int i = 0; i < originalOtherMachine.size(); i++) {
if (addedNum < newOrder.getMachineNum()) {
originalOtherMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CHANGED)));
originalOtherMachine.get(i).setOrderId(newOrder.getId());
machineService.update(originalInitialMachine.get(i));
addedNum++;
} else {
originalOtherMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CANCELED)));
machineService.update(originalInitialMachine.get(i));
}
///对于删除状态的机器不做处理
// else {
// originalOtherMachine.get(i).setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_CANCELED)));
// machineService.update(originalInitialMachine.get(i));
// }
}
}
*/
} else {
// /在同一个合同中没有找到新的需求单,抛出异常
throw new RuntimeException();
}
}
}
return ResultGenerator.genSuccessResult();
}
use of tk.mybatis.mapper.entity.Condition in project sinsim by WilsonHu.
the class MachineOrderController method isOrderNumExist.
@PostMapping("/isOrderNumExist")
public Result isOrderNumExist(@RequestParam String orderNum) {
if (orderNum == null) {
return ResultGenerator.genFailResult("请输入需求单编号!");
} else {
Condition condition = new Condition(MachineOrder.class);
condition.createCriteria().andCondition("order_num = ", orderNum);
List<MachineOrder> list = machineOrderService.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 OrderSignController method update.
@PostMapping("/update")
@Transactional(rollbackFor = Exception.class)
public Result update(Integer contractId, String orderSign) {
if (orderSign == null || "".equals(orderSign)) {
ResultGenerator.genFailResult("签核信息为空!");
}
if (contractId == null || contractId <= 0) {
ResultGenerator.genFailResult("合同ID不存在或者无效!");
}
OrderSign orderSignObj = JSONObject.parseObject(orderSign, OrderSign.class);
if (orderSignObj == null) {
ResultGenerator.genFailResult("签核信息JSON解析失败!");
} else {
// 更新需求单签核记录
orderSignObj.setUpdateTime(new Date());
orderSignService.update(orderSignObj);
// 更新需求单状态
List<SignContentItem> orderSignContentList = JSON.parseArray(orderSignObj.getSignContent(), SignContentItem.class);
boolean haveReject = false;
for (SignContentItem item : orderSignContentList) {
// 如果签核内容中有“拒绝”状态的签核信息,需要将该
if (item.getResult().equals(Constant.SIGN_REJECT)) {
haveReject = true;
break;
}
}
MachineOrder machineOrder = machineOrderService.findById(orderSignObj.getOrderId());
if (haveReject) {
machineOrder.setStatus(Constant.ORDER_REJECTED);
// 需要把之前的签核状态result设置为初始状态“SIGN_INITIAL”,但是签核内容不变(contract & machineOrder)
// 合同相关
ContractSign contractSignObj = contractSignService.detailByContractId(String.valueOf(contractId));
List<SignContentItem> contractSignList = JSON.parseArray(contractSignObj.getSignContent(), SignContentItem.class);
for (SignContentItem item : contractSignList) {
item.setResult(Constant.SIGN_INITIAL);
}
contractSignObj.setSignContent(JSONObject.toJSONString(contractSignList));
// 当前审核步骤变成空
contractSignObj.setCurrentStep("");
contractSignService.update(contractSignObj);
// 需求单相关,当前需求单审核变为初始化“SIGN_INITIAL”
for (SignContentItem item : orderSignContentList) {
item.setResult(Constant.SIGN_INITIAL);
}
orderSignObj.setSignContent(JSONObject.toJSONString(orderSignContentList));
orderSignService.update(orderSignObj);
} else {
if (!machineOrder.getStatus().equals(Constant.ORDER_CHECKING)) {
machineOrder.setStatus(Constant.ORDER_CHECKING);
}
}
machineOrderService.update(machineOrder);
// 更新合同签核记录
String step = commonService.getCurrentSignStep(contractId);
ContractSign contractSign = contractSignService.detailByContractId(String.valueOf(contractId));
if (step == null || contractSign == null) {
throw new RuntimeException();
} else {
Contract contract = contractService.findById(contractId);
if (step.equals(Constant.SIGN_FINISHED)) {
// 表示签核已经完成,合同设置“CONTRACT_CHECKING_FINISHED”
contract.setStatus(Constant.CONTRACT_CHECKING_FINISHED);
// 需求单也需要设置为签核完成状态“ORDER_CHECKING_FINISHED”
Condition tempCondition = new Condition(ContractSign.class);
tempCondition.createCriteria().andCondition("contract_id = ", contractId);
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(contractId);
} else {
if (haveReject) {
contract.setStatus(Constant.CONTRACT_REJECTED);
} else if (contract.getStatus().equals(Constant.CONTRACT_REJECTED)) {
contract.setStatus(Constant.CONTRACT_CHECKING);
}
}
contract.setUpdateTime(new Date());
contractService.update(contract);
}
contractSign.setCurrentStep(step);
contractSignService.update(contractSign);
}
return ResultGenerator.genSuccessResult();
}
Aggregations