Browse Source

Merge branch 'dev' of yeshijie/jw2.0 into dev

yeshijie 7 years ago
parent
commit
9379b5cfde

+ 5 - 4
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceOrderDO.java

@ -23,7 +23,7 @@ public class IotDeviceOrderDO extends IdEntityWithOperation implements Serializa
    private String orderNo;//订单编号
    @Column(name = "order_status")
    private String orderStatus;//订单状态(1新增、2已采购、3已入库)
    private String orderStatus;//订单状态(1草稿、2生效、3已完成、4作废)
    @Column(name = "purchase_time")
    private Date purchaseTime;//采购时间
@ -68,9 +68,10 @@ public class IotDeviceOrderDO extends IdEntityWithOperation implements Serializa
    private Integer del;//删除标志
    public enum DeviceOrderStatus {
        create("新增", "1"),
        purchased("已采购", "2"),
        storaged("已入库", "3");
        create("草稿", "1"),
        effected("生效", "2"),
        completed("已完成", "3"),
        canceled("作废", "4");
        private String name;
        private String value;

+ 1 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/iot/device/IotDeviceOrderVO.java

@ -20,7 +20,7 @@ public class IotDeviceOrderVO extends BaseVO implements Serializable{
    @ApiModelProperty("订单编号")
    private String orderNo;
    @ApiModelProperty("订单状态")
    @ApiModelProperty("订单状态(1草稿、2生效、3已完成、4作废)")
    private String orderStatus;
    @ApiModelProperty("采购时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")

+ 3 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceDao.java

@ -21,6 +21,9 @@ public interface IotDeviceDao extends PagingAndSortingRepository<IotDeviceDO, St
    @Query("select count(*) from IotDeviceDO w where w.purchaseId =?1 and w.del=1")
    int countByPurchaseId(String purchaseId);
    @Query("select count(*) from IotDeviceDO w where w.orderId =?1 and w.del=1")
    int countByOrderId(String orderId);
    @Query("from IotDeviceDO w where w.deviceSn =?1 and w.del=1")
    IotDeviceDO findByDeviceSn(String deviceSn);

+ 4 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotOrderPurchaseDao.java

@ -15,4 +15,8 @@ public interface IotOrderPurchaseDao extends PagingAndSortingRepository<IotOrder
    @Query("select count(*) from IotOrderPurchaseDO a where  a.del = 1 and a.productId = ?1 ")
    long countByProductId(String productId);
    @Query(value = "SELECT IFNULL(SUM(purchase_num),0)  from iot_order_purchase WHERE order_id =?1 and del = 1 ",nativeQuery = true)
    int sumByOrderId(String orderId);
}

+ 7 - 2
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceQualityInspectionPlanService.java

@ -121,8 +121,13 @@ public class IotDeviceQualityInspectionPlanService extends BaseJpaService<IotDev
            IotDeviceQualityInspectionPlanDO last = iotDeviceQualityInspectionPlanDao.findLastByPurchaseId(purchaseId,IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            IotOrderPurchaseDO purchaseDO = iotOrderPurchaseDao.findById(purchaseId);
            purchaseDO.setQualityStatus(IotDeviceQualityInspectionPlanDO.QualityPlanStatus.complete.getValue());
            purchaseDO.setNextQualityTime(last.getPlanTime());
            purchaseDO.setQualityLeader(last.getQualityLeader());
            if(last==null){
                purchaseDO.setNextQualityTime(null);
                purchaseDO.setQualityLeader(null);
            }else{
                purchaseDO.setNextQualityTime(last.getPlanTime());
                purchaseDO.setQualityLeader(last.getQualityLeader());
            }
            iotOrderPurchaseDao.save(purchaseDO);
        }else {
            IotDeviceQualityInspectionPlanDO last = list.get(0);

+ 14 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -55,6 +55,8 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
    private IotSystemDictService iotSystemDictService;
    @Autowired
    private IotProductDataTransmissionDao iotProductDataTransmissionDao;
    @Autowired
    private IotDeviceOrderDao iotDeviceOrderDao;
    /**
     * 新增
@ -81,11 +83,22 @@ public class IotDeviceService extends BaseJpaService<IotDeviceDO,IotDeviceDao> {
            if(planDO!=null){
                iotDevice.setNextQualityTime(planDO.getPlanTime());//下次质检时间
            }
            //计算是否已经完成订单
            Integer num = iotDeviceDao.countByPurchaseId(iotDevice.getPurchaseId());//订单已经采购的数量
            Integer purchaseNum = iotOrderPurchaseDao.sumByOrderId(purchaseDO.getOrderId());//订单需采购的数量
            if((num+1)>=purchaseNum){
                //采购订单已经完成
                IotDeviceOrderDO iotDeviceOrderDO = iotDeviceOrderDao.findById(purchaseDO.getOrderId());
                iotDeviceOrderDO.setOrderStatus(IotDeviceOrderDO.DeviceOrderStatus.completed.getValue());
                iotDeviceOrderDao.save(iotDeviceOrderDO);
            }
        }
        iotDevice.setSaasId(getCode());
        iotDevice.setDel(1);
        return iotDeviceDao.save(iotDevice);
        iotDeviceDao.save(iotDevice);
        return iotDevice;
    }
    /**