Search in sources :

Example 6 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class CommonService method createMachineByContractId.

/**
 * 根据合同编号对应的需求单的机器
 *
 * @param contractId
 */
public void createMachineByContractId(Integer contractId) {
    Condition condition = new Condition(MachineOrder.class);
    condition.createCriteria().andCondition("contract_id = ", contractId);
    List<MachineOrder> orderList = machineOrderService.findByCondition(condition);
    for (MachineOrder orderItem : orderList) {
        // 选取有效需求单,无效需求单对应的机器数不cover在内
        if (orderItem.getStatus().equals(Constant.ORDER_CHECKING_FINISHED) || orderItem.getStatus().equals(Constant.ORDER_SPLITED)) {
            Condition tempCondition = new Condition(Machine.class);
            tempCondition.createCriteria().andCondition("order_id = ", orderItem.getId());
            List<Machine> machineExistList = machineService.findByCondition(tempCondition);
            int haveToCreate = orderItem.getMachineNum() - machineExistList.size();
            int i = 1;
            while (i <= haveToCreate) {
                Machine machine = new Machine();
                machine.setMachineStrId(Utils.createMachineBasicId() + i);
                machine.setOrderId(orderItem.getId());
                machine.setMachineType(orderItem.getMachineType());
                machine.setStatus(Byte.parseByte(String.valueOf(Constant.MACHINE_INITIAL)));
                machine.setCreateTime(new Date());
                machineService.save(machine);
                i++;
            }
        }
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) MachineOrder(com.eservice.api.model.machine_order.MachineOrder) Machine(com.eservice.api.model.machine.Machine)

Example 7 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class AbnormalRecordController method updateAbnormalRecordDetail.

/**
 * 根据传入的strAbnormalRecordDetail,更新对应多表:
 * "machine_id":"", --> machine.machine_id
 * "安装是否异常":"", --> task_record.status  task状态,“1”==>未开始, “2”==>进行中,“3”==>安装完成, “4”==>质检完成,“5“===>异常
 * "异常类型":"",	--> abnormal_record.abnormal_type
 * "异常原因":"", --> abnormal_record.comment
 * "异常照片":"", -->abnormal_image.image
 * "安装完成":"",  -->   task_record.status或machine.status都可以,反正这两个表都更新
 * 注意:有外键的字段,需要上传实际存在的外键数据。
 * 一项update失败的情况下,全部update无效(事务OK)
 *
 * @param strAbnormalRecordDetail
 * @return
 */
@PostMapping("/updateAbnormalRecordDetail")
@Transactional
public Result updateAbnormalRecordDetail(@RequestParam String strAbnormalRecordDetail) {
    // 获取整体detail
    AbnormalRecordDetail abnormalRecordDetail1 = JSON.parseObject(strAbnormalRecordDetail, AbnormalRecordDetail.class);
    Integer abnormalRecordDetail_ID = abnormalRecordDetail1.getId();
    AbnormalRecord abnormalRecord = abnormalRecordService.findById(abnormalRecordDetail_ID);
    abnormalRecord.setAbnormalType(abnormalRecordDetail1.getAbnormalType());
    abnormalRecord.setTaskRecordId(abnormalRecordDetail1.getTaskRecordId());
    abnormalRecord.setSubmitUser(abnormalRecordDetail1.getSubmitUser());
    abnormalRecord.setSolutionUser(abnormalRecordDetail1.getSolutionUser());
    abnormalRecord.setComment(abnormalRecordDetail1.getComment());
    abnormalRecord.setSolution(abnormalRecordDetail1.getSolution());
    Abnormal abnormal = abnormalRecordDetail1.getAbnormal();
    AbnormalImage abnormalImage = abnormalRecordDetail1.getAbnormalImage();
    TaskRecord taskRecord = abnormalRecordDetail1.getTaskRecord();
    Machine machine = abnormalRecordDetail1.getMachine();
    abnormalRecordService.update(abnormalRecord);
    abnormalService.update(abnormal);
    abnormalImageService.update(abnormalImage);
    taskRecordService.update(taskRecord);
    machineService.update(machine);
    return ResultGenerator.genSuccessResult();
}
Also used : TaskRecord(com.eservice.api.model.task_record.TaskRecord) AbnormalRecord(com.eservice.api.model.abnormal_record.AbnormalRecord) AbnormalImage(com.eservice.api.model.abnormal_image.AbnormalImage) AbnormalRecordDetail(com.eservice.api.model.abnormal_record.AbnormalRecordDetail) Abnormal(com.eservice.api.model.abnormal.Abnormal) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class ContractController method splitOrder.

@PostMapping("/splitOrder")
@Transactional(rollbackFor = Exception.class)
public Result splitOrder(String contract, String contractSign, String requisitionForms, String splitMachines) {
    if (contract == null || "".equals(contract)) {
        return ResultGenerator.genFailResult("合同信息为空!");
    }
    if (contractSign == null || "".equals(contractSign)) {
        return ResultGenerator.genFailResult("合同审核初始化信息为空!");
    }
    if (requisitionForms == null || "".equals(requisitionForms)) {
        return ResultGenerator.genFailResult("订单信息为空!");
    }
    if (splitMachines == null || "".equals(splitMachines)) {
        return ResultGenerator.genFailResult("拆单机器信息为空!");
    }
    Contract contractObj = JSONObject.parseObject(contract, Contract.class);
    if (contractObj == null || contractSign == null || requisitionForms == null || splitMachines == null) {
        return ResultGenerator.genFailResult("JSON解析失败!");
    }
    // 更改合同的状态为“拆单”
    contractObj.setStatus(Constant.CONTRACT_SPLITED);
    contractObj.setUpdateTime(new Date());
    contractService.update(contractObj);
    Integer contractId = contractObj.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);
    List<Machine> splitMachineList = JSONObject.parseArray(splitMachines, Machine.class);
    for (MachineOrderWrapper orderItem : machineOrderWrapperList) {
        MachineOrder machineOrder = orderItem.getMachineOrder();
        if (machineOrder.getId() == null && machineOrder.getOriginalOrderId() != 0) {
            // 插入新增改单项的detail
            OrderDetail temp = orderItem.getOrderDetail();
            orderDetailService.saveAndGetID(temp);
            machineOrder.setOrderDetailId(temp.getId());
            machineOrder.setContractId(contractObj.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);
            // 被拆分出来的机器绑定到新的需求单
            for (Machine splitMachine : splitMachineList) {
                splitMachine.setOrderId(machineOrder.getId());
                splitMachine.setStatus(Constant.MACHINE_SPLITED);
                // /MQTT 有拆单状态的机器,通知全部安装组长
                ServerToClientMsg msg = new ServerToClientMsg();
                msg.setOrderNum(machineOrder.getOrderNum());
                msg.setNameplate(splitMachine.getNameplate());
                msg.setType(ServerToClientMsg.MsgType.ORDER_SPLIT);
                mqttMessageHelper.sendToClient(Constant.S2C_MACHINE_STATUS_CHANGE, JSON.toJSONString(msg));
                splitMachine.setUpdateTime(new Date());
                machineService.update(splitMachine);
            }
            // 拆单记录(插入或者修改)
            OrderSplitRecord splitRecord = orderItem.getOrderSplitRecord();
            if (splitRecord.getId() == null) {
                splitRecord.setSplitTime(new Date());
                orderSplitRecordService.save(splitRecord);
            } else {
                splitRecord.setSplitTime(new Date());
                orderSplitRecordService.update(splitRecord);
            }
        }
    }
    // 处于拆单状态的需求单,更新状态成“ORDER_SPLIT”
    for (MachineOrderWrapper orderItem : machineOrderWrapperList) {
        MachineOrder machineOrder = orderItem.getMachineOrder();
        // TODO:同一个合同中其他为“ORDER_SPLIT”状态的需求单也会被更新,需要完善
        if (machineOrder.getStatus().equals(Constant.ORDER_SPLITED)) {
            machineOrder.setUpdateTime(new Date());
            machineOrderService.update(machineOrder);
        }
    }
    return ResultGenerator.genSuccessResult();
}
Also used : MachineOrderWrapper(com.eservice.api.model.contract.MachineOrderWrapper) ServerToClientMsg(com.eservice.api.service.mqtt.ServerToClientMsg) Date(java.util.Date) Machine(com.eservice.api.model.machine.Machine) OrderDetail(com.eservice.api.model.order_detail.OrderDetail) MachineOrderDetail(com.eservice.api.model.machine_order.MachineOrderDetail) OrderSign(com.eservice.api.model.order_sign.OrderSign) OrderSplitRecord(com.eservice.api.model.order_split_record.OrderSplitRecord) 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 9 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class MachineController method update.

