ソースを参照

物联网相关

yeshijie 7 年 前
コミット
1df99e38c3

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/iot/device/IotDeviceOrderDO.java

@ -64,6 +64,9 @@ public class IotDeviceOrderDO extends IdEntityWithOperation implements Serializa
    @Column(name = "instruction")
    private String instruction;//订单说明
    @Column(name = "ymd")
    private String ymd;//年月日
    @Column(name = "del")
    private Integer del;//删除标志
@ -202,4 +205,12 @@ public class IotDeviceOrderDO extends IdEntityWithOperation implements Serializa
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getYmd() {
        return ymd;
    }
    public void setYmd(String ymd) {
        this.ymd = ymd;
    }
}

+ 2 - 2
svr/svr-iot/src/main/java/com/yihu/iot/controller/common/FileUploadController.java

@ -66,7 +66,7 @@ public class FileUploadController extends EnvelopRestController{
            uploadVO.setFileType(fileType);
            uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", ""));
            uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", ""));
            return Envelop.getSuccess(IotRequestMapping.DeviceSupplier.message_success_create, uploadVO);
            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);
@ -91,7 +91,7 @@ public class FileUploadController extends EnvelopRestController{
            uploadVO.setFileType(fileType);
            uploadVO.setFullUri(objectNode.get("fid").toString().replaceAll("\"", ""));
            uploadVO.setFullUrl(fastdfs_file_url + objectNode.get("fid").toString().replaceAll("\"", ""));
            return Envelop.getSuccess(IotRequestMapping.DeviceSupplier.message_success_create, uploadVO);
            return Envelop.getSuccess(IotRequestMapping.Common.message_success_create, uploadVO);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError(IotRequestMapping.FileUpload.message_fail_upload, IotRequestMapping.api_iot_fail);

+ 6 - 1
svr/svr-iot/src/main/java/com/yihu/iot/dao/device/IotDeviceOrderDao.java

@ -5,11 +5,16 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * @author yeshijie on 2017/12/1.
 */
public interface IotDeviceOrderDao extends PagingAndSortingRepository<IotDeviceOrderDO,String>,JpaSpecificationExecutor<IotDeviceOrderDO> {
    @Query("from IotDeviceOrderDO w where w.id =?1")
    @Query("from IotDeviceOrderDO w where w.id =?1 and w.del=1")
    IotDeviceOrderDO findById(String id);
    @Query("from IotDeviceOrderDO w where w.ymd =?1")
    List<IotDeviceOrderDO> findByYmd(String ymd);
}

+ 11 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceOrderService.java

@ -7,6 +7,9 @@ import com.yihu.jw.util.date.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * @author yeshijie on 2017/12/8.
 */
@ -23,13 +26,20 @@ public class IotDeviceOrderService extends BaseJpaService<IotDeviceOrderDO,IotDe
     */
    public IotDeviceOrderDO create(IotDeviceOrderDO iotDeviceOrder) {
        String time = DateUtil.yyyy_MM_dd_HH_mm_ss;
        String time = DateUtil.dateToStr(new Date(),DateUtil.YYYYMMDD);
        List<IotDeviceOrderDO> doList = iotDeviceOrderDao.findByYmd(time);
        iotDeviceOrder.setOrderNo(String.format("",doList.size()));
        iotDeviceOrder.setSaasId(getCode());
        iotDeviceOrder.setDel(1);
        iotDeviceOrder.setYmd(time);
        return iotDeviceOrderDao.save(iotDeviceOrder);
    }
    public IotDeviceOrderDO findById(String id) {
        return iotDeviceOrderDao.findById(id);
    }
    public static void main(String[] args) {
        System.out.println(String.format("%05d", 5));
    }
}