@PostMapping("/update")
public Result update(String machine) {
    Machine machine1 = JSON.parseObject(machine, Machine.class);
    if (machine1.getNameplate() == null || machine1.getNameplate() == "") {
        return ResultGenerator.genFailResult("机器编号不能为空!");
    } else {
        // 检查机器编号是否存在,存在则返回错误
        Condition condition = new Condition(Machine.class);
        condition.createCriteria().andCondition("nameplate = ", machine1.getNameplate());
        List<Machine> list = machineService.findByCondition(condition);
        if (list.size() >= 1) {
            return ResultGenerator.genFailResult("机器编号已存在!");
        } else {
            machineService.update(machine1);
            return ResultGenerator.genSuccessResult();
        }
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 10 with Machine

use of com.eservice.api.model.machine.Machine in project sinsim by WilsonHu.

the class MachineController method add.

@PostMapping("/add")
public Result add(String machine) {
    Machine machine1 = JSON.parseObject(machine, Machine.class);
    machineService.save(machine1);
    return ResultGenerator.genSuccessResult();
}
Also used : Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Machine (com.eservice.api.model.machine.Machine)15 PostMapping (org.springframework.web.bind.annotation.PostMapping)12 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)8 Condition (tk.mybatis.mapper.entity.Condition)8 TaskRecord (com.eservice.api.model.task_record.TaskRecord)7 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)6 Transactional (org.springframework.transaction.annotation.Transactional)6 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)5 Date (java.util.Date)5 Task (com.eservice.api.model.task.Task)4 PageInfo (com.github.pagehelper.PageInfo)3 AbnormalRecord (com.eservice.api.model.abnormal_record.AbnormalRecord)2 Contract (com.eservice.api.model.contract.Contract)2 MachineOrderWrapper (com.eservice.api.model.contract.MachineOrderWrapper)2 ContractSign (com.eservice.api.model.contract_sign.ContractSign)2 MachineOrderDetail (com.eservice.api.model.machine_order.MachineOrderDetail)2 OrderDetail (com.eservice.api.model.order_detail.OrderDetail)2 OrderSign (com.eservice.api.model.order_sign.OrderSign)2 Abnormal (com.eservice.api.model.abnormal.Abnormal)1 AbnormalImage (com.eservice.api.model.abnormal_image.AbnormalImage)1